/* BEF — modernized befclips design language (shared by Workspace + Webmail).
   Keeps the brand (warm paper, forest-green ink, sage/lime/brick, Fraunces + Inter)
   but refines it: soft shadows instead of hard offset, restrained lime accent,
   softer rounded buttons, tighter rhythm, and a paired warm dark theme.
   NOTE: this file is deployed to both apps' static dirs — keep the copies in sync. */

@import url("https://fonts.googleapis.com/css2?family=Fraunces:opsz,wght@9..144,500;9..144,600;9..144,700&family=Inter:wght@400;500;600;700&display=swap");

/* ===================== LIGHT (default) ===================== */
:root {
  --bg: #f7f0e6;
  --bg-alt: #efe7d8;
  --surface: #fffcf4;
  --surface-2: #f6efe1;
  --topbar-bg: rgba(255, 252, 244, 0.82);

  --ink: #1f2a1f;          /* strong foreground / borders / primary */
  --ink-hover: #2c3b2d;
  --ink-70: rgba(29, 43, 31, 0.70);
  --ink-45: rgba(29, 43, 31, 0.45);
  --ink-25: rgba(29, 43, 31, 0.22);
  --ink-12: rgba(29, 43, 31, 0.12);
  --ink-06: rgba(29, 43, 31, 0.055);

  --text: #26332a;
  --text-dim: #55655a;
  --text-faint: #7c8a7e;

  --sage: #b9d9c4;
  --sage-soft: rgba(185, 217, 196, 0.35);
  --lime: #bfea4b;
  --lime-soft: rgba(191, 234, 75, 0.22);
  --lime-hover: #cbef63;
  --brick: #c53a20;
  --brick-soft: rgba(197, 58, 32, 0.10);
  --blue: #1e5bff;
  --amber: #b45309;
  --green-deep: #2e6b3f;

  --border: rgba(29, 43, 31, 0.14);
  --border-strong: rgba(29, 43, 31, 0.28);
  --ring: rgba(46, 107, 63, 0.40);

  --radius: 14px;
  --radius-sm: 10px;
  --radius-lg: 18px;

  /* Soft, layered shadows — the key modernization vs. the old hard offset. */
  --shadow-sm: 0 1px 2px rgba(31, 42, 31, 0.08), 0 1px 1px rgba(31, 42, 31, 0.04);
  --shadow: 0 4px 14px rgba(31, 42, 31, 0.10), 0 1px 3px rgba(31, 42, 31, 0.06);
  --shadow-lg: 0 18px 44px rgba(31, 42, 31, 0.18), 0 4px 12px rgba(31, 42, 31, 0.08);

  --font: "Inter", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  --font-display: "Fraunces", "Georgia", serif;
  --font-mono: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;

  /* legacy aliases kept so old markup keeps working */
  --accent: var(--ink); --green: var(--green-deep); --yellow: var(--amber);
  --red: var(--brick); --red-soft: var(--brick-soft); --panel: var(--surface);
  --panel-alt: var(--surface-2); --border-strong-legacy: var(--ink);
}

