/* ============================================
   AJ-BOT CRM — Premium Dark Navy Theme
   ============================================ */

@import url('https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600;700;800&display=swap');

/* ---- CSS Variables ---- */
:root {
  /* Core Colors */
  --navy-900: #0B0F1A;
  --navy-800: #111827;
  --navy-700: #1C2333;
  --navy-600: #243047;
  --navy-500: #2D3B55;

  /* Accent */
  --blue-500:  #3B82F6;
  --blue-400:  #60A5FA;
  --blue-glow: rgba(59, 130, 246, 0.25);

  --cyan-500:  #06B6D4;
  --cyan-glow: rgba(6, 182, 212, 0.2);

  /* Semantic */
  --success:  #10B981;
  --danger:   #F43F5E;
  --warning:  #F59E0B;
  --purple:   #8B5CF6;

  /* Text */
  --text-100: #F1F5F9;
  --text-300: #94A3B8;
  --text-500: #475569;

  /* Surfaces */
  --surface-1: #111827;   /* main bg */
  --surface-2: #1C2333;   /* card bg */
  --surface-3: #243047;   /* input bg */
  --surface-4: #2D3B55;   /* hover bg */

  /* Borders */
  --border:      rgba(255,255,255,0.07);
  --border-blue: rgba(59,130,246,0.35);

  /* Sidebar */
  --sidebar-bg: #0D1220;
  --sidebar-w:  240px;

  /* Header */
  --header-h: 66px;
}

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

body {
  font-family: 'Inter', system-ui, sans-serif;
  background: var(--surface-1);
  color: var(--text-100);
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  -webkit-font-smoothing: antialiased;
}

/* ---- Scrollbars ---- */
::-webkit-scrollbar { width: 5px; height: 5px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--navy-500); border-radius: 99px; }
::-webkit-scrollbar-thumb:hover { background: var(--blue-500); }

/* ===========================
   TOP HEADER
   =========================== */
.top-header {
  position: sticky;
  top: 0;
  z-index: 200;
  height: var(--header-h);
  background: var(--navy-900);
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 28px 0 20px;
  gap: 16px;
  box-shadow: 0 1px 0 var(--border), 0 4px 24px rgba(0,0,0,0.4);
}

.top-header .logo-area {
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 18px;
  font-weight: 800;
  letter-spacing: -0.03em;
  color: var(--text-100);
  white-space: nowrap;
}

.top-header .logo-area .dot {
  color: var(--cyan-500);
  text-shadow: 0 0 12px var(--cyan-500);
}

.top-header .page-info { display: flex; flex-direction: column; gap: 1px; }
.top-header .page-info h1 {
  font-size: 15px;
  font-weight: 700;
  color: var(--text-100);
  line-height: 1.2;
}
.top-header .page-info p {
  font-size: 11.5px;
  color: var(--text-300);
  line-height: 1.2;
}

.top-header .divider {
  width: 1px;
  height: 28px;
  background: var(--border);
}

.top-header .right {
  display: flex;
  align-items: center;
  gap: 18px;
}

/* AI toggle label */
.ai-toggle-wrap {
  display: flex;
  align-items: center;
  gap: 9px;
  background: var(--surface-3);
  border: 1px solid var(--border);
  border-radius: 999px;
  padding: 7px 14px 7px 12px;
  transition: border-color 0.2s;
}
.ai-toggle-wrap:hover { border-color: var(--border-blue); }
.ai-toggle-wrap .ai-label {
  font-size: 11.5px;
  font-weight: 700;
  color: var(--text-300);
  text-transform: uppercase;
  letter-spacing: 0.06em;
  user-select: none;
}

/* Switch */
.switch { position: relative; display: inline-block; width: 36px; height: 18px; }
.switch input { opacity: 0; width: 0; height: 0; }
.slider {
  position: absolute; inset: 0;
  background: var(--navy-600);
  border: 1px solid var(--border);
  border-radius: 999px;
  cursor: pointer;
  transition: .3s;
}
.slider::before {
  content: '';
  position: absolute;
  width: 10px; height: 10px;
  left: 3px; top: 3px;
  background: var(--text-500);
  border-radius: 50%;
  transition: .3s;
}
.switch input:checked + .slider { background: rgba(16,185,129,0.18); border-color: rgba(16,185,129,0.5); }
.switch input:checked + .slider::before {
  transform: translateX(18px);
  background: var(--success);
  box-shadow: 0 0 8px var(--success);
}

/* User Badge */
.user-badge {
  display: flex;
  align-items: center;
  gap: 8px;
  background: var(--surface-3);
  border: 1px solid var(--border);
  border-radius: 999px;
  padding: 6px 14px 6px 10px;
  font-size: 12.5px;
  font-weight: 600;
  color: var(--text-100);
  transition: border-color 0.2s;
}
.user-badge:hover { border-color: var(--border-blue); }
.user-badge .avatar {
  width: 24px; height: 24px;
  background: linear-gradient(135deg, var(--blue-500), var(--cyan-500));
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 11px;
  font-weight: 800;
  color: white;
  flex-shrink: 0;
}

/* ===========================
   LAYOUT SHELL
   =========================== */
