/* SmartCaller CRM - Modern Dark/Light Design System & Mobile Responsive UI */
@import url('https://fonts.googleapis.com/css2?family=Plus+Jakarta+Sans:wght@400;500;600;700;800&display=swap');

:root {
  --font-primary: 'Plus Jakarta Sans', system-ui, -apple-system, sans-serif;
  
  /* Color Palette - Dark Modern Glassmorphism Default */
  --bg-dark: #0f172a;
  --bg-card: rgba(30, 41, 59, 0.85);
  --bg-card-hover: rgba(51, 65, 85, 0.9);
  --border-color: rgba(255, 255, 255, 0.1);
  --border-accent: rgba(99, 102, 241, 0.3);
  
  --text-main: #f8fafc;
  --text-muted: #94a3b8;
  --text-dim: #64748b;
  
  --primary: #6366f1;
  --primary-hover: #4f46e5;
  --primary-glow: rgba(99, 102, 241, 0.35);
  
  --success: #10b981;
  --success-bg: rgba(16, 185, 129, 0.15);
  --warning: #f59e0b;
  --warning-bg: rgba(245, 158, 11, 0.15);
  --danger: #ef4444;
  --danger-bg: rgba(239, 68, 68, 0.15);
  --info: #06b6d4;
  --info-bg: rgba(6, 182, 212, 0.15);
  --purple: #8b5cf6;
  
  --radius-sm: 8px;
  --radius-md: 14px;
  --radius-lg: 20px;
  --radius-full: 9999px;
  
  --shadow-sm: 0 4px 6px -1px rgba(0, 0, 0, 0.2);
  --shadow-glow: 0 10px 30px -5px rgba(99, 102, 241, 0.3);
  --transition: all 0.25s cubic-bezier(0.4, 0, 0.2, 1);
}

/* Light Theme Variables */
[data-theme="light"] {
  --bg-dark: #f1f5f9;
  --bg-card: rgba(255, 255, 255, 0.9);
  --bg-card-hover: #ffffff;
  --border-color: rgba(0, 0, 0, 0.08);
  --text-main: #0f172a;
  --text-muted: #475569;
  --text-dim: #94a3b8;
}

* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
  font-family: var(--font-primary);
  -webkit-tap-highlight-color: transparent;
}

body {
  background-color: var(--bg-dark);
  color: var(--text-main);
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  overflow-x: hidden;
  background-image: 
    radial-gradient(circle at 10% 20%, rgba(99, 102, 241, 0.12) 0%, transparent 40%),
    radial-gradient(circle at 90% 80%, rgba(139, 92, 246, 0.12) 0%, transparent 40%);
}

a {
  color: inherit;
  text-decoration: none;
}

/* Utility Layouts */
.hidden { display: none !important; }
.flex { display: flex; }
.flex-between { display: flex; justify-content: space-between; align-items: center; }
.gap-2 { gap: 0.5rem; }
.gap-3 { gap: 0.75rem; }
.gap-4 { gap: 1rem; }

/* Global Header */
.app-header {
  height: 65px;
  padding: 0 1.5rem;
  background: rgba(15, 23, 42, 0.85);
  backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--border-color);
  position: sticky;
  top: 0;
  z-index: 100;
}

