/* ═══════════════════════════════════════════════════════════════════
   Ricky Diala Admin — LUMEN dark/white system
═══════════════════════════════════════════════════════════════════ */

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

/* Make the [hidden] attribute beat any class that sets display:flex/grid */
[hidden] { display: none !important; }

:root {
  --bg-0: #000;
  --bg-1: #0a0a0a;
  --bg-2: #121212;
  --bg-3: #1a1a1a;
  --bg-4: #242424;
  --line:    rgba(255,255,255,0.06);
  --line-2:  rgba(255,255,255,0.10);
  --line-3:  rgba(255,255,255,0.18);
  --text-1: #fff;
  --text-2: #b8b8b8;
  --text-3: #6e6e6e;
  --text-4: #4a4a4a;
  --success: #22c55e;
  --warning: #f59e0b;
  --info:    #3b82f6;
  --danger:  #ef4444;
  --ease: cubic-bezier(0.2, 0.8, 0.2, 1);
}

html, body {
  background: var(--bg-0);
  color: var(--text-1);
  min-height: 100vh;
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

button { font-family: inherit; cursor: pointer; border: none; background: none; color: inherit; }
input, textarea, select {
  font-family: inherit; color: inherit;
  background: var(--bg-1);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 10px 12px;
  font-size: 13px;
  outline: none;
  transition: border-color 0.18s var(--ease);
}
input:focus, textarea:focus, select:focus { border-color: var(--line-3); }
textarea { resize: vertical; line-height: 1.5; }

a { color: inherit; text-decoration: none; }
.muted { color: var(--text-3); font-size: 11px; letter-spacing: 0.04em; }

/* ═══════════════════════════════════════════════════════════════════
   LOGIN
═══════════════════════════════════════════════════════════════════ */
.login-wrap {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
  background:
    radial-gradient(ellipse at top, rgba(255,255,255,0.04), transparent 60%),
    var(--bg-0);
}
.login-card {
  width: 360px;
  background: var(--bg-1);
  border: 1px solid var(--line);
  border-radius: 18px;
  padding: 32px 28px;
  box-shadow:
    0 1px 0 rgba(255,255,255,0.04) inset,
    0 24px 60px -20px rgba(0,0,0,0.7);
}
.login-logo {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 10px;
  margin-bottom: 28px;
}
.login-logo .wordmark {
  font-size: 18px;
  font-weight: 800;
  letter-spacing: 0.22em;
  color: var(--text-1);
  margin-top: 2px;
}
.login-logo .tagline {
  font-size: 9.5px;
  font-weight: 700;
  letter-spacing: 0.42em;
  color: var(--text-3);
}
.login-form {
  display: flex;
  flex-direction: column;
  gap: 14px;
}
.field { display: flex; flex-direction: column; gap: 6px; }
.field > span {
  font-size: 9.5px;
  font-weight: 700;
  letter-spacing: 0.22em;
  text-transform: uppercase;
  color: var(--text-3);
}
.field-error {
  color: var(--danger);
  font-size: 11px;
  min-height: 14px;
  letter-spacing: 0.04em;
}

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

.sidebar {
  background: var(--bg-1);
  border-right: 1px solid var(--line);
  display: flex;
  flex-direction: column;
  padding: 22px 14px 16px;
}
.sidebar-logo {
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 11px;
  font-weight: 800;
  letter-spacing: 0.22em;
  color: var(--text-1);
  padding: 0 8px 24px;
  border-bottom: 1px solid var(--line);
  margin-bottom: 16px;
}
.nav { display: flex; flex-direction: column; gap: 2px; flex: 1; }
.nav-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 12px;
  border-radius: 8px;
  color: var(--text-3);
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  transition: background 0.15s var(--ease), color 0.15s var(--ease);
}
.nav-item:hover { color: var(--text-2); background: var(--bg-2); }
.nav-item.active {
  color: var(--text-1);
  background: var(--bg-3);
  box-shadow: inset 0 1px 0 rgba(255,255,255,0.05);
}
.nav-item svg { color: currentColor; opacity: 0.8; }