.container {
  display: flex;
  height: calc(100vh - var(--header-h));
  overflow-x: hidden;
  overflow-y: auto;
  position: relative;
}

/* ===========================
   SIDEBAR — Floating Capsule
   =========================== */
.nav-tabs {
  position: fixed;
  left: 16px;
  top: calc(var(--header-h) + 16px);
  bottom: 16px;
  height: calc(100vh - var(--header-h) - 32px);
  width: 60px;
  background: #1E2D40;
  border: 1px solid rgba(255,255,255,0.08);
  border-radius: 30px;
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 10px 8px;
  gap: 2px;
  z-index: 500;
  overflow: hidden;
  transition: width 0.3s cubic-bezier(0.4,0,0.2,1);
  box-shadow: 0 8px 32px rgba(0,0,0,0.35);
}

.nav-tabs:hover {
  width: 224px;
  align-items: flex-start;
  box-shadow: 0 12px 40px rgba(0,0,0,0.5);
}

.nav-tabs::-webkit-scrollbar { display: none; }
.nav-tabs { scrollbar-width: none; }

/* No section labels */
.nav-section-label { display: none; }

.nav-tabs .tab-link {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0;
  padding: 7px;
  border-radius: 12px;
  color: rgba(255,255,255,0.72);
  background: transparent;
  border: none;
  cursor: pointer;
  font-size: 13px;
  font-weight: 500;
  font-family: inherit;
  text-align: left;
  width: 42px;
  min-height: 34px;
  white-space: nowrap;
  overflow: hidden;
  transition: background 0.18s, color 0.18s, width 0.3s;
  position: relative;
  flex-shrink: 0;
}

.nav-tabs:hover .tab-link {
  width: 202px;
  min-height: 34px;
  padding: 8px 12px;
  justify-content: flex-start;
  gap: 12px;
}

.nav-tabs .tab-icon {
  width: 24px;
  height: 20px;
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  color: currentColor;
}

.nav-tabs .tab-icon svg {
  width: 17px;
  height: 17px;
  display: block;
  fill: none;
  stroke: currentColor;
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.nav-tabs .tab-label {
  width: 0;
  opacity: 0;
  visibility: hidden;
  transition: opacity 0.2s 0.1s;
  font-size: 13px;
  white-space: nowrap;
}

.nav-tabs:hover .tab-label {
  width: auto;
  opacity: 1;
  visibility: visible;
}

.nav-tabs .tab-link:hover {
  background: rgba(255,255,255,0.07);
  color: rgba(255,255,255,0.85);
}

.nav-tabs .tab-link.active {
  background: rgba(59,130,246,0.2);
  color: #93C5FD;
  font-weight: 600;
}

/* Active dot on left */
.nav-tabs .tab-link.active::before {
  content: '';
  position: absolute;
  left: 4px;
  top: 50%;
  transform: translateY(-50%);
  width: 5px;
  height: 5px;
  background: #60A5FA;
  border-radius: 50%;
  box-shadow: 0 0 6px #3B82F6;
}

.tab-link.logout-btn {
  margin-top: 6px;
  border-top: 1px solid rgba(255,255,255,0.07);
  color: rgba(251,113,133,0.6);
}
.tab-link.logout-btn:hover {
  background: rgba(244,63,94,0.1);
  color: #F87171;
}

/* ===========================
   MAIN CONTENT
   =========================== */
.main-content {
  flex: 1;
  overflow-y: auto;
  padding: 28px 32px;
  padding-left: 100px; /* space for floating sidebar */
  background: var(--surface-1);
  height: 100%;
}

/* ===========================
   STAT CARDS
   =========================== */
.stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 20px;
  margin-bottom: 28px;
}

.stat-card {
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: 16px;
  padding: 22px 24px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  transition: transform 0.2s, border-color 0.2s, box-shadow 0.2s;
  position: relative;
  overflow: hidden;
}
.stat-card::after {
  content: '';
  position: absolute;
  inset: 0;
  border-radius: 16px;
  opacity: 0;
  transition: opacity 0.2s;
}
.stat-card:hover {
  transform: translateY(-3px);
  border-color: var(--border-blue);
  box-shadow: 0 8px 30px rgba(0,0,0,0.25), 0 0 0 1px var(--border-blue);
}

.stat-card h3 {
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.09em;
  color: var(--text-300);
}
.stat-card .value {
  font-size: 30px;
  font-weight: 800;
  color: var(--text-100);
  letter-spacing: -0.02em;
  line-height: 1;
}
.stat-card .stat-icon {
  position: absolute;
  top: 18px;
  right: 18px;
  width: 38px;
  height: 38px;
  border-radius: 10px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 18px;
}

/* Stat card accent strips (top border per card) */
.stats-grid > div:nth-child(1) { border-top: 2px solid var(--blue-500); }
.stats-grid > div:nth-child(1) .stat-icon { background: rgba(59,130,246,0.12); }
.stats-grid > div:nth-child(2) { border-top: 2px solid var(--cyan-500); }
.stats-grid > div:nth-child(2) .stat-icon { background: rgba(6,182,212,0.12); }
.stats-grid > div:nth-child(3) { border-top: 2px solid var(--purple); }
.stats-grid > div:nth-child(3) .stat-icon { background: rgba(139,92,246,0.12); }
.stats-grid > div:nth-child(4) { border-top: 2px solid var(--success); }
.stats-grid > div:nth-child(4) .stat-icon { background: rgba(16,185,129,0.12); }