.brand-logo {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  font-size: 1.25rem;
  font-weight: 800;
  background: linear-gradient(135deg, #818cf8, #c084fc);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
}

.brand-icon {
  width: 38px;
  height: 38px;
  background: linear-gradient(135deg, var(--primary), var(--purple));
  border-radius: var(--radius-md);
  display: flex;
  align-items: center;
  justify-content: center;
  color: white;
  font-size: 1.2rem;
  box-shadow: var(--shadow-glow);
}

.user-badge {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  background: var(--bg-card);
  padding: 0.4rem 0.8rem;
  border-radius: var(--radius-full);
  border: 1px solid var(--border-color);
  font-size: 0.85rem;
}

.role-tag {
  padding: 0.15rem 0.5rem;
  border-radius: var(--radius-full);
  font-size: 0.7rem;
  font-weight: 700;
  text-transform: uppercase;
}

.role-tag.admin { background: rgba(99, 102, 241, 0.2); color: #818cf8; }
.role-tag.caller { background: rgba(16, 185, 129, 0.2); color: #34d399; }

/* Buttons & Inputs */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  padding: 0.65rem 1.2rem;
  border-radius: var(--radius-md);
  font-weight: 600;
  font-size: 0.9rem;
  cursor: pointer;
  border: none;
  transition: var(--transition);
}

.btn-primary {
  background: linear-gradient(135deg, var(--primary), var(--purple));
  color: white;
  box-shadow: var(--shadow-glow);
}

.btn-primary:hover {
  transform: translateY(-2px);
  filter: brightness(1.1);
}

.btn-secondary {
  background: var(--bg-card);
  color: var(--text-main);
  border: 1px solid var(--border-color);
}

.btn-secondary:hover {
  background: var(--bg-card-hover);
}

.btn-success {
  background: var(--success);
  color: white;
}

.btn-call {
  background: linear-gradient(135deg, #10b981, #059669);
  color: white;
  font-size: 1rem;
  font-weight: 700;
  padding: 0.75rem 1.4rem;
  border-radius: var(--radius-full);
  box-shadow: 0 4px 15px rgba(16, 185, 129, 0.4);
}

.btn-call:active {
  transform: scale(0.96);
}

.btn-whatsapp {
  background: linear-gradient(135deg, #25D366, #128C7E);
  color: #ffffff !important;
  font-size: 1rem;
  font-weight: 700;
  padding: 0.75rem 1.4rem;
  border-radius: var(--radius-full);
  box-shadow: 0 4px 15px rgba(37, 211, 102, 0.35);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.35rem;
  text-decoration: none;
  border: none;
  transition: var(--transition);
}

.btn-whatsapp:hover, .btn-whatsapp:active {
  transform: scale(0.96);
  filter: brightness(1.1);
  color: #ffffff !important;
}

.btn-whatsapp-sm {
  background: linear-gradient(135deg, #25D366, #128C7E);
  color: #ffffff !important;
  font-size: 0.8rem;
  font-weight: 700;
  padding: 0.4rem 0.75rem;
  border-radius: var(--radius-sm);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.3rem;
  text-decoration: none;
  border: none;
  transition: var(--transition);
}

.btn-whatsapp-sm:hover {
  filter: brightness(1.1);
  color: #ffffff !important;
}

.btn-sm {
  padding: 0.4rem 0.8rem;
  font-size: 0.8rem;
  border-radius: var(--radius-sm);
}

.form-control {
  width: 100%;
  padding: 0.75rem 1rem;
  background: rgba(15, 23, 42, 0.8);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  color: #ffffff;
  font-size: 0.95rem;
  font-weight: 600;
  outline: none;
  transition: var(--transition);
}

.form-control:focus {
  border-color: #818cf8;
  box-shadow: 0 0 0 3px var(--primary-glow);
}

/* Explicit Select Option Styling for Dark Mode Contrast */
select.form-control option {
  background-color: #1e293b;
  color: #ffffff;
  padding: 0.6rem 1rem;
  font-size: 0.95rem;
  font-weight: 600;
}

/* Glassmorphism Cards */
.glass-card {
  background: var(--bg-card);
  backdrop-filter: blur(16px);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-lg);
  padding: 1.5rem;
  box-shadow: var(--shadow-sm);
}

/* Auth Section */
.auth-container {
  max-width: 420px;
  margin: auto;
  width: 90%;
  padding: 2.5rem 2rem;
}

.auth-tabs {
  display: flex;
  background: rgba(15, 23, 42, 0.6);
  padding: 0.25rem;
  border-radius: var(--radius-md);
  margin-bottom: 1.5rem;
}

.auth-tab {
  flex: 1;
  text-align: center;
  padding: 0.6rem;
  font-weight: 600;
  border-radius: var(--radius-sm);
  cursor: pointer;
  color: var(--text-muted);
  transition: var(--transition);
}

.auth-tab.active {
  background: var(--primary);
  color: white;
}

/* Admin Dashboard Layout */
.admin-layout {
  display: grid;
  grid-template-columns: 240px 1fr;
  min-height: calc(100vh - 65px);
}

.sidebar {
  background: rgba(15, 23, 42, 0.9);
  border-right: 1px solid var(--border-color);
  padding: 1.5rem 1rem;
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.nav-link {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 0.75rem 1rem;
  border-radius: var(--radius-md);
  color: var(--text-muted);
  font-weight: 600;
  cursor: pointer;
  transition: var(--transition);
}

.nav-link:hover, .nav-link.active {
  background: var(--primary-glow);
  color: #818cf8;
}

.admin-main {
  padding: 2rem;
  overflow-y: auto;
}

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

.stat-card {
  display: flex;
  align-items: center;
  gap: 1.25rem;
}

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

.stat-icon.total { background: rgba(99, 102, 241, 0.2); color: #818cf8; }
.stat-icon.called { background: rgba(6, 182, 212, 0.2); color: #22d3ee; }
.stat-icon.converted { background: rgba(16, 185, 129, 0.2); color: #34d399; }
.stat-icon.followup { background: rgba(245, 158, 11, 0.2); color: #fbbf24; }

.stat-val {
  font-size: 1.75rem;
  font-weight: 800;
}

.stat-lbl {
  font-size: 0.85rem;
  color: var(--text-muted);
}

/* Status Badges */
.badge {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  padding: 0.25rem 0.65rem;
  border-radius: var(--radius-full);
  font-size: 0.75rem;
  font-weight: 700;
}

.badge-Pending { background: rgba(148, 163, 184, 0.15); color: #cbd5e1; }
.badge-Connected { background: var(--info-bg); color: var(--info); }
.badge-Converted { background: var(--success-bg); color: var(--success); }
.badge-FollowUp { background: var(--warning-bg); color: var(--warning); }
.badge-NotConnected { background: var(--danger-bg); color: var(--danger); }
.badge-Busy { background: rgba(139, 92, 246, 0.15); color: var(--purple); }

/* Table Styling */
.table-responsive {
  overflow-x: auto;
}

.custom-table {
  width: 100%;
  border-collapse: collapse;
  margin-top: 1rem;
  font-size: 0.9rem;
}

.custom-table th {
  text-align: left;
  padding: 0.85rem 1rem;
  background: rgba(15, 23, 42, 0.6);
  color: var(--text-muted);
  font-weight: 700;
  border-bottom: 1px solid var(--border-color);
}

.custom-table td {
  padding: 1rem;
  border-bottom: 1px solid var(--border-color);
  color: var(--text-main);
}

.cdm-panel { display: block; }
.cdm-panel.hidden { display: none !important; }

/* Mobile Caller UI (Smartphone Optimized) */
.mobile-caller-container {
  max-width: 480px;
  margin: 0 auto;
  width: 100%;
  padding-bottom: 90px; /* Space for bottom nav */
}

.caller-header-card {
  margin: 1rem;
  background: linear-gradient(135deg, rgba(99, 102, 241, 0.2), rgba(139, 92, 246, 0.2));
  border: 1px solid var(--border-accent);
  padding: 1.2rem;
  border-radius: var(--radius-lg);
}

.tab-buttons {
  display: flex;
  gap: 0.5rem;
  margin: 1rem;
  overflow-x: auto;
  padding-bottom: 0.25rem;
}

.mobile-tab-btn {
  padding: 0.5rem 1rem;
  border-radius: var(--radius-full);
  background: var(--bg-card);
  color: var(--text-muted);
  border: 1px solid var(--border-color);
  font-size: 0.85rem;
  font-weight: 600;
  white-space: nowrap;
  cursor: pointer;
}

.mobile-tab-btn.active {
  background: var(--primary);
  color: white;
  border-color: var(--primary);
}

/* Mobile Lead Card */
.lead-card {
  margin: 0.75rem 1rem;
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-lg);
  padding: 1.2rem;
  display: flex;
  flex-direction: column;
  gap: 0.85rem;
  transition: var(--transition);
  box-shadow: 0 2px 10px rgba(0, 0, 0, 0.15);
}

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

.lead-name {
  font-size: 1.1rem;
  font-weight: 700;
}

.lead-phone {
  font-size: 1rem;
  color: #818cf8;
  font-weight: 600;
  display: flex;
  align-items: center;
  gap: 0.4rem;
}

.lead-meta {
  font-size: 0.82rem;
  color: var(--text-muted);
  display: flex;
  flex-wrap: wrap;
  gap: 0.75rem;
}

.lead-actions {
  display: flex;
  gap: 0.6rem;
  margin-top: 0.25rem;
}

/* Bottom Navigation Bar for Mobile */
.mobile-bottom-nav {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  height: 65px;
  background: rgba(15, 23, 42, 0.95);
  backdrop-filter: blur(16px);
  border-top: 1px solid var(--border-color);
  display: flex;
  justify-content: space-around;
  align-items: center;
  z-index: 99;
}

.bottom-nav-item {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.25rem;
  color: var(--text-muted);
  font-size: 0.75rem;
  font-weight: 600;
  cursor: pointer;
}

.bottom-nav-item.active {
  color: var(--primary);
}

.bottom-nav-icon {
  font-size: 1.3rem;
}

/* Modal Bottom Sheet */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.7);
  backdrop-filter: blur(6px);
  z-index: 200;
  display: flex;
  align-items: flex-end;
  justify-content: center;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.3s ease;
}

.modal-overlay.active {
  opacity: 1;
  pointer-events: auto;
}

.modal-sheet {
  background: #1e293b;
  width: 100%;
  max-width: 520px;
  border-top-left-radius: var(--radius-lg);
  border-top-right-radius: var(--radius-lg);
  padding: 1.75rem;
  transform: translateY(100%);
  transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  border: 1px solid var(--border-color);
  max-height: 90vh;
  overflow-y: auto;
}

.modal-overlay.active .modal-sheet {
  transform: translateY(0);
}

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

.status-options-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 0.75rem;
  margin: 1rem 0;
}

.status-opt-btn {
  padding: 0.8rem;
  border-radius: var(--radius-md);
  background: rgba(15, 23, 42, 0.6);
  border: 1px solid var(--border-color);
  color: var(--text-main);
  font-weight: 600;
  font-size: 0.85rem;
  cursor: pointer;
  text-align: center;
  transition: var(--transition);
}

.status-opt-btn.selected {
  border-color: var(--primary);
  background: var(--primary-glow);
  color: #818cf8;
}

/* File Upload Zone */
.upload-zone {
  border: 2px dashed var(--border-accent);
  border-radius: var(--radius-lg);
  padding: 2.5rem 1.5rem;
  text-align: center;
  background: rgba(99, 102, 241, 0.05);
  cursor: pointer;
  transition: var(--transition);
}

.upload-zone:hover {
  background: rgba(99, 102, 241, 0.1);
  border-color: var(--primary);
}

/* Admin Mobile Navigation & Mobile Cards System */
.admin-mobile-nav {
  display: none;
  overflow-x: auto;
  gap: 0.5rem;
  padding-bottom: 0.5rem;
  margin-bottom: 1rem;
  white-space: nowrap;
  -webkit-overflow-scrolling: touch;
}

.admin-mobile-nav .mobile-tab-btn {
  padding: 0.5rem 1rem;
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-full);
  color: var(--text-muted);
  font-size: 0.85rem;
  font-weight: 700;
  cursor: pointer;
}

.admin-mobile-nav .mobile-tab-btn.active {
  background: var(--primary-glow);
  border-color: var(--primary);
  color: #818cf8;
}

.admin-mobile-cards {
  display: none;
  flex-direction: column;
  gap: 0.85rem;
  padding: 0.85rem;
}

.admin-card-lead {
  background: rgba(15, 23, 42, 0.7);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  padding: 1rem;
  display: flex;
  flex-direction: column;
  gap: 0.65rem;
}

/* Responsive Rules */
@media (max-width: 768px) {
  .admin-layout {
    grid-template-columns: 1fr;
  }
  .sidebar {
    display: none; /* Hide desktop sidebar on mobile, use mobile nav */
  }
  .admin-main {
    padding: 0.75rem;
  }
  .admin-mobile-nav {
    display: flex;
  }
  .admin-desktop-table {
    display: none !important;
  }
  .admin-mobile-cards {
    display: flex !important;
  }
  #leads-csv-upload-card > div[style*="grid-template-columns"] {
    grid-template-columns: 1fr !important;
  }
}

/* Calling Data Register & Dedup Badge Styles */
.badge.badge-new, .badge.new {
  background: rgba(63, 214, 160, 0.15);
  color: #3fd6a0;
  border: 1px solid rgba(63, 214, 160, 0.3);
}
.badge.badge-dup, .badge.dup {
  background: rgba(216, 101, 74, 0.15);
  color: #f87171;
  border: 1px solid rgba(216, 101, 74, 0.3);
}
.dup-note {
  color: var(--text-muted);
  font-size: 0.8rem;
}
.cdm-tab.active {
  background: var(--primary-glow) !important;
  border-color: var(--primary) !important;
  color: #818cf8 !important;
}