.sidebar-footer {
  margin-top: 16px;
  padding-top: 14px;
  border-top: 1px solid var(--line);
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.sidebar-helper-link {
  display: block;
  text-align: center;
  padding: 8px 10px;
  background: transparent;
  border: 1px solid var(--line);
  border-radius: 8px;
  color: var(--text-3);
  font-size: 10.5px;
  font-weight: 600;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  text-decoration: none;
  transition: all 0.15s var(--ease);
}
.sidebar-helper-link:hover {
  border-color: var(--line-2);
  color: var(--text-1);
  background: var(--bg-2);
}

.btn-ghost {
  width: 100%;
  padding: 9px 12px;
  background: transparent;
  border: 1px solid var(--line-2);
  border-radius: 8px;
  color: var(--text-2);
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  transition: all 0.15s var(--ease);
}
.btn-ghost:hover { border-color: var(--line-3); color: var(--text-1); }

.btn-primary {
  width: 100%;
  padding: 12px;
  background: var(--text-1);
  color: #000;
  border-radius: 999px;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.22em;
  text-transform: uppercase;
  box-shadow:
    0 1px 0 rgba(255,255,255,0.5) inset,
    0 -1px 0 rgba(0,0,0,0.06) inset,
    0 4px 12px -4px rgba(0,0,0,0.4);
  transition: transform 0.12s var(--ease), background 0.18s var(--ease);
}
.btn-primary:hover { background: #f0f0f0; transform: translateY(-1px); }
.btn-primary:active { transform: translateY(0); }
.btn-primary:disabled { background: var(--bg-3); color: var(--text-3); cursor: not-allowed; transform: none; box-shadow: none; }

/* ═══════════════════════════════════════════════════════════════════
   MAIN AREA
═══════════════════════════════════════════════════════════════════ */
.main { padding: 0 32px 40px; min-width: 0; }

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 22px 0 24px;
  border-bottom: 1px solid var(--line);
  margin-bottom: 28px;
}
.topbar-title {
  font-size: 20px;
  font-weight: 700;
  letter-spacing: -0.01em;
}
.topbar-status {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 6px 14px;
  background: var(--bg-1);
  border: 1px solid var(--line);
  border-radius: 999px;
  font-size: 11px;
  color: var(--text-2);
  letter-spacing: 0.04em;
}
.ws-dot {
  width: 6px; height: 6px; border-radius: 50%;
  background: var(--text-4);
  transition: background 0.18s, box-shadow 0.18s;
}
.ws-dot.connected {
  background: var(--success);
  box-shadow: 0 0 6px rgba(34,197,94,0.5);
  animation: ws-pulse 2s ease-in-out infinite;
}
.ws-dot.connecting { background: var(--warning); animation: ws-pulse 0.8s ease-in-out infinite; }
.ws-dot.error      { background: var(--danger); }
@keyframes ws-pulse {
  0%, 100% { opacity: 1; }
  50%       { opacity: 0.55; }
}

.page { padding-bottom: 40px; }

/* ═══════════════════════════════════════════════════════════════════
   STATS
═══════════════════════════════════════════════════════════════════ */
.stats-row {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 14px;
  margin-bottom: 32px;
}
.stat {
  background: var(--bg-1);
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 18px 20px;
}
.stat-label {
  font-size: 9.5px;
  font-weight: 700;
  letter-spacing: 0.22em;
  text-transform: uppercase;
  color: var(--text-3);
}
.stat-value {
  font-size: 36px;
  font-weight: 800;
  color: var(--text-1);
  margin-top: 4px;
  line-height: 1;
  font-variant-numeric: tabular-nums;
  letter-spacing: -0.02em;
}

/* ═══════════════════════════════════════════════════════════════════
   SECTION HEAD
═══════════════════════════════════════════════════════════════════ */
.section-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  margin-bottom: 14px;
}
.section-head h2 {
  font-size: 15px;
  font-weight: 700;
  letter-spacing: -0.01em;
}

