/* JiveVoice — Main Stylesheet */
:root {
  --primary: #6366f1;
  --primary-hover: #4f46e5;
  --bg: #0f1117;
  --bg2: #1a1d27;
  --bg3: #22263a;
  --border: #2e3347;
  --text: #f1f3f9;
  --text2: #9ba3bf;
  --text3: #5c6480;
  --success: #22c55e;
  --warning: #f59e0b;
  --danger: #ef4444;
  --sidebar-w: 220px;
  --radius: 10px;
}

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

body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  background: var(--bg);
  color: var(--text);
  font-size: 14px;
  line-height: 1.5;
}

/* ── Login / Register ─────────────────────────────────────────────────────── */
#loginScreen, #registerScreen {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--bg);
}

.login-card {
  background: var(--bg2);
  border: 1px solid var(--border);
  border-radius: 16px;
  padding: 40px;
  width: 100%;
  max-width: 420px;
}

.login-logo {
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 20px;
  font-weight: 700;
  margin-bottom: 24px;
  color: var(--text);
}

.login-card h2 {
  font-size: 18px;
  font-weight: 600;
  margin-bottom: 24px;
  color: var(--text);
}

.login-error {
  margin-top: 12px;
  color: var(--danger);
  font-size: 13px;
}

.login-footer {
  margin-top: 20px;
  text-align: center;
  color: var(--text2);
  font-size: 13px;
}

.login-footer a { color: var(--primary); text-decoration: none; }

/* ── App Layout ───────────────────────────────────────────────────────────── */
#app {
  display: flex;
  min-height: 100vh;
}

/* ── Sidebar ──────────────────────────────────────────────────────────────── */
.sidebar {
  width: var(--sidebar-w);
  background: var(--bg2);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  position: fixed;
  top: 0; left: 0; bottom: 0;
  z-index: 100;
  transition: width 0.2s;
  overflow: hidden;
}

.sidebar-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 18px 16px 12px;
  border-bottom: 1px solid var(--border);
}

.brand {
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 16px;
  font-weight: 700;
  color: var(--text);
  white-space: nowrap;
}

.sidebar-toggle {
  background: none;
  border: none;
  color: var(--text2);
  cursor: pointer;
  font-size: 18px;
  padding: 4px;
}

.nav-section {
  padding: 12px 8px 4px;
}

.nav-section-label {
  font-size: 10px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--text3);
  padding: 0 8px 6px;
}

.nav-btn {
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
  padding: 9px 10px;
  border: none;
  background: none;
  color: var(--text2);
  border-radius: 8px;
  cursor: pointer;
  font-size: 13.5px;
  font-weight: 500;
  text-align: left;
  transition: background 0.15s, color 0.15s;
  white-space: nowrap;
}

.nav-btn:hover { background: var(--bg3); color: var(--text); }
.nav-btn.active { background: var(--primary); color: #fff; }
.nav-btn.nav-logout { color: var(--danger); }
.nav-btn.nav-logout:hover { background: rgba(239,68,68,0.1); }

.nav-icon { width: 18px; height: 18px; flex-shrink: 0; }
.nav-label { overflow: hidden; text-overflow: ellipsis; }

.nav-bottom { margin-top: auto; border-top: 1px solid var(--border); padding-top: 12px; }

/* ── Main Content ─────────────────────────────────────────────────────────── */
#main {
  margin-left: var(--sidebar-w);
  flex: 1;
  padding: 32px;
  min-height: 100vh;
}

.page { display: none; }
.page.active { display: block; }

.page-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  margin-bottom: 24px;
}

.page-title { font-size: 22px; font-weight: 700; color: var(--text); }
.page-sub { font-size: 13.5px; color: var(--text2); margin-top: 3px; }

/* ── Cards ────────────────────────────────────────────────────────────────── */
.card {
  background: var(--bg2);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px;
  margin-bottom: 16px;
}

.card-title {
  font-size: 15px;
  font-weight: 600;
  color: var(--text);
  margin-bottom: 14px;
}

.card-desc { font-size: 13px; color: var(--text2); margin-bottom: 16px; }

/* ── Stats Grid ───────────────────────────────────────────────────────────── */
.stats-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 16px;
  margin-bottom: 24px;
}

.stat-card {
  background: var(--bg2);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px;
  text-align: center;
}

.stat-value { font-size: 28px; font-weight: 700; color: var(--primary); }
.stat-label { font-size: 12px; color: var(--text2); margin-top: 4px; }

