/* Argus — shared styles for the app shell and the login page.
   Color tokens are the reports.jollyweb.co set (same surfaces, borders, brand
   purple and green, DM Sans + Space Mono). Reports defaults to dark; Argus
   defaults to light. The theme lives on <html data-theme="light|dark">. */
@import url('https://fonts.googleapis.com/css2?family=DM+Sans:ital,opsz,wght@0,9..40,100..1000;1,9..40,100..1000&family=Space+Mono:wght@400;700&display=swap');

*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root, [data-theme='light'] {
  color-scheme: light;
  --bg: #FAFAFC;
  --surface: #F0EEF5;
  --panel: #FFFFFF;
  --border: #E5E2EE;
  --hover: #F2EFF8;
  --text: #1A1A2E;
  --text-secondary: #4B5563;
  --text-muted: #6B7280;
  --placeholder: #9CA3AF;
  --scrollbar: #C8C4D7;

  --accent: #8F0FFF;
  --accent-light: #7A0BDB;          /* hover */
  --accent-text: #7A0BDB;
  --accent-bg: rgba(143, 15, 255, 0.08);
  --brand-green: #00AB55;
  --green-solid: #008A45;
  --green-solid-hover: #00753A;
  --green-text: #04703B;
  --danger: #C81E2E;
  --danger-bg: rgba(200, 30, 46, 0.08);

  --shadow: 0 1px 2px rgba(30, 30, 56, 0.06);
  --shadow-md: 0 8px 24px rgba(30, 30, 56, 0.08);
  --shadow-lg: 0 16px 48px rgba(30, 30, 56, 0.16);
  --overlay: rgba(26, 26, 46, 0.35);

  --draft-bg: rgba(245, 158, 11, 0.14);   --draft-text: #A14A07;
  --posted-bg: rgba(0, 171, 85, 0.12);    --posted-text: #04703B;
  --skipped-bg: #F0EEF5;                  --skipped-text: #6B7280;
  --pill-sub-bg: rgba(0, 171, 85, 0.10);  --pill-sub-text: #04703B;
  --pill-client-bg: rgba(143, 15, 255, 0.08); --pill-client-text: #7A0BDB;
  --pill-keyword-bg: #F0EEF5;             --pill-keyword-text: #4B5563;
  --pill-reddit-bg: rgba(255, 86, 0, 0.10);    --pill-reddit-text: #B83A07;
  --pill-facebook-bg: rgba(24, 119, 242, 0.10); --pill-facebook-text: #1D4ED8;
  --pill-alignable-bg: rgba(0, 184, 217, 0.12); --pill-alignable-text: #0E6E82;
  --count-bg: rgba(26, 26, 46, 0.07);

  --radius: 10px;
  --radius-card: 16px;
  --radius-pill: 999px;
  --sidebar-w: 250px;
}

[data-theme='dark'] {
  color-scheme: dark;
  --bg: #0F0F1A;
  --surface: #232340;
  --panel: #1A1A2E;
  --border: #2D2D4A;
  --hover: #1E1E38;
  --text: #FFFFFF;
  --text-secondary: #B0ADC0;
  --text-muted: #8A879E;
  --placeholder: #706D85;
  --scrollbar: #2D2D4A;

  --accent-light: #A43DFF;
  --accent-text: #C084FC;
  --accent-bg: rgba(143, 15, 255, 0.14);
  --green-solid: #00AB55;
  --green-solid-hover: #009648;
  --green-text: #2FD487;
  --danger: #FF6B6B;
  --danger-bg: rgba(220, 53, 69, 0.15);

  --shadow: 0 1px 3px rgba(0, 0, 0, 0.3);
  --shadow-md: 0 4px 12px rgba(0, 0, 0, 0.4);
  --shadow-lg: 0 12px 40px rgba(0, 0, 0, 0.5);
  --overlay: rgba(0, 0, 0, 0.5);

  --draft-bg: rgba(255, 193, 7, 0.15);    --draft-text: #FFC107;
  --posted-bg: rgba(0, 171, 85, 0.15);    --posted-text: #2FD487;
  --skipped-bg: rgba(255, 255, 255, 0.05); --skipped-text: #8A879E;
  --pill-sub-bg: rgba(0, 171, 85, 0.15);  --pill-sub-text: #2FD487;
  --pill-client-bg: rgba(143, 15, 255, 0.15); --pill-client-text: #C084FC;
  --pill-keyword-bg: rgba(255, 255, 255, 0.08); --pill-keyword-text: #B0ADC0;
  --pill-reddit-bg: rgba(255, 86, 0, 0.15);    --pill-reddit-text: #FF8A4C;
  --pill-facebook-bg: rgba(24, 119, 242, 0.18); --pill-facebook-text: #6EA8FE;
  --pill-alignable-bg: rgba(0, 184, 217, 0.15); --pill-alignable-text: #4DD0E1;
  --count-bg: rgba(255, 255, 255, 0.08);
}