/* ═══════════════════════════════════════════════════════════════════
   AGENT GRID
═══════════════════════════════════════════════════════════════════ */
.agent-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
  gap: 14px;
}
.agent-card {
  background: var(--bg-1);
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  transition: border-color 0.18s var(--ease), background 0.18s var(--ease);
}
.agent-card:hover { border-color: var(--line-2); }
.agent-card.on-call  { border-color: rgba(34,197,94,0.35); }
.agent-card.dialing  { border-color: rgba(245,158,11,0.35); }

.agent-card-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}
.agent-name {
  font-size: 14px;
  font-weight: 700;
  color: var(--text-1);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.agent-alias {
  font-size: 10.5px;
  color: var(--text-3);
  letter-spacing: 0.04em;
  margin-top: 2px;
}
.agent-state {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 3px 9px;
  background: var(--bg-3);
  border: 1px solid var(--line);
  border-radius: 999px;
  font-size: 9.5px;
  font-weight: 700;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  color: var(--text-2);
  flex-shrink: 0;
}
.agent-state .dot {
  width: 5px; height: 5px; border-radius: 50%;
  background: currentColor;
  flex-shrink: 0;
}
.agent-state.idle      { color: var(--text-3); }
.agent-state.dialing   { color: var(--warning); border-color: rgba(245,158,11,0.35); }
.agent-state.ringing   { color: var(--warning); border-color: rgba(245,158,11,0.35); }
.agent-state.connected { color: var(--success); border-color: rgba(34,197,94,0.35); }
.agent-state.connected .dot { animation: ws-pulse 1.4s ease-in-out infinite; box-shadow: 0 0 5px currentColor; }

.agent-lead {
  font-size: 12px;
  color: var(--text-2);
  font-variant-numeric: tabular-nums;
  letter-spacing: 0.02em;
}
.agent-lead.empty { color: var(--text-4); font-style: italic; letter-spacing: 0; }

.agent-actions {
  display: flex;
  gap: 6px;
  margin-top: 4px;
  padding-top: 10px;
  border-top: 1px solid var(--line);
}
.agent-action {
  flex: 1;
  padding: 7px 10px;
  background: var(--bg-2);
  border: 1px solid var(--line);
  border-radius: 7px;
  color: var(--text-2);
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  transition: all 0.15s var(--ease);
}
.agent-action:hover { background: var(--bg-3); color: var(--text-1); border-color: var(--line-2); }
.agent-action.danger:hover { color: var(--danger); border-color: rgba(239,68,68,0.4); background: rgba(239,68,68,0.06); }

.empty {
  grid-column: 1 / -1;
  text-align: center;
  padding: 60px 20px;
  color: var(--text-3);
  font-size: 13px;
  border: 1px dashed var(--line-2);
  border-radius: 12px;
}

/* ═══════════════════════════════════════════════════════════════════
   TABLE
═══════════════════════════════════════════════════════════════════ */
.table-wrap {
  background: var(--bg-1);
  border: 1px solid var(--line);
  border-radius: 12px;
  overflow: hidden;
}
.data-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 12.5px;
}
.data-table th {
  text-align: left;
  font-size: 9.5px;
  font-weight: 700;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  color: var(--text-3);
  padding: 12px 16px;
  border-bottom: 1px solid var(--line);
  background: var(--bg-2);
}
.data-table td {
  padding: 14px 16px;
  border-bottom: 1px solid var(--line);
  color: var(--text-2);
  vertical-align: middle;
}
.data-table tr:last-child td { border-bottom: none; }
.data-table tr:hover td { background: var(--bg-2); }

.cell-alias { color: var(--text-1); font-weight: 600; }
.cell-status {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.14em;
  text-transform: uppercase;
}
.cell-status.online  { color: var(--success); }
.cell-status.offline { color: var(--text-4); }
.cell-status .dot { width: 6px; height: 6px; border-radius: 50%; background: currentColor; }
.cell-status.online .dot { box-shadow: 0 0 5px currentColor; }

.quota-input {
  width: 70px;
  padding: 5px 8px;
  font-size: 12px;
  text-align: center;
  font-variant-numeric: tabular-nums;
}

