/* Small overrides on top of Tailwind. Most styling is utility-first. */

[x-cloak] { display: none !important; }

::-webkit-scrollbar { width: 8px; height: 8px; }
::-webkit-scrollbar-thumb { background: #94a3b8; border-radius: 4px; }
::-webkit-scrollbar-track { background: transparent; }

/* HTMX request indicator */
.htmx-request .htmx-indicator { display: inline-block; }
.htmx-indicator { display: none; }

table.compact td, table.compact th { padding: 0.5rem 0.75rem; }

/* =============================================================
 * v9.9.13.2 — Theme system
 * -------------------------------------------------------------
 * Tailwind's `brand`, `primary`, `sidebar` palettes resolve to
 * `rgb(var(--brand-N) / <alpha-value>)` (see tailwind.config in
 * base.html). Switching the `data-theme` attribute on <html>
 * therefore re-skins every brand-/primary-/sidebar- utility
 * across the entire app — no template changes required.
 *
 * Variables hold SPACE-SEPARATED rgb triples (no commas, no
 * `rgb(...)` wrapper) so Tailwind can compose alpha onto them.
 *
 *   --brand-500: 93 122 78;          /* #5d7a4e (forest)
 *
 * Themes shipped:
 *   - forest   (default, original)
 *   - sunrise  (orange — opt-in via the sidebar picker)
 * ============================================================= */

/* ---------- Forest (default) ---------- */
:root,
html[data-theme="forest"] {
  /* brand — deeper forest green (action buttons & accents) */
  --brand-50:  241 246 236;
  --brand-100: 222 233 210;
  --brand-200: 188 210 164;
  --brand-300: 155 187 120;
  --brand-400: 126 163  90;
  --brand-500:  93 122  78;
  --brand-600:  74  98  64;
  --brand-700:  58  78  51;
  --brand-800:  44  58  38;
  --brand-900:  29  39  25;

  /* primary — soft sage green (surfaces) */
  --primary-50:  241 246 236;
  --primary-100: 224 234 214;
  --primary-200: 200 216 184;
  --primary-300: 168 192 148;
  --primary-400: 138 171 116;
  --primary-500: 122 153 104;
  --primary-600:  93 122  78;
  --primary-700:  74  98  64;
  --primary-800:  55  74  48;
  --primary-900:  36  49  32;

  --sidebar-700:  74  98  64;
  --sidebar-800:  55  74  48;
  --sidebar-900:  36  49  32;

  /* Used by hard-coded gradients (sidebar, dashboard hero, login splash) */
  --sidebar-grad-top:    #5d7a4e;
  --sidebar-grad-bottom: #243120;
  --hero-grad-from:      #7a9968;
  --hero-grad-mid:       #5d7a4e;
  --hero-grad-to:        #4a6240;
  --brand-logo-accent:   #ff7a18;     /* unchanged orange logo chip */

  /* ---- Login page ---- */
  --login-bg-from:       #e7f1dd;
  --login-bg-mid:        #d8e8e3;
  --login-bg-to:         #d4e7ee;
  --login-heading:       #243120;
  --login-muted:         #6b7a5e;
  --login-link:          #5d7a4e;
  --login-input-bg:      #fafbf7;
  --login-input-border:  #d8e0cc;
  --login-input-focus:   #7a9968;
  --login-input-ring:    122 153 104;   /* rgb triple for rgba() */
  --login-input-text:    #243120;
  --login-placeholder:   #9bab8c;
  --login-icon:          #7a9968;
  --login-btn-from:      #8aab74;
  --login-btn-mid:       #5d7a4e;
  --login-btn-to:        #4a6240;
  --login-btn-hover-from:#7a9968;
  --login-btn-hover-mid: #4a6240;
  --login-btn-hover-to:  #3a4e33;
  --login-btn-shadow:    74 98 64;      /* rgb triple */
  --login-leaf-fill:     #7a9968;
  --login-leaf-fill-alt: #8aab74;
  --login-leaf-fill-3:   #9bbb78;
  --login-leaf-stem:     #5d7a4e;
  --login-brand-icon-from:#8aab74;
  --login-brand-icon-to:  #5d7a4e;
}

/* ---------- Sunrise (orange) ---------- */
html[data-theme="sunrise"] {
  /* brand — vibrant carrot orange */
  --brand-50:  255 245 236;
  --brand-100: 255 231 207;
  --brand-200: 255 201 153;
  --brand-300: 255 168  99;
  --brand-400: 255 138  55;
  --brand-500: 244 113  24;       /* #f47118 */
  --brand-600: 217  90  11;       /* #d95a0b */
  --brand-700: 168  67  10;
  --brand-800: 124  50   9;
  --brand-900:  90  36   7;

  /* primary — warm amber (surfaces) */
  --primary-50:  255 245 236;
  --primary-100: 255 231 207;
  --primary-200: 255 201 153;
  --primary-300: 255 168  99;
  --primary-400: 255 138  55;
  --primary-500: 244 113  24;
  --primary-600: 217  90  11;
  --primary-700: 168  67  10;
  --primary-800: 124  50   9;
  --primary-900:  90  36   7;

  /* darker sidebar slate (matches the "production" orange mock) */
  --sidebar-700:  26  42  74;
  --sidebar-800:  19  32  58;
  --sidebar-900:  14  23  38;

  --sidebar-grad-top:    #0e1726;
  --sidebar-grad-bottom: #080f1d;
  --hero-grad-from:      #ff8a37;
  --hero-grad-mid:       #f47118;
  --hero-grad-to:        #d95a0b;
  --brand-logo-accent:   #ffffff;

  /* ---- Login page (Sunrise) ---- */
  --login-bg-from:       #fff5ec;
  --login-bg-mid:        #ffe7cf;
  --login-bg-to:         #fde0b8;
  --login-heading:       #5a2407;
  --login-muted:         #8a6238;
  --login-link:          #d95a0b;
  --login-input-bg:      #fffaf3;
  --login-input-border:  #ffd4a8;
  --login-input-focus:   #f47118;
  --login-input-ring:    244 113 24;
  --login-input-text:    #5a2407;
  --login-placeholder:   #c39870;
  --login-icon:          #f47118;
  --login-btn-from:      #ff8a37;
  --login-btn-mid:       #f47118;
  --login-btn-to:        #d95a0b;
  --login-btn-hover-from:#f47118;
  --login-btn-hover-mid: #d95a0b;
  --login-btn-hover-to:  #a8430a;
  --login-btn-shadow:    217 90 11;
  --login-leaf-fill:     #ffa863;
  --login-leaf-fill-alt: #ffc999;
  --login-leaf-fill-3:   #ff8a37;
  --login-leaf-stem:     #d95a0b;
  --login-brand-icon-from:#ff8a37;
  --login-brand-icon-to:  #d95a0b;
}

/* ----------------------------------------------------------------------
 * v9.9.11.4 - hide the sidebar scrollbar.
 * -------------------------------------------------------------------- */
.no-scrollbar {
  scrollbar-width: none;        /* Firefox */
  -ms-overflow-style: none;     /* IE / old Edge */
}
.no-scrollbar::-webkit-scrollbar {
  width: 0 !important;
  height: 0 !important;
  display: none;
  background: transparent;
}
.no-scrollbar::-webkit-scrollbar-thumb,
.no-scrollbar::-webkit-scrollbar-track {
  background: transparent;
}

aside > nav.no-scrollbar { scroll-behavior: smooth; }

/* Themed sidebar gradient — used by the hard-coded gradient in _sidebar.html.
   Setting via CSS variables means the gradient re-themes when data-theme flips. */
.themed-sidebar {
  background: linear-gradient(180deg,
              var(--sidebar-grad-top)    0%,
              var(--sidebar-grad-bottom) 100%);
}

/* Themed dashboard hero — wins over inline `style` via !important so
   v9-era inline-gradient backgrounds still re-skin on theme change. */
.theme-hero {
  background:
    radial-gradient(circle at 18% 22%, rgba(255,255,255,0.18) 0, rgba(255,255,255,0) 40%),
    radial-gradient(circle at 82% 75%, rgba(0,0,0,0.18) 0, rgba(0,0,0,0) 40%),
    linear-gradient(120deg,
      var(--hero-grad-from) 0%,
      var(--hero-grad-mid)  50%,
      var(--hero-grad-to)   100%) !important;
}

/* Small transition so theme swaps feel smooth instead of a hard flash. */
html, body, aside, header, button, a, .themed-sidebar {
  transition-property: background-color, color, border-color, fill, stroke;
  transition-duration: 180ms;
}

/* =============================================================
 * v9.10.0 — Responsive hardening
 * Makes the app render cleanly on phones, tablets, laptops,
 * desktops, Macs and iPads without changing the desktop look.
 * ============================================================= */

/* Never allow a stray wide element to cause horizontal page scroll. */
html, body { max-width: 100%; }
body { overflow-x: hidden; -webkit-text-size-adjust: 100%; text-size-adjust: 100%; }

/* Media + embeds scale down inside their container. */
img, svg, video, canvas { max-width: 100%; height: auto; }

/* iOS safe-area padding (notch / home indicator). */
@supports (padding: max(0px)) {
  footer { padding-left: max(1.5rem, env(safe-area-inset-left));
           padding-right: max(1.5rem, env(safe-area-inset-right)); }
}

/* Avatar: initials sit underneath; the photo overlays and is removed on
 * load error so a missing/broken image never shows the browser's broken
 * icon -- the initials show through instead. */
.avatar-img { object-fit: cover; }

/* Content tables: on small screens let them scroll horizontally instead of
 * overflowing the viewport. Scoped to <main> so layout/login tables are
 * untouched. */
@media (max-width: 768px) {
  main table {
    display: block;
    width: 100%;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    white-space: nowrap;
  }
  /* Keep cards / form sections from forcing the page wider than the screen. */
  main .max-w-5xl, main .max-w-4xl, main .max-w-3xl { max-width: 100%; }
}

/* Prevent the iOS "tap to zoom" that fires when an input font is < 16px. */
@media (max-width: 640px) {
  input, select, textarea { font-size: 16px; }
}

/* Tablets / iPad portrait: the fixed sidebar is hidden until toggled (it is
 * lg: only), so make sure the toggle button stays comfortably tappable. */
@media (max-width: 1023px) {
  header button { min-width: 40px; min-height: 40px; }
}

/* ---------- Dark (near-black / navy corporate) ---------- */
html[data-theme="dark"] {
  --brand-50:  23 37 84;
  --brand-100: 30 58 138;
  --brand-200: 30 64 175;
  --brand-300: 29 78 216;
  --brand-400: 37 99 235;
  --brand-500: 96 165 250;        /* #60a5fa — bright accent on dark */
  --brand-600: 59 130 246;
  --brand-700: 37 99 235;
  --brand-800: 191 219 254;
  --brand-900: 219 234 254;

  --primary-50:  15 23 42;
  --primary-100: 30 41 59;
  --primary-200: 51 65 85;
  --primary-300: 71 85 105;
  --primary-400: 100 116 139;
  --primary-500: 148 163 184;
  --primary-600: 203 213 225;
  --primary-700: 226 232 240;
  --primary-800: 241 245 249;
  --primary-900: 248 250 252;

  --sidebar-700:  17 24 39;
  --sidebar-800:  11 16 27;
  --sidebar-900:  7 11 20;

  --sidebar-grad-top:    #111827;
  --sidebar-grad-bottom: #070b14;
  --hero-grad-from:      #1e293b;
  --hero-grad-mid:       #0f172a;
  --hero-grad-to:        #0b1220;
  --brand-logo-accent:   #60a5fa;

  --login-bg-from:       #0b1220;
  --login-bg-mid:        #0f172a;
  --login-bg-to:         #111827;
  --login-heading:       #f1f5f9;
  --login-muted:         #94a3b8;
  --login-link:          #60a5fa;
  --login-input-bg:      #111827;
  --login-input-border:  #334155;
  --login-input-focus:   #60a5fa;
  --login-input-ring:    96 165 250;
  --login-input-text:    #f1f5f9;
  --login-placeholder:   #64748b;
  --login-icon:          #60a5fa;
  --login-btn-from:      #3b82f6;
  --login-btn-mid:       #2563eb;
  --login-btn-to:        #1d4ed8;
  --login-btn-hover-from:#60a5fa;
  --login-btn-hover-mid: #3b82f6;
  --login-btn-hover-to:  #2563eb;
  --login-btn-shadow:    2 6 23;
  --login-leaf-fill:     #1e3a8a;
  --login-leaf-fill-alt: #1e40af;
  --login-leaf-fill-3:   #2563eb;
  --login-leaf-stem:     #60a5fa;
  --login-brand-icon-from:#3b82f6;
  --login-brand-icon-to:  #1d4ed8;
}

/* Dark theme: flip the app's default light body surfaces. Scoped globally but
   only active under data-theme="dark". Keep it minimal + safe. */
html[data-theme="dark"] body { background: #0b1220 !important; color: #e2e8f0; }
html[data-theme="dark"] .bg-white { background: #111827 !important; }
html[data-theme="dark"] .bg-slate-100 { background: #0b1220 !important; }
html[data-theme="dark"] .bg-slate-50 { background: #0f172a !important; }
html[data-theme="dark"] .text-slate-800,
html[data-theme="dark"] .text-slate-700 { color: #e2e8f0 !important; }
html[data-theme="dark"] .text-slate-500,
html[data-theme="dark"] .text-slate-400 { color: #94a3b8 !important; }
html[data-theme="dark"] .border-slate-200,
html[data-theme="dark"] .border-slate-100 { border-color: #1f2937 !important; }

/* v10.22.2 -- notice-board header: the template sets an inline light gradient
   which the blanket theme rules can't reskin, so its title went invisible on
   the dark theme (light title on light bar). Reskin per theme (!important beats
   the inline style). */
html[data-theme="dark"] .notice-head { background: #0f172a !important; border-color:#1f2937 !important; }
html[data-theme="dark"] .notice-head h3 { color:#e2e8f0 !important; }

/* v10.22.2 -- dark theme: form controls were browser-default WHITE, so every
   form (organization, employee, leave, etc.) showed white boxes on the dark
   page. Dark-skin text inputs / selects / textareas; leave checkboxes, radios,
   file and color pickers native. Scoped to the dark theme only. */
html[data-theme="dark"] input:not([type=checkbox]):not([type=radio]):not([type=file]):not([type=color]):not([type=range]):not([type=submit]):not([type=button]),
html[data-theme="dark"] select,
html[data-theme="dark"] textarea {
  background-color: #111827 !important;
  color: #e2e8f0 !important;
  border-color: #334155 !important;
}
html[data-theme="dark"] input::placeholder,
html[data-theme="dark"] textarea::placeholder { color: #64748b !important; }
html[data-theme="dark"] select option { background-color: #111827; color: #e2e8f0; }

/* v10.22.2 -- dark theme coverage broadening. The original dark theme only
   flipped text-slate-{800,700,500,400}; text-slate-600 (83 uses) and
   text-slate-900 stayed dark -> dark-on-dark. bg-slate-200 (29 uses) stayed
   light. Flip these too. (Semantic status tints bg-amber/emerald/blue/red-50
   and bg-white/NN overlays are intentionally left: readable / decorative.) */
html[data-theme="dark"] .text-slate-900 { color: #f1f5f9 !important; }
html[data-theme="dark"] .text-slate-600 { color: #cbd5e1 !important; }
html[data-theme="dark"] .bg-slate-200 { background-color: #1f2937 !important; }
html[data-theme="dark"] .border-slate-300 { border-color: #334155 !important; }

/* v10.26.5 -- dark theme HOVER fix. The base bg/text utilities were flipped for
   dark, but their hover: variants were not, so hovering (chat toolbar, message
   actions, DM/channel rows, reaction pills, tabs) re-applied the ORIGINAL light
   background or a dark text -> light-on-light / dark-on-dark = invisible words.
   Flip the hover variants too so hovered text stays readable in dark mode. */
html[data-theme="dark"] .hover\:bg-white:hover      { background-color: #111827 !important; }
html[data-theme="dark"] .hover\:bg-slate-50:hover   { background-color: #172033 !important; }
html[data-theme="dark"] .hover\:bg-slate-100:hover  { background-color: #1e293b !important; }
html[data-theme="dark"] .hover\:bg-slate-200:hover  { background-color: #334155 !important; }
html[data-theme="dark"] .hover\:text-slate-900:hover,
html[data-theme="dark"] .hover\:text-slate-800:hover,
html[data-theme="dark"] .hover\:text-slate-700:hover,
html[data-theme="dark"] .hover\:text-slate-600:hover { color: #f1f5f9 !important; }


/* v10.22.4 -- dark theme: the primary scale is INVERTED (primary-600..800 -> near
   white), so the common "dark-primary background + white text" pattern (13+ page
   heroes using `from-primary-600 to-primary-800`, and bg-primary-600/700/800
   buttons/headers) rendered white-on-white. Force those BACKGROUND utilities to
   real dark blues so the white text is readable. (text-primary-* stays inverted
   for headings; brand-* backgrounds already read fine.) */
html[data-theme="dark"] .bg-primary-600 { background-color:#1d4ed8 !important; }
html[data-theme="dark"] .bg-primary-700 { background-color:#1e40af !important; }
html[data-theme="dark"] .bg-primary-800 { background-color:#1e3a8a !important; }
html[data-theme="dark"] [class*="from-primary-600"][class*="to-primary-800"] {
  background-image: linear-gradient(to bottom right, #1e3a8a 0%, #0f172a 100%) !important;
}


/* v10.22.5 -- DARK theme login page. The login card + input focus bg are
   hard-coded #ffffff, but the dark theme makes --login-heading light and
   --login-input-bg dark -> "Welcome back" went invisible on the white card and
   the dark inputs clashed. Give the card (and focus state) a dark surface so
   heading/inputs/card are consistent. Forest/Sunrise keep the white card. */
html[data-theme="dark"] .login-card { background:#0f172a !important; border-color:#1f2937 !important; }
html[data-theme="dark"] .pill-input:focus { background:#111827 !important; }

/* ============================================================= */
/* v10.28.0 -- searchable dropdowns (Tom Select) + bigger chat font */
/* ============================================================= */

/* Make Tom Select match the app's inputs (light theme). */
.ts-wrapper { font-size: 0.875rem; margin: 0; vertical-align: middle; min-width: 150px; }
/* v10.30.1 -- match native <select> metrics (px-2 py-1.5 text-sm) so a
   Tom Select dropdown lines up with the plain selects beside it in filter bars. */
.ts-control {
  border: 1px solid #cbd5e1;           /* slate-300 */
  border-radius: 0.5rem;               /* rounded-lg */
  padding: 0.25rem 0.5rem;             /* == px-2 py-1.5 */
  min-height: 34px;
  line-height: 1.5;
  box-shadow: none;
}
.ts-wrapper.single .ts-control { display: flex; align-items: center; }
.ts-control > .item, .ts-control > input { margin: 0 !important; }
.ts-control:focus-within,
.ts-wrapper.focus .ts-control {
  border-color: rgb(var(--brand-500));
  box-shadow: 0 0 0 2px rgb(var(--brand-500) / 0.30);
}
.ts-dropdown {
  border: 1px solid #e2e8f0;
  border-radius: 0.5rem;
  box-shadow: 0 12px 30px -12px rgba(0,0,0,0.25);
  font-size: 0.875rem;
  z-index: 60;
}
.ts-dropdown .active { background: rgb(var(--brand-500) / 0.12); color: inherit; }

/* Dark theme: the default Tom Select styles are light-on-light in dark mode.
   Flip control, dropdown, items, input text and the active-option highlight. */
html[data-theme="dark"] .ts-control {
  background: #0f172a !important;
  border-color: #334155 !important;
  color: #e2e8f0 !important;
}
html[data-theme="dark"] .ts-control input,
html[data-theme="dark"] .ts-control .item { color: #e2e8f0 !important; }
html[data-theme="dark"] .ts-control input::placeholder { color: #64748b !important; }
html[data-theme="dark"] .ts-dropdown {
  background: #111827 !important;
  border-color: #1f2937 !important;
  color: #e2e8f0 !important;
}
html[data-theme="dark"] .ts-dropdown .option { color: #e2e8f0 !important; }
html[data-theme="dark"] .ts-dropdown .active { background: #1e293b !important; color: #f1f5f9 !important; }
html[data-theme="dark"] .ts-dropdown .no-results { color: #94a3b8 !important; }
/* Tom Select multi-item chips in dark. */
html[data-theme="dark"] .ts-control .item { background: #1e293b !important; border-color: #334155 !important; }

/* v10.28.0 -- larger, more readable chat message text. */
.chat-body { font-size: 0.9375rem; line-height: 1.6; }   /* 15px */
.chat-body p { margin: 0.15rem 0; }
