/* =====================================================================
   QUANTIVO ADMIN — futuristic theme
   Dark (night) by default; light (day) via [data-theme="light"].
   ===================================================================== */

:root {
  --accent: #29e0d6;      /* cyan */
  --accent-2: #7c5cff;    /* violet */
  --accent-3: #ff5cc8;    /* pink */
  --radius: 14px;
  --radius-sm: 9px;
  --font: 'Inter', system-ui, sans-serif;
  --display: 'Orbitron', var(--font);
  --mono: 'JetBrains Mono', ui-monospace, monospace;
  --shadow: 0 18px 50px -20px rgba(0, 0, 0, 0.6);
  --trans: 0.22s cubic-bezier(0.4, 0, 0.2, 1);
}

/* ---------- NIGHT (default) ---------- */
[data-theme='dark'] {
  --bg: #070912;
  --bg-2: #0c1020;
  --panel: rgba(18, 23, 43, 0.72);
  --panel-solid: #121730;
  --panel-border: rgba(124, 92, 255, 0.18);
  --text: #e8ecf8;
  --text-dim: #8b93b3;
  --text-faint: #5b6288;
  --row-hover: rgba(41, 224, 214, 0.06);
  --input-bg: rgba(8, 11, 24, 0.7);
  --glow: 0 0 24px rgba(41, 224, 214, 0.25);
}

/* ---------- DAY ---------- */
[data-theme='light'] {
  --bg: #edf0f8;
  --bg-2: #e3e8f5;
  --panel: rgba(255, 255, 255, 0.82);
  --panel-solid: #ffffff;
  --panel-border: rgba(124, 92, 255, 0.22);
  --text: #141a33;
  --text-dim: #55608a;
  --text-faint: #8a93b8;
  --row-hover: rgba(124, 92, 255, 0.06);
  --input-bg: rgba(255, 255, 255, 0.9);
  --glow: 0 0 22px rgba(124, 92, 255, 0.18);
}

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

body {
  font-family: var(--font);
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
  overflow-x: hidden;
  transition: background var(--trans), color var(--trans);
}