/* ═══════════════════════════════════════════════════════════════════
   AGENT CARD STATS
═══════════════════════════════════════════════════════════════════ */
.agent-stats {
  display: flex;
  gap: 14px;
  padding-top: 8px;
  margin-top: 4px;
  border-top: 1px solid var(--line);
  font-size: 11px;
  color: var(--text-3);
}
.agent-stats b {
  color: var(--text-1);
  font-weight: 700;
  font-variant-numeric: tabular-nums;
}
.agent-stats .stat-pill {
  display: flex;
  flex-direction: column;
  gap: 1px;
}
.agent-stats .stat-pill span {
  font-size: 9px;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  color: var(--text-4);
}

/* ═══════════════════════════════════════════════════════════════════
   LEADS PAGE
═══════════════════════════════════════════════════════════════════ */
.leads-import {
  background: var(--bg-1);
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 16px;
}
.leads-import textarea {
  width: 100%;
  min-height: 140px;
  background: var(--bg-2);
  font-family: 'SFMono-Regular', Menlo, Consolas, monospace;
  font-size: 12px;
  line-height: 1.6;
}
.leads-preview {
  margin-top: 10px;
  min-height: 18px;
  font-size: 11px;
  color: var(--text-3);
  letter-spacing: 0.04em;
}
.leads-preview.ok  b { color: var(--success); }
.leads-preview.err b { color: var(--danger); }
.leads-preview b { font-weight: 700; }
.leads-actions {
  display: flex;
  gap: 10px;
  justify-content: flex-end;
  margin-top: 12px;
}
.leads-actions .btn-primary { width: auto; padding: 11px 22px; }
.leads-actions .btn-ghost   { width: auto; padding: 11px 18px; }

.filter-row {
  display: flex;
  gap: 6px;
  align-items: center;
  flex-wrap: wrap;
}
.filter-pill {
  background: var(--bg-1);
  border: 1px solid var(--line);
  color: var(--text-3);
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  padding: 6px 12px;
  border-radius: 999px;
  cursor: pointer;
  transition: all 0.15s var(--ease);
}
.filter-pill:hover { color: var(--text-2); border-color: var(--line-2); }
.filter-pill.active {
  background: var(--bg-3);
  color: var(--text-1);
  border-color: var(--line-3);
}
.btn-ghost.danger-ghost {
  border-color: rgba(239,68,68,0.25);
  color: var(--danger);
  width: auto;
  padding: 6px 14px;
  font-size: 9.5px;
  margin-left: auto;
}
.btn-ghost.danger-ghost:hover {
  background: rgba(239,68,68,0.06);
  border-color: rgba(239,68,68,0.45);
}

.lead-status-badge {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  font-size: 9.5px;
  font-weight: 700;
  letter-spacing: 0.16em;
  text-transform: uppercase;
}
.lead-status-badge .dot { width: 5px; height: 5px; border-radius: 50%; background: currentColor; }
.lead-status-badge.pending { color: var(--text-3); }
.lead-status-badge.claimed { color: var(--warning); }
.lead-status-badge.called  { color: var(--success); }

.cell-phone { color: var(--text-1); font-weight: 600; font-variant-numeric: tabular-nums; }
.cell-email { color: var(--text-3); font-size: 11.5px; }

.btn-row-delete {
  background: transparent;
  border: 1px solid var(--line);
  color: var(--text-3);
  border-radius: 6px;
  padding: 5px 10px;
  font-size: 9.5px;
  font-weight: 700;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  cursor: pointer;
}
.btn-row-delete:hover {
  color: var(--danger);
  border-color: rgba(239,68,68,0.4);
  background: rgba(239,68,68,0.06);
}
.btn-row-delete:disabled { opacity: 0.3; cursor: not-allowed; }

