/* ═══════════════════════════════════════════════════════════════
   public/css/style.css
   WhatsApp Trust Manager — Monochrome Design System
   Black & White, Dark Mode First, Geist Typography
   ═══════════════════════════════════════════════════════════════ */

/* ── 1. Fonts ────────────────────────────────────────────────── */
@import url('https://fonts.googleapis.com/css2?family=Geist+Mono:wght@400;500;600&family=Geist:wght@400;500;600&display=swap');

/* ── 2. Design Tokens ────────────────────────────────────────── */
:root {
  /* Colors - Dark Mode (Default) */
  --bg: #000000;
  --surface: #0a0a0a;
  --surface-2: #111111;
  --surface-3: #1a1a1a;
  --border: #222222;
  --border-hover: #444444;
  --text: #ffffff;
  --text-secondary: #888888;
  --text-muted: #555555;
  --btn-bg: #ffffff;
  --btn-text: #000000;
  --btn-hover: #e0e0e0;
  
  /* Layout */
  --sidebar-w: 220px;
  --radius: 12px;
  --radius-pill: 999px;
  --transition: 0.15s ease;
  --page-padding: 32px;
}

/* Light Mode Overrides */
html.light {
  --bg: #ffffff;
  --surface: #fafafa;
  --surface-2: #f5f5f5;
  --surface-3: #eeeeee;
  --border: #e5e5e5;
  --border-hover: #bbbbbb;
  --text: #000000;
  --text-secondary: #666666;
  --text-muted: #999999;
  --btn-bg: #000000;
  --btn-text: #ffffff;
  --btn-hover: #222222;
}

/* ── 3. Base Styles ──────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

body {
  font-family: 'Geist', system-ui, sans-serif;
  background: var(--bg);
  color: var(--text);
  font-size: 14px;
  line-height: 1.5;
  min-height: 100vh;
  overflow-x: hidden;
  transition: background var(--transition), color var(--transition);
}

h1, h2, h3, h4, .section-label, .table-header {
  font-family: 'Geist Mono', monospace;
}

button {
  font-family: inherit;
  cursor: pointer;
  border: none;
  background: none;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  transition: all var(--transition);
}

input, select, textarea {
  font-family: inherit;
  font-size: 13px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 8px;
  color: var(--text);
  padding: 10px 14px;
  outline: none;
  width: 100%;
  transition: border-color var(--transition);
}
input::placeholder { color: #444444; }
input:focus, select:focus, textarea:focus { border-color: var(--text); }

/* ── 4. App Shell ──────────────────────────────────────────────── */
#app { display: none; height: 100vh; overflow: hidden; }
#app.ready { display: flex; }

/* Sidebar */
.sidebar {
  width: var(--sidebar-w);
  background: var(--bg);
  border-right: 1px solid var(--surface-2);
  display: flex;
  flex-direction: column;
  flex-shrink: 0;
  height: 100vh;
  z-index: 10;
}

.sidebar-header {
  padding: 24px 16px;
  border-bottom: 1px solid var(--surface-2);
  display: flex;
  align-items: center;
  gap: 12px;
}
.sidebar-header h1 { font-size: 14px; font-weight: 600; text-transform: uppercase; letter-spacing: 0.05em; }
.sidebar-header span { font-size: 10px; color: var(--text-muted); text-transform: uppercase; }

.sidebar-nav { flex: 1; padding: 16px 0; }

.nav-section-label {
  font-family: 'Geist Mono', monospace;
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: var(--text-muted);
  padding: 16px 16px 8px;
}

.nav-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 16px;
  margin: 2px 8px;
  border-radius: 8px;
  color: var(--text-secondary);
  font-size: 13px;
  font-weight: 400;
  transition: all var(--transition);
}
.nav-item:hover { background: var(--surface-2); color: var(--text); }
.nav-item.active { background: var(--text); color: var(--bg); border-radius: var(--radius-pill); font-weight: 500; }
.nav-item svg { width: 18px; height: 18px; }