body {
  font-family: 'DM Sans', system-ui, -apple-system, 'Segoe UI', sans-serif;
  background: var(--bg);
  color: var(--text);
  line-height: 1.5;
  min-height: 100vh;
  -webkit-font-smoothing: antialiased;
}
.font-accent { font-family: 'Space Mono', monospace; }
::placeholder { color: var(--placeholder); }
* { scrollbar-color: var(--scrollbar) transparent; scrollbar-width: thin; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

/* Which chrome shows is a convenience only. The server decides what each role may read or change. */
.mode-client .staff-only { display: none !important; }
.mode-staff .client-only { display: none !important; }
.hidden { display: none !important; }

/* ─── TOP BAR ─── */
.topbar {
  background: var(--panel);
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  gap: 16px;
  padding: 0 20px;
  height: 60px;
  position: sticky;
  top: 0;
  z-index: 100;
}
.brand { display: flex; align-items: center; gap: 10px; white-space: nowrap; text-decoration: none; }
.brand img { width: 30px; height: 30px; display: block; }
.topbar-title { font-size: 18px; font-weight: 700; color: var(--text); letter-spacing: -0.01em; }
.brand-client {
  font-size: 13px; color: var(--text-secondary); padding-left: 12px; margin-left: 2px;
  border-left: 1px solid var(--border); max-width: 30ch; overflow: hidden; text-overflow: ellipsis;
}
.topbar-stats { display: flex; gap: 16px; flex: 1; align-items: center; margin-left: 12px; }
.stat-item { font-size: 13px; color: var(--text-secondary); }
.stat-item strong { font-family: 'Space Mono', monospace; font-size: 15px; color: var(--text); margin-right: 5px; }
.topbar-actions { display: flex; gap: 8px; align-items: center; margin-left: auto; }
.topbar select, .scope-select {
  height: 34px; padding: 0 30px 0 10px; border: 1px solid var(--border); border-radius: var(--radius);
  background: var(--panel); color: var(--text); font: inherit; font-size: 13px; max-width: 270px; cursor: pointer;
}
.btn-icon {
  background: none;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  width: 36px;
  height: 36px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--text-secondary);
  transition: all 0.15s;
  flex-shrink: 0;
}
.btn-icon:hover { background: var(--hover); color: var(--text); }
[data-theme='light'] .icon-sun, [data-theme='dark'] .icon-moon { display: none; }

/* ─── VIEW-AS BANNER ─── */
.viewas-banner {
  display: flex; align-items: center; justify-content: center; gap: 12px; flex-wrap: wrap;
  padding: 8px 16px; font-size: 13px; color: var(--accent-text);
  background: var(--accent-bg); border-bottom: 1px solid var(--border);
}
.viewas-banner strong { font-weight: 700; }

/* ─── LAYOUT ─── */
.layout { display: flex; min-height: calc(100vh - 60px); }
.mode-client .layout { justify-content: center; }

/* ─── SIDEBAR ─── */
.sidebar {
  width: var(--sidebar-w);
  background: var(--panel);
  border-right: 1px solid var(--border);
  padding: 16px 12px;
  display: flex;
  flex-direction: column;
  gap: 4px;
  flex-shrink: 0;
  overflow-y: auto;
}
.sidebar-label {
  font-family: 'Space Mono', monospace;
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--text-muted);
  padding: 8px 12px 4px;
}
.client-btn {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 12px;
  border: none;
  background: none;
  border-radius: 8px;
  cursor: pointer;
  font: inherit;
  font-size: 14px;
  color: var(--text);
  text-align: left;
  width: 100%;
  transition: background 0.12s;
}
.client-btn:hover { background: var(--hover); }
.client-btn.active { background: var(--accent-bg); color: var(--accent-text); font-weight: 600; }
.client-btn .dot { width: 8px; height: 8px; border-radius: 50%; background: var(--accent); flex-shrink: 0; }
.client-btn .dot.inactive { background: var(--placeholder); }
.client-btn .seats { margin-left: auto; font-family: 'Space Mono', monospace; font-size: 11px; color: var(--text-muted); }
.sidebar-hint { font-size: 12px; color: var(--text-muted); padding: 8px 12px 0; }
.sidebar-bottom { margin-top: auto; padding-top: 12px; border-top: 1px solid var(--border); }
.btn-add-client {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  width: 100%;
  padding: 8px;
  border: 1px dashed var(--border);
  border-radius: 8px;
  background: none;
  cursor: pointer;
  font: inherit;
  font-size: 13px;
  color: var(--text-secondary);
  transition: all 0.15s;
}
.btn-add-client:hover { border-color: var(--accent); color: var(--accent-text); background: var(--accent-bg); }