/* ===========================
   PANELS
   =========================== */
.content-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 22px;
}
@media (max-width: 1024px) { .content-grid { grid-template-columns: 1fr; } }

.panel {
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: 18px;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  transition: border-color 0.2s;
}
.panel:hover { border-color: rgba(59,130,246,0.18); }

.panel-header {
  padding: 17px 22px;
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  background: var(--surface-2);
}
.panel-title {
  font-size: 14px;
  font-weight: 700;
  color: var(--text-100);
  display: flex;
  align-items: center;
  gap: 8px;
}
.panel-content { padding: 20px 22px; flex: 1; overflow-y: auto; }

/* ===========================
   FORMS
   =========================== */
.form-group { margin-bottom: 16px; }
.form-group label {
  display: block;
  font-size: 12px;
  font-weight: 600;
  color: var(--text-300);
  margin-bottom: 7px;
  letter-spacing: 0.02em;
}
.form-group input:not([type="checkbox"]):not([type="radio"]),
.form-group select,
.form-group textarea {
  width: 100%;
  background: var(--surface-3);
  border: 1px solid var(--border);
  color: var(--text-100);
  padding: 10px 14px;
  border-radius: 10px;
  font-size: 13.5px;
  font-family: inherit;
  outline: none;
  transition: border-color 0.2s, box-shadow 0.2s;
  appearance: none;
}
.form-group input:not([type="checkbox"]):not([type="radio"])::placeholder,
.form-group textarea::placeholder { color: var(--text-500); }
.form-group input:not([type="checkbox"]):not([type="radio"]):focus,
.form-group select:focus,
.form-group textarea:focus {
  border-color: var(--blue-500);
  box-shadow: 0 0 0 3px var(--blue-glow);
}

/* ===========================
   CAPABILITY TOGGLE ROWS
   =========================== */
.cap-toggle-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  background: var(--surface-3);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 11px 14px;
  transition: border-color 0.2s;
}
.cap-toggle-row:hover { border-color: rgba(59,130,246,0.25); }

.cap-toggle-label {
  font-size: 13px;
  color: var(--text-100);
  flex: 1;
  line-height: 1.4;
}

/* Custom pill toggle switch for capabilities */
.cap-switch {
  position: relative;
  display: inline-block;
  width: 44px;
  height: 24px;
  flex-shrink: 0;
  cursor: pointer;
}
.cap-switch input {
  opacity: 0;
  width: 0;
  height: 0;
  position: absolute;
}
.cap-slider {
  position: absolute;
  inset: 0;
  background: var(--surface-4);
  border: 1px solid rgba(255,255,255,0.1);
  border-radius: 999px;
  transition: background 0.3s, border-color 0.3s;
  cursor: pointer;
}
.cap-slider::before {
  content: '';
  position: absolute;
  width: 16px;
  height: 16px;
  left: 3px;
  top: 3px;
  background: var(--text-500);
  border-radius: 50%;
  transition: transform 0.3s, background 0.3s;
}
.cap-switch input:checked + .cap-slider {
  background: rgba(16,185,129,0.2);
  border-color: rgba(16,185,129,0.45);
}
.cap-switch input:checked + .cap-slider::before {
  transform: translateX(20px);
  background: var(--success);
  box-shadow: 0 0 8px rgba(16,185,129,0.5);
}

/* ===========================
   WEBHOOK LOG ROWS
   =========================== */
.webhook-log-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 9px 12px;
  border-radius: 8px;
  background: var(--surface-3);
  border: 1px solid var(--border);
  gap: 12px;
  transition: border-color 0.15s;
}
.webhook-log-row:hover { border-color: rgba(59,130,246,0.2); }

.webhook-dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--blue-500);
  flex-shrink: 0;
  box-shadow: 0 0 6px var(--blue-500);
}

.webhook-event-type {
  font-size: 12.5px;
  font-weight: 600;
  color: var(--text-100);
}

.webhook-source {
  font-size: 11.5px;
  color: var(--text-300);
}

.webhook-status {
  font-size: 11px;
  font-weight: 700;
  padding: 2px 8px;
  border-radius: 99px;
}
.webhook-status.ok {
  background: rgba(16,185,129,0.12);
  color: var(--success);
  border: 1px solid rgba(16,185,129,0.2);
}
.webhook-status.neutral {
  background: rgba(148,163,184,0.1);
  color: var(--text-300);
  border: 1px solid var(--border);
}

.webhook-time {
  font-size: 10.5px;
  color: var(--text-500);
  white-space: nowrap;
}