.sidebar-footer {
  padding: 16px;
  border-top: 1px solid var(--surface-2);
}
.agent-info {
  display: flex; align-items: center; gap: 10px;
  padding: 8px;
  border-radius: 8px;
}
.agent-avatar {
  width: 32px; height: 32px;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: 50%;
  display: grid; place-items: center;
  font-size: 12px; font-weight: 600;
}

/* ── 5. Main Content Area ──────────────────────────────────────── */
.main-content {
  flex: 1;
  display: flex;
  flex-direction: column;
  height: 100vh;
  overflow: hidden;
  max-width: 1200px;
}

.page { display: none; flex: 1; overflow: hidden; flex-direction: column; padding: var(--page-padding); }
.page.active { display: flex; }

.page-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 24px;
}
.page-header h2 { font-size: 20px; font-weight: 500; }
.page-header .subtitle { font-size: 11px; text-transform: uppercase; letter-spacing: 0.1em; color: var(--text-muted); margin-top: 4px; }

/* ── 6. Buttons ────────────────────────────────────────────────── */
.btn {
  border-radius: var(--radius-pill);
  font-size: 13px;
  font-weight: 500;
  padding: 10px 20px;
  gap: 8px;
  white-space: nowrap;
}

.btn-primary { background: var(--btn-bg); color: var(--btn-text); }
.btn-primary:hover { background: var(--btn-hover); }

.btn-secondary {
  background: transparent;
  color: var(--text);
  border: 1px solid var(--border-hover);
}
.btn-secondary:hover { border-color: var(--text); background: var(--surface-2); }

.btn-danger {
  background: transparent;
  color: var(--text);
  border: 1px solid var(--border-hover);
}
.btn-danger:hover { border-color: var(--text); }

.btn-sm { font-size: 11px; padding: 5px 12px; }

.btn-icon {
  width: 32px; height: 32px;
  border-radius: 8px;
  background: transparent;
  border: 1px solid var(--border);
}
.btn-icon:hover { border-color: var(--border-hover); background: var(--surface-2); }
.btn-icon svg { width: 16px; height: 16px; }

/* ── 7. Cards & Stats ──────────────────────────────────────────── */
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px 24px;
  transition: border-color var(--transition);
}
.card:hover { border-color: var(--border-hover); }

.stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 12px;
  margin-bottom: 24px;
}

.stat-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px;
}
.stat-card .card-title {
  font-family: 'Geist Mono', monospace;
  font-size: 11px; text-transform: uppercase; letter-spacing: 0.1em;
  color: var(--text-muted); margin-bottom: 8px;
}
.stat-card .card-value {
  font-size: 28px; font-weight: 500; line-height: 1.1;
}

/* ── 8. Table ─────────────────────────────────────────────────── */
.table-wrap { width: 100%; overflow-x: auto; }
table { width: 100%; border-collapse: collapse; }

thead th {
  font-family: 'Geist Mono', monospace;
  font-size: 11px; text-transform: uppercase; letter-spacing: 0.08em;
  color: var(--text-muted);
  text-align: left;
  padding: 12px 16px;
  border-bottom: 1px solid var(--border);
}

