/* Design tokens and shared components for every page (landing, login, app). */
:root {
  --brand-1: #0d3a7a;           /* navy (logo #002050, lifted for gradients) */
  --brand-2: #00a098;           /* teal (logo) */
  --brand-grad: linear-gradient(135deg, var(--brand-1), var(--brand-2));
  --ink: #0b1020;               /* deep navy, hero / dark panels */
  --ink-2: #131a33;
  --ink-text: #e6e9f5;
  --ink-muted: #9aa3c4;

  --bg: #f6f7fb;
  --panel: #ffffff;
  --border: #e3e6ef;
  --text: #0f172a;
  --muted: #5b6478;
  --accent: #0a8a84;
  --accent-hover: #087570;
  --accent-weak: #e3f4f2;
  --danger: #dc2626;
  --success: #059669;
  --radius: 12px;
  --radius-sm: 8px;
  --shadow: 0 1px 2px rgba(15, 23, 42, .05), 0 8px 24px rgba(15, 23, 42, .07);
  --shadow-lg: 0 24px 64px rgba(11, 16, 32, .18);
  --font: "Inter", "Heebo", "IBM Plex Sans Arabic", system-ui, -apple-system, "Segoe UI", Arial, sans-serif;
  color-scheme: light;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #0b0f1a; --panel: #121829; --border: #232b42; --text: #e6e9f5; --muted: #98a1bd;
    --accent: #2fc4b9; --accent-hover: #5dd6cd; --accent-weak: #0f2e33;
    --shadow: 0 1px 2px rgba(0, 0, 0, .3), 0 8px 24px rgba(0, 0, 0, .35);
    color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --bg: #0b0f1a; --panel: #121829; --border: #232b42; --text: #e6e9f5; --muted: #98a1bd;
  --accent: #2fc4b9; --accent-hover: #5dd6cd; --accent-weak: #0f2e33;
  --shadow: 0 1px 2px rgba(0, 0, 0, .3), 0 8px 24px rgba(0, 0, 0, .35);
  color-scheme: dark;
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body { margin: 0; background: var(--bg); color: var(--text); font: 15px/1.55 var(--font); -webkit-font-smoothing: antialiased; }
button, input, select { font: inherit; color: inherit; }
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
[hidden] { display: none !important; }

/* ---- brand -------------------------------------------------------------------------- */
.logo { display: inline-flex; align-items: center; gap: 8px; line-height: 0; }
.logo:hover { text-decoration: none; }
.logo img { height: 30px; width: auto; display: block; }
.logo .logo-word { height: 22px; }

/* ---- buttons ---------------------------------------------------------------------------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px; padding: 8px 16px;
  border-radius: var(--radius-sm); border: 1px solid var(--border); background: var(--panel); color: var(--text);
  font-weight: 500; cursor: pointer; white-space: nowrap; text-decoration: none; transition: border-color .15s, background .15s, box-shadow .15s;
}
.btn:hover:not(:disabled) { border-color: var(--accent); text-decoration: none; }
.btn:disabled { opacity: .45; cursor: default; }
.btn.primary { background: var(--accent); border-color: var(--accent); color: #fff; }
.btn.primary:hover:not(:disabled) { background: var(--accent-hover); border-color: var(--accent-hover); }
.btn.grad { background: var(--brand-grad); border: 0; color: #fff; box-shadow: 0 8px 24px rgba(0, 160, 152, .3); }
.btn.grad:hover { filter: brightness(1.08); }
.btn.ghost-dark { background: rgba(255, 255, 255, .06); border-color: rgba(255, 255, 255, .18); color: var(--ink-text); }
.btn.ghost-dark:hover { border-color: rgba(255, 255, 255, .4); }
.btn.lg { padding: 12px 22px; font-size: 16px; border-radius: 10px; }
.btn.small { padding: 4px 10px; font-size: 13px; }
.btn.block { width: 100%; }

/* ---- language picker (js/i18n.js mountLangSelect) ------------------------------------------- */
.lang-picker { position: relative; }
.lang-btn {
  display: inline-flex; align-items: center; gap: 6px; height: 36px; padding: 0 10px; border-radius: var(--radius-sm);
  border: 1px solid var(--border); background: var(--panel); color: var(--text); cursor: pointer; font-weight: 600; font-size: 13px;
  letter-spacing: .02em; transition: border-color .15s, background .15s;
}
.lang-btn:hover, .lang-btn[aria-expanded="true"] { border-color: var(--accent); }
.lang-btn svg { width: 18px; height: 18px; fill: none; stroke: currentColor; stroke-width: 1.5; stroke-linecap: round; stroke-linejoin: round; }
.lang-btn .chev { width: 14px; height: 14px; opacity: .7; transition: transform .15s; }
.lang-btn[aria-expanded="true"] .chev { transform: rotate(180deg); }
.on-dark .lang-btn, .topbar .lang-btn { background: rgba(255, 255, 255, .06); border-color: rgba(255, 255, 255, .18); color: var(--ink-text); }
.on-dark .lang-btn:hover, .topbar .lang-btn:hover,
.on-dark .lang-btn[aria-expanded="true"], .topbar .lang-btn[aria-expanded="true"] { border-color: rgba(255, 255, 255, .45); }
.lang-menu {
  position: absolute; top: calc(100% + 8px); inset-inline-end: 0; z-index: 50; min-width: 200px; margin: 0; padding: 6px; list-style: none;
  background: var(--panel); color: var(--text); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow);
  animation: pop .12s ease-out;
}
@keyframes pop { from { opacity: 0; transform: translateY(-4px); } }
.lang-menu li {
  display: grid; grid-template-columns: 1fr auto 18px; align-items: center; gap: 10px; padding: 8px 10px; border-radius: 6px;
  cursor: pointer; font-size: 14px; outline: none;
}
.lang-menu li:hover, .lang-menu li:focus { background: var(--accent-weak); }
.lang-menu .ls { font-size: 11px; font-weight: 600; color: var(--muted); letter-spacing: .04em; direction: ltr; }
.lang-menu .ck svg { width: 18px; height: 18px; fill: none; stroke: var(--accent); stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; visibility: hidden; }
.lang-menu li[aria-selected="true"] { font-weight: 600; }
.lang-menu li[aria-selected="true"] .ck svg { visibility: visible; }
@media (prefers-reduced-motion: reduce) { .lang-menu { animation: none; } }

