/* ─── Reset & Base ─────────────────────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
  --bg:         #0a0b0f;
  --bg2:        #111218;
  --bg3:        #1a1b24;
  --border:     rgba(255,255,255,0.07);
  --border2:    rgba(255,255,255,0.12);
  --text:       #e8eaf0;
  --text-muted: #7c8094;
  --text-dim:   #4a4e61;
  --purple:     #7c6fff;
  --purple-glow:rgba(124,111,255,0.25);
  --blue:       #3b82f6;
  --green:      #10b981;
  --yellow:     #f59e0b;
  --red:        #ef4444;
  --teal:       #14b8a6;
  --sidebar-w:  240px;
  --radius:     12px;
  --radius-sm:  8px;
}

html { font-size: 15px; }
body {
  font-family: 'Inter', system-ui, sans-serif;
  background: var(--bg);
  color: var(--text);
  display: flex;
  min-height: 100vh;
  overflow-x: hidden;
}

/* ─── 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: 50;
  padding: 0 0 20px;
}

.sidebar-brand {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 24px 20px;
  border-bottom: 1px solid var(--border);
}
.brand-icon {
  width: 38px; height: 38px;
  background: linear-gradient(135deg, var(--purple), #a855f7);
  border-radius: 10px;
  display: grid; place-items: center;
  font-size: 18px;
  box-shadow: 0 4px 16px var(--purple-glow);
}
.brand-name { font-size: 16px; font-weight: 700; color: var(--text); display: block; }
.brand-sub  { font-size: 11px; color: var(--text-muted); font-weight: 400; }

.sidebar-nav {
  display: flex;
  flex-direction: column;
  gap: 2px;
  padding: 16px 12px;
  flex: 1;
}

.nav-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 12px;
  border-radius: var(--radius-sm);
  text-decoration: none;
  color: var(--text-muted);
  font-size: 14px;
  font-weight: 500;
  transition: all 0.2s;
  cursor: pointer;
}
.nav-item:hover {
  background: rgba(255,255,255,0.05);
  color: var(--text);
}
.nav-item.active {
  background: linear-gradient(135deg, rgba(124,111,255,0.2), rgba(168,85,247,0.15));
  color: var(--purple);
  border: 1px solid rgba(124,111,255,0.3);
}
.nav-icon { font-size: 16px; width: 20px; text-align: center; }

.sidebar-status {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 12px 20px;
  font-size: 12px;
  color: var(--text-muted);
}
.status-dot {
  width: 8px; height: 8px;
  border-radius: 50%;
  background: var(--text-dim);
  flex-shrink: 0;
}
.status-dot.active {
  background: var(--green);
  box-shadow: 0 0 8px var(--green);
  animation: pulse-green 2s infinite;
}
@keyframes pulse-green {
  0%, 100% { box-shadow: 0 0 8px var(--green); }
  50%       { box-shadow: 0 0 16px var(--green); }
}

/* ─── Main ─────────────────────────────────────────────────────────────────── */
.main {
  margin-left: var(--sidebar-w);
  flex: 1;
  display: flex;
  flex-direction: column;
  min-height: 100vh;
  padding: 0 28px 40px;
}

/* ─── Topbar ───────────────────────────────────────────────────────────────── */
.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 24px 0 20px;
  border-bottom: 1px solid var(--border);
  margin-bottom: 24px;
}
.page-title { font-size: 22px; font-weight: 700; color: var(--text); }
.page-sub   { font-size: 13px; color: var(--text-muted); display: block; margin-top: 2px; }