/* Animated grid backdrop */
.grid-backdrop {
  position: fixed;
  inset: 0;
  z-index: -2;
  background:
    radial-gradient(900px 500px at 80% -10%, rgba(124, 92, 255, 0.22), transparent 60%),
    radial-gradient(800px 500px at 0% 110%, rgba(41, 224, 214, 0.16), transparent 55%),
    var(--bg);
}
.grid-backdrop::after {
  content: '';
  position: absolute;
  inset: 0;
  background-image:
    linear-gradient(rgba(124, 92, 255, 0.06) 1px, transparent 1px),
    linear-gradient(90deg, rgba(124, 92, 255, 0.06) 1px, transparent 1px);
  background-size: 46px 46px;
  mask-image: radial-gradient(circle at 50% 40%, #000 0%, transparent 80%);
}

/* ============ APP SHELL ============ */
.app { display: grid; grid-template-columns: 262px 1fr; min-height: 100vh; }

/* ============ SIDEBAR ============ */
.sidebar {
  display: flex;
  flex-direction: column;
  padding: 22px 16px;
  gap: 24px;
  background: var(--panel);
  backdrop-filter: blur(18px);
  border-right: 1px solid var(--panel-border);
  position: sticky;
  top: 0;
  height: 100vh;
}

.brand { display: flex; align-items: center; gap: 12px; padding: 4px 6px; }
.brand-mark {
  width: 42px; height: 42px;
  display: grid; place-items: center;
  font-family: var(--display); font-weight: 900; font-size: 22px;
  color: #05060f;
  border-radius: 12px;
  background: linear-gradient(135deg, var(--accent), var(--accent-2));
  box-shadow: var(--glow);
}
.brand-text h1 { font-family: var(--display); font-size: 17px; letter-spacing: 2px; }
.brand-text span { font-size: 10.5px; color: var(--text-dim); letter-spacing: 2.5px; text-transform: uppercase; }

.nav { display: flex; flex-direction: column; gap: 6px; margin-top: 4px; }
.nav-item {
  display: flex; align-items: center; gap: 12px;
  padding: 12px 14px;
  border: 1px solid transparent;
  border-radius: var(--radius-sm);
  background: transparent;
  color: var(--text-dim);
  font-family: var(--font); font-size: 14px; font-weight: 500;
  cursor: pointer;
  text-align: left;
  transition: var(--trans);
}
.nav-item .nav-ico { font-size: 14px; color: var(--accent); width: 16px; text-align: center; }
.nav-item:hover { color: var(--text); background: var(--row-hover); }
.nav-item.active {
  color: var(--text);
  background: linear-gradient(90deg, rgba(41, 224, 214, 0.14), rgba(124, 92, 255, 0.12));
  border-color: var(--panel-border);
  box-shadow: inset 0 0 0 1px rgba(41, 224, 214, 0.1);
}
.nav-item.active .nav-ico { color: var(--accent); text-shadow: var(--glow); }

.sidebar-foot { margin-top: auto; display: flex; flex-direction: column; gap: 14px; }

/* Day/Night toggle */
.theme-toggle {
  display: flex; align-items: center; gap: 10px;
  background: transparent; border: none; cursor: pointer;
  color: var(--text-dim); font-family: var(--font); font-size: 12.5px;
  padding: 4px 6px;
}
.tt-track {
  width: 42px; height: 22px; border-radius: 20px;
  background: var(--input-bg);
  border: 1px solid var(--panel-border);
  position: relative; transition: var(--trans);
}
.tt-thumb {
  position: absolute; top: 2px; left: 2px;
  width: 16px; height: 16px; border-radius: 50%;
  background: linear-gradient(135deg, var(--accent-2), var(--accent-3));
  transition: var(--trans);
}
[data-theme='light'] .tt-thumb { transform: translateX(20px); background: linear-gradient(135deg, var(--accent), var(--accent-2)); }

/* User chip + logout */
.user-chip {
  display: flex; align-items: center; gap: 10px;
  padding: 10px;
  border-radius: var(--radius-sm);
  background: var(--input-bg);
  border: 1px solid var(--panel-border);
}
.user-avatar { width: 34px; height: 34px; border-radius: 50%; object-fit: cover; background: var(--bg-2); border: 1px solid var(--panel-border); }
.user-meta { display: flex; flex-direction: column; min-width: 0; flex: 1; }
.user-meta span { font-size: 13px; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.user-meta small { font-size: 10.5px; color: var(--text-faint); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.logout-btn {
  background: transparent; border: 1px solid var(--panel-border);
  color: var(--text-dim); width: 30px; height: 30px; border-radius: 8px;
  cursor: pointer; font-size: 15px; transition: var(--trans); flex-shrink: 0;
}
.logout-btn:hover { color: #fff; background: linear-gradient(135deg, #ff5c7a, var(--accent-3)); border-color: transparent; }

/* ============ MAIN ============ */
.main { padding: 26px 32px 40px; min-width: 0; }
.topbar { display: flex; justify-content: space-between; align-items: flex-end; gap: 16px; margin-bottom: 22px; }
.topbar h2 { font-family: var(--display); font-size: 26px; letter-spacing: 1px; }
.crumb { color: var(--text-dim); font-size: 12.5px; margin-top: 4px; }

.toolbar { display: flex; align-items: center; gap: 14px; margin-bottom: 16px; }
.search {
  display: flex; align-items: center; gap: 8px; flex: 1; max-width: 380px;
  background: var(--input-bg); border: 1px solid var(--panel-border);
  border-radius: 10px; padding: 0 12px; color: var(--text-dim);
}
.search input { flex: 1; background: transparent; border: none; outline: none; color: var(--text); font-family: var(--font); font-size: 14px; padding: 11px 0; }
.count-pill { font-family: var(--mono); font-size: 12px; color: var(--text-dim); padding: 7px 12px; border: 1px solid var(--panel-border); border-radius: 20px; white-space: nowrap; }

/* ============ GRID ============ */
.grid-wrap {
  background: var(--panel);
  backdrop-filter: blur(14px);
  border: 1px solid var(--panel-border);
  border-radius: var(--radius);
  overflow-x: auto;
  box-shadow: var(--shadow);
}
.grid { width: 100%; border-collapse: collapse; min-width: 640px; }
.grid thead th {
  text-align: left; font-family: var(--mono); font-size: 11px; letter-spacing: 0.6px; text-transform: uppercase;
  color: var(--text-dim); padding: 15px 18px;
  border-bottom: 1px solid var(--panel-border);
  cursor: pointer; user-select: none; white-space: nowrap;
}
.grid thead th:hover { color: var(--accent); }
.grid thead th.sorted { color: var(--accent); }
.grid thead th .arrow { opacity: 0.5; font-size: 10px; }
.grid thead th.actions-col, .grid td.actions-cell { text-align: right; cursor: default; }
.grid tbody td { padding: 14px 18px; font-size: 13.5px; border-bottom: 1px solid rgba(124,92,255,0.07); white-space: nowrap; }
.grid tbody tr:last-child td { border-bottom: none; }
.grid tbody tr { transition: background 0.15s; }
.grid tbody tr:hover { background: var(--row-hover); }
.grid td.id-cell { font-family: var(--mono); color: var(--text-faint); }

/* status + role badges */
.badge {
  display: inline-block; padding: 3px 10px; border-radius: 20px;
  font-size: 11px; font-weight: 600; font-family: var(--mono); letter-spacing: 0.3px;
  border: 1px solid transparent;
}
.badge.active, .badge.subscribed { color: #29e0a8; background: rgba(41,224,168,0.12); border-color: rgba(41,224,168,0.3); }
.badge.pending { color: #ffce54; background: rgba(255,206,84,0.12); border-color: rgba(255,206,84,0.3); }
.badge.suspended, .badge.bounced, .badge.cancelled { color: #ff6b8a; background: rgba(255,107,138,0.12); border-color: rgba(255,107,138,0.3); }
.badge.inactive, .badge.unsubscribed { color: #8b93b3; background: rgba(139,147,179,0.12); border-color: rgba(139,147,179,0.28); }
.badge.admin { color: #7c5cff; background: rgba(124,92,255,0.14); border-color: rgba(124,92,255,0.34); }
.badge.manager { color: #29e0d6; background: rgba(41,224,214,0.12); border-color: rgba(41,224,214,0.3); }
.badge.support, .badge.viewer { color: #8b93b3; background: rgba(139,147,179,0.12); border-color: rgba(139,147,179,0.26); }

.grid-empty { padding: 48px; text-align: center; color: var(--text-dim); font-size: 14px; }

/* row action buttons */
.row-actions { display: inline-flex; gap: 6px; }
.icon-btn {
  background: transparent; border: 1px solid var(--panel-border); color: var(--text-dim);
  width: 30px; height: 30px; border-radius: 8px; cursor: pointer; font-size: 13px; transition: var(--trans);
}
.icon-btn:hover { color: var(--text); border-color: var(--accent); }
.icon-btn.del:hover { color: #fff; background: #ff5c7a; border-color: transparent; }

/* ============ PAGER ============ */
.pager { display: flex; align-items: center; justify-content: center; gap: 6px; margin-top: 20px; flex-wrap: wrap; }
.pager button {
  min-width: 34px; height: 34px; padding: 0 10px;
  background: var(--input-bg); border: 1px solid var(--panel-border);
  color: var(--text-dim); border-radius: 8px; cursor: pointer; font-family: var(--mono); font-size: 12.5px; transition: var(--trans);
}
.pager button:hover:not(:disabled) { color: var(--text); border-color: var(--accent); }
.pager button.active { color: #05060f; background: linear-gradient(135deg, var(--accent), var(--accent-2)); border-color: transparent; }
.pager button:disabled { opacity: 0.4; cursor: not-allowed; }

/* ============ BUTTONS ============ */
.btn {
  font-family: var(--font); font-size: 13.5px; font-weight: 600;
  padding: 11px 18px; border-radius: 10px; cursor: pointer; border: 1px solid transparent; transition: var(--trans);
}
.btn.primary { color: #05060f; background: linear-gradient(135deg, var(--accent), var(--accent-2)); box-shadow: var(--glow); }
.btn.primary:hover { filter: brightness(1.08); transform: translateY(-1px); }
.btn.ghost { background: transparent; border-color: var(--panel-border); color: var(--text-dim); }
.btn.ghost:hover { color: var(--text); border-color: var(--accent); }
.btn.danger { color: #fff; background: linear-gradient(135deg, #ff5c7a, var(--accent-3)); }
.btn.danger:hover { filter: brightness(1.06); }

/* ============ MODAL ============ */
.modal-backdrop {
  position: fixed; inset: 0; z-index: 50;
  background: rgba(3, 5, 12, 0.66); backdrop-filter: blur(4px);
  display: grid; place-items: center; padding: 20px;
  animation: fade 0.18s ease;
}
/* The [hidden] attribute must override the display above, or dialogs show on load. */
.modal-backdrop[hidden] { display: none; }
@keyframes fade { from { opacity: 0; } to { opacity: 1; } }
.modal {
  width: 100%; max-width: 460px;
  background: var(--panel-solid);
  border: 1px solid var(--panel-border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  overflow: hidden;
  animation: pop 0.2s cubic-bezier(0.2, 0.8, 0.2, 1.1);
}
.modal.small { max-width: 380px; }
@keyframes pop { from { transform: translateY(10px) scale(0.98); opacity: 0; } to { transform: none; opacity: 1; } }
.modal-head { display: flex; justify-content: space-between; align-items: center; padding: 18px 20px; border-bottom: 1px solid var(--panel-border); }
.modal-head h3 { font-family: var(--display); font-size: 16px; letter-spacing: 0.5px; }
.modal-body { padding: 20px; display: grid; gap: 14px; max-height: 62vh; overflow-y: auto; }
.modal-body p { color: var(--text-dim); font-size: 14px; line-height: 1.5; }
.modal-foot { display: flex; justify-content: flex-end; gap: 10px; padding: 16px 20px; border-top: 1px solid var(--panel-border); }

.field { display: flex; flex-direction: column; gap: 6px; }
.field label { font-size: 12px; color: var(--text-dim); font-weight: 500; }
.field label .req { color: var(--accent-3); }
.field input, .field select {
  background: var(--input-bg); border: 1px solid var(--panel-border);
  border-radius: 9px; padding: 11px 13px; color: var(--text);
  font-family: var(--font); font-size: 14px; outline: none; transition: var(--trans); width: 100%;
}
.field input:focus, .field select:focus { border-color: var(--accent); box-shadow: 0 0 0 3px rgba(41,224,214,0.14); }
.field select { appearance: none; cursor: pointer; }

/* ============ TOAST ============ */
.toast {
  position: fixed; bottom: 24px; left: 50%; transform: translateX(-50%) translateY(20px);
  background: var(--panel-solid); border: 1px solid var(--panel-border);
  color: var(--text); padding: 13px 20px; border-radius: 11px; font-size: 13.5px; font-weight: 500;
  box-shadow: var(--shadow); z-index: 100; opacity: 0; transition: var(--trans);
}
.toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }
.toast.ok { border-color: rgba(41,224,168,0.4); }
.toast.err { border-color: rgba(255,107,138,0.5); }

/* ============ LOGIN ============ */
.login-body { display: grid; place-items: center; min-height: 100vh; padding: 20px; }
.login-card {
  width: 100%; max-width: 400px;
  background: var(--panel); backdrop-filter: blur(20px);
  border: 1px solid var(--panel-border); border-radius: 20px;
  padding: 40px 34px; box-shadow: var(--shadow); text-align: center;
}
.login-card .brand { justify-content: center; margin-bottom: 22px; }
.login-sub { color: var(--text-dim); font-size: 13.5px; line-height: 1.55; margin-bottom: 26px; }
.google-btn {
  display: flex; align-items: center; justify-content: center; gap: 12px;
  width: 100%; padding: 13px; border-radius: 11px; text-decoration: none;
  background: #fff; color: #1a1a1a; font-family: var(--font); font-weight: 600; font-size: 14.5px;
  border: 1px solid rgba(0,0,0,0.1); transition: var(--trans);
}
.google-btn:hover { transform: translateY(-1px); box-shadow: 0 10px 30px -10px rgba(41,224,214,0.5); }
.login-error { color: #ff6b8a; font-size: 13px; margin-top: 16px; min-height: 18px; }
.login-foot { margin-top: 26px; font-size: 11px; color: var(--text-faint); font-family: var(--mono); letter-spacing: 0.5px; }

/* ============ RESPONSIVE ============ */
@media (max-width: 820px) {
  .app { grid-template-columns: 1fr; }
  .sidebar { position: relative; height: auto; flex-direction: row; flex-wrap: wrap; align-items: center; }
  .nav { flex-direction: row; flex-wrap: wrap; }
  .sidebar-foot { margin: 0 0 0 auto; flex-direction: row; align-items: center; }
  .main { padding: 20px 16px 32px; }
}