/* ---- forms --------------------------------------------------------------------------------- */
.field { display: grid; gap: 6px; margin-bottom: 14px; }
.field label { font-size: 13px; font-weight: 500; color: var(--muted); }
.field input {
  padding: 10px 12px; border-radius: var(--radius-sm); border: 1px solid var(--border); background: var(--panel); outline: none;
  transition: border-color .15s, box-shadow .15s;
}
.field input:focus { border-color: var(--accent); box-shadow: 0 0 0 3px color-mix(in srgb, var(--accent) 20%, transparent); }
.hint { font-size: 12px; color: var(--muted); }
.alert { padding: 10px 12px; border-radius: var(--radius-sm); font-size: 14px; margin-bottom: 14px; }
.alert.error { background: color-mix(in srgb, var(--danger) 10%, transparent); color: var(--danger); }
.alert.ok { background: color-mix(in srgb, var(--success) 12%, transparent); color: var(--success); }

/* ---- user menu --------------------------------------------------------------------------- */
.user { position: relative; }
.avatar {
  width: 34px; height: 34px; border-radius: 50%; border: 0; padding: 0; cursor: pointer; overflow: hidden;
  background: var(--brand-grad); color: #fff; font-weight: 700; font-size: 14px; display: grid; place-items: center;
}
.avatar img { width: 100%; height: 100%; object-fit: cover; }
.menu {
  position: absolute; top: calc(100% + 8px); inset-inline-end: 0; z-index: 40; min-width: 240px;
  background: var(--panel); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow); padding: 6px;
}
.menu .who { padding: 8px 10px 10px; border-bottom: 1px solid var(--border); margin-bottom: 6px; }
.menu .who b { display: block; font-size: 14px; }
.menu .who span { color: var(--muted); font-size: 13px; word-break: break-all; }
.menu button { width: 100%; text-align: start; padding: 8px 10px; border: 0; background: none; border-radius: 6px; cursor: pointer; }
.menu button:hover { background: var(--accent-weak); }

/* ---- top bar of signed-in pages (dark, matches the site navigation) -------------------------------------------------- */
.topbar {
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  padding: 10px 16px; background: var(--ink); color: var(--ink-text); border-bottom: 1px solid rgba(255, 255, 255, .06);
}
.brand { display: flex; align-items: center; gap: 14px; min-width: 0; }
.brand .logo { color: #fff; }
.file-name {
  color: var(--ink-muted); font-size: 13px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
  padding-inline-start: 14px; border-inline-start: 1px solid rgba(255, 255, 255, .14);
}
.file-name:empty { display: none; }
.actions { display: flex; align-items: center; gap: 8px; flex-shrink: 0; }
.topbar .btn { padding: 7px 14px; }
.topbar .btn:not(.primary) { background: rgba(255, 255, 255, .06); border-color: rgba(255, 255, 255, .16); color: var(--ink-text); }
.topbar .btn:not(.primary):hover:not(:disabled) { border-color: rgba(255, 255, 255, .4); }
.topbar .btn.primary { background: var(--brand-grad); border: 0; }
.bi { width: 16px; height: 16px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
.topbar .user { margin-inline-start: 4px; }
.topbar .menu { color: var(--text); }

.topbar .nav-link { color: var(--ink-muted); font-size: 14px; font-weight: 500; padding-inline-start: 14px; border-inline-start: 1px solid rgba(255, 255, 255, .14); }
.topbar .nav-link:hover { color: #fff; text-decoration: none; }
.menu a.menu-item { display: block; padding: 8px 10px; border-radius: 6px; color: var(--text); }
.menu a.menu-item:hover { background: var(--accent-weak); text-decoration: none; }

/* ---- dialogs and shared buttons ------------------------------------------------------------- */
.dlg { border: 0; border-radius: 16px; padding: 24px; width: min(480px, calc(100% - 32px)); background: var(--panel); color: var(--text); box-shadow: var(--shadow-lg); }
.dlg::backdrop { background: rgba(11, 16, 32, .55); backdrop-filter: blur(2px); }
.dlg h3 { margin: 0 0 16px; font-size: 18px; }
.dlg p { margin: 0 0 16px; }
.dlg-actions { display: flex; justify-content: flex-end; gap: 10px; margin-top: 8px; }

.btn.danger { background: var(--danger); border-color: var(--danger); color: #fff; }
.btn.danger-ghost { color: var(--danger); }
.btn.danger-ghost:hover:not(:disabled) { border-color: var(--danger); }
.alert.warn { background: color-mix(in srgb, #f59e0b 14%, transparent); color: #92400e; }

.dlg textarea, .field select, .field textarea {
  padding: 10px 12px; border-radius: var(--radius-sm); border: 1px solid var(--border); background: var(--panel); font: inherit; color: inherit; resize: vertical;
}
.field select:focus, .field textarea:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px color-mix(in srgb, var(--accent) 20%, transparent); }
.hp { position: absolute; left: -10000px; width: 1px; height: 1px; opacity: 0; }