/* ===========================
   BUTTONS
   =========================== */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  padding: 10px 20px;
  border-radius: 10px;
  font-size: 13.5px;
  font-weight: 600;
  font-family: inherit;
  cursor: pointer;
  border: 1px solid transparent;
  transition: all 0.18s ease;
}
.btn-primary {
  background: var(--blue-500);
  color: #fff;
  border-color: var(--blue-500);
  box-shadow: 0 4px 14px rgba(59,130,246,0.3);
}
.btn-primary:hover {
  background: var(--blue-400);
  box-shadow: 0 6px 20px rgba(59,130,246,0.45);
  transform: translateY(-1px);
}
.btn-secondary {
  background: var(--surface-3);
  color: var(--text-100);
  border-color: var(--border);
}
.btn-secondary:hover { background: var(--surface-4); border-color: var(--border-blue); }
.btn-danger { background: var(--danger); color: #fff; border-color: var(--danger); }
.btn-danger:hover { opacity: 0.85; }
.btn-success { background: var(--success); color: #fff; border-color: var(--success); }
.btn-success:hover { opacity: 0.85; }
.btn-outline {
  background: transparent;
  border-color: var(--blue-500);
  color: var(--blue-400);
}
.btn-outline:hover { background: rgba(59,130,246,0.08); }
.btn-sm { padding: 6px 14px; font-size: 12px; border-radius: 8px; }

/* ===========================
   TABLES
   =========================== */
.table-container {
  border-radius: 14px;
  border: 1px solid var(--border);
  overflow: hidden;
  background: var(--surface-2);
}
table { width: 100%; border-collapse: collapse; text-align: left; }
th {
  background: var(--surface-3);
  color: var(--text-300);
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  padding: 13px 18px;
  border-bottom: 1px solid var(--border);
}
td {
  padding: 13px 18px;
  font-size: 13.5px;
  color: var(--text-100);
  border-bottom: 1px solid var(--border);
}
tr:last-child td { border-bottom: none; }
tbody tr:hover td { background: var(--surface-3); }

/* ===========================
   STATUS BADGES
   =========================== */
.status-badge {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 3px 10px;
  border-radius: 999px;
  font-size: 11.5px;
  font-weight: 600;
}
.status-badge.pending    { background: rgba(245,158,11,0.12);  color: var(--warning); border: 1px solid rgba(245,158,11,0.2); }
.status-badge.completed,
.status-badge.delivered  { background: rgba(16,185,129,0.12);  color: var(--success); border: 1px solid rgba(16,185,129,0.2); }
.status-badge.cancelled  { background: rgba(244,63,94,0.1);    color: var(--danger);  border: 1px solid rgba(244,63,94,0.2);  }

/* ===========================
   INNER TABS
   =========================== */
.inner-tabs {
  display: flex;
  gap: 4px;
  border-bottom: 1px solid var(--border);
  margin-bottom: 20px;
  padding-bottom: 0;
}
.inner-tab-btn {
  padding: 9px 16px;
  background: none;
  border: none;
  border-bottom: 2px solid transparent;
  color: var(--text-300);
  font-size: 13px;
  font-weight: 600;
  font-family: inherit;
  cursor: pointer;
  transition: all 0.2s;
  margin-bottom: -1px;
  border-radius: 6px 6px 0 0;
}
.inner-tab-btn:hover { color: var(--text-100); background: var(--surface-3); }
.inner-tab-btn.active { color: var(--blue-400); border-bottom-color: var(--blue-500); background: transparent; }

/* ===========================
   LIST ITEMS
   =========================== */
.list-item {
  background: var(--surface-3);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 14px 16px;
  margin-bottom: 10px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  transition: all 0.18s;
}
.list-item:hover { border-color: var(--border-blue); background: var(--surface-4); transform: translateX(2px); }
.list-item-info h4 { font-size: 13.5px; font-weight: 600; color: var(--text-100); margin-bottom: 3px; }
.list-item-info p  { font-size: 12px; color: var(--text-300); }
.list-item-actions { display: flex; gap: 8px; }

/* ===========================
   MODAL
   =========================== */
.modal {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.65);
  backdrop-filter: blur(10px);
  z-index: 1000;
  align-items: center;
  justify-content: center;
  padding: 20px;
}
.modal.active { display: flex; }
.modal-content {
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: 22px;
  padding: 30px;
  max-width: 500px;
  width: 100%;
  box-shadow: 0 25px 60px rgba(0,0,0,0.5), 0 0 0 1px var(--border);
  animation: modalSlide 0.25s cubic-bezier(0.34,1.56,0.64,1);
}
.modal-header {
  font-size: 17px;
  font-weight: 700;
  color: var(--text-100);
  margin-bottom: 20px;
  display: flex;
  justify-content: space-between;
  align-items: center;
}
.modal-close { background: none; border: none; color: var(--text-300); font-size: 20px; cursor: pointer; }
.modal-close:hover { color: var(--danger); }
.modal-footer { display: flex; justify-content: flex-end; gap: 10px; margin-top: 24px; }

/* ===========================
   AUTH PAGE
   =========================== */
#auth-container {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 100vh;
  background: var(--navy-900);
  background-image: radial-gradient(at 30% 20%, rgba(59,130,246,0.06), transparent 50%),
                    radial-gradient(at 80% 80%, rgba(6,182,212,0.04), transparent 50%);
}
.auth-card {
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: 22px;
  padding: 40px;
  width: 100%;
  max-width: 420px;
  box-shadow: 0 25px 60px rgba(0,0,0,0.4);
  animation: fadeIn 0.3s ease;
}
.auth-logo {
  text-align: center;
  font-size: 28px;
  font-weight: 800;
  color: var(--text-100);
  margin-bottom: 6px;
  letter-spacing: -0.03em;
}
.auth-logo span { color: var(--cyan-500); text-shadow: 0 0 14px var(--cyan-500); }
.auth-subtitle { text-align: center; color: var(--text-300); font-size: 13.5px; margin-bottom: 28px; }
.auth-tabs { display: flex; border-bottom: 1px solid var(--border); margin-bottom: 24px; }
.auth-tab-btn {
  flex: 1;
  padding: 11px;
  background: none;
  border: none;
  border-bottom: 2px solid transparent;
  color: var(--text-300);
  font-size: 13.5px;
  font-weight: 600;
  font-family: inherit;
  cursor: pointer;
  transition: all 0.2s;
  margin-bottom: -1px;
}
.auth-tab-btn.active { color: var(--blue-400); border-bottom-color: var(--blue-500); }