/* ===================== DARK (paired warm dark) ===================== */
/* Applied when the user picks dark, OR follows the OS unless they picked light. */
:root[data-theme="dark"] {
  --bg: #16180f;
  --bg-alt: #1c1f14;
  --surface: #1f2218;
  --surface-2: #262a1d;
  --topbar-bg: rgba(31, 34, 24, 0.82);

  --ink: #edefe4;
  --ink-hover: #dfe3d2;
  --ink-70: rgba(237, 239, 228, 0.70);
  --ink-45: rgba(237, 239, 228, 0.42);
  --ink-25: rgba(237, 239, 228, 0.22);
  --ink-12: rgba(237, 239, 228, 0.12);
  --ink-06: rgba(237, 239, 228, 0.06);

  --text: #e7e9dd;
  --text-dim: #b3bba7;
  --text-faint: #899279;

  --sage: #9ec7ad;
  --sage-soft: rgba(158, 199, 173, 0.16);
  --lime: #c6ea5e;
  --lime-soft: rgba(198, 234, 94, 0.15);
  --lime-hover: #d2f06e;
  --brick: #f0785c;
  --brick-soft: rgba(240, 120, 92, 0.15);
  --blue: #7aa3ff;
  --amber: #e0a44a;
  --green-deep: #7fc496;

  --border: rgba(237, 239, 228, 0.13);
  --border-strong: rgba(237, 239, 228, 0.26);
  --ring: rgba(127, 196, 150, 0.50);

  --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.45);
  --shadow: 0 6px 20px rgba(0, 0, 0, 0.48), 0 1px 3px rgba(0, 0, 0, 0.4);
  --shadow-lg: 0 20px 48px rgba(0, 0, 0, 0.6), 0 4px 12px rgba(0, 0, 0, 0.5);
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #16180f; --bg-alt: #1c1f14; --surface: #1f2218; --surface-2: #262a1d;
    --topbar-bg: rgba(31, 34, 24, 0.82);
    --ink: #edefe4; --ink-hover: #dfe3d2;
    --ink-70: rgba(237,239,228,0.70); --ink-45: rgba(237,239,228,0.42);
    --ink-25: rgba(237,239,228,0.22); --ink-12: rgba(237,239,228,0.12); --ink-06: rgba(237,239,228,0.06);
    --text: #e7e9dd; --text-dim: #b3bba7; --text-faint: #899279;
    --sage: #9ec7ad; --sage-soft: rgba(158,199,173,0.16);
    --lime: #c6ea5e; --lime-soft: rgba(198,234,94,0.15); --lime-hover: #d2f06e;
    --brick: #f0785c; --brick-soft: rgba(240,120,92,0.15);
    --blue: #7aa3ff; --amber: #e0a44a; --green-deep: #7fc496;
    --border: rgba(237,239,228,0.13); --border-strong: rgba(237,239,228,0.26);
    --ring: rgba(127,196,150,0.50);
    --shadow-sm: 0 1px 2px rgba(0,0,0,0.45);
    --shadow: 0 6px 20px rgba(0,0,0,0.48), 0 1px 3px rgba(0,0,0,0.4);
    --shadow-lg: 0 20px 48px rgba(0,0,0,0.6), 0 4px 12px rgba(0,0,0,0.5);
  }
}

* { box-sizing: border-box; }
html { scrollbar-color: var(--ink-45) transparent; }
body {
  margin: 0; background: var(--bg); color: var(--text);
  font-family: var(--font); font-size: 15px; line-height: 1.55;
  -webkit-font-smoothing: antialiased;
  transition: background 0.3s ease, color 0.3s ease;
}

h1, h2, .display { font-family: var(--font-display); font-weight: 600; letter-spacing: -0.01em; color: var(--ink); }
a { color: var(--ink); text-decoration: underline; text-decoration-color: var(--ink-45); text-underline-offset: 3px; }
a:hover { text-decoration-color: var(--ink); }
svg.icon { width: 17px; height: 17px; flex: none; stroke: currentColor; fill: none; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; vertical-align: -3px; }

/* ---------- Top bar ---------- */
header.topbar {
  display: flex; align-items: center; justify-content: space-between;
  padding: 13px 26px; border-bottom: 1px solid var(--border);
  background: var(--topbar-bg); backdrop-filter: blur(10px);
  position: sticky; top: 0; z-index: 50; flex-wrap: wrap; gap: 10px;
}
header.topbar .brand { font-family: var(--font-display); font-weight: 700; font-size: 20px; letter-spacing: -0.01em; display: flex; align-items: center; gap: 10px; }
header.topbar .brand, header.topbar .brand a { text-decoration: none; color: var(--ink); }
header.topbar .brand::before {
  content: ""; width: 12px; height: 12px; border-radius: 50%;
  background: var(--lime); box-shadow: 0 0 0 3px var(--lime-soft);
}
nav.tabs { display: flex; gap: 3px; flex-wrap: wrap; align-items: center; }
nav.tabs a {
  padding: 7px 13px; border-radius: var(--radius-sm); border: 1px solid transparent;
  color: var(--text-dim); font-size: 14px; font-weight: 500; min-height: 36px;
  display: inline-flex; align-items: center; gap: 7px; text-decoration: none;
  transition: background 0.15s ease, color 0.15s ease;
}
nav.tabs a:hover { background: var(--ink-06); color: var(--ink); }
nav.tabs a.active { background: var(--surface-2); color: var(--ink); font-weight: 600; box-shadow: inset 0 0 0 1px var(--border); }
nav.tabs a.logout { color: var(--brick); }