/* ── Clients Grid ─────────────────────────────────────────────────────────── */
.clients-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 16px;
}

.client-card {
  background: var(--bg2);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px;
  cursor: pointer;
  transition: border-color 0.15s, transform 0.1s;
}

.client-card:hover { border-color: var(--primary); transform: translateY(-2px); }
.client-card-name { font-size: 15px; font-weight: 600; margin-bottom: 4px; }
.client-card-type { font-size: 12px; color: var(--text2); margin-bottom: 12px; }
.client-card-meta { display: flex; gap: 12px; font-size: 12px; color: var(--text3); }

/* ── Forms ────────────────────────────────────────────────────────────────── */
.form-group { margin-bottom: 14px; }
.form-label { display: block; font-size: 12.5px; font-weight: 500; color: var(--text2); margin-bottom: 5px; }

input, select, textarea {
  width: 100%;
  background: var(--bg3);
  border: 1px solid var(--border);
  border-radius: 7px;
  color: var(--text);
  padding: 8px 11px;
  font-size: 13.5px;
  outline: none;
  transition: border-color 0.15s;
  font-family: inherit;
}

input:focus, select:focus, textarea:focus { border-color: var(--primary); }
input[disabled] { opacity: 0.5; cursor: not-allowed; }
textarea { resize: vertical; min-height: 80px; }
input[type="color"] { padding: 3px 6px; height: 36px; cursor: pointer; }

.form-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0 20px;
}

.btn-row { display: flex; gap: 8px; margin-top: 12px; }

/* ── Buttons ──────────────────────────────────────────────────────────────── */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 9px 18px;
  border-radius: 8px;
  border: none;
  cursor: pointer;
  font-size: 13.5px;
  font-weight: 500;
  transition: background 0.15s, opacity 0.15s;
}