/* ─── MOBILE CLIENT DROPDOWN ─── */
.mobile-client-select { display: none; padding: 12px 16px; background: var(--panel); border-bottom: 1px solid var(--border); }
.mobile-client-select select {
  width: 100%; padding: 8px 12px; border: 1px solid var(--border); border-radius: 8px;
  font: inherit; font-size: 14px; background: var(--bg); color: var(--text);
}

/* ─── MAIN CONTENT ─── */
.main { flex: 1; padding: 20px 24px; max-width: 900px; min-width: 0; }
.mode-client .main { max-width: 820px; padding-top: 28px; }
.client-intro { margin-bottom: 20px; }
.client-intro h1 { font-size: 24px; font-weight: 700; letter-spacing: -0.02em; text-wrap: balance; }
.client-intro p { font-size: 14px; color: var(--text-secondary); margin-top: 4px; max-width: 62ch; }

/* ─── STATUS TABS ─── */
.status-tabs { display: flex; gap: 4px; margin-bottom: 16px; border-bottom: 1px solid var(--border); padding-bottom: 0; }
.status-tab {
  padding: 8px 16px;
  border: none;
  background: none;
  cursor: pointer;
  font: inherit;
  font-size: 14px;
  color: var(--text-secondary);
  border-bottom: 2px solid transparent;
  margin-bottom: -1px;
  transition: all 0.15s;
}
.status-tab:hover { color: var(--text); }
.status-tab.active { color: var(--accent-text); border-bottom-color: var(--accent); font-weight: 600; }

/* ─── PLATFORM TABS ─── */
.platform-tabs { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 12px; }
.platform-tab {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 5px 12px;
  border: 1px solid var(--border);
  border-radius: var(--radius-pill);
  background: var(--panel);
  cursor: pointer;
  font: inherit;
  font-size: 13px;
  color: var(--text-secondary);
  transition: all 0.15s;
}
.platform-tab:hover { color: var(--text); border-color: var(--placeholder); }
.platform-tab.active { color: var(--text); border-color: var(--accent); background: var(--accent-bg); font-weight: 600; }
.platform-count {
  min-width: 18px;
  padding: 0 5px;
  border-radius: 9px;
  background: var(--count-bg);
  font-family: 'Space Mono', monospace;
  font-size: 11px;
  line-height: 18px;
  text-align: center;
}
.platform-count:empty { display: none; }

/* ─── ADD COMMENT FORM ─── */
.add-form-toggle {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 10px 16px;
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  cursor: pointer;
  font: inherit;
  font-size: 14px;
  color: var(--accent-text);
  font-weight: 600;
  margin-bottom: 16px;
  width: 100%;
  transition: all 0.15s;
}
.add-form-toggle:hover { background: var(--accent-bg); }
.add-form-toggle .chevron { transition: transform 0.2s; font-size: 10px; }
.add-form-toggle.open .chevron { transform: rotate(180deg); }
.add-form-container { max-height: 0; overflow: hidden; transition: max-height 0.3s ease; }
.add-form-container.open { max-height: 640px; }
.add-form {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: var(--radius-card);
  padding: 20px;
  margin-bottom: 16px;
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
}
.add-form .full { grid-column: 1 / -1; }
.form-group label { display: block; font-size: 12px; font-weight: 600; color: var(--text-secondary); margin-bottom: 4px; }
.form-group input,
.form-group select,
.form-group textarea {
  width: 100%;
  padding: 8px 12px;
  border: 1px solid var(--border);
  border-radius: 8px;
  font-size: 14px;
  font-family: inherit;
  transition: border-color 0.15s;
  background: var(--bg);
  color: var(--text);
}
.form-group select option { background: var(--panel); color: var(--text); }
.form-group input:focus,
.form-group select:focus,
.form-group textarea:focus { outline: none; border-color: var(--accent); }
.form-group textarea { resize: vertical; min-height: 80px; }
.form-hint { font-size: 12px; color: var(--text-muted); margin-top: 4px; }