/* ---------- Layout ---------- */
main { max-width: 1240px; margin: 0 auto; padding: 30px 26px 56px; }
.card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 20px; box-shadow: var(--shadow-sm); }
.card.flat { box-shadow: none; }
.card h3 { font-size: 12px; font-weight: 600; color: var(--text-dim); letter-spacing: 0.09em; text-transform: uppercase; }
.grid { display: grid; gap: 16px; }
.section-title { font-family: var(--font-display); font-size: 22px; font-weight: 600; color: var(--ink); margin: 40px 0 14px; display: flex; align-items: baseline; gap: 10px; }
.two-col { display: grid; grid-template-columns: 320px 1fr; gap: 18px; }

/* ---------- Badges & chips ---------- */
.badge { display: inline-flex; align-items: center; gap: 7px; padding: 4px 12px; border-radius: 999px; border: 1px solid var(--border-strong); font-size: 12px; font-weight: 700; letter-spacing: 0.04em; text-transform: uppercase; }
.badge::before { content: ""; width: 7px; height: 7px; border-radius: 50%; flex: none; background: currentColor; }
.badge.online { background: var(--sage-soft); color: var(--green-deep); border-color: var(--green-deep); }
.badge.offline { background: var(--bg-alt); color: var(--brick); border-color: var(--brick); }
.chip { display: inline-flex; align-items: center; gap: 6px; padding: 2px 10px; border-radius: 999px; border: 1px solid var(--border); background: var(--surface-2); font-size: 12px; font-weight: 500; color: var(--text-dim); white-space: nowrap; }
.chip.sage { background: var(--sage-soft); border-color: var(--green-deep); color: var(--green-deep); }
.chip.lime { background: var(--lime-soft); border-color: var(--green-deep); color: var(--green-deep); }
.chip.brick { background: var(--brick-soft); border-color: var(--brick); color: var(--brick); }

@keyframes pulse { 0%, 100% { opacity: 1; } 50% { opacity: 0.35; } }
@media (prefers-reduced-motion: reduce) { * { transition-duration: 0.01ms !important; animation-duration: 0.01ms !important; } }

/* ---------- Tables ---------- */
table { width: 100%; border-collapse: collapse; }
th, td { text-align: left; padding: 10px 12px; border-bottom: 1px solid var(--ink-12); font-size: 14px; }
th { color: var(--text-faint); font-weight: 600; font-size: 11px; text-transform: uppercase; letter-spacing: 0.08em; padding-bottom: 8px; border-bottom: 1px solid var(--border-strong); white-space: nowrap; }
td { font-variant-numeric: tabular-nums; }
tbody tr:last-child td { border-bottom: none; }
tbody tr { transition: background 0.12s ease; }
tbody tr:hover { background: var(--ink-06); }

/* ---------- Buttons & forms ---------- */
button, .btn {
  background: var(--surface); color: var(--ink); border: 1px solid var(--border-strong);
  border-radius: var(--radius-sm); padding: 8px 16px; min-height: 40px; cursor: pointer;
  font-size: 14px; font-weight: 600; font-family: var(--font);
  display: inline-flex; align-items: center; justify-content: center; gap: 7px;
  text-decoration: none; box-shadow: var(--shadow-sm);
  transition: background 0.15s ease, border-color 0.15s ease, box-shadow 0.15s ease, transform 0.08s ease;
}
button:hover, .btn:hover { background: var(--surface-2); border-color: var(--ink-45); text-decoration: none; box-shadow: var(--shadow); }
button:active, .btn:active { transform: translateY(1px); box-shadow: var(--shadow-sm); }
button:focus-visible, .btn:focus-visible, a:focus-visible, input:focus-visible, select:focus-visible, textarea:focus-visible { outline: none; box-shadow: 0 0 0 3px var(--ring); }