.btn-primary { background: var(--primary); color: #fff; }
.btn-primary:hover { background: var(--primary-hover); }
.btn-secondary { background: var(--bg3); color: var(--text); border: 1px solid var(--border); }
.btn-secondary:hover { border-color: var(--primary); color: var(--primary); }
.btn-danger { background: var(--danger); color: #fff; }
.btn-sm { padding: 6px 12px; font-size: 12.5px; }
.btn-full { width: 100%; justify-content: center; }

/* ── Tabs ─────────────────────────────────────────────────────────────────── */
.tabs {
  display: flex;
  gap: 4px;
  border-bottom: 1px solid var(--border);
  margin-bottom: 20px;
}

.tab {
  background: none;
  border: none;
  border-bottom: 2px solid transparent;
  color: var(--text2);
  padding: 10px 16px;
  cursor: pointer;
  font-size: 13.5px;
  font-weight: 500;
  transition: color 0.15s, border-color 0.15s;
  margin-bottom: -1px;
}

.tab:hover { color: var(--text); }
.tab.active { color: var(--primary); border-bottom-color: var(--primary); }

.tab-panel { display: none; }
.tab-panel.active { display: block; }

/* ── Filter Bar ───────────────────────────────────────────────────────────── */
.filter-bar {
  display: flex;
  gap: 10px;
  margin-bottom: 16px;
  flex-wrap: wrap;
}

.filter-bar select, .filter-bar input { width: auto; min-width: 140px; }

/* ── Tables ───────────────────────────────────────────────────────────────── */
.table-wrap { overflow-x: auto; }

table { width: 100%; border-collapse: collapse; font-size: 13px; }
th { text-align: left; padding: 10px 12px; color: var(--text2); font-weight: 500; border-bottom: 1px solid var(--border); white-space: nowrap; }
td { padding: 10px 12px; border-bottom: 1px solid var(--border); color: var(--text); }
tr:last-child td { border-bottom: none; }
tr:hover td { background: var(--bg3); }

/* ── Calendar ─────────────────────────────────────────────────────────────── */
.calendar-layout { display: grid; grid-template-columns: 1fr 340px; gap: 16px; }
.calendar-nav { display: flex; align-items: center; justify-content: space-between; margin-bottom: 14px; }
.cal-grid { display: grid; grid-template-columns: repeat(7, 1fr); gap: 4px; }
.cal-day-label { text-align: center; font-size: 11px; color: var(--text3); padding: 4px 0; font-weight: 600; }
.cal-day { text-align: center; padding: 8px 4px; border-radius: 6px; cursor: pointer; font-size: 13px; }
.cal-day:hover { background: var(--bg3); }
.cal-day.has-events { color: var(--primary); font-weight: 600; }
.cal-day.selected { background: var(--primary); color: #fff; }
.cal-day.today { border: 1px solid var(--primary); }
.cal-day.other-month { color: var(--text3); }

/* ── Modal ────────────────────────────────────────────────────────────────── */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.6);
  z-index: 500;
  display: flex;
  align-items: center;
  justify-content: center;
}

.modal-box {
  background: var(--bg2);
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 28px;
  width: 100%;
  max-width: 520px;
  max-height: 90vh;
  overflow-y: auto;
}

/* ── Badges ───────────────────────────────────────────────────────────────── */
.badge {
  display: inline-block;
  padding: 2px 8px;
  border-radius: 20px;
  font-size: 11px;
  font-weight: 600;
}

.badge-green { background: rgba(34,197,94,0.15); color: var(--success); }
.badge-yellow { background: rgba(245,158,11,0.15); color: var(--warning); }
.badge-red { background: rgba(239,68,68,0.15); color: var(--danger); }
.badge-blue { background: rgba(99,102,241,0.15); color: var(--primary); }

/* ── Empty State ──────────────────────────────────────────────────────────── */
.empty-state { color: var(--text3); font-size: 13px; padding: 24px; text-align: center; }

/* ── Mobile Topbar ────────────────────────────────────────────────────────── */
.mobile-topbar {
  display: none;
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  height: 52px;
  background: var(--bg2);
  border-bottom: 1px solid var(--border);
  z-index: 300;
  align-items: center;
  padding: 0 16px;
  gap: 12px;
}
.mobile-burger {
  background: none;
  border: none;
  color: var(--text);
  font-size: 20px;
  cursor: pointer;
  padding: 6px;
  border-radius: 6px;
  line-height: 1;
}
.mobile-burger:hover { background: var(--bg3); }
.mobile-brand {
  font-size: 16px;
  font-weight: 700;
  color: var(--text);
}

/* ── Responsive ───────────────────────────────────────────────────────────── */
@media (max-width: 900px) {
  .stats-grid { grid-template-columns: repeat(2, 1fr); }
  .form-grid { grid-template-columns: 1fr; }
  .calendar-layout { grid-template-columns: 1fr; }
}

@media (max-width: 640px) {
  :root { --sidebar-w: 0px; }
  .sidebar { transform: translateX(-100%); }
  .sidebar.open { transform: translateX(0); width: 220px; z-index: 500; }
  #main { margin-left: 0; padding: 16px; padding-top: 68px; }
  .stats-grid { grid-template-columns: 1fr 1fr; }
  .mobile-topbar { display: flex; }
}

/* ── Plan Selection (Register Step 1) ────────────────────────────────────── */
.register-plans {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 40px 20px;
  background: var(--bg);
}

.register-plans-header {
  text-align: center;
  margin-bottom: 32px;
}

.register-plans-header h2 {
  font-size: 24px;
  font-weight: 700;
  margin-bottom: 8px;
}

.plans-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
  gap: 20px;
  max-width: 860px;
  width: 100%;
}

.plan-card {
  background: var(--bg2);
  border: 2px solid var(--border);
  border-radius: 16px;
  padding: 28px 24px;
  cursor: pointer;
  transition: border-color 0.2s, transform 0.15s;
  position: relative;
}

.plan-card:hover {
  border-color: var(--primary);
  transform: translateY(-2px);
}

.plan-card.plan-popular {
  border-color: var(--primary);
}

.plan-badge {
  position: absolute;
  top: -12px;
  left: 50%;
  transform: translateX(-50%);
  background: var(--primary);
  color: #fff;
  font-size: 11px;
  font-weight: 700;
  padding: 3px 12px;
  border-radius: 20px;
  white-space: nowrap;
  letter-spacing: 0.5px;
}

.plan-name {
  font-size: 18px;
  font-weight: 700;
  margin-bottom: 8px;
}

.plan-price {
  font-size: 32px;
  font-weight: 800;
  color: var(--primary);
  margin-bottom: 20px;
}

.plan-price span {
  font-size: 14px;
  font-weight: 400;
  color: var(--text2);
}

.plan-features {
  list-style: none;
  margin-bottom: 24px;
}

.plan-features li {
  padding: 5px 0;
  color: var(--text2);
  font-size: 13px;
}

.plan-features li::before {
  content: '✓ ';
  color: var(--success);
  font-weight: 700;
}

