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

@layer base {
  :root {
    /* Miaro brand — Primary #101828 · Secondary #5A6473 */
    --brand-primary: 221 43% 11%;
    --brand-secondary: 216 13% 40%;
    --background: 220 33% 98%;
    --foreground: 221 43% 11%;
    --card: 0 0% 100%;
    --card-foreground: 221 43% 11%;
    --popover: 0 0% 100%;
    --popover-foreground: 221 43% 11%;
    --primary: 221 43% 11%;
    --primary-foreground: 0 0% 100%;
    --secondary: 220 14% 94%;
    --secondary-foreground: 216 13% 40%;
    --muted: 220 14% 95%;
    --muted-foreground: 216 13% 40%;
    --accent: 220 16% 94%;
    --accent-foreground: 221 43% 11%;
    --destructive: 0 72% 46%;
    --destructive-foreground: 0 0% 100%;
    --success: 152 45% 32%;
    --success-foreground: 0 0% 100%;
    --warning: 38 92% 42%;
    --warning-foreground: 221 43% 11%;
    --border: 220 16% 88%;
    --input: 220 16% 88%;
    --ring: 221 43% 11%;
    --radius: 0.75rem;
    /* Avatar initials — always navy + white (Miaro pattern, both themes) */
    --avatar: 221 43% 11%;
    --avatar-foreground: 0 0% 100%;
    --chart-1: 221 43% 11%;
    --chart-2: 216 13% 40%;
    --chart-3: 221 28% 28%;
    --chart-4: 216 12% 55%;
    --chart-5: 220 10% 70%;
    /* Miaro sidebar: white surface, soft muted active pill */
    --sidebar: 0 0% 100%;
    --sidebar-foreground: 221 43% 11%;
    --sidebar-muted: 220 14% 96%;
    --sidebar-border: 220 16% 92%;
    --sidebar-accent: 220 14% 94%;
    --sidebar-accent-foreground: 221 43% 11%;
    --scrollbar-size: 10px;
    --scrollbar-track: 220 14% 94%;
    --scrollbar-thumb: 216 10% 72%;
    --scrollbar-thumb-hover: 216 13% 55%;
    --scrollbar-thumb-active: 221 43% 11%;
    /* Secondary typeface — SF Pro (Apple) with system fallbacks */
    --font-secondary:
      "SF Pro Text", "SF Pro Display", -apple-system, BlinkMacSystemFont,
      "Segoe UI", sans-serif;
  }

  .dark {
    --brand-primary: 220 18% 92%;
    --brand-secondary: 216 12% 62%;
    --background: 221 43% 7%;
    --foreground: 220 20% 96%;
    --card: 221 35% 10%;
    --card-foreground: 220 20% 96%;
    --popover: 221 35% 10%;
    --popover-foreground: 220 20% 96%;
    /* Lifted primary for contrast on dark navy surfaces */
    --primary: 220 18% 92%;
    --primary-foreground: 221 43% 11%;
    --secondary: 221 22% 14%;
    --secondary-foreground: 216 12% 68%;
    --muted: 221 22% 13%;
    --muted-foreground: 216 12% 62%;
    --accent: 221 22% 15%;
    --accent-foreground: 220 20% 96%;
    --destructive: 0 62% 55%;
    --destructive-foreground: 0 0% 100%;
    --success: 152 40% 45%;
    --success-foreground: 0 0% 100%;
    --warning: 38 90% 50%;
    --warning-foreground: 221 43% 11%;
    --border: 221 20% 16%;
    --input: 221 20% 16%;
    --ring: 220 18% 80%;
    --avatar: 221 43% 11%;
    --avatar-foreground: 0 0% 100%;
    --chart-1: 220 18% 88%;
    --chart-2: 216 12% 58%;
    --chart-3: 220 14% 72%;
    --chart-4: 216 10% 48%;
    --chart-5: 221 15% 35%;
    --sidebar: 221 43% 8%;
    --sidebar-foreground: 220 18% 94%;
    --sidebar-muted: 221 28% 12%;
    --sidebar-border: 221 22% 14%;
    /* Soft lifted pill — dark text stays readable on light accent */
    --sidebar-accent: 221 18% 18%;
    --sidebar-accent-foreground: 220 20% 96%;
    --scrollbar-track: 221 28% 10%;
    --scrollbar-thumb: 221 14% 28%;
    --scrollbar-thumb-hover: 216 12% 42%;
    --scrollbar-thumb-active: 220 18% 72%;
  }
}

