/*
  Get Reply Quik design tokens (v1, Nov 2026)
  Source of truth for colour, type, spacing, radius, shadow and motion.
  Contrast rules (WCAG 2.2 AA, measured): see docs/02_BRAND_IDENTITY.md section 5.
  Components must use these variables. Never hardcode hex values or px sizes in components.
  Tailwind config maps to these variables (see docs/04_ARCHITECTURE.md).
*/

/* Palette follows the Get Reply Quik logo: the green gradient of the mark, charcoal text, light surfaces.
   Brand v3 (9 Nov 2026): light sidebar, no large dark panels in light mode. */
:root {
  /* Ink / midnight (neutrals, from the logo's charcoal) */
  --ink-950: #081019;   /* text on green fills and gradients; dark mode base */
  --ink-900: #18242F;   /* main text, outbound bubble */
  --ink-700: #33434F;
  --ink-600: #46566A;
  --ink-500: #5B6B79;   /* muted text (5.5:1 on white) */
  --ink-400: #76848F;   /* form field borders (3.8:1 on white, 3.5:1 on app bg) */
  --ink-300: #A9B8C4;
  --ink-100: #E3E9EE;
  --ink-50:  #F3F6F8;
  --white:   #FFFFFF;

  /* Signal green (from the logo). Bright green is a FILL with dark ink text, never text on white. */
  --green-500: #02D86A;   /* fills: primary button, unread badge. Text on it: ink-950 (10:1). White fails (1.9:1) */
  --green-600: #02B854;   /* hover and pressed fill. Text on it: ink-950 (7.3:1) */
  --green-700: #067A3E;   /* text, links, icons, thin indicators on white (5.4:1); white text on this fill passes */
  --green-100: #D2F7E3;
  --green-50:  #EAFBF2;

  /* Brand gradients (from the logo mark). Text on any of them is ink-950 (6.1:1 at the darkest stop).
     Use only where listed in docs/02 section 5: primary buttons, active nav bar, logo, auth brand panel,
     progress and usage bars, onboarding step markers. Never on page backgrounds, cards or text. */
  --gradient-brand:       linear-gradient(135deg, #3FF29A 0%, #02D86A 55%, #02B854 100%);
  --gradient-brand-hover: linear-gradient(135deg, #02D86A 0%, #02B854 55%, #02A84C 100%);
  --gradient-brand-hero:  linear-gradient(135deg, #77F8B8 0%, #06EA77 50%, #02B854 100%);  /* auth brand panel, large areas only */
  --gradient-soft:        linear-gradient(180deg, #EAFBF2 0%, #FFFFFF 100%);              /* empty states, onboarding header */

  /* Status.
     -600 = icons, borders, dots, bar fills ONLY (never small text).
     -700 = status text on white or on the -50 background (4.7:1 or better).
     -50  = soft background for banners and bars. */
  --success-600: #0B9A4B;
  --warning-600: #B7791F;
  --danger-600:  #C93B3B;
  --info-600:    #2F6FDE;
  --success-700: #067A3E;
  --warning-700: #8A5A0B;
  --danger-700:  #A82B2B;
  --info-700:    #1F55B8;
  --success-50:  #EAFBF2;
  --warning-50:  #FBF1DC;
  --danger-50:   #FBEAEA;
  --info-50:     #E8EFFC;

  /* Semantic roles (components use these, not the raw scale) */
  --color-bg:              var(--ink-50);
  --color-surface:         var(--white);
  --color-surface-raised:  var(--white);
  --color-border:          var(--ink-100);        /* dividers and card edges only */
  --color-border-strong:   var(--ink-400);        /* inputs, selects, checkboxes (needs 3:1) */
  --color-text:            var(--ink-900);
  --color-text-muted:      var(--ink-500);
  --color-primary:         var(--green-500);      /* flat fill fallback; buttons use --color-primary-fill */
  --color-primary-fill:    var(--gradient-brand);
  --color-primary-fill-hover: var(--gradient-brand-hover);
  --color-primary-hover:   var(--green-600);
  --color-text-on-primary: var(--ink-950);        /* dark text on green. White fails (1.9:1) */
  --color-primary-soft:    var(--green-50);
  --color-selected:        var(--green-50);       /* selected row: add a 3 px green-700 start bar */
  --color-link:            var(--green-700);      /* links, active nav text and icons on light surfaces */
  --color-indicator:       var(--green-700);      /* thin lines and icons that must reach 3:1 on white */
  --color-accent:          var(--green-500);      /* unread badges and small highlights */
  --color-on-accent:       var(--ink-950);
  --color-accent-soft:     var(--green-50);
  /* Light sidebar (desktop navigation) */
  --sidebar-bg:            var(--white);          /* with a 1 px ink-100 end border */
  --sidebar-text:          var(--ink-700);        /* 10.2:1 */
  --sidebar-text-muted:    var(--ink-500);        /* section labels, 5.5:1 */
  --sidebar-hover-bg:      var(--ink-50);
  --sidebar-active-bg:     var(--green-50);
  --sidebar-active-text:   var(--ink-900);        /* semibold, 14.7:1 on green-50 */
  --sidebar-active-icon:   var(--green-700);      /* 5.1:1 on green-50 */
  --sidebar-active-indicator: var(--gradient-brand); /* 3 px start bar, decorative; active state also shown by bg, weight and icon */
  /* Status: icon, border, dot, bar fill colours. Never use these for small text. */
  --color-success:         var(--success-600);
  --color-warning:         var(--warning-600);
  --color-danger:          var(--danger-600);
  --color-info:            var(--info-600);
  /* Status: text colours (on white or on the soft background). Body words may also stay ink. */
  --color-success-text:    var(--success-700);
  --color-warning-text:    var(--warning-700);
  --color-danger-text:     var(--danger-700);
  --color-info-text:       var(--info-700);
  /* Status: soft backgrounds for banners and bars (add a -600 border and an icon). */
  --color-success-soft:    var(--success-50);
  --color-warning-soft:    var(--warning-50);
  --color-danger-soft:     var(--danger-50);
  --color-info-soft:       var(--info-50);
  /* Solid status fills that carry white text */
  --color-success-solid:   var(--success-700);
  --color-on-success-solid:var(--white);
  --color-focus-ring:      var(--ink-900);        /* 15.8:1 on white */

  /* Message bubbles (light slate outbound, white inbound with border; no green bubbles, no chat-app look) */
  --bubble-inbound-bg:   var(--white);           /* with a 1 px ink-100 border */
  --bubble-inbound-text: var(--ink-900);
  --bubble-outbound-bg:  #EEF2F5;
  --bubble-outbound-text:var(--ink-900);         /* 14.0:1 */
  --bubble-outbound-meta:var(--ink-500);         /* time and ticks (4.9:1) */
  --bubble-note-bg:      #FFF8E1; /* internal notes, never sent */
  --bubble-system-text:  var(--ink-500);

  /* Typography */
  --font-sans: "Roboto", "Noto Sans Arabic", system-ui, -apple-system, "Segoe UI", sans-serif;   /* Roboto is the Android system font; WhatsApp uses each phone's system font, so this is the closest free match */
  --font-arabic: "Noto Sans Arabic", "Roboto", system-ui, sans-serif;
  --font-mono: "Roboto Mono", ui-monospace, "SFMono-Regular", Menlo, monospace;

  --text-xs:   0.75rem;   /* 12 */
  --text-sm:   0.875rem;  /* 14, default UI */
  --text-base: 1rem;      /* 16, messages and mobile inputs */
  --text-lg:   1.125rem;  /* 18 */
  --text-xl:   1.25rem;   /* 20 */
  --text-2xl:  1.5rem;    /* 24 */
  --text-3xl:  1.875rem;  /* 30 */

  --weight-regular: 400;
  --weight-medium:  500;
  --weight-semibold:600;

  --leading-tight:  1.25;
  --leading-normal: 1.5;
  --leading-arabic: 1.7;

  /* Spacing (4px grid) */
  --space-1: 4px;
  --space-2: 8px;
  --space-3: 12px;
  --space-4: 16px;
  --space-6: 24px;
  --space-8: 32px;
  --space-12: 48px;

  /* Radius */
  --radius-sm: 6px;
  --radius-md: 10px;
  --radius-lg: 16px;
  --radius-full: 9999px;

  /* Shadow (two levels only) */
  --shadow-card:    0 1px 2px rgba(8, 16, 25, 0.06), 0 1px 1px rgba(8, 16, 25, 0.04);
  --shadow-overlay: 0 8px 24px rgba(8, 16, 25, 0.16);

  /* Motion */
  --duration-fast: 150ms;
  --duration-base: 200ms;
  --ease-out: cubic-bezier(0.2, 0.8, 0.2, 1);

  /* Layout */
  --sidebar-width: 240px;
  --sidebar-collapsed: 64px;
  --conversation-list-width: 360px;
  --contact-panel-width: 320px;
  --topbar-height: 56px;
  --bottom-nav-height: 64px;
  --touch-target: 44px;

  /* Safe areas for mobile shells (Capacitor / PWA) */
  --safe-top: env(safe-area-inset-top, 0px);
  --safe-bottom: env(safe-area-inset-bottom, 0px);
}

/* Arabic content gets more line height */
:lang(ar) {
  font-family: var(--font-arabic);
  line-height: var(--leading-arabic);
}

/* Dark mode tokens: defined now, shipped in Phase 2. All pairs measured, 4.5:1 text, 3:1 borders. */
:root[data-theme="dark"] {
  --color-bg:              #081019;
  --color-surface:         #0F1A24;
  --color-surface-raised:  #16232F;
  --color-border:          #243543;
  --color-border-strong:   #5C7184;
  --color-text:            #E8EEF2;
  --color-text-muted:      #9BAAB6;
  --color-primary:         #02D86A;
  --color-primary-hover:   #3FE58E;
  --color-primary-fill:    linear-gradient(135deg, #3FF29A 0%, #02D86A 55%, #02B854 100%);
  --color-primary-fill-hover: linear-gradient(135deg, #77F8B8 0%, #3FF29A 55%, #02D86A 100%);
  --color-text-on-primary: #081019;   /* 10:1 on green */
  --color-on-accent:       #081019;
  --color-primary-soft:    #0F2E20;
  --color-selected:        #12352A;
  --color-link:            #02D86A;   /* 9.2:1 on surface */
  --color-indicator:       #02D86A;
  --color-accent:          #02D86A;
  --color-accent-soft:     #0F2E20;
  --color-focus-ring:      #02D86A;
  --sidebar-bg:            #0F1A24;
  --sidebar-text:          #C5D0D9;
  --sidebar-text-muted:    #9BAAB6;
  --sidebar-hover-bg:      #16232F;
  --sidebar-active-bg:     #12352A;
  --sidebar-active-text:   #FFFFFF;
  --sidebar-active-icon:   #02D86A;
  --bubble-inbound-bg:     #16232F;
  --bubble-inbound-text:   #E8EEF2;
  --bubble-outbound-bg:    #1E2C38;
  --bubble-outbound-text:  #E8EEF2;
  --bubble-outbound-meta:  #9BAAB6;
  --bubble-note-bg:        #3A3320;
  /* Status in dark mode: one set, used for icons and text (all 6.9:1 or better on surface) */
  --color-success:         #5FD08F;
  --color-warning:         #E3B04B;
  --color-danger:          #FF8A8A;
  --color-info:            #7FA8F5;
  --color-success-text:    #5FD08F;
  --color-warning-text:    #E3B04B;
  --color-danger-text:     #FF8A8A;
  --color-info-text:       #7FA8F5;
  --color-success-soft:    #0F2E1E;
  --color-warning-soft:    #33280F;
  --color-danger-soft:     #3A1D1F;
  --color-info-soft:       #15284A;
  --color-success-solid:   #5FD08F;
  --color-on-success-solid:#081019;
}

@media (prefers-reduced-motion: reduce) {
  :root {
    --duration-fast: 0ms;
    --duration-base: 0ms;
  }
}
