@import "tailwindcss";
@import "tw-animate-css";

@custom-variant dark (&:is(.dark *));

@keyframes marquee {
  from { transform: translateX(0); }
  to   { transform: translateX(calc(-100% - var(--gap))); }
}
@keyframes marquee-vertical {
  from { transform: translateY(0); }
  to   { transform: translateY(calc(-100% - var(--gap))); }
}

@theme inline {
  /* Tailwind CSS Color Integration */
  --color-background: var(--background);
  --color-foreground: var(--foreground);

  /* Typography system — fonts come from dashboard settings (SiteFontLoader sets
     --app-font-body / --app-font-heading). System fonts are the fallback only. */
  --font-body: var(--app-font-body, system-ui, -apple-system, sans-serif);
  --font-heading: var(--app-font-heading, var(--font-body));
  --font-sans: var(--font-body);
  --font-mono: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;

  /* shadcn/ui colors */
  --color-sidebar-ring: var(--sidebar-ring);
  --color-sidebar-border: var(--sidebar-border);
  --color-sidebar-accent-foreground: var(--sidebar-accent-foreground);
  --color-sidebar-accent: var(--sidebar-accent);
  --color-sidebar-primary-foreground: var(--sidebar-primary-foreground);
  --color-sidebar-primary: var(--sidebar-primary);
  --color-sidebar-foreground: var(--sidebar-foreground);
  --color-sidebar: var(--sidebar);
  --color-chart-5: var(--chart-5);
  --color-chart-4: var(--chart-4);
  --color-chart-3: var(--chart-3);
  --color-chart-2: var(--chart-2);
  --color-chart-1: var(--chart-1);
  --color-ring: var(--ring);
  --color-input: var(--input);
  --color-border: var(--border);
  --color-destructive: var(--destructive);
  --color-destructive-foreground: var(--destructive-foreground);
  --color-accent-foreground: var(--accent-foreground);
  --color-accent: var(--accent);
  --color-muted-foreground: var(--muted-foreground);
  --color-muted: var(--muted);
  --color-secondary-foreground: var(--secondary-foreground);
  --color-secondary: var(--secondary);
  --color-primary-foreground: var(--primary-foreground);
  --color-primary: var(--primary);
  --color-popover-foreground: var(--popover-foreground);
  --color-popover: var(--popover);
  --color-card-foreground: var(--card-foreground);
  --color-card: var(--card);

  /* Figma Design System - Custom colors */
  --color-primary-50: var(--primary-50);
  --color-primary-100: var(--primary-100);
  --color-primary-200: var(--primary-200);
  --color-primary-300: var(--primary-300);
  --color-primary-400: var(--primary-400);
  --color-primary-500: var(--primary-500);
  --color-primary-600: var(--primary-600);
  --color-primary-700: var(--primary-700);
  --color-primary-800: var(--primary-800);
  --color-primary-900: var(--primary-900);
  --color-secondary-50: var(--secondary-50);
  --color-secondary-100: var(--secondary-100);
  --color-secondary-200: var(--secondary-200);
  --color-secondary-300: var(--secondary-300);
  --color-secondary-400: var(--secondary-400);
  --color-secondary-500: var(--secondary-500);
  --color-secondary-600: var(--secondary-600);
  --color-secondary-700: var(--secondary-700);
  --color-secondary-800: var(--secondary-800);
  --color-secondary-900: var(--secondary-900);
  --color-highlights-bg: var(--highlights-bg);
  --color-highlights-border: var(--highlights-border);
  --color-artboard-main-bg: var(--artboard-main-bg);
  --color-white: var(--bg-white);
  --color-white-87: var(--font-white-87);
  --color-white-60: var(--font-white-60);
  --color-font-primary: var(--font-primary);
  --color-font-secondary: var(--font-secondary);
  --color-font-tertiary: var(--font-tertiary);
  --color-stroke: var(--stroke);
  --color-stroke-divider: var(--stroke-divider);
  --color-divider: var(--stroke-divider);
  --color-interactive-hover: var(--interactive-hover);
  --color-interactive-active: var(--interactive-active);
  --color-interactive-pressed: var(--interactive-pressed);
  --color-focus-ring-soft: var(--focus-ring-soft);
  --color-dangerous: var(--dangerous);
  --color-danger-500: var(--dangerous);
  --color-success-50: var(--status-green);
  --color-status-green: var(--status-green);
  --color-table-title-bg: var(--table-title-bg);
  --color-foundation-sec-500: var(--foundation-sec-500);
  --color-foundation-black-300: var(--font-secondary);

  /* Marquee animations */
  --animate-marquee: marquee var(--duration) linear infinite;
  --animate-marquee-vertical: marquee-vertical var(--duration) linear infinite;

  /* Font Family Utilities (legacy naming kept for compatibility) */
  --font-family-almarai: var(--font-body);
  --font-family-ibm-plex: var(--font-heading);

  /* Radius */
  --radius-sm: calc(var(--radius) - 4px);
  --radius-md: calc(var(--radius) - 2px);
  --radius-lg: var(--radius);
  --radius-xl: calc(var(--radius) + 4px);
}

