@import "cropperjs/dist/cropper.css";

@tailwind base;
@tailwind components;
@tailwind utilities;

/* 組織図のスクロール領域。印刷時に解除できるよう、インラインstyleではなく
   クラスで持つ (#1081)。 */
.org-chart-scroll {
  height: 70vh;
  min-height: 500px;
}

@media print {
  /* Set page to A3 landscape */
  @page {
    size: A3 landscape;
    margin: 15mm;
  }

  /* Prevent page breaks */
  body, html {
    height: auto !important;
    overflow: visible !important;
  }

  /* Constrain to single page - A3 landscape without margins is ~297mm height */
  body {
    max-height: 267mm !important;
  }

  .print-calendar-only {
    max-height: 267mm !important;
    overflow: hidden !important;
  }

  body:not(.print-layout) * {
    page-break-after: avoid !important;
    page-break-before: avoid !important;
    page-break-inside: avoid !important;
  }

  .print\:text-xxs {
    font-size: 0.625rem;
    line-height: 0.75rem;
  }

  /* Hide all dashboard sections except calendar */
  .print-hide-dashboard {
    display: none !important;
  }

  /* Hide sidebar and navigation */
  #sidebar,
  .fixed.top-0.left-0.right-0 {
    display: none !important;
  }

  /* Remove left margin and padding from main content area */
  .lg\:ml-64,
  main {
    margin-left: 0 !important;
    padding-top: 0 !important;
  }

  /* Make calendar full width for print */
  .print-calendar-only {
    width: 100% !important;
    max-width: 100% !important;
    grid-column: 1 / -1 !important;
    page-break-inside: avoid !important;
    page-break-after: avoid !important;
    page-break-before: avoid !important;
  }

  .print-calendar-only > div {
    border: none !important;
    box-shadow: none !important;
    max-width: none !important;
    page-break-inside: avoid !important;
  }

  /* Ensure grid doesn't create extra pages */
  .grid {
    page-break-inside: avoid !important;
  }

  /* ── 組織図の印刷 (#1081) ────────────────────────────────
     A3横1枚に収める。共通ルールの body { max-height } と
     page-break-inside: avoid が効いたままだと図が切れるため、
     組織図のページでだけ打ち消す。
     ⚠️ 共通ルール側は触らないこと（ダッシュボードのカレンダー印刷が壊れる）。 */
  .org-chart-print-page {
    max-height: none !important;
  }

  /* 画面用の 70vh / スクロールを解除して全体を出す */
  .org-chart-scroll {
    height: auto !important;
    min-height: 0 !important;
    overflow: visible !important;
  }

  /* JS が SVG にインラインで width/height を入れるため !important で上書きし、
     用紙の幅に合わせて縮小する。高さは縦横比を保つ。
     従業員を表示したままだと大きく縮小され文字が小さくなるが、
     「1枚に収める」を優先する方針 (#1081 の回答 b)。 */
  .org-chart-print-page svg[data-org-chart-target="svg"] {
    width: 100% !important;
    height: auto !important;
    max-height: 267mm !important;
  }
}