tbody td {
  padding: 12px 16px;
  font-size: 13px;
  border-bottom: 1px solid var(--surface-2);
}
tbody tr { transition: background var(--transition); }
tbody tr:hover { background: #0d0d0d; }
html.light tbody tr:hover { background: #fdfdfd; }

/* ── 9. Filters ────────────────────────────────────────────────── */
.filter-bar {
  display: flex; gap: 12px; align-items: center; margin-bottom: 24px;
}
.filter-bar input, .filter-bar select { max-width: 180px; }

/* ── 10. Badges ────────────────────────────────────────────────── */
.badge {
  display: inline-flex; align-items: center;
  padding: 3px 10px; border-radius: var(--radius-pill);
  font-family: 'Geist Mono', monospace;
  font-size: 10px; text-transform: uppercase; letter-spacing: 0.05em;
  background: var(--surface-2);
  border: 1px solid var(--border);
  color: var(--text-secondary);
}

/* Status variants */
.badge-active { background: #ffffff; color: #000000; border-color: #ffffff; }
.badge-inactive { background: transparent; color: #ffffff; border-color: #ffffff; }
.badge-warning { background: #333333; color: #ffffff; border-color: #333333; }

/* ── 11. Modal ─────────────────────────────────────────────────── */
.modal-overlay {
  display: none; position: fixed; inset: 0;
  background: rgba(0,0,0,0.8); backdrop-filter: blur(4px);
  z-index: 100; place-items: center;
}
.modal-overlay.open { display: grid; }
.modal {
  background: var(--surface);
  border: 1px solid var(--border-hover);
  border-radius: 16px;
  width: min(540px, 95vw);
  max-height: 90vh; overflow-y: auto;
  box-shadow: 0 20px 50px rgba(0,0,0,0.5);
}
.modal-header {
  padding: 24px 24px 16px;
  display: flex; align-items: center; justify-content: space-between;
}
.modal-header h3 { font-size: 16px; font-weight: 500; }
.modal-body { padding: 0 24px 24px; }
.modal-footer {
  padding: 16px 24px 24px;
  display: flex; gap: 12px; justify-content: flex-end;
}

/* ── 12. Inbox & Chat ─────────────────────────────────────────── */
.inbox-layout { display: flex; height: 100%; border: 1px solid var(--border); border-radius: var(--radius); overflow: hidden; background: var(--bg); }

.conv-list-panel {
  width: 320px; border-right: 1px solid var(--border);
  display: flex; flex-direction: column; background: var(--bg);
}
.conv-item {
  padding: 16px; border-bottom: 1px solid var(--surface-2); cursor: pointer;
}
.conv-item:hover { background: var(--surface); }
.conv-item.active { background: var(--surface-2); }

.chat-panel { flex: 1; display: flex; flex-direction: column; background: var(--bg); }
.chat-messages { padding: 24px; display: flex; flex-direction: column; gap: 16px; overflow-y: auto; }

.msg-bubble {
  max-width: 70%; padding: 12px 16px; border-radius: 12px; font-size: 14px;
}
.msg-bubble.out { background: var(--text); color: var(--bg); align-self: flex-end; border-bottom-right-radius: 4px; }
.msg-bubble.in { background: var(--surface-2); color: var(--text); border: 1px solid var(--border); align-self: flex-start; border-bottom-left-radius: 4px; }

.chat-input-bar {
  padding: 16px 24px; border-top: 1px solid var(--border); display: flex; gap: 12px; align-items: center;
}
.chat-input-bar textarea { min-height: 44px; height: 44px; padding-top: 11px; resize: none; border-radius: var(--radius-pill); }

/* ── 13. Toasts ────────────────────────────────────────────────── */
#toast-container { position: fixed; bottom: 32px; right: 32px; z-index: 1000; display: flex; flex-direction: column; gap: 12px; }
.toast {
  background: #ffffff; color: #000000;
  padding: 10px 24px; border-radius: var(--radius-pill);
  font-size: 13px; font-weight: 500;
  box-shadow: 0 10px 30px rgba(0,0,0,0.5);
  animation: slideIn 0.3s ease;
}
@keyframes slideIn { from { transform: translateY(20px); opacity: 0; } to { transform: translateY(0); opacity: 1; } }

/* ── 14. Theme Toggle ──────────────────────────────────────────── */
.theme-toggle {
  position: fixed; top: 20px; right: 24px; z-index: 1000;
}

/* ── 15. Scrollbars ────────────────────────────────────────────── */
::-webkit-scrollbar { width: 6px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--border); border-radius: 10px; }
::-webkit-scrollbar-thumb:hover { background: var(--border-hover); }

/* ── Mobile ────────────────────────────────────────────────────── */
@media (max-width: 768px) {
  --page-padding: 16px;
  .sidebar { display: none; }
  .inbox-layout { border-radius: 0; border: none; }
  .conv-list-panel { width: 100%; }
}
