/* ==========================================================================
   SAIFNEX — core design system
   Brand tokens, reset, glass and shared primitives. Loaded by every page
   (mail, admin, auth) so there is a single source of truth for the palette.
   ========================================================================== */

:root {
  /* Brand (exact, per the kit) */
  --indigo:  #273469;
  --blue:    #3B82F6;
  --cyan:    #22D3EE;

  --font-display: 'Outfit', 'Helvetica Neue', Arial, sans-serif;
  --font-body:    'Inter', 'Helvetica Neue', Arial, sans-serif;

  --radius:    20px;
  --radius-sm: 13px;
  --ease: cubic-bezier(.22, 1, .36, 1);

  --glass: blur(24px) saturate(160%);
}

/* ---- Dark (default) ---- */
:root, :root[data-theme="dark"] {
  color-scheme: dark;
  --bg:        #070B18;
  --panel:     rgba(255, 255, 255, .045);
  --panel-2:   rgba(255, 255, 255, .075);
  --edge:      rgba(255, 255, 255, .10);
  --edge-lit:  rgba(255, 255, 255, .14);
  --shadow:    0 24px 60px -30px rgba(0, 0, 0, .9);

  --text:      #E8ECF6;
  --text-soft: #A5B0C8;
  --text-dim:  #6B7899;
  --accent:    var(--cyan);

  --row-hover:  rgba(255, 255, 255, .05);
  --row-unread: rgba(59, 130, 246, .09);
  --scroll:       rgba(255, 255, 255, .13);
  --scroll-hover: rgba(255, 255, 255, .26);
  --wash-1: rgba(39, 52, 105, .55);
  --wash-2: rgba(59, 130, 246, .22);
  --wash-3: rgba(34, 211, 238, .16);
}

/* ---- Light ---- */
:root[data-theme="light"] {
  color-scheme: light;
  --bg:        #FAFAFC;
  --panel:     rgba(255, 255, 255, .55);
  --panel-2:   rgba(255, 255, 255, .80);
  --edge:      rgba(255, 255, 255, .85);
  --edge-lit:  #FFFFFF;
  --shadow:    0 18px 46px -22px rgba(39, 52, 105, .30);

  --text:      #0F172A;
  --text-soft: #475569;
  --text-dim:  #64748B;
  /* Cyan measures ~1.6:1 on white, so meaning-bearing colour darkens */
  --accent:    #0E7490;

  --row-hover:  rgba(255, 255, 255, .75);
  --row-unread: rgba(59, 130, 246, .07);
  --scroll:       rgba(39, 52, 105, .20);
  --scroll-hover: rgba(39, 52, 105, .38);
  --wash-1: rgba(59, 130, 246, .26);
  --wash-2: rgba(34, 211, 238, .26);
  --wash-3: rgba(39, 52, 105, .14);
}

*, *::before, *::after { box-sizing: border-box; }

/* An author rule that sets `display` beats the UA's [hidden] rule, which
   silently un-hid the bulk toolbar. Make the attribute authoritative. */
[hidden] { display: none !important; }

html, body { height: 100%; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font-body);
  font-size: 14px;
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
  overflow: hidden;
}

/* Fixed brand wash — the thing the glass actually refracts */
.wash {
  position: fixed;
  inset: 0;
  z-index: -1;
  pointer-events: none;
  background:
    radial-gradient(44% 40% at 10%  6%, var(--wash-1), transparent 70%),
    radial-gradient(40% 36% at 92% 14%, var(--wash-2), transparent 68%),
    radial-gradient(46% 42% at 78% 88%, var(--wash-3), transparent 72%);
}

button, input, textarea { font: inherit; color: inherit; }
button { cursor: pointer; border: 0; background: none; }
img { display: block; max-width: 100%; }
ul { list-style: none; margin: 0; padding: 0; }

::selection { background: rgba(59, 130, 246, .3); }

select option {
  background-color: #0E1526;
  color: #E8ECF6;
}
[data-theme="light"] select option {
  background-color: #FFFFFF;
  color: #0F172A;
}

/* ---- Scrollbars: hidden everywhere -------------------------------------
   Panes still scroll by wheel, touch, keyboard and programmatically —
   only the visual track is removed. */
* {
  scrollbar-width: none;          /* Firefox / standards */
  -ms-overflow-style: none;       /* legacy Edge */
}
::-webkit-scrollbar { width: 0; height: 0; display: none; }

:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
  border-radius: 6px;
}