/* ===========================
   CHAT MONITOR
   =========================== */
.chat-shell {
  display: grid;
  grid-template-columns: 300px 1fr 320px;
  height: 680px;
  border: 1px solid var(--border);
  border-radius: 18px;
  overflow: hidden;
  background: var(--surface-2);
}

.chat-list-panel {
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  height: 100%;
  overflow: hidden;
}
.chat-panel-header {
  padding: 15px 18px;
  border-bottom: 1px solid var(--border);
  font-weight: 700;
  font-size: 14px;
  color: var(--text-100);
  display: flex;
  justify-content: space-between;
  align-items: center;
  background: var(--surface-3);
}
.chat-search-box { padding: 10px 14px; border-bottom: 1px solid var(--border); }
.chat-search-box input {
  width: 100%;
  background: var(--surface-1);
  border: 1px solid var(--border);
  border-radius: 9px;
  padding: 8px 12px;
  color: var(--text-100);
  font-size: 12.5px;
  outline: none;
  font-family: inherit;
  transition: border-color 0.2s;
}
.chat-search-box input:focus { border-color: var(--blue-500); }
.chat-list-items { flex: 1; overflow-y: auto; }

.chat-item {
  padding: 13px 18px;
  border-bottom: 1px solid var(--border);
  cursor: pointer;
  border-left: 3px solid transparent;
  transition: all 0.15s;
}
.chat-item:hover { background: var(--surface-3); }
.chat-item.active { background: var(--surface-4); border-left-color: var(--blue-500); }
.chat-item-header { display: flex; justify-content: space-between; margin-bottom: 4px; }
.chat-item-phone { font-weight: 700; font-size: 13.5px; color: var(--text-100); }
.chat-item-name { font-size: 11.5px; color: var(--text-300); }
.chat-item-time { font-size: 10.5px; color: var(--text-500); }
.chat-item-preview { font-size: 12px; color: var(--text-300); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

.chat-messages-panel { display: flex; flex-direction: column; height: 100%; overflow: hidden; }
.chat-header { padding: 15px 22px; border-bottom: 1px solid var(--border); display: flex; align-items: center; justify-content: space-between; background: var(--surface-3); }
.chat-header-info h4 { font-weight: 700; font-size: 14px; color: var(--text-100); }
.chat-header-info p { font-size: 11.5px; color: var(--text-300); margin-top: 2px; }

.chat-messages { flex: 1; overflow-y: auto; padding: 20px; display: flex; flex-direction: column; gap: 14px; background: var(--surface-1); }

.message { max-width: 72%; display: flex; flex-direction: column; gap: 4px; }
.message.received { align-self: flex-start; }
.message.sent { align-self: flex-end; }
.message-bubble { padding: 11px 15px; border-radius: 14px; font-size: 13.5px; line-height: 1.5; word-wrap: break-word; white-space: pre-wrap; }
.message.received .message-bubble { background: var(--surface-3); color: var(--text-100); border: 1px solid var(--border); border-top-left-radius: 4px; }
.message.sent .message-bubble { background: linear-gradient(135deg, var(--blue-500), var(--cyan-500)); color: #fff; border-top-right-radius: 4px; box-shadow: 0 4px 14px rgba(59,130,246,0.25); }
.message-time { font-size: 10px; color: var(--text-500); padding: 0 4px; }
.message.sent .message-time { text-align: right; }

.chat-footer { padding: 14px 20px; border-top: 1px solid var(--border); background: var(--surface-2); }
.chat-composer { display: flex; gap: 10px; align-items: flex-end; }
.chat-composer textarea {
  flex: 1;
  background: var(--surface-3);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 10px 14px;
  color: var(--text-100);
  font-family: inherit;
  resize: none;
  height: 42px;
  max-height: 110px;
  outline: none;
  font-size: 13.5px;
  transition: border-color 0.2s;
}
.chat-composer textarea:focus { border-color: var(--blue-500); }

.chat-profile-panel { border-left: 1px solid var(--border); display: flex; flex-direction: column; height: 100%; overflow-y: auto; }
.profile-header { padding: 15px 18px; border-bottom: 1px solid var(--border); font-weight: 700; font-size: 14px; color: var(--text-100); background: var(--surface-3); }
.profile-body { padding: 18px; flex: 1; }
.crm-section { border-bottom: 1px solid var(--border); padding-bottom: 14px; margin-bottom: 14px; }
.crm-section:last-child { border-bottom: none; margin-bottom: 0; padding-bottom: 0; }
.crm-section-title { font-size: 10.5px; font-weight: 700; color: var(--text-500); text-transform: uppercase; letter-spacing: 0.09em; margin-bottom: 10px; }
.crm-tags-list { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 7px; }
.crm-tag-pill { background: var(--surface-4); border: 1px solid var(--border); color: var(--text-100); padding: 3px 10px; border-radius: 99px; font-size: 11px; font-weight: 600; display: flex; align-items: center; gap: 5px; }

/* ===========================
   TEMPLATE BUILDER
   =========================== */
.template-builder-container { display: grid; grid-template-columns: 1fr 280px; gap: 24px; align-items: start; }
@media (max-width: 900px) { .template-builder-container { grid-template-columns: 1fr; } }
.phone-frame {
  width: 100%;
  max-width: 260px;
  height: 460px;
  border: 9px solid #1a1a1a;
  border-radius: 34px;
  background: #ece5dd;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  margin: 0 auto;
  box-shadow: 0 15px 40px rgba(0,0,0,0.4);
}

/* ===========================
   TOAST
   =========================== */
#toast-container { position: fixed; top: 22px; right: 22px; z-index: 9999; display: flex; flex-direction: column; gap: 8px; }
.toast {
  background: var(--surface-2);
  color: var(--text-100);
  border: 1px solid var(--border);
  box-shadow: 0 12px 30px rgba(0,0,0,0.4);
  padding: 14px 18px;
  border-radius: 14px;
  font-size: 13px;
  font-weight: 600;
  min-width: 280px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  animation: toastSlide 0.25s ease;
}
.toast.success { border-color: rgba(16,185,129,0.35); }
.toast.error   { border-color: rgba(244,63,94,0.35); }

/* ===========================
   LOADING SPINNER
   =========================== */
.loading-spinner {
  width: 22px; height: 22px;
  border: 3px solid rgba(255,255,255,0.1);
  border-top-color: var(--blue-500);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}

/* ===========================
   ANIMATIONS
   =========================== */
@keyframes spin { to { transform: rotate(360deg); } }
@keyframes fadeIn {
  from { opacity: 0; transform: translateY(6px); }
  to   { opacity: 1; transform: translateY(0); }
}
@keyframes modalSlide {
  from { opacity: 0; transform: translateY(16px) scale(0.97); }
  to   { opacity: 1; transform: translateY(0) scale(1); }
}
@keyframes toastSlide {
  from { opacity: 0; transform: translateX(14px); }
  to   { opacity: 1; transform: translateX(0); }
}

.page-content { display: none; animation: fadeIn 0.25s ease; }
.page-content.active { display: block; }

/* ===========================
   RESPONSIVE
   =========================== */
@media (max-width: 900px) {
  .stats-grid { grid-template-columns: 1fr 1fr; }
  .content-grid { grid-template-columns: 1fr; }
  .chat-shell { grid-template-columns: 1fr; height: auto; }
}

@media (max-width: 640px) {
  .nav-tabs { width: 60px; }
  .nav-tabs .tab-label { display: none; }
  .nav-tabs:hover .tab-label { display: inline; }
  .nav-tabs .tab-link { justify-content: center; padding: 10px; gap: 0; }
  .nav-tabs:hover .tab-link { justify-content: flex-start; padding: 11px 14px; gap: 12px; }
  .nav-section-label { display: none; }
  .main-content { padding: 18px 16px; }
  .stats-grid { grid-template-columns: 1fr; }
  .top-header { padding: 0 16px; }
  .top-header .page-info p { display: none; }
}

/* ===========================
   CHAT MONITOR — MESSAGE BUBBLES
   =========================== */
#chatMessagesStream {
  display: flex;
  flex-direction: column;
  gap: 6px;
  padding: 18px 16px;
  overflow-y: auto;
}

/* Base message row */
.message {
  display: flex;
  flex-direction: column;
  max-width: 72%;
  gap: 3px;
}

/* Customer messages → LEFT */
.message.user {
  align-self: flex-start;
  align-items: flex-start;
}

/* Assistant / Agent messages → RIGHT */
.message.assistant {
  align-self: flex-end;
  align-items: flex-end;
}

/* Bubble */
.message-bubble {
  padding: 10px 14px;
  border-radius: 18px;
  font-size: 13.5px;
  line-height: 1.55;
  word-break: break-word;
  position: relative;
  max-width: 100%;
}

/* Customer bubble — dark, left tail */
.message.user .message-bubble {
  background: var(--surface-3);
  border: 1px solid var(--border);
  color: var(--text-100);
  border-top-left-radius: 4px;
}

/* Assistant/Agent bubble — blue, right tail */
.message.assistant .message-bubble {
  background: linear-gradient(135deg, #2563EB, #1D4ED8);
  color: #fff;
  border: none;
  border-top-right-radius: 4px;
  box-shadow: 0 2px 12px rgba(37,99,235,0.3);
}

/* Timestamp */
.message-time {
  font-size: 10.5px;
  color: var(--text-500);
  padding: 0 4px;
}

.message.assistant .message-time {
  color: rgba(255,255,255,0.4);
}

/* ===========================
   SHARED COMPACT NAVIGATION RAIL
   =========================== */
.nav-tabs {
  left: 16px;
  top: calc(var(--header-h) + 16px);
  bottom: 16px;
  width: 64px;
  height: calc(100vh - var(--header-h) - 32px);
  padding: 12px 9px;
  gap: 5px;
  align-items: center;
  background: #081829;
  border: 1px solid #334155;
  border-radius: 18px;
  box-shadow: 0 16px 42px rgba(0,0,0,.34);
  overflow: hidden;
}
.nav-tabs:hover {
  width: 224px;
  align-items: flex-start;
  box-shadow: 0 18px 48px rgba(0,0,0,.45);
}
.nav-tabs .tab-link {
  width: 44px;
  min-height: 44px;
  padding: 0;
  justify-content: center;
  border-radius: 9px;
  gap: 0;
}
.nav-tabs:hover .tab-link {
  width: 202px;
  min-height: 44px;
  padding: 0 13px;
  justify-content: flex-start;
  gap: 12px;
}
.nav-tabs .tab-icon {
  width: 28px;
  height: 28px;
}
.nav-tabs .tab-icon svg {
  width: 22px;
  height: 22px;
}
.nav-tabs .tab-label {
  display: block;
  width: 0;
  opacity: 0;
  visibility: hidden;
}
.nav-tabs:hover .tab-label {
  display: block;
  width: auto;
  opacity: 1;
  visibility: visible;
}
.nav-tabs .tab-link.active {
  background: #0d2137;
  color: #b7c6ff;
  box-shadow: inset 2px 0 0 #b7c6ff;
}
.nav-tabs .tab-link.active::before { display: none; }
.nav-tabs .tab-link:hover {
  background: #0b1d30;
  color: #e2e8f0;
}
.tab-link.logout-btn { margin-top: auto; }
.main-content { padding-left: 100px; }
@media (max-width: 700px) {
  .nav-tabs,
  .nav-tabs:hover { left: 8px; width: 56px; padding: 10px 6px; }
  .nav-tabs .tab-link,
  .nav-tabs:hover .tab-link { width: 42px; min-height: 42px; padding: 0; justify-content: center; }
  .nav-tabs:hover .tab-label { display: none; }
  .main-content { padding-left: 76px; }
}

/* ===========================
   GLOBAL OMNICHAT-STYLE DESIGN SYSTEM
   =========================== */
:root {
  --navy-900: #051322;
  --navy-800: #071829;
  --navy-700: #0b1b2c;
  --navy-600: #0d2034;
  --navy-500: #172b43;
  --blue-500: #668df5;
  --blue-400: #8aa7fb;
  --blue-glow: rgba(102,141,245,.2);
  --surface-1: #061525;
  --surface-2: #0b1b2c;
  --surface-3: #0d2034;
  --surface-4: #142941;
  --text-100: #e2e8f0;
  --text-300: #9aa9bd;
  --text-500: #64748b;
  --border: #2d4056;
  --border-blue: #5677b6;
}
body { background: var(--surface-1); }
.top-header {
  background: #061525;
  border-bottom-color: #334155;
  box-shadow: none;
}
.top-header .logo-area { letter-spacing: .02em; }
.top-header .page-info h1 { font-size: 17px; }
.top-header .page-info p {
  color: #8d9bb0;
  letter-spacing: .08em;
  text-transform: uppercase;
  font-size: 9.5px;
}
.main-content { background: var(--surface-1); }
.panel,
.stat-card,
.campaign-report-card,
.template-card,
.settings-card {
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: 10px;
  box-shadow: none;
}
.panel:hover,
.stat-card:hover { border-color: #415873; }
.panel-header {
  min-height: 64px;
  padding: 16px 22px;
  background: transparent;
  border-bottom-color: var(--border);
}
.panel-title {
  color: var(--text-100);
  font-size: 15px;
  letter-spacing: .01em;
}
.panel-content { padding: 24px; }
.form-group { margin-bottom: 18px; }
.form-group label {
  color: #a9b5c7;
  font-size: 10.5px;
  font-weight: 700;
  letter-spacing: .09em;
  text-transform: uppercase;
  margin-bottom: 8px;
}
input:not([type="checkbox"]):not([type="radio"]):not([type="range"]):not([type="hidden"]):not([type="file"]),
select,
textarea {
  min-height: 44px;
  padding: 10px 13px;
  background-color: var(--surface-3);
  color: var(--text-100);
  border: 1px solid #344b65;
  border-radius: 6px;
  outline: none;
  font: inherit;
  font-size: 13px;
  transition: border-color .16s, box-shadow .16s, background-color .16s;
}
.form-group input:not([type="checkbox"]):not([type="radio"]):not([type="file"]),
.form-group select,
.form-group textarea {
  min-height: 44px;
  padding: 10px 13px;
  background: var(--surface-3);
  color: var(--text-100);
  border: 1px solid #344b65;
  border-radius: 6px;
  font-size: 13px;
}
input:not([type="checkbox"]):not([type="radio"]):not([type="range"]):not([type="hidden"]):not([type="file"]):hover,
select:hover,
textarea:hover { border-color: #526983; }
input:not([type="checkbox"]):not([type="radio"]):not([type="range"]):not([type="hidden"]):not([type="file"]):focus,
select:focus,
textarea:focus {
  background-color: #10243a;
  border-color: var(--blue-500);
  box-shadow: 0 0 0 3px var(--blue-glow);
}
.form-group input:not([type="checkbox"]):not([type="radio"]):not([type="file"]):focus,
.form-group select:focus,
.form-group textarea:focus {
  background: #10243a;
  border-color: var(--blue-500);
  box-shadow: 0 0 0 3px var(--blue-glow);
}
input::placeholder,
textarea::placeholder { color: #5f6e82; opacity: 1; }
select {
  appearance: none;
  padding-right: 38px;
  background-image:
    linear-gradient(45deg,transparent 50%,#8998ad 50%),
    linear-gradient(135deg,#8998ad 50%,transparent 50%);
  background-position: calc(100% - 17px) 18px,calc(100% - 12px) 18px;
  background-size: 5px 5px,5px 5px;
  background-repeat: no-repeat;
}
select option { background: #0b1b2c; color: var(--text-100); }
input[type="file"] {
  color: var(--text-300);
  font-size: 12px;
}
input[type="file"]::file-selector-button {
  margin-right: 10px;
  padding: 8px 12px;
  color: #cbd7ff;
  background: #142941;
  border: 1px solid #48617f;
  border-radius: 6px;
  font-weight: 700;
  cursor: pointer;
}
.btn {
  min-height: 40px;
  padding: 9px 17px;
  border-radius: 7px;
  font-size: 12px;
  font-weight: 700;
  letter-spacing: .015em;
  box-shadow: none;
  transform: none;
}
.btn:hover { transform: none; }
.btn-primary {
  background: #668df5;
  border-color: #668df5;
  color: #07162b;
  box-shadow: 0 7px 18px rgba(65,100,190,.2);
}
.btn-primary:hover {
  background: #7b9cf7;
  border-color: #7b9cf7;
  box-shadow: 0 8px 22px rgba(65,100,190,.28);
}
.btn-secondary {
  background: #101f32;
  color: #d8e0ec;
  border-color: #40536b;
}
.btn-secondary:hover { background: #172b43; border-color: #60748f; }
.btn-danger {
  background: #ef4444;
  border-color: #ef4444;
  color: #fff;
}
.btn-danger:hover { background: #f05252; border-color: #f05252; opacity: 1; }
.btn-success { background: #10b981; border-color: #10b981; color: #041b16; }
.btn-outline { background: transparent; border-color: #668df5; color: #9bb1ff; }
.btn:disabled { opacity: .45; cursor: not-allowed; box-shadow: none; }
.list-item,
.cap-toggle-row,
.webhook-log-row {
  background: var(--surface-3);
  border-color: var(--border);
  border-radius: 8px;
}
.list-item:hover {
  background: var(--surface-4);
  border-color: #506681;
  transform: none;
}
.table-container {
  background: var(--surface-2);
  border-color: var(--border);
  border-radius: 9px;
}
th {
  background: #0d2034;
  color: #9eacc0;
  border-bottom-color: #35485e;
  font-size: 10px;
  letter-spacing: .1em;
}
td { border-bottom-color: #26394e; }
tbody tr:hover td { background: #0d2034; }
.inner-tabs {
  gap: 7px;
  padding: 5px;
  background: #081829;
  border: 1px solid var(--border);
  border-radius: 8px;
}
.inner-tab-btn {
  margin: 0;
  border: 1px solid transparent;
  border-radius: 6px;
  color: var(--text-300);
}
.inner-tab-btn:hover { background: #10243a; }
.inner-tab-btn.active {
  color: #dbe4ff;
  background: #172b48;
  border-color: #47638f;
}
.status-badge,
.campaign-status-pill {
  border-radius: 999px;
  font-size: 10px;
  letter-spacing: .04em;
}
.modal { background: rgba(1,9,18,.78); backdrop-filter: blur(7px); }
.modal-content {
  background: #0b1b2c;
  border-color: #3b4f67;
  border-radius: 11px;
  box-shadow: 0 28px 70px rgba(0,0,0,.55);
}
.modal-header {
  padding-bottom: 16px;
  border-bottom: 1px solid var(--border);
}
.modal-close {
  width: 34px;
  height: 34px;
  display: grid;
  place-items: center;
  border: 1px solid #40536b;
  border-radius: 7px;
  background: #101f32;
}
.modal-footer {
  padding-top: 18px;
  border-top: 1px solid var(--border);
}
@media (max-width: 700px) {
  .panel-content { padding: 18px; }
  .top-header .page-info h1 { font-size: 14px; }
  .btn { min-height: 38px; padding: 8px 13px; }
}
