@import url('https://fonts.googleapis.com/css2?family=Prompt:ital,wght@0,300;0,400;0,500;0,600;0,700;1,400&family=Kanit:wght@300;400;500;600;700&family=Inter:wght@300;400;500;600;700&display=swap');

:root {
  --font-main: 'Prompt', 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  --font-heading: 'Kanit', 'Prompt', sans-serif;
  --primary: #1e40af;
  --primary-hover: #1d4ed8;
}

body {
  font-family: var(--font-main);
  background-color: #f8fafc;
  color: #1e293b;
  -webkit-font-smoothing: antialiased;
}

h1, h2, h3, h4, h5, h6, .font-heading {
  font-family: var(--font-heading);
}

/* Custom Scrollbars */
::-webkit-scrollbar {
  width: 8px;
  height: 8px;
}
::-webkit-scrollbar-track {
  background: #f1f5f9;
  border-radius: 4px;
}
::-webkit-scrollbar-thumb {
  background: #cbd5e1;
  border-radius: 4px;
}
::-webkit-scrollbar-thumb:hover {
  background: #94a3b8;
}

/* Tree Chart Hierarchy Styling */
.tree-container {
  display: flex;
  flex-direction: column;
  align-items: center;
  overflow-x: auto;
  padding: 2rem 1rem;
}

.tree-node-card {
  transition: all 0.25s ease-in-out;
}
.tree-node-card:hover {
  transform: translateY(-3px);
  box-shadow: 0 12px 24px -6px rgba(0, 0, 0, 0.12), 0 4px 8px -4px rgba(0, 0, 0, 0.06);
}

/* Branch connectors for tree */
.tree-branch {
  position: relative;
  display: flex;
  justify-content: center;
  padding-top: 24px;
}

.tree-branch::before {
  content: '';
  position: absolute;
  top: 0;
  left: 50%;
  border-left: 2px solid #cbd5e1;
  height: 24px;
  transform: translateX(-50%);
}

.tree-children {
  display: flex;
  justify-content: center;
  position: relative;
  padding-top: 24px;
  gap: 1.5rem;
}

.tree-children::before {
  content: '';
  position: absolute;
  top: 0;
  left: 50%;
  border-left: 2px solid #cbd5e1;
  height: 24px;
  transform: translateX(-50%);
}

.tree-child-item {
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: center;
}

.tree-child-item::before {
  content: '';
  position: absolute;
  top: -24px;
  left: 0;
  right: 0;
  height: 24px;
  border-top: 2px solid #cbd5e1;
}

.tree-child-item:first-child::before {
  left: 50%;
}

.tree-child-item:last-child::before {
  right: 50%;
}

.tree-child-item:only-child::before {
  display: none;
}

.tree-child-item::after {
  content: '';
  position: absolute;
  top: -24px;
  left: 50%;
  border-left: 2px solid #cbd5e1;
  height: 24px;
  transform: translateX(-50%);
}

/* Drag & Drop ghost & chosen styles */
.sortable-ghost {
  opacity: 0.4;
  border: 2px dashed #3b82f6 !important;
  background-color: #eff6ff !important;
}

.sortable-chosen {
  box-shadow: 0 15px 30px rgba(0,0,0,0.15) !important;
}

/* Animation utilities */
.animate-fade-in {
  animation: fadeIn 0.3s cubic-bezier(0.16, 1, 0.3, 1) forwards;
}

@keyframes fadeIn {
  from {
    opacity: 0;
    transform: translateY(6px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

/* Print Stylesheet */
@media print {
  body {
    background: white !important;
    color: black !important;
    font-size: 11pt;
  }

  .no-print, nav, header, .action-bar, .modal, .toast-container, button:not(.print-keep) {
    display: none !important;
  }

  .print-only {
    display: block !important;
  }

  .page-break {
    page-break-before: always;
  }

  .tree-container, .group-board {
    overflow: visible !important;
    padding: 0 !important;
  }

  .card, .tree-node-card {
    box-shadow: none !important;
    border: 1px solid #94a3b8 !important;
    break-inside: avoid;
  }

/* ========================================================================= */
/* STRICT 1-PAGE A4 LANDSCAPE PRINT / PDF RULES - PERFECT FULL WIDTH FIT      */
/* ========================================================================= */
@page {
  size: A4 landscape !important;
  margin: 5mm 6mm !important;
}

@media print {
  html, body {
    width: 297mm !important;
    min-width: 297mm !important;
    margin: 0 !important;
    padding: 0 !important;
    background: #ffffff !important;
    color: #000000 !important;
    overflow: visible !important;
    -webkit-print-color-adjust: exact !important;
    print-color-adjust: exact !important;
  }

  /* Hide navigation, buttons, modals, toasts */
  #toastContainer, .no-print, header, nav, footer, button, input, .modal, .action-bar {
    display: none !important;
    visibility: hidden !important;
  }

  /* Ensure flowchart diagram is fully visible and spans entire page width */
  #flowchartDiagram {
    display: block !important;
    visibility: visible !important;
    position: static !important;
    width: 100% !important;
    max-width: 100% !important;
    min-width: 100% !important;
    margin: 0 auto !important;
    padding: 4px 6px !important;
    border: 1px solid #94a3b8 !important;
    border-radius: 6px !important;
    box-shadow: none !important;
    background: #ffffff !important;
    transform: none !important;
    page-break-inside: avoid !important;
    break-inside: avoid !important;
  }

  #flowchartDiagram * {
    visibility: visible !important;
  }

  /* CRITICAL: FORCE EXACT 4 COLUMNS ON PRINT - NEVER COLLAPSE TO 2 COLUMNS! */
  #flowchartDiagram .grid-cols-4,
  #flowchartDiagram .md\:grid-cols-2,
  #flowchartDiagram .lg\:grid-cols-4,
  #flowchartDiagram [class*="grid-cols-"] {
    display: grid !important;
    grid-template-columns: repeat(4, minmax(0, 1fr)) !important;
    gap: 12px !important;
  }

  /* Compact text sizing for perfect 1-page fit */
  #flowchartDiagram h2 {
    font-size: 15pt !important;
    margin-bottom: 2px !important;
  }
  #flowchartDiagram p {
    font-size: 8.5pt !important;
    margin-bottom: 4px !important;
  }
}