/* ═══════════════════════════════════════════════════════════════════
   SETTINGS PAGE
═══════════════════════════════════════════════════════════════════ */
.settings-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(340px, 1fr));
  gap: 16px;
}
.settings-card {
  background: var(--bg-1);
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 18px 20px;
  display: flex;
  flex-direction: column;
  gap: 14px;
}
.settings-card-head {
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.22em;
  text-transform: uppercase;
  color: var(--text-3);
  padding-bottom: 6px;
  border-bottom: 1px solid var(--line);
}
.settings-field { display: flex; flex-direction: column; gap: 6px; }
.settings-field > span {
  font-size: 9.5px;
  font-weight: 700;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  color: var(--text-3);
}
.settings-field > span small {
  font-size: 9.5px;
  font-weight: 500;
  color: var(--text-4);
  letter-spacing: 0.04em;
  text-transform: none;
  margin-left: 6px;
}
.settings-field > span code {
  background: var(--bg-3);
  border-radius: 4px;
  padding: 1px 5px;
  color: var(--text-2);
  font-family: 'SFMono-Regular', Menlo, Consolas, monospace;
  font-size: 10px;
}
.settings-field > small {
  font-size: 11px;
  color: var(--text-3);
  letter-spacing: 0.02em;
  margin-top: 2px;
}
.settings-field input[readonly] {
  background: var(--bg-2);
  color: var(--text-2);
  cursor: default;
}
.settings-actions {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-top: 4px;
}
.settings-actions .btn-primary { width: auto; padding: 10px 20px; }
.settings-saved {
  font-size: 11px;
  color: var(--success);
  letter-spacing: 0.04em;
  opacity: 0;
  transition: opacity 0.18s var(--ease);
}
.settings-saved.show { opacity: 1; }

.kv-row {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  font-size: 12.5px;
  color: var(--text-2);
  padding: 8px 0;
  border-bottom: 1px solid var(--line);
}
.kv-row:last-child { border-bottom: none; }
.kv-row b {
  font-size: 18px;
  font-weight: 700;
  color: var(--text-1);
  font-variant-numeric: tabular-nums;
}

/* ═══════════════════════════════════════════════════════════════════
   PLACEHOLDER (P2/P5 stubs)
═══════════════════════════════════════════════════════════════════ */
.placeholder {
  text-align: center;
  padding: 80px 20px;
  background: var(--bg-1);
  border: 1px dashed var(--line-2);
  border-radius: 14px;
  color: var(--text-3);
}
.placeholder h3 { color: var(--text-1); font-size: 18px; margin-bottom: 8px; }
.placeholder p { font-size: 13px; max-width: 380px; margin: 0 auto; line-height: 1.5; }
.placeholder-icon { color: var(--text-4); margin-bottom: 14px; }

/* ═══════════════════════════════════════════════════════════════════
   MODAL
═══════════════════════════════════════════════════════════════════ */
.modal {
  position: fixed; inset: 0;
  background: rgba(0,0,0,0.7);
  display: flex; align-items: center; justify-content: center;
  z-index: 1000;
  backdrop-filter: blur(4px);
}
.modal-card {
  width: 420px;
  background: var(--bg-1);
  border: 1px solid var(--line-2);
  border-radius: 14px;
  padding: 24px;
  box-shadow: 0 24px 60px -20px rgba(0,0,0,0.7);
  display: flex;
  flex-direction: column;
  gap: 14px;
}
.modal-card h3 { font-size: 16px; font-weight: 700; }
.modal-row { display: grid; grid-template-columns: 1fr; gap: 12px; }
.modal-actions {
  display: flex;
  gap: 10px;
  margin-top: 6px;
}
.modal-actions .btn-ghost { width: auto; padding: 10px 18px; }
.modal-actions .btn-primary { width: auto; padding: 10px 22px; }

/* ═══════════════════════════════════════════════════════════════════
   RESPONSIVE
═══════════════════════════════════════════════════════════════════ */
@media (max-width: 880px) {
  .app { grid-template-columns: 1fr; }
  .sidebar {
    flex-direction: row; flex-wrap: wrap; align-items: center;
    border-right: none; border-bottom: 1px solid var(--line);
    padding: 14px 18px;
  }
  .sidebar-logo { padding: 0; border: none; margin: 0; flex: 1; }
  .nav { flex-direction: row; flex: none; gap: 4px; }
  .nav-item { padding: 8px 12px; font-size: 12px; }
  .sidebar-footer { margin: 0 0 0 8px; padding: 0; border: none; flex: 0; }
  .sidebar-footer .btn-ghost { width: auto; padding: 8px 14px; }
  .stats-row { grid-template-columns: repeat(2, 1fr); }
  .main { padding: 0 16px 32px; }
}