:root {
  --radius: 0.625rem;
  --website-header-height: 136px; /* 56px top bar + 80px main nav */

  /* Figma Design System Colors */
  /* Primary Colors */
  --primary-50: #E9F2F1;
  --primary-100: #B9D6D4;
  --primary-200: #98C3BF;
  --primary-300: #68A7A1;
  --primary-400: #4B968F;
  --primary-500: #1E7C73;
  --primary-600: #1B7169;
  --primary-700: #155852;
  --primary-800: #11443F;
  --primary-900: #0D3430;

  --secondary-50: #E9F6F6;
  --secondary-100: #BCE2E2;
  --secondary-200: #9BD5D5;
  --secondary-300: #6EC1C1;
  --secondary-400: #51B5B5;
  --secondary-500: #26A3A3;
  --secondary-600: #239494;
  --secondary-700: #1B7474;
  --secondary-800: #155A5A;
  --secondary-900: #104444;

  --highlights-bg: #E9F6F6;
  --highlights-border: #BCE2E2;
  --font-primary: #202020;
  --font-secondary: #646464;
  --font-tertiary: #9A9A9A;
  --font-white: #FFFFFF;
  --font-white-87: rgba(255, 255, 255, 0.87);
  --font-white-60: rgba(255, 255, 255, 0.6);
  --text-status-red: #FF0000;
  --text-status-green: #34CB63;
  --bg-white: #FFFFFF;
  --bg-gray-01: #F9F9F9;
  --stroke-divider: #F4F4F4;
  --stroke: #E9E9E9;
  --artboard-main-bg: #FAFAFA;
  --dangerous: #FF3141;
  --status-green: #22C55E;
  --table-title-bg: #E8F1F8;
  --yellow-500: #E5B32C;
  --foundation-sec-500: #000324;
  --shadow-card: 0 4px 4px 4px rgba(198, 198, 198, 1);
  --interactive-hover: rgba(30, 124, 115, 0.08);
  --interactive-active: rgba(30, 124, 115, 0.14);
  --interactive-pressed: rgba(30, 124, 115, 0.2);
  --focus-ring-soft: rgba(30, 124, 115, 0.3);

  /* shadcn/ui Color Mapping */
  --background: var(--artboard-main-bg);
  --foreground: var(--font-primary);
  --card: var(--bg-white);
  --card-foreground: var(--font-primary);
  --popover: var(--bg-white);
  --popover-foreground: var(--font-primary);
  --primary: var(--primary-500);
  --primary-foreground: #FFFFFF;
  --secondary: var(--secondary-500);
  --secondary-foreground: #FFFFFF;
  --muted: var(--bg-gray-01);
  --muted-foreground: var(--font-secondary);
  --accent: var(--highlights-bg);
  --accent-foreground: var(--font-primary);
  --destructive: var(--dangerous);
  --destructive-foreground: #FFFFFF;
  --border: var(--stroke);
  --input: var(--stroke);
  --ring: var(--primary-500);
  --chart-1: var(--primary-500);
  --chart-2: var(--primary-600);
  --chart-3: var(--primary-100);
  --chart-4: var(--secondary-500);
  --chart-5: var(--font-secondary);
  --sidebar: var(--primary-900);
  --sidebar-foreground: #FFFFFF;
  --sidebar-primary: var(--primary-900);
  --sidebar-primary-foreground: #FFFFFF;
  --sidebar-accent: rgba(255, 255, 255, 0.12);
  --sidebar-accent-foreground: #FFFFFF;
  --sidebar-border: rgba(255, 255, 255, 0.12);
  --sidebar-ring: #FFFFFF;
}