/* ── CSS variable aliases for text-muted ─────────────────────────────────── */
:root {
  --text-muted: #9ba3bf;
  --surface-2: #22263a;
}

/* ── Agent Drawer (slide-out right panel) ────────────────────────────────── */
.drawer-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.5);
  z-index: 400;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.25s;
}
.drawer-overlay.open {
  opacity: 1;
  pointer-events: all;
}
.drawer {
  position: fixed;
  top: 0;
  right: 0;
  bottom: 0;
  width: 780px;
  max-width: 100vw;
  background: var(--bg2);
  border-left: 1px solid var(--border);
  z-index: 401;
  display: flex;
  flex-direction: column;
  transform: translateX(100%);
  transition: transform 0.28s cubic-bezier(0.4,0,0.2,1);
  overflow: hidden;
  box-sizing: border-box;
}
.drawer.open {
  transform: translateX(0);
}
.drawer-head {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 18px 24px 14px;
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
}
.drawer-agent-icon {
  width: 40px;
  height: 40px;
  border-radius: 10px;
  background: var(--primary);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 20px;
  flex-shrink: 0;
}
.drawer-agent-name {
  font-size: 17px;
  font-weight: 700;
  color: var(--text);
}
.drawer-agent-sub {
  font-size: 12px;
  color: var(--text2);
  margin-top: 1px;
}
.drawer-close {
  margin-left: auto;
  background: none;
  border: none;
  color: var(--text2);
  font-size: 22px;
  cursor: pointer;
  padding: 4px 8px;
  border-radius: 6px;
  transition: background 0.15s;
  line-height: 1;
}
.drawer-close:hover { background: var(--bg3); color: var(--text); }
.drawer-tabs {
  display: flex;
  gap: 0;
  padding: 0 24px;
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
  overflow-x: auto;
}
.drawer-tab {
  background: none;
  border: none;
  border-bottom: 2px solid transparent;
  color: var(--text2);
  font-size: 13px;
  font-weight: 500;
  padding: 10px 14px;
  cursor: pointer;
  white-space: nowrap;
  transition: color 0.15s, border-color 0.15s;
  margin-bottom: -1px;
}
.drawer-tab:hover { color: var(--text); }
.drawer-tab.active {
  color: var(--primary);
  border-bottom-color: var(--primary);
}
.drawer-tab .badge {
  margin-left: 5px;
  font-size: 10px;
  padding: 1px 6px;
}
.drawer-body {
  flex: 1;
  overflow-y: auto;
  overflow-x: hidden;
  padding: 24px;
}
.drawer-footer {
  padding: 14px 24px;
  border-top: 1px solid var(--border);
  display: flex;
  gap: 10px;
  flex-shrink: 0;
  background: var(--bg2);
}
/* ── Orders & Reservations type tabs ─────────────────────────────────────── */
.order-type-tabs {
  display: flex;
  gap: 8px;
  margin-bottom: 20px;
}
.order-type-tab {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 7px 18px;
  border-radius: 999px;
  border: 1px solid var(--border);
  background: var(--bg3);
  color: var(--text2);
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.15s;
}
.order-type-tab.active {
  background: var(--primary);
  border-color: var(--primary);
  color: #fff;
}
.order-type-tab:hover:not(.active) {
  border-color: var(--primary);
  color: var(--text);
}
/* ── Settings section titles ─────────────────────────────────────────────── */
.settings-section-title {
  font-size: 15px;
  font-weight: 700;
  color: var(--text);
  margin-bottom: 4px;
}
.settings-section-sub {
  font-size: 13px;
  color: var(--text2);
  margin-bottom: 20px;
}
/* ── Badge gray ──────────────────────────────────────────────────────────── */
.badge-gray { background: rgba(148,163,184,0.15); color: var(--text2); }
/* ── Field with toggle ───────────────────────────────────────────────────── */
.field-with-toggle { display: flex; gap: 8px; align-items: center; }
.field-with-toggle input { flex: 1; }
/* ── Booking provider cards ──────────────────────────────────────────────── */
.booking-provider-card {
  background: var(--bg3);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px 20px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 12px;
}
.booking-provider-name { font-weight: 600; font-size: 14px; }
.booking-provider-desc { font-size: 12px; color: var(--text2); margin-top: 2px; }
/* ── Drawer tab panels ───────────────────────────────────────────────────── */
.drawer-tab-panel { display: none; padding: 1.25rem 1.5rem; }
.drawer-tab-panel.active { display: block; }
/* ── Recent calls table ──────────────────────────────────────────────────── */
#recentCallsList table { width: 100%; }

