/* =====================================================================
   🗿 MOAI FLOW — Dashboard CSS
   =====================================================================
   Dark premium theme matching MOAI Flow landing page aesthetics
   ===================================================================== */

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

:root {
  /* Core colors */
  --bg-primary: #0a0e1a;
  --bg-secondary: #0f1629;
  --bg-card: #131b2e;
  --bg-card-hover: #182240;
  --bg-input: #0d1220;
  --bg-sidebar: #0c1122;

  /* Borders */
  --border-primary: rgba(100, 116, 139, 0.15);
  --border-hover: rgba(6, 182, 212, 0.3);
  --border-focus: rgba(6, 182, 212, 0.5);

  /* Text */
  --text-primary: #f1f5f9;
  --text-secondary: #94a3b8;
  --text-muted: #64748b;

  /* Accent */
  --accent-cyan: #22d3ee;
  --accent-blue: #3b82f6;
  --accent-green: #4ade80;
  --accent-orange: #fb923c;
  --accent-red: #f87171;
  --accent-purple: #a78bfa;
  --accent-teal: #2dd4bf;
  --accent-yellow: #facc15;

  /* Gradients */
  --gradient-primary: linear-gradient(135deg, #06b6d4, #3b82f6);
  --gradient-card: linear-gradient(135deg, rgba(30, 41, 59, 0.5), rgba(15, 23, 42, 0.6));

  /* Shadows */
  --shadow-sm: 0 2px 8px rgba(0, 0, 0, 0.3);
  --shadow-md: 0 4px 16px rgba(0, 0, 0, 0.4);
  --shadow-lg: 0 8px 32px rgba(0, 0, 0, 0.5);
  --shadow-glow: 0 0 20px rgba(6, 182, 212, 0.15);

  /* Sizing */
  --sidebar-width: 260px;
  --sidebar-collapsed: 72px;
  --header-height: 64px;
  --radius-sm: 8px;
  --radius-md: 12px;
  --radius-lg: 16px;
  --radius-xl: 20px;

  /* Transitions */
  --transition: 0.25s cubic-bezier(0.4, 0, 0.2, 1);
}

html {
  font-size: 14px;
  scroll-behavior: smooth;
}

body {
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
  background: var(--bg-primary);
  color: var(--text-primary);
  line-height: 1.6;
  overflow-x: hidden;
  -webkit-font-smoothing: antialiased;
}

a { color: var(--accent-cyan); text-decoration: none; }
a:hover { color: #67e8f9; }

/* ---- Utilities ---- */
.text-gradient {
  background: var(--gradient-primary);
  -webkit-background-clip: text;
  background-clip: text;
  -webkit-text-fill-color: transparent;
}

/* ---- Screens ---- */
.screen { display: none; }
.screen.active { display: flex; }

/* ===================================================================
   LOGIN SCREEN
   =================================================================== */
.login-container {
  width: 100vw;
  height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  position: relative;
  background: var(--bg-primary);
}

.login-glow {
  position: absolute;
  width: 500px;
  height: 500px;
  background: radial-gradient(circle, rgba(6, 182, 212, 0.12) 0%, transparent 70%);
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  pointer-events: none;
}

.login-card {
  background: var(--gradient-card);
  backdrop-filter: blur(20px);
  border: 1px solid var(--border-primary);
  border-radius: var(--radius-xl);
  padding: 2.5rem;
  width: 100%;
  max-width: 420px;
  position: relative;
  z-index: 1;
  box-shadow: var(--shadow-lg);
}

.login-logo {
  text-align: center;
  margin-bottom: 2rem;
}

.logo-icon {
  font-size: 3rem;
  margin-bottom: 0.5rem;
}

.login-logo h1 {
  font-size: 1.8rem;
  font-weight: 800;
  letter-spacing: -0.02em;
}

.login-subtitle {
  color: var(--text-secondary);
  margin-top: 0.25rem;
  font-size: 0.9rem;
}

.login-form { display: flex; flex-direction: column; gap: 1rem; }

.form-group { display: flex; flex-direction: column; gap: 0.35rem; }

.form-group label {
  font-size: 0.85rem;
  font-weight: 500;
  color: var(--text-secondary);
}

.form-group input,
.form-group textarea,
.form-group select {
  background: var(--bg-input);
  border: 1px solid var(--border-primary);
  border-radius: var(--radius-sm);
  padding: 0.7rem 0.9rem;
  color: var(--text-primary);
  font-family: inherit;
  font-size: 0.92rem;
  transition: border-color var(--transition), box-shadow var(--transition);
  outline: none;
}

.form-group input:focus,
.form-group textarea:focus,
.form-group select:focus {
  border-color: var(--border-focus);
  box-shadow: 0 0 0 3px rgba(6, 182, 212, 0.1);
}

.form-group input::placeholder,
.form-group textarea::placeholder {
  color: var(--text-muted);
}

.form-error {
  color: var(--accent-red);
  font-size: 0.82rem;
  min-height: 1.2rem;
  text-align: center;
}

.register-link {
  text-align: center;
  margin-top: 0.5rem;
  font-size: 0.85rem;
  color: var(--text-secondary);
}

.form-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1rem;
}

/* ===================================================================
   BUTTONS
   =================================================================== */
.btn-primary {
  background: var(--gradient-primary);
  color: white;
  border: none;
  border-radius: var(--radius-sm);
  padding: 0.6rem 1.2rem;
  font-weight: 600;
  font-size: 0.88rem;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  transition: transform var(--transition), box-shadow var(--transition);
  font-family: inherit;
}

.btn-primary:hover {
  transform: translateY(-1px);
  box-shadow: 0 4px 20px rgba(6, 182, 212, 0.3);
}

.btn-secondary {
  background: rgba(100, 116, 139, 0.15);
  color: var(--text-secondary);
  border: 1px solid var(--border-primary);
  border-radius: var(--radius-sm);
  padding: 0.6rem 1.2rem;
  font-weight: 500;
  font-size: 0.88rem;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  transition: all var(--transition);
  font-family: inherit;
}

.btn-secondary:hover {
  background: rgba(100, 116, 139, 0.25);
  color: var(--text-primary);
  border-color: var(--border-hover);
}

.btn-full { width: 100%; justify-content: center; }

.btn-sm {
  padding: 0.35rem 0.7rem;
  font-size: 0.8rem;
}

.btn-icon {
  background: none;
  border: none;
  color: var(--text-muted);
  cursor: pointer;
  padding: 0.35rem;
  border-radius: var(--radius-sm);
  transition: all var(--transition);
  display: inline-flex;
  align-items: center;
}

.btn-icon:hover {
  color: var(--accent-cyan);
  background: rgba(6, 182, 212, 0.1);
}

/* ===================================================================
   SIDEBAR
   =================================================================== */
.sidebar {
  position: fixed;
  left: 0;
  top: 0;
  bottom: 0;
  width: var(--sidebar-width);
  background: var(--bg-sidebar);
  border-right: 1px solid var(--border-primary);
  display: flex;
  flex-direction: column;
  z-index: 50;
  transition: width var(--transition);
}

.sidebar-header {
  padding: 1.25rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
  border-bottom: 1px solid var(--border-primary);
  min-height: var(--header-height);
}

.country-selector-container {
  padding: 0.75rem 1.25rem;
  border-bottom: 1px solid var(--border-primary);
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
}

.country-selector-label {
  font-size: 0.7rem;
  font-weight: 600;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.custom-select-wrapper {
  position: relative;
  width: 100%;
}

.custom-select-trigger {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.5rem 0.75rem;
  background: var(--bg-card);
  color: var(--text-primary);
  border: 1px solid var(--border-primary);
  border-radius: var(--radius-sm);
  font-size: 0.85rem;
  cursor: pointer;
  user-select: none;
  transition: border-color var(--transition), box-shadow var(--transition);
}

.custom-select-trigger:hover {
  border-color: rgba(255, 255, 255, 0.2);
}

.custom-select-arrow {
  margin-left: auto;
  font-size: 0.65rem;
  color: var(--text-muted);
  transition: transform var(--transition);
}

.custom-select-wrapper.open .custom-select-arrow {
  transform: rotate(180deg);
}

.custom-select-options {
  position: absolute;
  top: 100%;
  left: 0;
  right: 0;
  margin-top: 0.25rem;
  background: var(--bg-sidebar);
  border: 1px solid var(--border-primary);
  border-radius: var(--radius-sm);
  z-index: 100;
  display: none;
  box-shadow: var(--shadow-lg);
  overflow: hidden;
}

.custom-select-wrapper.open .custom-select-options {
  display: block;
}

.custom-option {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.5rem 0.75rem;
  cursor: pointer;
  transition: background var(--transition);
  font-size: 0.85rem;
}

.custom-option:hover {
  background: rgba(255, 255, 255, 0.05);
}

.flag-icon {
  width: 16px;
  height: 12px;
  object-fit: cover;
  border-radius: 1px;
  border: 1px solid rgba(255, 255, 255, 0.15);
}


.sidebar-logo {
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.logo-emoji { font-size: 1.6rem; }

.logo-text {
  font-size: 1.15rem;
  font-weight: 700;
  letter-spacing: -0.01em;
}

.sidebar-toggle {
  background: none;
  border: none;
  color: var(--text-muted);
  cursor: pointer;
  padding: 0.4rem;
  border-radius: var(--radius-sm);
  transition: all var(--transition);
  display: none;
}

.sidebar-toggle:hover { color: var(--text-primary); background: rgba(100,116,139,0.15); }

.sidebar-nav {
  flex: 1;
  padding: 0.75rem;
  display: flex;
  flex-direction: column;
  gap: 0.2rem;
  overflow-y: auto;
}

.nav-item {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 0.7rem 0.85rem;
  border-radius: var(--radius-sm);
  color: var(--text-secondary);
  font-weight: 500;
  font-size: 0.9rem;
  transition: all var(--transition);
  position: relative;
  text-decoration: none;
}

.nav-item:hover {
  background: rgba(100, 116, 139, 0.1);
  color: var(--text-primary);
}

.nav-item.active {
  background: rgba(6, 182, 212, 0.1);
  color: var(--accent-cyan);
}

.nav-item.active::before {
  content: '';
  position: absolute;
  left: 0;
  top: 50%;
  transform: translateY(-50%);
  width: 3px;
  height: 60%;
  background: var(--gradient-primary);
  border-radius: 0 3px 3px 0;
}

.nav-badge {
  margin-left: auto;
  background: var(--accent-red);
  color: white;
  font-size: 0.7rem;
  font-weight: 700;
  padding: 0.1rem 0.45rem;
  border-radius: 999px;
  min-width: 20px;
  text-align: center;
}

.nav-separator {
  height: 1px;
  background: var(--border-primary);
  margin: 0.5rem 0;
}

.sidebar-footer {
  padding: 1rem;
  border-top: 1px solid var(--border-primary);
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.user-info {
  display: flex;
  align-items: center;
  gap: 0.65rem;
}

.user-avatar {
  width: 34px;
  height: 34px;
  border-radius: 50%;
  background: var(--gradient-primary);
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  font-size: 0.85rem;
  flex-shrink: 0;
}

.user-details { display: flex; flex-direction: column; }
.user-name { font-size: 0.85rem; font-weight: 600; }
.user-role { font-size: 0.72rem; color: var(--text-muted); text-transform: capitalize; }

.btn-logout {
  background: none;
  border: none;
  color: var(--text-muted);
  cursor: pointer;
  padding: 0.4rem;
  border-radius: var(--radius-sm);
  transition: all var(--transition);
}

.btn-logout:hover {
  color: var(--accent-red);
  background: rgba(248, 113, 113, 0.1);
}

/* ===================================================================
   MAIN CONTENT
   =================================================================== */
.main-content {
  margin-left: var(--sidebar-width);
  height: 100vh;
  padding: 1.5rem;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  transition: margin-left var(--transition);
  flex: 1;
}

.page {
  display: none;
  flex: 1;
  flex-direction: column;
  min-height: 0;
  overflow-y: auto;
}
.page.active {
  display: flex;
}

.page-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  margin-bottom: 1.5rem;
  flex-wrap: wrap;
  gap: 1rem;
}

.page-title {
  font-size: 1.6rem;
  font-weight: 700;
  letter-spacing: -0.02em;
}

.page-subtitle {
  color: var(--text-secondary);
  font-size: 0.9rem;
  margin-top: 0.15rem;
}

.header-actions {
  display: flex;
  align-items: center;
  gap: 0.65rem;
  flex-wrap: wrap;
}

/* ===================================================================
   CARDS
   =================================================================== */
.card {
  background: var(--bg-card);
  border: 1px solid var(--border-primary);
  border-radius: var(--radius-md);
  overflow: hidden;
  transition: border-color var(--transition);
}

.card:hover { border-color: rgba(100, 116, 139, 0.25); }

.card-header {
  padding: 1rem 1.25rem;
  border-bottom: 1px solid var(--border-primary);
}

.card-header h3 {
  font-size: 1rem;
  font-weight: 600;
}

.card-body {
  padding: 1.25rem;
}

/* ===================================================================
   KPI CARDS
   =================================================================== */
.kpi-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 1rem;
  margin-bottom: 1.5rem;
}

.kpi-card {
  background: var(--bg-card);
  border: 1px solid var(--border-primary);
  border-radius: var(--radius-md);
  padding: 1.15rem;
  display: flex;
  align-items: center;
  gap: 1rem;
  transition: all var(--transition);
}

.kpi-card:hover {
  border-color: var(--border-hover);
  box-shadow: var(--shadow-glow);
  transform: translateY(-2px);
}

.kpi-icon {
  width: 48px;
  height: 48px;
  border-radius: var(--radius-sm);
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.kpi-blue { background: rgba(59, 130, 246, 0.12); color: var(--accent-blue); }
.kpi-cyan { background: rgba(6, 182, 212, 0.12); color: var(--accent-cyan); }
.kpi-green { background: rgba(74, 222, 128, 0.12); color: var(--accent-green); }
.kpi-orange { background: rgba(251, 146, 60, 0.12); color: var(--accent-orange); }
.kpi-purple { background: rgba(167, 139, 250, 0.12); color: var(--accent-purple); }
.kpi-teal { background: rgba(45, 212, 191, 0.12); color: var(--accent-teal); }

.kpi-data { display: flex; flex-direction: column; }

.kpi-value {
  font-size: 1.5rem;
  font-weight: 700;
  letter-spacing: -0.02em;
  line-height: 1.2;
}

.kpi-label {
  font-size: 0.78rem;
  color: var(--text-muted);
  font-weight: 500;
}

/* ===================================================================
   DASHBOARD GRID
   =================================================================== */
.dashboard-grid {
  display: grid;
  grid-template-columns: 1.5fr 1fr;
  gap: 1rem;
}

/* ===================================================================
   DATA TABLE
   =================================================================== */
.table-container { overflow-x: auto; }

.data-table {
  width: 100%;
  border-collapse: collapse;
}

.data-table th {
  text-align: left;
  padding: 0.75rem 1rem;
  font-size: 0.78rem;
  font-weight: 600;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.04em;
  border-bottom: 1px solid var(--border-primary);
  white-space: nowrap;
}

.data-table td {
  padding: 0.75rem 1rem;
  font-size: 0.88rem;
  border-bottom: 1px solid rgba(100, 116, 139, 0.08);
  vertical-align: middle;
}

.data-table tbody tr {
  transition: background var(--transition);
  cursor: pointer;
}

.data-table tbody tr:hover {
  background: rgba(100, 116, 139, 0.06);
}

.empty-cell {
  text-align: center;
  padding: 3rem 1rem !important;
  color: var(--text-muted);
}

.table-footer {
  padding: 0.75rem 1rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
  border-top: 1px solid var(--border-primary);
  font-size: 0.82rem;
  color: var(--text-muted);
}

/* ===================================================================
   STATUS BADGES
   =================================================================== */
.status-badge {
  display: inline-flex;
  align-items: center;
  padding: 0.2rem 0.6rem;
  border-radius: 999px;
  font-size: 0.75rem;
  font-weight: 600;
  white-space: nowrap;
}

.badge-new { background: rgba(59, 130, 246, 0.15); color: var(--accent-blue); }
.badge-contacted { background: rgba(6, 182, 212, 0.15); color: var(--accent-cyan); }
.badge-proposal { background: rgba(167, 139, 250, 0.15); color: var(--accent-purple); }
.badge-negotiation { background: rgba(251, 146, 60, 0.15); color: var(--accent-orange); }
.badge-won { background: rgba(74, 222, 128, 0.15); color: var(--accent-green); }
.badge-lost { background: rgba(248, 113, 113, 0.15); color: var(--accent-red); }
.badge-active { background: rgba(74, 222, 128, 0.15); color: var(--accent-green); }
.badge-pending { background: rgba(250, 204, 21, 0.15); color: var(--accent-yellow); }

.temp-hot { color: var(--accent-red); }
.temp-warm { color: var(--accent-orange); }
.temp-cold { color: var(--accent-blue); }

/* ===================================================================
   PIPELINE (KANBAN)
   =================================================================== */
.pipeline-board {
  display: flex;
  gap: 1rem;
  overflow-x: auto;
  min-height: 0;
  flex: 1;
  padding-bottom: 1rem;
}

.pipeline-column {
  min-width: 260px;
  flex: 1;
  display: flex;
  flex-direction: column;
  background: var(--bg-secondary);
  border-radius: var(--radius-md);
  border: 1px solid var(--border-primary);
}

.pipeline-col-header {
  padding: 1rem;
  display: flex;
  align-items: center;
  gap: 0.5rem;
  border-bottom: 1px solid var(--border-primary);
}

.pipeline-dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  flex-shrink: 0;
}

.dot-new { background: var(--accent-blue); }
.dot-contacted { background: var(--accent-cyan); }
.dot-proposal { background: var(--accent-purple); }
.dot-negotiation { background: var(--accent-orange); }
.dot-won { background: var(--accent-green); }

.pipeline-col-header h4 {
  font-size: 0.88rem;
  font-weight: 600;
  flex: 1;
}

.pipeline-count {
  font-size: 0.75rem;
  background: rgba(100, 116, 139, 0.2);
  padding: 0.15rem 0.5rem;
  border-radius: 999px;
  color: var(--text-muted);
  font-weight: 600;
}

.pipeline-cards {
  padding: 0.75rem;
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  overflow-y: auto;
}

.pipe-card {
  background: var(--bg-card);
  border: 1px solid var(--border-primary);
  border-radius: var(--radius-sm);
  padding: 0.85rem;
  cursor: pointer;
  transition: all var(--transition);
}

.pipe-card:hover {
  border-color: var(--border-hover);
  transform: translateY(-1px);
  box-shadow: var(--shadow-sm);
}

.pipe-card-name {
  font-weight: 600;
  font-size: 0.88rem;
  margin-bottom: 0.3rem;
}

.pipe-card-company {
  font-size: 0.78rem;
  color: var(--text-muted);
  margin-bottom: 0.5rem;
}

.pipe-card-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-size: 0.75rem;
}

.pipe-card-channel {
  color: var(--text-muted);
  display: flex;
  align-items: center;
  gap: 0.3rem;
}

.pipe-card-score {
  font-weight: 700;
}

/* ===================================================================
   WHATSAPP INBOX
   =================================================================== */
.whatsapp-layout {
  display: flex;
  flex: 1;
  min-height: 0;
  border: 1px solid var(--border-primary);
  border-radius: var(--radius-md);
  overflow: hidden;
  background: var(--bg-card);
}

.wa-sidebar {
  width: 340px;
  border-right: 1px solid var(--border-primary);
  display: flex;
  flex-direction: column;
  flex-shrink: 0;
}

.wa-sidebar-header {
  padding: 1rem;
  border-bottom: 1px solid var(--border-primary);
}

.wa-sidebar-header h3 {
  font-size: 1.1rem;
  font-weight: 700;
  margin-bottom: 0.75rem;
}

.search-box {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  background: var(--bg-input);
  border: 1px solid var(--border-primary);
  border-radius: var(--radius-sm);
  padding: 0.5rem 0.75rem;
}

.search-box input {
  border: none;
  background: none;
  color: var(--text-primary);
  font-family: inherit;
  font-size: 0.88rem;
  outline: none;
  width: 100%;
}

.search-box svg { flex-shrink: 0; color: var(--text-muted); }

.search-small { padding: 0.4rem 0.6rem; }
.search-small input { font-size: 0.82rem; }

.filter-select {
  background: var(--bg-input);
  border: 1px solid var(--border-primary);
  border-radius: var(--radius-sm);
  padding: 0.5rem 0.75rem;
  color: var(--text-secondary);
  font-family: inherit;
  font-size: 0.85rem;
  cursor: pointer;
  outline: none;
  transition: border-color var(--transition);
}

.filter-select:focus { border-color: var(--border-focus); }

.wa-conversation-list {
  flex: 1;
  overflow-y: auto;
}

.wa-conv-item {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 0.85rem 1rem;
  border-bottom: 1px solid rgba(100, 116, 139, 0.08);
  cursor: pointer;
  transition: background var(--transition);
}

.wa-conv-item:hover { background: rgba(100, 116, 139, 0.06); }
.wa-conv-item.active { background: rgba(6, 182, 212, 0.08); }

.wa-conv-avatar {
  width: 42px;
  height: 42px;
  border-radius: 50%;
  background: var(--gradient-primary);
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  font-size: 0.9rem;
  flex-shrink: 0;
}

.wa-conv-info {
  flex: 1;
  min-width: 0;
}

.wa-conv-name {
  font-weight: 600;
  font-size: 0.9rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.wa-conv-time {
  font-size: 0.72rem;
  color: var(--text-muted);
  font-weight: 400;
}

.wa-conv-preview {
  font-size: 0.8rem;
  color: var(--text-muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem;
}

.wa-unread-badge {
  background: var(--accent-cyan);
  color: var(--bg-primary);
  font-size: 0.68rem;
  font-weight: 700;
  min-width: 20px;
  height: 20px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.wa-chat-area {
  flex: 1;
  display: flex;
  flex-direction: column;
}

.wa-empty-chat {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  color: var(--text-muted);
  gap: 0.5rem;
}

.wa-empty-icon { font-size: 3rem; opacity: 0.5; }
.wa-empty-chat h3 { font-weight: 600; color: var(--text-secondary); }

/* Chat messages inside WA */
.wa-chat-header {
  padding: 0.85rem 1.25rem;
  border-bottom: 1px solid var(--border-primary);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  background: var(--bg-secondary);
}

.wa-chat-header-name { font-weight: 600; font-size: 0.95rem; }
.wa-chat-header-phone { font-size: 0.78rem; color: var(--text-muted); }

.wa-messages {
  flex: 1;
  padding: 1rem;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  background: var(--bg-primary);
}

.wa-msg {
  max-width: 65%;
  padding: 0.6rem 0.85rem;
  border-radius: var(--radius-sm);
  font-size: 0.88rem;
  line-height: 1.5;
  position: relative;
}

.wa-msg-in {
  align-self: flex-start;
  background: #1f2c34;
  border-bottom-left-radius: 2px;
}

.wa-msg-out {
  align-self: flex-end;
  background: #005c4b;
  border-bottom-right-radius: 2px;
}

.wa-msg-time {
  font-size: 0.68rem;
  color: rgba(255,255,255,0.45);
  text-align: right;
  margin-top: 0.2rem;
}

.wa-msg-bot-badge {
  font-size: 0.65rem;
  background: rgba(6, 182, 212, 0.2);
  color: var(--accent-cyan);
  padding: 0.1rem 0.35rem;
  border-radius: 3px;
  margin-left: 0.4rem;
}

.wa-input-area {
  padding: 0.85rem 1rem;
  border-top: 1px solid var(--border-primary);
  display: flex;
  gap: 0.65rem;
  align-items: center;
  background: var(--bg-secondary);
}

.wa-input-area input {
  flex: 1;
  background: var(--bg-input);
  border: 1px solid var(--border-primary);
  border-radius: 20px;
  padding: 0.65rem 1rem;
  color: var(--text-primary);
  font-family: inherit;
  font-size: 0.9rem;
  outline: none;
  transition: border-color var(--transition);
}

.wa-input-area input:focus { border-color: var(--border-focus); }

.wa-send-btn {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  background: var(--gradient-primary);
  border: none;
  color: white;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  transition: transform var(--transition);
}

.wa-send-btn:hover { transform: scale(1.05); }

/* ===================================================================
   MODALS
   =================================================================== */
.modal-overlay {
  position: fixed;
  inset: 0;
  z-index: 100;
  background: rgba(0, 0, 0, 0.6);
  backdrop-filter: blur(4px);
  display: none;
  align-items: center;
  justify-content: center;
  padding: 1rem;
}

.modal-overlay.active { display: flex; }

.modal-card {
  background: var(--bg-card);
  border: 1px solid var(--border-primary);
  border-radius: var(--radius-lg);
  max-width: 520px;
  width: 100%;
  max-height: 90vh;
  overflow-y: auto;
  animation: modalIn 0.3s ease;
  box-shadow: var(--shadow-lg);
}

.modal-large { max-width: 700px; }

@keyframes modalIn {
  from { opacity: 0; transform: scale(0.95) translateY(10px); }
  to { opacity: 1; transform: scale(1) translateY(0); }
}

.modal-header {
  padding: 1.25rem 1.5rem;
  border-bottom: 1px solid var(--border-primary);
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.modal-header h3 { font-size: 1.1rem; font-weight: 600; }

.modal-close {
  background: none;
  border: none;
  color: var(--text-muted);
  font-size: 1.5rem;
  cursor: pointer;
  line-height: 1;
  padding: 0.2rem;
  transition: color var(--transition);
}

.modal-close:hover { color: var(--text-primary); }

.modal-body { padding: 1.5rem; }
.modal-footer {
  padding: 1rem 1.5rem;
  border-top: 1px solid var(--border-primary);
  display: flex;
  justify-content: flex-end;
  gap: 0.65rem;
}

/* ===================================================================
   SETTINGS
   =================================================================== */
.settings-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
  gap: 1rem;
}

.setting-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0.85rem 0;
  border-bottom: 1px solid rgba(100, 116, 139, 0.08);
}

.setting-item:last-child { border-bottom: none; }

.setting-info strong { font-size: 0.9rem; }
.setting-info p { font-size: 0.8rem; color: var(--text-muted); margin-top: 0.1rem; }

/* ===================================================================
   TOAST NOTIFICATIONS
   =================================================================== */
.toast-container {
  position: fixed;
  top: 1.5rem;
  right: 1.5rem;
  z-index: 200;
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.toast {
  background: var(--bg-card);
  border: 1px solid var(--border-primary);
  border-radius: var(--radius-sm);
  padding: 0.85rem 1.25rem;
  min-width: 280px;
  max-width: 400px;
  display: flex;
  align-items: center;
  gap: 0.65rem;
  font-size: 0.88rem;
  box-shadow: var(--shadow-md);
  animation: toastIn 0.35s ease;
  border-left: 3px solid var(--accent-cyan);
}

.toast.error { border-left-color: var(--accent-red); }
.toast.success { border-left-color: var(--accent-green); }

@keyframes toastIn {
  from { opacity: 0; transform: translateX(20px); }
  to { opacity: 1; transform: translateX(0); }
}

/* ===================================================================
   EMPTY STATE
   =================================================================== */
.empty-state {
  text-align: center;
  padding: 2rem;
  color: var(--text-muted);
}

/* ===================================================================
   ACTIVITY ITEM
   =================================================================== */
.activity-item {
  display: flex;
  align-items: flex-start;
  gap: 0.75rem;
  padding: 0.65rem 0;
  border-bottom: 1px solid rgba(100, 116, 139, 0.08);
}

.activity-item:last-child { border-bottom: none; }

.activity-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  flex-shrink: 0;
  margin-top: 0.45rem;
}

.activity-content { flex: 1; min-width: 0; }
.activity-text { font-size: 0.85rem; }
.activity-time { font-size: 0.75rem; color: var(--text-muted); margin-top: 0.1rem; }

/* Channel breakdown bars */
.channel-bar-item {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  margin-bottom: 0.85rem;
}

.channel-bar-label {
  font-size: 0.82rem;
  font-weight: 500;
  width: 90px;
  flex-shrink: 0;
  text-transform: capitalize;
}

.channel-bar-track {
  flex: 1;
  height: 8px;
  background: rgba(100, 116, 139, 0.1);
  border-radius: 999px;
  overflow: hidden;
}

.channel-bar-fill {
  height: 100%;
  border-radius: 999px;
  transition: width 0.8s ease;
}

.channel-bar-count {
  font-size: 0.78rem;
  color: var(--text-muted);
  font-weight: 600;
  width: 30px;
  text-align: right;
}

/* ===================================================================
   MOBILE STYLING & RESPONSIVENESS
   =================================================================== */

/* ---- Mobile Header ---- */
.mobile-header {
  display: none;
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  height: var(--header-height);
  background: var(--bg-sidebar);
  border-bottom: 1px solid var(--border-primary);
  align-items: center;
  padding: 0 1.25rem;
  z-index: 40;
  backdrop-filter: blur(10px);
}

.menu-toggle {
  background: none;
  border: none;
  color: var(--text-primary);
  cursor: pointer;
  padding: 0.5rem;
  border-radius: var(--radius-sm);
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background var(--transition);
}

.menu-toggle:hover {
  background: rgba(100, 116, 139, 0.15);
}

.mobile-logo {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  margin-left: 0.75rem;
}

/* ---- Sidebar Overlay ---- */
.sidebar-overlay {
  display: none;
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(10, 14, 26, 0.6);
  backdrop-filter: blur(4px);
  z-index: 45;
  opacity: 0;
  pointer-events: none;
  transition: opacity var(--transition);
}

.sidebar-overlay.open {
  display: block;
  opacity: 1;
  pointer-events: auto;
}

/* ---- WhatsApp Mobile Back Button ---- */
.wa-back-btn {
  display: none;
  background: none;
  border: none;
  color: var(--text-primary);
  cursor: pointer;
  padding: 0.4rem;
  border-radius: var(--radius-sm);
  margin-right: 0.5rem;
}

.wa-back-btn:hover {
  background: rgba(100, 116, 139, 0.15);
}

/* ===================================================================
   MEDIA QUERIES
   =================================================================== */
@media (max-width: 1024px) {
  .dashboard-grid { grid-template-columns: 1fr; }
  .form-row { grid-template-columns: 1fr; }
}

@media (max-width: 768px) {
  /* Layout */
  .mobile-header {
    display: flex;
  }
  
  .main-content {
    margin-left: 0;
    padding: calc(var(--header-height) + 1.25rem) 1.25rem 1.25rem 1.25rem;
  }

  .sidebar {
    transform: translateX(-100%);
    z-index: 100;
  }

  .sidebar.open {
    transform: translateX(0);
    box-shadow: 5px 0 25px rgba(0, 0, 0, 0.5);
  }

  .sidebar-toggle {
    display: flex;
  }

  /* Grid adaptations */
  .kpi-grid {
    grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
  }

  .settings-grid {
    grid-template-columns: 1fr;
  }

  /* WhatsApp adaptations */
  .whatsapp-layout {
    flex-direction: column;
    height: calc(100vh - var(--header-height) - 4rem);
  }

  .wa-sidebar {
    width: 100%;
    height: 100%;
  }

  .wa-chat-area {
    display: none;
    position: fixed;
    top: var(--header-height);
    left: 0;
    right: 0;
    bottom: 0;
    z-index: 90;
    background: var(--bg-primary);
  }

  .wa-chat-area.active {
    display: flex;
  }

  .wa-back-btn {
    display: flex;
    align-items: center;
    justify-content: center;
  }

  /* Pipeline board scroll */
  .pipeline-board {
    display: flex;
    overflow-x: auto;
    gap: 1rem;
    padding-bottom: 1rem;
    align-items: flex-start;
    -webkit-overflow-scrolling: touch;
  }

  .pipeline-column {
    min-width: 280px;
    flex-shrink: 0;
  }

  /* Modals scaling */
  .modal-card {
    width: 95%;
    margin: 1rem;
    padding: 1.5rem;
  }
}

/* ---- Bot Toggle Custom CSS ---- */
.bot-toggle-wrapper {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  background: rgba(30, 41, 59, 0.4);
  padding: 0.4rem 0.8rem;
  border-radius: 50px;
  border: 1px solid var(--border-primary);
  transition: border-color var(--transition);
}
.bot-toggle-wrapper:hover {
  border-color: var(--border-hover);
}
.bot-toggle-label {
  font-size: 0.85rem;
  font-weight: 500;
  color: var(--text-secondary);
}
.bot-toggle-no-lead {
  font-size: 0.82rem;
  color: var(--text-muted);
  font-style: italic;
}

/* Switch styling */
.switch {
  position: relative;
  display: inline-block;
  width: 36px;
  height: 20px;
}
.switch input {
  opacity: 0;
  width: 0;
  height: 0;
}
.slider {
  position: absolute;
  cursor: pointer;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background-color: var(--bg-input);
  border: 1px solid var(--border-primary);
  transition: .3s;
}
.slider:before {
  position: absolute;
  content: "";
  height: 14px;
  width: 14px;
  left: 2px;
  bottom: 2px;
  background-color: var(--text-muted);
  transition: .3s;
}
input:checked + .slider {
  background-color: var(--accent-cyan);
  border-color: var(--accent-cyan);
  box-shadow: 0 0 8px rgba(6, 182, 212, 0.4);
}
input:checked + .slider:before {
  transform: translateX(16px);
  background-color: #000;
}
.slider.round {
  border-radius: 20px;
}
.slider.round:before {
  border-radius: 50%;
}

/* Custom Page Layout Overrides for Widescreen & App-like Feel */
#page-whatsapp, #page-pipeline {
  overflow: hidden;
}