.dark {
  /* Dark mode tuned for interaction parity while preserving palette identity */
  --highlights-bg: rgba(255, 255, 255, 0.06);
  --highlights-border: rgba(255, 255, 255, 0.12);
  --stroke-divider: #2A2A2A;
  --stroke: #2A2A2A;
  --artboard-main-bg: #121212;
  --font-primary: #FFFFFF;
  --font-secondary: rgba(255, 255, 255, 0.6);
  --font-tertiary: rgba(255, 255, 255, 0.38);
  --bg-white: #1E1E1E;
  --table-title-bg: rgba(255, 255, 255, 0.06);
  --status-green: #22C55E;
  --background: #121212;
  --foreground: #FFFFFF;
  --card: #1E1E1E;
  --card-foreground: #FFFFFF;
  --popover: #1E1E1E;
  --popover-foreground: #FFFFFF;
  --primary: var(--primary-500);
  --primary-foreground: #FFFFFF;
  --secondary: var(--secondary-500);
  --secondary-foreground: #FFFFFF;
  --muted: #232323;
  --muted-foreground: rgba(255, 255, 255, 0.6);
  --accent: rgba(255, 255, 255, 0.08);
  --accent-foreground: #FFFFFF;
  --destructive: var(--dangerous);
  --destructive-foreground: #FFFFFF;
  --border: #2A2A2A;
  --input: #2A2A2A;
  --ring: var(--primary-500);
  --chart-1: var(--primary-500);
  --chart-2: var(--primary-600);
  --chart-3: var(--primary-100);
  --chart-4: var(--secondary-500);
  --chart-5: var(--font-white-60);
  --sidebar-hover: rgba(255, 255, 255, 0.12);
  --sidebar-active: rgba(255, 255, 255, 0.18);
  --sidebar-input: rgba(255, 255, 255, 0.08);
  --sidebar: var(--primary-900);
  --sidebar-foreground: #FFFFFF;
  --sidebar-primary: var(--primary-900);
  --sidebar-primary-foreground: #FFFFFF;
  --sidebar-accent: var(--sidebar-hover);
  --sidebar-accent-foreground: #FFFFFF;
  --sidebar-border: rgba(255, 255, 255, 0.1);
  --sidebar-ring: #FFFFFF;
}

@layer base {
  * {
    @apply border-border outline-ring/50;
  }
  html, body {
    min-height: 100%;
    overflow-x: hidden;
    overflow-y: auto;
  }
  body {
    @apply bg-background text-foreground;
    font-family: var(--font-body);
  }

  /* Headings use the dashboard font stack */
  h1 {
    font-family: var(--font-heading);
    font-size: 28px;
    font-weight: 700;
    line-height: 1.2;
    letter-spacing: 0;
  }

  h2 {
    font-family: var(--font-heading);
    font-size: 20px;
    font-weight: 700;
    line-height: 1.5;
    letter-spacing: 0;
  }

  h3 {
    font-family: var(--font-heading);
    font-size: 14px;
    font-weight: 700;
    line-height: 1.2;
    letter-spacing: 0;
  }

  h4 {
    font-family: var(--font-heading);
    font-size: 12px;
    font-weight: 700;
    line-height: 1.2;
    letter-spacing: 0;
  }

  h5 {
    font-family: var(--font-heading);
    font-size: 20px;
    font-weight: 400;
    line-height: 1.6;
  }

  p {
    font-family: var(--font-body);
  }

  /* Hide scrollbar while maintaining scroll functionality */
  .scrollbar-hide {
    -ms-overflow-style: none;
    scrollbar-width: none;
    -webkit-overflow-scrolling: touch;
    scroll-behavior: smooth;
  }

  .scrollbar-hide::-webkit-scrollbar {
    display: none;
  }
}

/* Sidebar always uses white text regardless of color scheme */
[data-sidebar-nav] * {
  color: white !important;
}
[data-sidebar-nav] input {
  color: white !important;
}
[data-sidebar-nav] input::placeholder {
  color: rgba(255, 255, 255, 0.6) !important;
}

.page-content-editor {
  color: var(--font-primary);
  line-height: 1.7;
}

.page-content-editor p {
  margin: 0;
}

.page-content-editor p.is-editor-empty:first-child::before {
  color: var(--font-tertiary);
  content: attr(data-placeholder);
  float: right;
  height: 0;
  pointer-events: none;
}

[dir="ltr"] .page-content-editor p.is-editor-empty:first-child::before {
  float: left;
}

.page-content-editor ul,
.page-content-editor ol {
  margin: 0.75rem 0;
  padding-inline-start: 1.25rem;
}

.page-content-editor ul {
  list-style-type: disc;
}

.page-content-editor ol {
  list-style-type: decimal;
}

.page-content-editor img {
  border-radius: 8px;
  height: auto;
  margin: 0.75rem 0;
  max-width: 100%;
}