/* ── Agents Grid ─────────────────────────────────────────────────────────── */
.agents-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 16px;
}
.agent-card {
  background: var(--bg2);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 20px;
  cursor: pointer;
  transition: border-color .15s, box-shadow .15s;
  position: relative;
}
.agent-card:hover { border-color: var(--primary); box-shadow: 0 0 0 1px var(--primary); }
.agent-card-add {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-height: 160px;
  color: var(--text2);
  font-size: 14px;
  border: 2px dashed var(--border);
  background: transparent;
}
.agent-card-add:hover { border-color: var(--primary); color: var(--primary); }
.agent-card-add .add-icon { font-size: 28px; line-height: 1; }
.agent-card-head { display: flex; align-items: flex-start; gap: 12px; margin-bottom: 14px; }
.agent-card-icon {
  width: 44px; height: 44px; border-radius: 10px;
  background: linear-gradient(135deg, var(--primary), #7c3aed);
  display: flex; align-items: center; justify-content: center;
  font-size: 22px; flex-shrink: 0;
}
.agent-card-info { flex: 1; min-width: 0; }
.agent-card-name { font-weight: 700; font-size: 15px; margin-bottom: 2px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.agent-card-meta { font-size: 11px; color: var(--text2); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.agent-card-status { position: absolute; top: 14px; right: 14px; }
.agent-card-stats { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; margin-top: 4px; }
.agent-stat { text-align: center; }
.agent-stat-value { font-size: 22px; font-weight: 700; line-height: 1.1; }
.agent-stat-value.qa-good { color: #22c55e; }
.agent-stat-value.qa-warn { color: #f59e0b; }
.agent-stat-value.qa-bad  { color: #ef4444; }
.agent-stat-label { font-size: 10px; color: var(--text2); margin-top: 2px; text-transform: uppercase; letter-spacing: .04em; }

/* ── View Toggle ─────────────────────────────────────────────────────────── */
.view-toggle { display: flex; gap: 2px; background: var(--bg2); border-radius: 8px; padding: 3px; }
.view-btn {
  background: transparent; border: none; color: var(--text2);
  padding: 5px 8px; border-radius: 6px; cursor: pointer; display: flex; align-items: center;
  transition: background .15s, color .15s;
}
.view-btn.active { background: var(--bg3); color: var(--text1); }
.view-btn:hover:not(.active) { color: var(--text1); }

/* ── Client Cards ────────────────────────────────────────────────────────── */
.clients-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(300px, 1fr)); gap: 16px; }
.clients-grid.list-view { grid-template-columns: 1fr; }
.client-card {
  background: var(--bg2); border: 1px solid var(--border); border-radius: 12px;
  padding: 20px; cursor: pointer; transition: border-color .15s, box-shadow .15s;
}
.client-card:hover { border-color: var(--primary); box-shadow: 0 0 0 1px var(--primary); }
.client-card-head { display: flex; align-items: flex-start; gap: 12px; margin-bottom: 16px; }
.client-card-icon {
  width: 44px; height: 44px; border-radius: 10px;
  background: linear-gradient(135deg, #6366f1, #8b5cf6);
  display: flex; align-items: center; justify-content: center;
  font-size: 22px; flex-shrink: 0;
}
.client-card-info { flex: 1; min-width: 0; }
.client-card-name { font-weight: 700; font-size: 15px; margin-bottom: 2px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.client-card-type { font-size: 12px; color: var(--text2); margin-bottom: 4px; }
.client-card-badges { display: flex; gap: 6px; flex-wrap: wrap; }
.client-card-stats {
  display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px;
  padding-top: 14px; border-top: 1px solid var(--border);
}
.client-stat { text-align: center; }
.client-stat-value { font-size: 18px; font-weight: 700; line-height: 1.1; }
.client-stat-label { font-size: 10px; color: var(--text2); margin-top: 2px; text-transform: uppercase; letter-spacing: .04em; }

/* List view overrides */
.clients-grid.list-view .client-card { display: flex; align-items: center; gap: 16px; padding: 14px 20px; }
.clients-grid.list-view .client-card-head { margin-bottom: 0; flex: 1; }
.clients-grid.list-view .client-card-stats { border-top: none; padding-top: 0; grid-template-columns: repeat(4, 80px); }