@layer base {
  * {
    @apply border-border;
  }

  html {
    font-family: var(--font-sans), "Lexend Deca", sans-serif;
  }

  body {
    @apply bg-background text-foreground font-sans antialiased;
    font-family: var(--font-sans), "Lexend Deca", sans-serif;
  }

  h1,
  h2,
  h3,
  h4,
  h5,
  h6 {
    font-family: var(--font-secondary), var(--font-sans), sans-serif;
  }

  button,
  input,
  textarea,
  select,
  optgroup,
  option,
  table,
  th,
  td,
  dialog,
  [role="dialog"],
  [role="menu"],
  [role="listbox"],
  [role="tooltip"],
  [data-radix-popper-content-wrapper] {
    font-family: inherit;
  }

  svg text,
  svg tspan {
    font-family: inherit !important;
  }

  * {
    scrollbar-width: thin;
    scrollbar-color: hsl(var(--scrollbar-thumb)) hsl(var(--scrollbar-track));
  }

  html[data-scrolling="true"] * {
    scrollbar-color: hsl(var(--scrollbar-thumb-active))
      hsl(var(--scrollbar-track));
  }

  *::-webkit-scrollbar {
    width: var(--scrollbar-size);
    height: var(--scrollbar-size);
  }

  *::-webkit-scrollbar-track {
    background: hsl(var(--scrollbar-track));
    border-radius: 9999px;
  }

  *::-webkit-scrollbar-thumb {
    background: hsl(var(--scrollbar-thumb));
    border-radius: 9999px;
    border: 2px solid hsl(var(--scrollbar-track));
    background-clip: padding-box;
    transition:
      background-color 0.2s cubic-bezier(0.22, 1, 0.36, 1),
      border-color 0.2s cubic-bezier(0.22, 1, 0.36, 1);
  }

  *::-webkit-scrollbar-thumb:hover {
    background: hsl(var(--scrollbar-thumb-hover));
    border: 2px solid hsl(var(--scrollbar-track));
    background-clip: padding-box;
  }

  *::-webkit-scrollbar-thumb:active {
    background: hsl(var(--scrollbar-thumb-active));
    border: 2px solid hsl(var(--scrollbar-track));
    background-clip: padding-box;
  }

  html[data-scrolling="true"] *::-webkit-scrollbar-thumb {
    background: hsl(var(--scrollbar-thumb-active) / 0.85);
    border: 2px solid hsl(var(--scrollbar-track));
    background-clip: padding-box;
  }

  *::-webkit-scrollbar-corner {
    background: transparent;
  }
}

@layer utilities {
  .animate-page-enter {
    animation: pageEnter 0.22s ease-out both;
  }

  .font-secondary {
    font-family: var(--font-secondary), var(--font-sans), sans-serif;
  }
}

@keyframes pageEnter {
  from {
    opacity: 0;
    transform: translateY(6px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

@keyframes slideInLeft {
  from {
    opacity: 0;
    transform: translateX(-100%);
  }
  to {
    opacity: 1;
    transform: translateX(0);
  }
}

@keyframes slideInRight {
  from {
    opacity: 0;
    transform: translateX(100%);
  }
  to {
    opacity: 1;
    transform: translateX(0);
  }
}

@keyframes slideOutLeft {
  from {
    opacity: 1;
    transform: translateX(0);
  }
  to {
    opacity: 0;
    transform: translateX(-100%);
  }
}

@keyframes slideOutRight {
  from {
    opacity: 1;
    transform: translateX(0);
  }
  to {
    opacity: 0;
    transform: translateX(100%);
  }
}

.animate-slide-in-left {
  animation: slideInLeft 0.3s ease-out forwards;
}

.animate-slide-in-right {
  animation: slideInRight 0.3s ease-out forwards;
}

.animate-slide-out-left {
  animation: slideOutLeft 0.3s ease-out forwards;
}

.animate-slide-out-right {
  animation: slideOutRight 0.3s ease-out forwards;
}

@media (prefers-reduced-motion: reduce) {
  .animate-page-enter,
  .animate-slide-in-left,
  .animate-slide-in-right,
  .animate-slide-out-left,
  .animate-slide-out-right {
    animation: none !important;
  }

  *::-webkit-scrollbar-thumb {
    transition: none;
  }
}
