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

/* 🌞 Light Theme (raw HSL values) */
:root {
  --background: 0 0% 100%;
  --foreground: 222.2 47.4% 11.2%;

  --muted: 210 40% 96.1%;
  --muted-foreground: 215.4 16.3% 46.9%;

  --popover: 0 0% 100%;
  --popover-foreground: 222.2 47.4% 11.2%;

  --card: 0 0% 100%;
  --card-foreground: 222.2 47.4% 11.2%;

  --border: 214.3 31.8% 91.4%;
  --input: 214.3 31.8% 91.4%;

  --primary: 222.2 47.4% 11.2%;
  --primary-foreground: 210 40% 98%;

  --secondary: 210 40% 96.1%;
  --secondary-foreground: 222.2 47.4% 11.2%;

  --accent: 210 40% 96.1%;
  --accent-foreground: 222.2 47.4% 11.2%;

  --destructive: 0 100% 50%;
  --destructive-foreground: 210 40% 98%;

  --ring: 215 20.2% 65.1%;

  --radius: 0.5rem;
}

/* 🌚 Dark Theme (raw HSL values) */
.dark {
  --background: 224 71% 4%;
  --foreground: 213 31% 91%;

  --muted: 223 47% 11%;
  --muted-foreground: 215.4 16.3% 56.9%;

  --popover: 224 71% 4%;
  --popover-foreground: 215 20.2% 65.1%;

  --card: 224 71% 4%;
  --card-foreground: 213 31% 91%;

  --border: 216 34% 17%;
  --input: 216 34% 17%;

  --primary: 210 40% 98%;
  --primary-foreground: 222.2 47.4% 1.2%;

  --secondary: 222.2 47.4% 11.2%;
  --secondary-foreground: 210 40% 98%;

  --accent: 216 34% 17%;
  --accent-foreground: 210 40% 98%;

  --destructive: 0 63% 31%;
  --destructive-foreground: 210 40% 98%;

  --ring: 216 34% 17%;

  --radius: 0.5rem;
}

@layer base {
  * {
    @apply border-border;
  }
  body {
    @apply bg-background text-foreground;
    font-feature-settings:
      "rlig" 1,
      "calt" 1;
  }
}

/* 🎨 Tailwind-aware theme tokens */
@theme inline {
  --color-background: hsl(var(--background));
  --color-foreground: hsl(var(--foreground));
  --color-muted: hsl(var(--muted));
  --color-muted-foreground: hsl(var(--muted-foreground));
  --color-popover: hsl(var(--popover));
  --color-popover-foreground: hsl(var(--popover-foreground));
  --color-card: hsl(var(--card));
  --color-card-foreground: hsl(var(--card-foreground));
  --color-border: hsl(var(--border));
  --color-input: hsl(var(--input));
  --color-primary: hsl(var(--primary));
  --color-primary-foreground: hsl(var(--primary-foreground));
  --color-secondary: hsl(var(--secondary));
  --color-secondary-foreground: hsl(var(--secondary-foreground));
  --color-accent: hsl(var(--accent));
  --color-accent-foreground: hsl(var(--accent-foreground));
  --color-destructive: hsl(var(--destructive));
  --color-destructive-foreground: hsl(var(--destructive-foreground));
  --color-ring: hsl(var(--ring));
}

/* 🔄 Spinner animation */
@keyframes spin {
  0% {
    transform: rotate(0deg);
  }
  100% {
    transform: rotate(360deg);
  }
}

.animate-spin {
  animation: spin 1s linear infinite;
}

@media print {
  body {
    background: white;
  }

  /* ---------------------------------
     PAGE LAYOUT
  --------------------------------- */

  @page {
    margin: 0;
  }

  /* Outer page padding (NOT scaled) */
  .print-page {
    padding: 20px 24px;
  }

  /* Inner content (scaled slightly) */
  .print-root {
    transform: scale(0.94);
    transform-origin: top left;
    width: 106.4%; /* 1 / 0.94 */
  }

  /* ---------------------------------
     HEADER
  --------------------------------- */

  .print-header {
    display: flex;
    align-items: center;
    gap: 16px;
    border-bottom: 2px solid #0b3c5d;
    padding-bottom: 12px;
    margin-bottom: 20px;
  }

  /* ---------------------------------
     PAGE BREAKS
  --------------------------------- */

  .page-break {
    break-before: page;
    page-break-before: always;
  }

  .avoid-break {
    break-inside: avoid;
    page-break-inside: avoid;
  }

  /* ---------------------------------
     GRID STABILITY
  --------------------------------- */

  .print-grid-3 {
    display: grid !important;
    grid-template-columns: repeat(3, minmax(0, 1fr)) !important;
    gap: 14px !important;
  }

  .print-grid-2 {
    display: grid !important;
    grid-template-columns: repeat(2, minmax(0, 1fr)) !important;
    gap: 14px !important;
  }

  /* ---------------------------------
     CARD FIXES
  --------------------------------- */

  section,
  .card,
  .gradient-card {
    break-inside: avoid;
    page-break-inside: avoid;
  }

  .gradient-card {
    background: none !important;
    border: 2px solid #e5e7eb;
  }

  .gradient-card > div {
    padding: 10px !important;
  }

  /* Disable gradient text */
  .print-text-solid {
    background: none !important;
    -webkit-background-clip: initial !important;
    background-clip: initial !important;
    color: #0b3c5d !important;
  }

  /* Hide UI chrome */
  button,
  nav,
  .no-print {
    display: none !important;
  }
}

@keyframes loading {
  0% { transform: translateX(-100%); }
  100% { transform: translateX(300%); }
}
