/* ═══════════════════════════════════════════════════════════
   ACTIO ZAP v2 — Design System
   Dark / Light mode via CSS custom properties
═══════════════════════════════════════════════════════════ */

:root {
  /* Brand */
  --brand-50:  #e8f5e9;
  --brand-100: #c8e6c9;
  --brand-200: #a5d6a7;
  --brand-400: #66bb6a;
  --brand-500: #25d366;
  --brand-600: #128c7e;
  --brand-700: #075e54;
  --brand-800: #054d44;

  /* Accent */
  --accent-blue:   #3b82f6;
  --accent-orange: #f59e0b;
  --accent-red:    #ef4444;
  --accent-purple: #8b5cf6;

  /* Light Mode */
  --bg:          #f0f2f5;
  --surface:     #ffffff;
  --surface-2:   #f8f9fa;
  --border:      #e0e0e0;
  --text:        #111827;
  --text-muted:  #6b7280;
  --text-light:  #9ca3af;
  --shadow:      0 1px 4px rgba(0,0,0,.08);
  --shadow-md:   0 4px 16px rgba(0,0,0,.10);
  --shadow-lg:   0 8px 32px rgba(0,0,0,.12);

  /* Chat */
  --chat-bg:     #efeae2;
  --bubble-in:   #ffffff;
  --bubble-out:  #d9fdd3;

  /* Sidebar */
  --sidebar-bg:  #ffffff;
  --header-bg:   #f0f2f5;

  /* Misc */
  --radius-sm:  6px;
  --radius-md:  10px;
  --radius-lg:  16px;
  --radius-xl:  20px;
  --transition: .15s ease;
}

[data-theme="dark"] {
  --bg:         #0d1117;
  --surface:    #161b22;
  --surface-2:  #1c2128;
  --border:     #30363d;
  --text:       #e6edf3;
  --text-muted: #8b949e;
  --text-light: #6e7681;
  --shadow:     0 1px 4px rgba(0,0,0,.3);
  --shadow-md:  0 4px 16px rgba(0,0,0,.4);
  --shadow-lg:  0 8px 32px rgba(0,0,0,.5);
  --chat-bg:    #1a1f2e;
  --bubble-in:  #1c2128;
  --bubble-out: #0c3225;
  --sidebar-bg: #161b22;
  --header-bg:  #1c2128;
}

/* ── Reset ──────────────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html { height: 100%; font-size: 16px; }
body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  background: var(--bg);
  color: var(--text);
  line-height: 1.5;
  transition: background var(--transition), color var(--transition);
}

/* ── Typography ─────────────────────────────────────────────── */
h1 { font-size: 1.5rem; font-weight: 700; }
h2 { font-size: 1.2rem; font-weight: 600; }
h3 { font-size: 1rem;   font-weight: 600; }
a  { color: var(--brand-600); text-decoration: none; }
a:hover { text-decoration: underline; }

/* ── Admin Layout ───────────────────────────────────────────── */
.admin-layout {
  display: flex;
  min-height: 100vh;
}

/* ── Sidebar ────────────────────────────────────────────────── */
.sidebar {
  width: 240px;
  background: var(--sidebar-bg);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  flex-shrink: 0;
  position: fixed;
  top: 0; left: 0; bottom: 0;
  z-index: 100;
  transition: transform var(--transition);
}

.sidebar-logo {
  padding: 1.25rem 1rem;
  display: flex;
  align-items: center;
  gap: 10px;
  border-bottom: 1px solid var(--border);
}

.logo-icon {
  width: 36px; height: 36px;
  background: linear-gradient(135deg, var(--brand-700), var(--brand-500));
  border-radius: var(--radius-md);
  display: flex; align-items: center; justify-content: center;
  font-size: 1.1rem; flex-shrink: 0;
}

.logo-text { font-weight: 700; font-size: .95rem; }
.logo-sub  { font-size: .68rem; color: var(--text-muted); }