/* ─── BUTTONS ─── */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 8px 14px;
  border: 1px solid transparent;
  border-radius: 8px;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.15s;
  font-family: inherit;
  text-decoration: none;
  white-space: nowrap;
}
.btn:disabled { opacity: 0.6; cursor: default; }
.btn-primary { background: var(--accent); color: #fff; }
.btn-primary:hover { background: var(--accent-light); }
.btn-secondary { background: var(--panel); color: var(--text); border-color: var(--border); }
.btn-secondary:hover { background: var(--hover); }
.btn-success { background: var(--green-solid); color: #fff; }
.btn-success:hover { background: var(--green-solid-hover); }
.btn-danger { background: var(--danger); color: #fff; }
.btn-sm { padding: 5px 11px; font-size: 12px; }
.btn-outline-danger { background: none; color: var(--danger); border-color: var(--danger-bg); }
.btn-outline-danger:hover { background: var(--danger-bg); }
.btn-link { background: none; border: none; color: var(--accent-text); font: inherit; font-size: 13px; font-weight: 600; cursor: pointer; text-decoration: underline; padding: 0; }

/* ─── BULK SELECT (staff) ─── */
.bulk-bar {
  display: flex; align-items: center; gap: 16px;
  min-height: 36px; margin-bottom: 14px; padding: 6px 18px; font-size: 13px; color: var(--text-secondary);
}
.bulk-all { display: inline-flex; align-items: center; gap: 10px; cursor: pointer; user-select: none; }
.bulk-all input, .card-check { width: 16px; height: 16px; accent-color: var(--accent); cursor: pointer; flex-shrink: 0; margin: 0; }
.card-check { margin-right: 4px; }
.comment-card.selected { border-color: var(--accent); background: var(--accent-bg); }

/* ─── COMMENT CARDS ─── */
.comment-list { display: flex; flex-direction: column; gap: 12px; }
.comment-card {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: var(--radius-card);
  padding: 16px 18px;
  box-shadow: var(--shadow);
  transition: box-shadow 0.15s, border-color 0.15s;
}
.comment-card:hover { box-shadow: var(--shadow-md); border-color: rgba(143, 15, 255, 0.3); }
.card-top { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; margin-bottom: 8px; }
.pill {
  display: inline-flex;
  align-items: center;
  padding: 2px 10px;
  border-radius: var(--radius-pill);
  font-size: 12px;
  font-weight: 600;
  white-space: nowrap;
}
.pill-sub { background: var(--pill-sub-bg); color: var(--pill-sub-text); }
.pill-client { background: var(--pill-client-bg); color: var(--pill-client-text); }
.pill-platform-reddit { background: var(--pill-reddit-bg); color: var(--pill-reddit-text); }
.pill-platform-facebook { background: var(--pill-facebook-bg); color: var(--pill-facebook-text); }
.pill-platform-alignable { background: var(--pill-alignable-bg); color: var(--pill-alignable-text); }
.pill-keyword { background: var(--pill-keyword-bg); color: var(--pill-keyword-text); }
.pill-status-draft { background: var(--draft-bg); color: var(--draft-text); }
.pill-status-posted { background: var(--posted-bg); color: var(--posted-text); }
.pill-status-skipped { background: var(--skipped-bg); color: var(--skipped-text); }
.card-note { font-size: 12px; color: var(--text-muted); margin: -2px 0 8px; }
.card-date { font-size: 12px; color: var(--text-muted); margin-left: auto; }
.card-post-title { font-size: 15px; font-weight: 600; margin-bottom: 10px; }
.card-post-title a { color: var(--text); text-decoration: none; }
.card-post-title a:hover { color: var(--accent-text); text-decoration: underline; }
.card-label { font-family: 'Space Mono', monospace; font-size: 11px; text-transform: uppercase; letter-spacing: 0.08em; color: var(--text-muted); margin-bottom: 4px; }
.card-textarea {
  width: 100%;
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 10px 12px;
  font-size: 14px;
  font-family: inherit;
  line-height: 1.55;
  resize: none;
  overflow: hidden;
  transition: border-color 0.15s;
  background: var(--bg);
  color: var(--text);
}
.card-textarea:focus { outline: none; border-color: var(--accent); background: var(--panel); }
.card-actions { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 10px; align-items: center; }
.card-actions-right { margin-left: auto; }

/* ─── MODALS ─── */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: var(--overlay);
  backdrop-filter: blur(4px);
  z-index: 500;
  display: flex;
  align-items: center;
  justify-content: center;
  opacity: 0;
  visibility: hidden;
  transition: opacity 0.2s, visibility 0.2s;
}
.modal-overlay.open { opacity: 1; visibility: visible; }
.modal {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: var(--radius-card);
  width: 90%;
  max-width: 520px;
  max-height: 85vh;
  overflow-y: auto;
  box-shadow: var(--shadow-lg);
  transform: translateY(12px);
  transition: transform 0.2s;
}
.modal-overlay.open .modal { transform: translateY(0); }
.modal-header { display: flex; align-items: center; justify-content: space-between; padding: 16px 20px; border-bottom: 1px solid var(--border); }
.modal-header h2 { font-size: 16px; font-weight: 700; }
.modal-close {
  background: none;
  border: none;
  font-size: 20px;
  cursor: pointer;
  color: var(--text-muted);
  width: 32px;
  height: 32px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 8px;
}
.modal-close:hover { background: var(--hover); color: var(--text); }
.modal-body { padding: 20px; display: flex; flex-direction: column; gap: 14px; }
.modal-footer { display: flex; gap: 8px; justify-content: flex-end; align-items: center; padding: 16px 20px; border-top: 1px solid var(--border); }
.modal-section-title {
  font-family: 'Space Mono', monospace;
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--text-muted);
  margin-top: 4px;
}
.read-only-group { display: flex; gap: 8px; }
.read-only-group input { flex: 1; }

/* ─── TOAST ─── */
.toast-container { position: fixed; bottom: 20px; right: 20px; z-index: 1000; display: flex; flex-direction: column; gap: 8px; pointer-events: none; }
.toast {
  padding: 10px 16px;
  border-radius: var(--radius);
  font-size: 14px;
  font-weight: 500;
  color: #fff;
  box-shadow: var(--shadow-md);
  animation: toastIn 0.25s ease, toastOut 0.3s ease 2.7s forwards;
  pointer-events: auto;
}
.toast-success { background: #008A45; }
.toast-error { background: #C81E2E; }
.toast-info { background: #8F0FFF; }
@keyframes toastIn { from { opacity: 0; transform: translateY(12px); } to { opacity: 1; transform: translateY(0); } }
@keyframes toastOut { from { opacity: 1; } to { opacity: 0; transform: translateY(-8px); } }

/* ─── EMPTY STATE ─── */
.empty-state { text-align: center; padding: 56px 20px; color: var(--text-muted); }
.empty-state img { width: 48px; height: 48px; opacity: 0.85; margin-bottom: 12px; }
.empty-state p { font-size: 15px; max-width: 46ch; margin: 0 auto; }
.empty-state .empty-title { color: var(--text); font-weight: 600; margin-bottom: 4px; }

/* ─── LOGIN PAGE ─── */
.login-body { display: flex; align-items: center; justify-content: center; padding: 24px; }
.login-card {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 20px;
  padding: 40px 36px;
  box-shadow: var(--shadow-md);
  width: 100%;
  max-width: 380px;
  text-align: center;
}
.login-mark { display: block; margin: 0 auto 14px; }
.login-card h1 { font-size: 26px; font-weight: 700; letter-spacing: -0.02em; }
.login-sub { font-size: 14px; color: var(--text-secondary); margin: 6px auto 24px; max-width: 30ch; text-wrap: balance; }
.login-sso { width: 100%; justify-content: center; padding: 12px; font-size: 15px; }
.login-hint { font-size: 12px; color: var(--text-muted); margin-top: 10px; }
.login-fallback { margin-top: 22px; padding-top: 16px; border-top: 1px solid var(--border); text-align: left; }
.login-fallback summary { font-size: 12px; color: var(--text-muted); cursor: pointer; text-align: center; }
.login-fallback form { margin-top: 12px; }
.login-card input {
  width: 100%; padding: 11px 12px; border: 1px solid var(--border); border-radius: 8px;
  font: inherit; font-size: 14px; margin-bottom: 10px; background: var(--bg); color: var(--text);
}
.login-card input:focus { outline: none; border-color: var(--accent); }
.login-card form .btn { width: 100%; justify-content: center; padding: 10px; }
.login-error {
  display: none; text-align: left; font-size: 13px; color: var(--danger);
  background: var(--danger-bg); border-radius: 8px; padding: 10px 12px; margin-bottom: 16px;
}

/* ─── NO ACCESS ─── */
.notice-page { min-height: 100vh; display: flex; align-items: center; justify-content: center; padding: 24px; }

/* ─── RESPONSIVE ─── */
@media (max-width: 768px) {
  .sidebar { display: none; }
  .mode-staff .mobile-client-select { display: block; }
  .main { padding: 16px; }
  .add-form { grid-template-columns: 1fr; }
  .topbar { padding: 0 12px; gap: 8px; }
  .topbar-stats { display: none; }
  .brand-client { display: none; }
  .topbar .btn-label { display: none; }
  .card-actions .btn { flex: 1 1 auto; justify-content: center; }
  .card-actions-right { margin-left: 0; }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { transition: none !important; animation-duration: 0.01ms !important; }
}