.topbar-right {
  display: flex;
  align-items: center;
  gap: 14px;
}
.refresh-btn {
  width: 34px; height: 34px;
  background: var(--bg3);
  border: 1px solid var(--border);
  border-radius: 8px;
  display: grid; place-items: center;
  cursor: pointer;
  font-size: 18px;
  color: var(--text-muted);
  transition: all 0.2s;
}
.refresh-btn:hover { border-color: var(--purple); color: var(--purple); }
.refresh-btn.spinning span { display: inline-block; animation: spin 0.7s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

.last-updated { font-size: 12px; color: var(--text-muted); }

/* ─── Pages ────────────────────────────────────────────────────────────────── */
.page { display: none; }
.page.active { display: block; }

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

.stat-card {
  background: var(--bg2);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 24px;
  display: flex;
  align-items: center;
  gap: 16px;
  transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  cursor: default;
  position: relative;
  overflow: hidden;
}
.stat-card:hover {
  border-color: var(--purple);
  transform: translateY(-4px);
  box-shadow: 0 12px 32px rgba(0,0,0,0.4);
}
.stat-card::after {
  content: '';
  position: absolute;
  top: 0; left: -100%;
  width: 100%; height: 100%;
  background: linear-gradient(90deg, transparent, rgba(255,255,255,0.03), transparent);
  transition: 0.5s;
}
.stat-card:hover::after { left: 100%; }

.stat-icon-wrap {
  width: 48px;
  height: 48px;
  background: var(--bg3);
  border-radius: 12px;
  display: grid;
  place-items: center;
  color: var(--purple);
  flex-shrink: 0;
  transition: all 0.3s;
}
.stat-card:hover .stat-icon-wrap {
  background: var(--purple);
  color: white;
  transform: rotate(-5deg) scale(1.1);
}

.icon-svg {
  width: 24px !important;
  height: 24px !important;
  flex-shrink: 0;
}

.stat-value {
  font-size: 28px;
  font-weight: 800;
  color: var(--text);
  line-height: 1.2;
}
.stat-label {
  font-size: 11px;
  color: var(--text-muted);
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

/* ─── Micro Animations ──────────────────────────────────────────────────────── */
.anim-pulse { animation: pulse-svg 2s infinite; }
@keyframes pulse-svg {
  0%, 100% { transform: scale(1); opacity: 1; }
  50% { transform: scale(1.1); opacity: 0.8; }
}

.anim-shake { animation: shake-svg 4s infinite; }
@keyframes shake-svg {
  0%, 90%, 100% { transform: rotate(0); }
  92% { transform: rotate(10deg); }
  94% { transform: rotate(-10deg); }
  96% { transform: rotate(10deg); }
  98% { transform: rotate(-10deg); }
}

.anim-spin { animation: spin-svg 10s linear infinite; }
@keyframes spin-svg {
  to { transform: rotate(360deg); }
}

.anim-glow { animation: glow-svg 3s infinite; }
@keyframes glow-svg {
  0%, 100% { filter: drop-shadow(0 0 2px var(--purple)); }
  50% { filter: drop-shadow(0 0 8px var(--purple)); }
}

/* ─── Split Grid ───────────────────────────────────────────────────────────── */
.split-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
}
@media (max-width: 900px) { .split-grid { grid-template-columns: 1fr; } }

/* ─── Card ─────────────────────────────────────────────────────────────────── */
.card {
  background: var(--bg2);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
}

.card-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 18px 20px;
  border-bottom: 1px solid var(--border);
}
.card-title { font-size: 15px; font-weight: 600; color: var(--text); }
.live-badge {
  font-size: 11px;
  color: var(--green);
  font-weight: 600;
  animation: blink 1.5s infinite;
}
@keyframes blink { 50% { opacity: 0.4; } }

/* ─── Pipeline ─────────────────────────────────────────────────────────────── */
.pipeline {
  padding: 16px 20px;
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.pipeline-stage {
  display: grid;
  grid-template-columns: 110px 1fr 36px;
  align-items: center;
  gap: 12px;
}
.stage-label { font-size: 13px; color: var(--text-muted); }
.stage-bar {
  height: 6px;
  background: var(--bg3);
  border-radius: 3px;
  overflow: hidden;
}
.stage-fill {
  height: 100%;
  border-radius: 3px;
  width: 0%;
  transition: width 0.8s cubic-bezier(0.4,0,0.2,1);
  opacity: 0.85;
}
.stage-count {
  font-size: 13px;
  font-weight: 600;
  color: var(--text);
  text-align: right;
}

/* ─── Activity Feed ────────────────────────────────────────────────────────── */
.activity-feed {
  padding: 12px 20px;
  max-height: 340px;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 2px;
}
.activity-item {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  padding: 10px 8px;
  border-radius: 8px;
  transition: background 0.2s;
}
.activity-item:hover { background: rgba(255,255,255,0.03); }
.activity-dot {
  width: 8px; height: 8px;
  border-radius: 50%;
  flex-shrink: 0;
  margin-top: 5px;
}
.activity-content { flex: 1; }
.activity-name { font-size: 13px; font-weight: 500; color: var(--text); }
.activity-desc { font-size: 12px; color: var(--text-muted); margin-top: 2px; }
.activity-time { font-size: 11px; color: var(--text-dim); flex-shrink: 0; margin-top: 3px; }

/* ─── Leads Table ──────────────────────────────────────────────────────────── */
.card .card-header + .table-controls,
.table-controls {
  display: flex;
  gap: 10px;
}

.search-input {
  background: var(--bg3);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text);
  padding: 7px 12px;
  font-size: 13px;
  font-family: inherit;
  outline: none;
  transition: border-color 0.2s;
  width: 220px;
}
.search-input:focus { border-color: var(--purple); }