button.primary, .btn.primary { background: var(--ink); color: var(--bg); border-color: var(--ink); }
button.primary:hover, .btn.primary:hover { background: var(--ink-hover); border-color: var(--ink-hover); }
button.accent, .btn.accent { background: var(--lime); color: #1f2a1f; border-color: var(--lime); }
button.accent:hover, .btn.accent:hover { background: var(--lime-hover); border-color: var(--lime-hover); }
button.danger, .btn.danger { background: transparent; color: var(--brick); border-color: var(--brick); box-shadow: none; }
button.danger:hover, .btn.danger:hover { background: var(--brick-soft); box-shadow: none; }
button.ghost, .btn.ghost { box-shadow: none; border-color: transparent; background: transparent; font-weight: 500; }
button.ghost:hover, .btn.ghost:hover { background: var(--ink-06); border-color: transparent; box-shadow: none; }
button:disabled, .btn:disabled { opacity: 0.45; cursor: not-allowed; transform: none !important; box-shadow: var(--shadow-sm) !important; }

input, select, textarea {
  background: var(--surface); color: var(--ink); border: 1px solid var(--border-strong);
  border-radius: var(--radius-sm); padding: 9px 13px; min-height: 40px; font-size: 14px;
  font-family: var(--font); width: 100%;
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
}
input::placeholder, textarea::placeholder { color: var(--text-faint); }
input:focus, select:focus, textarea:focus { outline: none; border-color: var(--green-deep); box-shadow: 0 0 0 3px var(--ring); }
input[type="checkbox"], input[type="radio"] { width: 16px; height: 16px; min-height: 0; padding: 0; margin: 0; border: none; border-radius: 0; background: none; flex: none; accent-color: var(--green-deep); cursor: pointer; box-shadow: none; }
label { display: block; margin-bottom: 6px; color: var(--text-dim); font-size: 13px; font-weight: 600; }
.form-row { margin-bottom: 14px; }
.search-wrap { position: relative; }
.search-wrap svg.icon { position: absolute; left: 13px; top: 50%; transform: translateY(-50%); color: var(--text-faint); pointer-events: none; }
.search-wrap input { padding-left: 38px; }

/* ---------- Theme toggle ---------- */
.theme-toggle { min-height: 36px; min-width: 36px; padding: 0 9px; border-radius: 999px; border: 1px solid var(--border); background: transparent; box-shadow: none; color: var(--text-dim); }
.theme-toggle:hover { background: var(--ink-06); border-color: var(--border); box-shadow: none; color: var(--ink); }
.theme-toggle .icon { width: 18px; height: 18px; }

/* ---------- Toast ---------- */
.toast {
  position: fixed; bottom: 22px; right: 22px; padding: 12px 18px; border-radius: var(--radius-sm);
  border: 1px solid var(--border); font-weight: 600; font-size: 14px; z-index: 300;
  box-shadow: var(--shadow-lg); background: var(--surface); color: var(--ink);
  animation: toast-in 0.22s cubic-bezier(0.2,0.7,0.3,1); display: inline-flex; align-items: center; gap: 8px;
}
.toast svg.icon { width: 16px; height: 16px; flex-shrink: 0; }
.toast.success { border-left: 3px solid var(--green-deep); }
.toast.success svg.icon { color: var(--green-deep); }
.toast.error { border-left: 3px solid var(--brick); }
.toast.error svg.icon { color: var(--brick); }
@keyframes toast-in { from { transform: translateY(10px); opacity: 0; } to { transform: none; opacity: 1; } }

/* ---------- Modal / dialog ---------- */
.modal-overlay { position: fixed; inset: 0; background: rgba(15, 20, 12, 0.5); backdrop-filter: blur(4px); display: flex; align-items: center; justify-content: center; z-index: 200; padding: 20px; animation: overlay-in 0.15s ease; }
@keyframes overlay-in { from { opacity: 0; } to { opacity: 1; } }
.modal { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-lg); max-width: 460px; width: 100%; max-height: 86vh; overflow-y: auto; box-shadow: var(--shadow-lg); animation: modal-in 0.2s cubic-bezier(0.2,0.7,0.3,1); }
@keyframes modal-in { from { transform: translateY(12px) scale(0.98); opacity: 0; } to { transform: none; opacity: 1; } }
.modal-head { display: flex; align-items: center; justify-content: space-between; gap: 10px; padding: 18px 20px 0; }
.modal-head h3 { font-family: var(--font-display); font-size: 19px; margin: 0; text-transform: none; letter-spacing: -0.01em; color: var(--ink); }
.modal-head .modal-x { min-height: 32px; min-width: 32px; padding: 0; border-radius: 8px; border: none; background: transparent; box-shadow: none; color: var(--text-faint); }
.modal-head .modal-x:hover { background: var(--ink-06); color: var(--ink); box-shadow: none; }
.modal-body { padding: 14px 20px; }
.modal-body p.modal-msg { margin: 2px 0 0; color: var(--text-dim); font-size: 14px; line-height: 1.5; }
.modal-foot { display: flex; justify-content: flex-end; gap: 8px; padding: 6px 20px 18px; flex-wrap: wrap; }
.hidden { display: none !important; }

