"use client";

import { useEffect } from "react";

export function AutoPrint() {
  useEffect(() => {
    const t = setTimeout(() => window.print(), 600);
    return () => clearTimeout(t);
  }, []);
  return null;
}

export function PrintActionBar() {
  return (
    <div
      className="no-print"
      style={{
        display: "flex",
        justifyContent: "flex-end",
        gap: "0.75rem",
        marginBottom: "1.5rem",
      }}
    >
      <button
        type="button"
        onClick={() => window.close()}
        style={{
          cursor: "pointer",
          padding: "0.5rem 1.25rem",
          borderRadius: "6px",
          fontSize: "0.85rem",
          fontWeight: 500,
          border: "1px solid #d1d5db",
          background: "#f9fafb",
          color: "#374151",
        }}
      >
        Kapat
      </button>
      <button
        type="button"
        onClick={() => window.print()}
        style={{
          cursor: "pointer",
          padding: "0.5rem 1.25rem",
          borderRadius: "6px",
          fontSize: "0.85rem",
          fontWeight: 500,
          border: "1px solid #111827",
          background: "#111827",
          color: "#fff",
        }}
      >
        Yazdır / PDF
      </button>
    </div>
  );
}