.filter-select {
  background: var(--bg3);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text);
  padding: 7px 10px;
  font-size: 13px;
  font-family: inherit;
  outline: none;
  cursor: pointer;
}

.table-wrap { overflow-x: auto; }

.leads-table {
  width: 100%;
  border-collapse: collapse;
}
.leads-table th {
  font-size: 11px;
  font-weight: 600;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.06em;
  padding: 12px 16px;
  text-align: left;
  border-bottom: 1px solid var(--border);
  background: var(--bg3);
}
.leads-table td {
  padding: 13px 16px;
  font-size: 13px;
  color: var(--text);
  border-bottom: 1px solid var(--border);
}
.leads-table tr:last-child td { border-bottom: none; }
.leads-table tbody tr {
  transition: background 0.15s;
  cursor: pointer;
}
.leads-table tbody tr:hover { background: rgba(255,255,255,0.03); }

.empty-state {
  text-align: center;
  padding: 40px;
  color: var(--text-muted);
  font-size: 14px;
}

/* ─── Status Badge ─────────────────────────────────────────────────────────── */
.badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 3px 10px;
  border-radius: 20px;
  font-size: 11px;
  font-weight: 600;
  text-transform: capitalize;
}
.badge-new            { background:rgba(124,111,255,0.15); color:#7c6fff; }
.badge-calling        { background:rgba(59,130,246,0.15);  color:#3b82f6; }
.badge-no_answer      { background:rgba(239,68,68,0.15);   color:#ef4444; }
.badge-following_up   { background:rgba(245,158,11,0.15);  color:#f59e0b; }
.badge-meeting_booked { background:rgba(16,185,129,0.15);  color:#10b981; }
.badge-meeting_attended{background:rgba(16,185,129,0.2);   color:#10b981; }
.badge-no_show        { background:rgba(239,68,68,0.15);   color:#ef4444; }
.badge-replied        { background:rgba(20,184,166,0.15);  color:#14b8a6; }
.badge-stopped        { background:rgba(107,114,128,0.15); color:#9ca3af; }
.badge-parked         { background:rgba(107,114,128,0.1);  color:#6b7280; }
.badge-closed         { background:rgba(16,185,129,0.1);   color:#6ee7b7; }

/* ─── Action Buttons ───────────────────────────────────────────────────────── */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 5px 12px;
  border-radius: 6px;
  font-size: 12px;
  font-weight: 500;
  cursor: pointer;
  border: none;
  transition: all 0.2s;
  font-family: inherit;
}
.btn-stop {
  background: rgba(239,68,68,0.15);
  color: var(--red);
  border: 1px solid rgba(239,68,68,0.3);
}
.btn-stop:hover { background: rgba(239,68,68,0.25); }
.btn-restart {
  background: rgba(16,185,129,0.15);
  color: var(--green);
  border: 1px solid rgba(16,185,129,0.3);
}
.btn-restart:hover { background: rgba(16,185,129,0.25); }
.btn-view {
  background: rgba(124,111,255,0.15);
  color: var(--purple);
  border: 1px solid rgba(124,111,255,0.3);
}
.btn-view:hover { background: rgba(124,111,255,0.25); }

/* ─── Pagination ───────────────────────────────────────────────────────────── */
.pagination {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 6px;
  padding: 14px 16px;
  border-top: 1px solid var(--border);
}
.page-btn {
  width: 32px; height: 32px;
  border-radius: 6px;
  background: var(--bg3);
  border: 1px solid var(--border);
  color: var(--text-muted);
  font-size: 13px;
  cursor: pointer;
  display: grid; place-items: center;
  transition: all 0.2s;
}
.page-btn:hover, .page-btn.active {
  border-color: var(--purple);
  color: var(--purple);
  background: rgba(124,111,255,0.1);
}

/* ─── Activity Full ────────────────────────────────────────────────────────── */
.activity-full {
  padding: 8px;
  max-height: 600px;
  overflow-y: auto;
}

/* ─── Owner Log ────────────────────────────────────────────────────────────── */
.owner-log {
  padding: 16px 20px;
  display: flex;
  flex-direction: column;
  gap: 12px;
  max-height: 600px;
  overflow-y: auto;
}
.log-item {
  background: var(--bg3);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 12px 16px;
}
.log-direction {
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  margin-bottom: 6px;
}
.log-direction.out { color: var(--purple); }
.log-direction.in  { color: var(--green); }
.log-message { font-size: 13px; color: var(--text); line-height: 1.5; }
.log-time { font-size: 11px; color: var(--text-muted); margin-top: 6px; }

/* ─── Modal ────────────────────────────────────────────────────────────────── */
.modal-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.7);
  backdrop-filter: blur(4px);
  z-index: 100;
  align-items: center;
  justify-content: center;
}
.modal-overlay.open { display: flex; }

.modal {
  background: var(--bg2);
  border: 1px solid var(--border2);
  border-radius: 16px;
  width: 90%;
  max-width: 700px;
  max-height: 85vh;
  overflow-y: auto;
  animation: modal-in 0.25s cubic-bezier(0.4,0,0.2,1);
}
@keyframes modal-in {
  from { opacity: 0; transform: scale(0.95) translateY(10px); }
  to   { opacity: 1; transform: scale(1) translateY(0); }
}
.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 20px 24px;
  border-bottom: 1px solid var(--border);
}
.modal-title { font-size: 17px; font-weight: 700; }
.modal-close {
  width: 30px; height: 30px;
  border-radius: 6px;
  background: var(--bg3);
  border: 1px solid var(--border);
  color: var(--text-muted);
  cursor: pointer;
  font-size: 14px;
  display: grid; place-items: center;
  transition: all 0.2s;
}
.modal-close:hover { border-color: var(--red); color: var(--red); }

.modal-body { padding: 24px; }

.modal-section { margin-bottom: 24px; }
.modal-section-title {
  font-size: 12px;
  font-weight: 600;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.07em;
  margin-bottom: 12px;
}

.info-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
}
.info-item label { font-size: 11px; color: var(--text-muted); display: block; margin-bottom: 3px; }
.info-item value, .info-item span { font-size: 14px; color: var(--text); font-weight: 500; }

.timeline {
  display: flex;
  flex-direction: column;
  gap: 0;
}
.timeline-item {
  display: flex;
  gap: 12px;
  padding: 8px 0;
  position: relative;
}
.timeline-item:not(:last-child)::after {
  content: '';
  position: absolute;
  left: 7px;
  top: 24px;
  bottom: -8px;
  width: 2px;
  background: var(--border);
}
.t-dot {
  width: 16px; height: 16px;
  border-radius: 50%;
  background: var(--bg3);
  border: 2px solid var(--border2);
  flex-shrink: 0;
  margin-top: 3px;
  z-index: 1;
}
.t-content .t-label { font-size: 13px; color: var(--text); }
.t-content .t-time  { font-size: 11px; color: var(--text-muted); margin-top: 2px; }

/* ─── Toast ────────────────────────────────────────────────────────────────── */
.toast {
  position: fixed;
  bottom: 28px; right: 28px;
  background: var(--bg3);
  border: 1px solid var(--border2);
  border-radius: 10px;
  padding: 14px 20px;
  font-size: 13px;
  color: var(--text);
  z-index: 200;
  opacity: 0;
  transform: translateY(10px);
  transition: all 0.3s;
  pointer-events: none;
  max-width: 320px;
}
.toast.show {
  opacity: 1;
  transform: translateY(0);
}

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

/* ─── Loading Spinner ──────────────────────────────────────────────────────── */
.spinner {
  display: inline-block;
  width: 12px;
  height: 12px;
  border: 2px solid rgba(255,255,255,0.3);
  border-radius: 50%;
  border-top-color: #fff;
  animation: spin-sm 0.8s linear infinite;
  margin-right: 6px;
  vertical-align: middle;
}
@keyframes spin-sm {
  to { transform: rotate(360deg); }
}

.btn:disabled {
  opacity: 0.6;
  cursor: not-allowed;
  pointer-events: none;
}