.sidebar-nav { flex: 1; padding: .75rem 0; overflow-y: auto; }

.nav-section-label {
  font-size: .62rem; font-weight: 700; text-transform: uppercase;
  letter-spacing: .08em; color: var(--text-light);
  padding: .5rem 1rem .25rem;
}

.nav-item {
  display: flex; align-items: center; gap: 10px;
  padding: .6rem 1rem;
  color: var(--text-muted);
  font-size: .875rem; font-weight: 500;
  cursor: pointer; border: none; background: none;
  width: 100%; text-align: left;
  border-radius: 0;
  transition: background var(--transition), color var(--transition);
  text-decoration: none;
}

.nav-item:hover { background: var(--bg); color: var(--text); text-decoration: none; }
.nav-item.active { background: var(--brand-50); color: var(--brand-700); font-weight: 600; }
[data-theme="dark"] .nav-item.active { background: rgba(37,211,102,.1); color: var(--brand-500); }

.nav-icon { width: 18px; text-align: center; flex-shrink: 0; font-size: 1rem; }
.nav-badge {
  margin-left: auto;
  background: var(--brand-500); color: #fff;
  font-size: .65rem; font-weight: 700;
  padding: 1px 6px; border-radius: 10px;
}

.sidebar-footer {
  padding: .75rem 1rem;
  border-top: 1px solid var(--border);
  font-size: .78rem;
  color: var(--text-muted);
}

/* ── Main Content ───────────────────────────────────────────── */
.main-content {
  margin-left: 240px;
  flex: 1;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

.topbar {
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  padding: .75rem 1.5rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
  position: sticky; top: 0; z-index: 50;
}

.topbar-title { font-weight: 600; font-size: .95rem; }

.topbar-actions { display: flex; align-items: center; gap: 10px; }

.page-body { padding: 1.5rem; flex: 1; }

/* ── Cards ──────────────────────────────────────────────────── */
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 1.25rem;
  box-shadow: var(--shadow);
}

.card-header {
  display: flex; align-items: center; justify-content: space-between;
  margin-bottom: 1.25rem;
}

.card-title { font-weight: 600; font-size: .95rem; }

/* ── Stats Grid ─────────────────────────────────────────────── */
.stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 1rem;
  margin-bottom: 1.5rem;
}

.stat-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 1.25rem;
  display: flex; align-items: center; gap: 1rem;
}

.stat-icon {
  width: 46px; height: 46px; border-radius: var(--radius-md);
  display: flex; align-items: center; justify-content: center;
  font-size: 1.25rem; flex-shrink: 0;
}