.avatar {
  width: 36px; height: 36px;
  flex: none;
  border-radius: 11px;
  display: grid;
  place-items: center;
  font-family: var(--font-display);
  font-size: 12.5px;
  font-weight: 700;
  color: #fff;
  background: linear-gradient(135deg, var(--a, #273469), var(--b, #3B82F6));
}

.icon-btn {
  width: 34px; height: 34px;
  flex: none;
  display: grid;
  place-items: center;
  border-radius: 10px;
  color: var(--text-soft);
  transition: background .25s var(--ease), color .25s var(--ease);
}
.icon-btn svg { width: 17px; height: 17px; }
.icon-btn:hover { background: var(--panel-2); color: var(--text); }

/* ==========================================================================
   BUTTONS
   ========================================================================== */

.btn {
  padding: 10px 18px;
  border-radius: 11px;
  font-family: var(--font-display);
  font-size: 14px;
  font-weight: 500;
  transition: transform .3s var(--ease), box-shadow .3s var(--ease);
}
.btn--primary {
  color: #fff;
  background: linear-gradient(120deg, var(--indigo), var(--blue) 55%, var(--cyan));
  box-shadow: 0 10px 24px -12px rgba(59, 130, 246, .7);
}
.btn--primary:hover { transform: translateY(-1px); }
.btn--ghost { color: var(--text-soft); border: 1px solid var(--edge); background: var(--panel-2); }
.btn--ghost:hover { color: var(--text); }

/* ==========================================================================
   COMPOSE
   ========================================================================== */

.modal { position: fixed; inset: 0; z-index: 50; display: grid; place-items: center; padding: 20px; }
.modal[hidden] { display: none; }
.modal__scrim { position: absolute; inset: 0; background: rgba(4, 7, 16, .55); backdrop-filter: blur(3px); }

.modal__panel {
  position: relative;
  width: min(620px, 100%);
  max-height: min(86vh, 720px);
  display: flex;
  flex-direction: column;
  padding: 20px;
  animation: pop .3s var(--ease);
}
@keyframes pop { from { opacity: 0; transform: translateY(10px) scale(.985); } }

.modal__head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 16px; }
.modal__head h2 { margin: 0; font-family: var(--font-display); font-size: 18px; font-weight: 600; }

.field { display: grid; gap: 5px; margin-bottom: 12px; }
.field span { font-size: 11.5px; letter-spacing: .1em; text-transform: uppercase; color: var(--text-dim); }
.field input, .field textarea {
  padding: 11px 13px;
  border-radius: 11px;
  border: 1px solid var(--edge);
  background: var(--panel-2);
  color: var(--text);
  outline: none;
  resize: vertical;
  font-family: inherit;
}
.field input:focus, .field textarea:focus { border-color: var(--blue); }
.field--grow { flex: 1; min-height: 0; }
.field--grow textarea { height: 100%; min-height: 130px; }

.modal__foot { display: flex; align-items: center; gap: 14px; flex-wrap: wrap; margin-top: 6px; }
.modal__note { margin: 0; margin-right: auto; font-size: 12px; color: var(--text-dim); }
.modal__note.is-ok { color: var(--accent); }
.modal__btns { display: flex; gap: 8px; }

/* Without backdrop-filter the panels would be washed out and low contrast */
@supports not ((backdrop-filter: blur(1px)) or (-webkit-backdrop-filter: blur(1px))) {
  :root[data-theme="light"] {
    --panel: rgba(255, 255, 255, .95);
    --panel-2: rgba(255, 255, 255, .98);
  }
  :root, :root[data-theme="dark"] {
    --panel: #0D1426;
    --panel-2: #141C33;
  }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .001ms !important; transition-duration: .001ms !important; }
}

/* ==========================================================================
   TOAST
   ========================================================================== */

.toast {
  position: fixed;
  left: 50%;
  bottom: 22px;
  transform: translateX(-50%);
  z-index: 60;
  display: flex;
  align-items: center;
  gap: 16px;
  padding: 12px 16px;
  border-radius: 12px;
  border: 1px solid var(--edge);
  background: var(--panel-2);
  backdrop-filter: var(--glass);
  -webkit-backdrop-filter: var(--glass);
  box-shadow: var(--shadow);
  font-size: 13.5px;
}
.toast button {
  font-family: var(--font-display);
  font-weight: 600;
  font-size: 13.5px;
  color: var(--accent);
}

@media print {
  .sidebar, .mail, .reader__bar, .replybar, .toast, .wash { display: none !important; }
  .app { display: block; padding: 0; }
  .reader { border: 0; box-shadow: none; background: #fff; backdrop-filter: none; }
  .msg__body { display: block !important; }
  body { overflow: visible; color: #000; }
}

/* ==========================================================================
   GLASS SURFACE
   ========================================================================== */

.glass {
  background: var(--panel);
  border: 1px solid var(--edge);
  border-radius: var(--radius);
  box-shadow: var(--shadow), inset 0 1px 0 0 var(--edge-lit);
  backdrop-filter: var(--glass);
  -webkit-backdrop-filter: var(--glass);
}