/* ---------- Member / DM picker (used in modals) ---------- */
.dm-picker { display: flex; flex-direction: column; gap: 2px; max-height: 320px; overflow-y: auto; margin: 0 -6px; }
.dm-pick { display: flex; align-items: center; gap: 11px; width: 100%; text-align: left; padding: 8px 10px; border: none; background: transparent; box-shadow: none; border-radius: var(--radius-sm); min-height: 52px; }
.dm-pick:hover { background: var(--ink-06); box-shadow: none; transform: none; }
.dm-avatar { flex: none; width: 34px; height: 34px; border-radius: 50%; display: inline-flex; align-items: center; justify-content: center; background: var(--green-deep); color: #fff; font-size: 12px; font-weight: 700; letter-spacing: 0.02em; }
.dm-pick-text { display: flex; flex-direction: column; line-height: 1.3; min-width: 0; }
.dm-pick-name { font-weight: 600; color: var(--ink); font-size: 14px; }
.dm-pick-email { color: var(--text-faint); font-size: 12.5px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* ---------- Skeleton loading ---------- */
.skeleton { border-radius: var(--radius-sm); background: linear-gradient(90deg, var(--ink-06) 25%, var(--ink-12) 50%, var(--ink-06) 75%); background-size: 200% 100%; animation: shimmer 1.4s ease infinite; color: transparent !important; user-select: none; }
@keyframes shimmer { from { background-position: 200% 0; } to { background-position: -200% 0; } }

/* ---------- Empty state ---------- */
.empty-state { text-align: center; padding: 44px 22px; color: var(--text-faint); font-size: 14px; display: flex; flex-direction: column; align-items: center; gap: 4px; }
.empty-state .empty-icon { width: 44px; height: 44px; border-radius: 50%; display: inline-flex; align-items: center; justify-content: center; background: var(--surface-2); color: var(--text-dim); margin-bottom: 8px; }
.empty-state .empty-icon svg.icon { width: 22px; height: 22px; }
.empty-state .big { font-family: var(--font-display); font-size: 18px; color: var(--text-dim); margin-bottom: 2px; }
.empty-state .sub { max-width: 300px; }
.empty-state .cta { margin-top: 14px; }

.divider { border: none; border-top: 1px solid var(--border); margin: 18px 0; }
::selection { background: var(--lime-soft); color: var(--ink); }

/* ---------- Responsive ---------- */
@media (max-width: 900px) { .two-col { grid-template-columns: 1fr; } }
@media (max-width: 768px) { main { padding: 18px 16px 44px; } header.topbar { padding: 10px 16px; } .section-title { margin-top: 30px; } }