.stat-icon.green  { background: #e8f5e9; }
.stat-icon.blue   { background: #dbeafe; }
.stat-icon.orange { background: #fef3c7; }
.stat-icon.red    { background: #fee2e2; }
.stat-icon.purple { background: #ede9fe; }

[data-theme="dark"] .stat-icon.green  { background: rgba(37,211,102,.15); }
[data-theme="dark"] .stat-icon.blue   { background: rgba(59,130,246,.15); }
[data-theme="dark"] .stat-icon.orange { background: rgba(245,158,11,.15); }
[data-theme="dark"] .stat-icon.red    { background: rgba(239,68,68,.15);  }
[data-theme="dark"] .stat-icon.purple { background: rgba(139,92,246,.15); }

.stat-value { font-size: 1.6rem; font-weight: 700; line-height: 1; }
.stat-label { font-size: .75rem; color: var(--text-muted); margin-top: 3px; }

/* ── Buttons ────────────────────────────────────────────────── */
.btn {
  display: inline-flex; align-items: center; gap: 6px;
  padding: .5rem 1rem;
  border-radius: var(--radius-md);
  font-size: .875rem; font-weight: 600;
  cursor: pointer; border: none;
  transition: opacity var(--transition), transform var(--transition);
  white-space: nowrap; text-decoration: none;
}
.btn:hover { opacity: .88; transform: translateY(-1px); text-decoration: none; }
.btn:active { transform: translateY(0); }

.btn-primary   { background: var(--brand-600); color: #fff; }
.btn-success   { background: var(--brand-500); color: #fff; }
.btn-danger    { background: var(--accent-red); color: #fff; }
.btn-warning   { background: var(--accent-orange); color: #fff; }
.btn-secondary { background: var(--surface-2); color: var(--text); border: 1px solid var(--border); }
.btn-ghost     { background: transparent; color: var(--text-muted); border: 1px solid var(--border); }
.btn-sm        { padding: .3rem .7rem; font-size: .78rem; }
.btn-lg        { padding: .75rem 1.5rem; font-size: 1rem; }
.btn-full      { width: 100%; justify-content: center; }
.btn:disabled  { opacity: .5; cursor: not-allowed; transform: none; }

/* ── Forms ──────────────────────────────────────────────────── */
.form-group { margin-bottom: 1rem; }
.form-label {
  display: block; font-size: .78rem; font-weight: 600;
  color: var(--text-muted); text-transform: uppercase;
  letter-spacing: .06em; margin-bottom: 5px;
}
.form-control {
  width: 100%; padding: .6rem .85rem;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  color: var(--text); font-size: .9rem;
  font-family: inherit; outline: none;
  transition: border-color var(--transition);
}
.form-control:focus { border-color: var(--brand-500); }
select.form-control { cursor: pointer; }
textarea.form-control { resize: vertical; min-height: 80px; }
.form-hint { font-size: .72rem; color: var(--text-muted); margin-top: 4px; }

/* ── Table ──────────────────────────────────────────────────── */
.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; font-size: .875rem; }
thead th {
  padding: .65rem 1rem; text-align: left;
  font-size: .72rem; font-weight: 700; text-transform: uppercase;
  letter-spacing: .06em; color: var(--text-muted);
  border-bottom: 1px solid var(--border);
  background: var(--surface-2);
}
tbody td { padding: .75rem 1rem; border-bottom: 1px solid var(--border); vertical-align: middle; }
tbody tr:last-child td { border-bottom: none; }
tbody tr:hover { background: var(--surface-2); }

/* ── Badges ─────────────────────────────────────────────────── */
.badge {
  display: inline-flex; align-items: center;
  padding: 2px 8px; border-radius: 20px;
  font-size: .68rem; font-weight: 700; white-space: nowrap;
}
.badge-green  { background: #dcfce7; color: #15803d; }
.badge-red    { background: #fee2e2; color: #b91c1c; }
.badge-orange { background: #fef3c7; color: #d97706; }
.badge-blue   { background: #dbeafe; color: #1d4ed8; }
.badge-gray   { background: var(--surface-2); color: var(--text-muted); border: 1px solid var(--border); }
.badge-purple { background: #ede9fe; color: #6d28d9; }

[data-theme="dark"] .badge-green  { background: rgba(21,128,61,.2);  color: #4ade80; }
[data-theme="dark"] .badge-red    { background: rgba(185,28,28,.2);  color: #f87171; }
[data-theme="dark"] .badge-orange { background: rgba(217,119,6,.2);  color: #fbbf24; }
[data-theme="dark"] .badge-blue   { background: rgba(29,78,216,.2);  color: #60a5fa; }
[data-theme="dark"] .badge-purple { background: rgba(109,40,217,.25); color: #c4b5fd; }

/* ── Toggle Switch ──────────────────────────────────────────── */
.toggle {
  position: relative; display: inline-block;
  width: 40px; height: 22px; flex-shrink: 0;
}
.toggle input { opacity: 0; width: 0; height: 0; }
.toggle-slider {
  position: absolute; inset: 0; cursor: pointer;
  background: var(--border); border-radius: 22px;
  transition: .2s;
}
.toggle-slider::before {
  content: ''; position: absolute;
  width: 16px; height: 16px; border-radius: 50%;
  background: #fff; left: 3px; top: 3px;
  transition: .2s;
  box-shadow: 0 1px 3px rgba(0,0,0,.3);
}
.toggle input:checked + .toggle-slider { background: var(--brand-500); }
.toggle input:checked + .toggle-slider::before { transform: translateX(18px); }

/* ── Alert ──────────────────────────────────────────────────── */
.alert {
  padding: .75rem 1rem; border-radius: var(--radius-md);
  font-size: .875rem; margin-bottom: 1rem;
  display: flex; align-items: flex-start; gap: 8px;
}
.alert-success { background: #dcfce7; color: #15803d; border: 1px solid #bbf7d0; }
.alert-error   { background: #fee2e2; color: #b91c1c; border: 1px solid #fecaca; }
.alert-warning { background: #fef3c7; color: #d97706; border: 1px solid #fde68a; }
.alert-info    { background: #dbeafe; color: #1d4ed8; border: 1px solid #bfdbfe; }

[data-theme="dark"] .alert-success { background: rgba(21,128,61,.15);  border-color: rgba(21,128,61,.3);  color: #4ade80; }
[data-theme="dark"] .alert-error   { background: rgba(185,28,28,.15);  border-color: rgba(185,28,28,.3);  color: #f87171; }
[data-theme="dark"] .alert-warning { background: rgba(217,119,6,.15);  border-color: rgba(217,119,6,.3);  color: #fbbf24; }
[data-theme="dark"] .alert-info    { background: rgba(29,78,216,.15);  border-color: rgba(29,78,216,.3);  color: #60a5fa; }

/* ── Modal ──────────────────────────────────────────────────── */
.modal-overlay {
  display: none; position: fixed; inset: 0;
  background: rgba(0,0,0,.5); z-index: 1000;
  align-items: center; justify-content: center; padding: 1rem;
}
.modal-overlay.open { display: flex; }
.modal {
  background: var(--surface); border-radius: var(--radius-lg);
  width: 100%; max-width: 480px;
  max-height: 90vh; overflow-y: auto;
  box-shadow: var(--shadow-lg);
  animation: modalIn .2s ease;
}
@keyframes modalIn { from { opacity:0; transform:scale(.95); } to { opacity:1; transform:scale(1); } }
.modal-header {
  padding: 1.25rem; border-bottom: 1px solid var(--border);
  display: flex; align-items: center; justify-content: space-between;
}
.modal-title { font-weight: 600; }
.modal-close { background: none; border: none; cursor: pointer; color: var(--text-muted); font-size: 1.2rem; line-height: 1; }
.modal-body  { padding: 1.25rem; }
.modal-footer { padding: 1rem 1.25rem; border-top: 1px solid var(--border); display: flex; justify-content: flex-end; gap: 8px; }

/* ── Theme toggle button ─────────────────────────────────────── */
.theme-btn {
  width: 34px; height: 34px; border-radius: 50%;
  background: var(--surface-2); border: 1px solid var(--border);
  cursor: pointer; display: flex; align-items: center; justify-content: center;
  font-size: 1rem; color: var(--text-muted);
  transition: background var(--transition);
}
.theme-btn:hover { background: var(--bg); }

/* ── Limit bar ──────────────────────────────────────────────── */
.limit-bar { margin-top: 4px; }
.limit-track { height: 4px; background: var(--border); border-radius: 4px; overflow: hidden; }
.limit-fill  { height: 100%; background: var(--brand-500); border-radius: 4px; transition: width .3s; }
.limit-fill.warn { background: var(--accent-orange); }
.limit-fill.full { background: var(--accent-red); }
.limit-text { font-size: .68rem; color: var(--text-muted); margin-top: 2px; }

/* ── Online dot ─────────────────────────────────────────────── */
.online-dot {
  width: 8px; height: 8px; border-radius: 50%;
  display: inline-block; flex-shrink: 0;
}
.online-dot.online  { background: var(--brand-500); }
.online-dot.offline { background: var(--text-light); }
.online-dot.busy    { background: var(--accent-orange); }

/* ── Empty state ─────────────────────────────────────────────── */
.empty-state {
  text-align: center; padding: 3rem 1rem;
  color: var(--text-muted);
}
.empty-state-icon { font-size: 2.5rem; margin-bottom: .75rem; opacity: .5; }
.empty-state h3 { font-size: .95rem; margin-bottom: .35rem; }
.empty-state p  { font-size: .82rem; }

/* ── Responsive ─────────────────────────────────────────────── */
@media (max-width: 768px) {
  .sidebar { transform: translateX(-100%); }
  .sidebar.open { transform: translateX(0); }
  .main-content { margin-left: 0; }
  .stats-grid { grid-template-columns: 1fr 1fr; }
}

/* ── Scrollbar ──────────────────────────────────────────────── */
::-webkit-scrollbar { width: 5px; height: 5px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--border); border-radius: 4px; }
::-webkit-scrollbar-thumb:hover { background: var(--text-light); }

/* ── Avatar ─────────────────────────────────────────────────── */
.avatar {
  width: 38px; height: 38px; border-radius: 50%;
  background: linear-gradient(135deg, var(--brand-700), var(--brand-500));
  color: #fff; font-weight: 700; font-size: .85rem;
  display: flex; align-items: center; justify-content: center;
  flex-shrink: 0;
}

/* ── Plan badge ─────────────────────────────────────────────── */
.plan-tag {
  display: inline-flex; align-items: center; gap: 4px;
  padding: 2px 8px; border-radius: 20px;
  font-size: .68rem; font-weight: 700;
  background: linear-gradient(135deg, var(--brand-700), var(--brand-500));
  color: #fff;
}

/* ── Divider ─────────────────────────────────────────────────── */
.divider { border: none; border-top: 1px solid var(--border); margin: 1rem 0; }

/* ── Search input ────────────────────────────────────────────── */
.search-wrap { position: relative; }
.search-wrap input { padding-left: 2.2rem; }
.search-wrap::before {
  content: '🔍';
  position: absolute; left: .65rem; top: 50%;
  transform: translateY(-50%); font-size: .8rem;
  pointer-events: none;
}

/* ── Login page ─────────────────────────────────────────────── */
.login-page {
  min-height: 100vh;
  display: flex; align-items: center; justify-content: center;
  background: var(--bg); padding: 1.5rem;
}
.login-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-xl);
  padding: 2.5rem;
  width: 100%; max-width: 400px;
  box-shadow: var(--shadow-lg);
}
.login-logo {
  text-align: center; margin-bottom: 2rem;
}
.login-logo .logo-icon {
  width: 52px; height: 52px;
  background: linear-gradient(135deg, var(--brand-700), var(--brand-500));
  border-radius: var(--radius-lg);
  display: flex; align-items: center; justify-content: center;
  margin: 0 auto .75rem; font-size: 1.5rem;
}
.login-logo h1 { font-size: 1.3rem; }
.login-logo p  { font-size: .82rem; color: var(--text-muted); margin-top: 3px; }

/* ── Utility classes ─────────────────────────────────────────── */
.d-flex { display: flex; }
.align-center { align-items: center; }
.justify-between { justify-content: space-between; }
.gap-1 { gap: .25rem; }
.gap-2 { gap: .5rem; }
.gap-3 { gap: .75rem; }
.gap-4 { gap: 1rem; }
.mt-1 { margin-top: .25rem; }
.mt-2 { margin-top: .5rem; }
.mt-3 { margin-top: .75rem; }
.mt-4 { margin-top: 1rem; }
.mb-1 { margin-bottom: .25rem; }
.mb-2 { margin-bottom: .5rem; }
.mb-3 { margin-bottom: .75rem; }
.mb-4 { margin-bottom: 1rem; }
.text-muted  { color: var(--text-muted); }
.text-sm     { font-size: .82rem; }
.text-xs     { font-size: .72rem; }
.font-bold   { font-weight: 700; }
.w-full      { width: 100%; }
.truncate    { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
