/* ==========================================================================
   TechSavy Leads Manager - Design System & Stylesheet
   Domain: lead.techsavyitltd.com
   ========================================================================== */

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

:root {
  /* Color Palette - Dark Theme (Default) */
  --bg-base: #090D16;
  --bg-surface: #0F172A;
  --bg-card: rgba(17, 24, 39, 0.85);
  --bg-card-hover: rgba(30, 41, 59, 0.9);
  --bg-glass: rgba(15, 23, 42, 0.75);
  --border-subtle: rgba(255, 255, 255, 0.08);
  --border-focus: rgba(99, 102, 241, 0.5);

  --text-primary: #F8FAFC;
  --text-secondary: #94A3B8;
  --text-muted: #64748B;
  --text-white: #FFFFFF;

  /* Brand Accents */
  --primary: #6366F1;
  --primary-glow: rgba(99, 102, 241, 0.25);
  --primary-hover: #4F46E5;
  --accent-cyan: #06B6D4;
  --accent-purple: #A855F7;

  /* Action Colors */
  --wa-green: #25D366;
  --wa-hover: #1EBE5D;
  --call-blue: #38BDF8;
  --mail-violet: #818CF8;
  --maps-red: #F87171;

  /* Status Colors */
  --status-new: #38BDF8;
  --status-contacted: #818CF8;
  --status-interested: #FBBF24;
  --status-followup: #FB923C;
  --status-qualified: #C084FC;
  --status-converted: #34D399;
  --status-lost: #F87171;

  /* Priority Colors */
  --priority-hot: #EF4444;
  --priority-warm: #F59E0B;
  --priority-cold: #3B82F6;

  /* Layout */
  --sidebar-width: 260px;
  --header-height: 70px;
  --radius-sm: 8px;
  --radius-md: 12px;
  --radius-lg: 18px;
  --radius-xl: 24px;
  --shadow-card: 0 10px 25px -5px rgba(0, 0, 0, 0.5), 0 8px 10px -6px rgba(0, 0, 0, 0.5);
  --shadow-glow: 0 0 20px rgba(99, 102, 241, 0.35);
  --transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
}

/* Light Theme Variables */
[data-theme="light"] {
  --bg-base: #F1F5F9;
  --bg-surface: #FFFFFF;
  --bg-card: rgba(255, 255, 255, 0.9);
  --bg-card-hover: #F8FAFC;
  --bg-glass: rgba(255, 255, 255, 0.85);
  --border-subtle: rgba(0, 0, 0, 0.08);
  --border-focus: rgba(99, 102, 241, 0.4);

  --text-primary: #0F172A;
  --text-secondary: #475569;
  --text-muted: #94A3B8;
  --shadow-card: 0 10px 25px -5px rgba(0, 0, 0, 0.07), 0 8px 10px -6px rgba(0, 0, 0, 0.05);
}

/* Base Resets */
* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

body {
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
  background-color: var(--bg-base);
  color: var(--text-primary);
  min-height: 100vh;
  display: flex;
  overflow-x: hidden;
  line-height: 1.5;
  background-image: 
    radial-gradient(circle at 10% 20%, rgba(99, 102, 241, 0.08) 0%, transparent 40%),
    radial-gradient(circle at 90% 80%, rgba(168, 85, 247, 0.06) 0%, transparent 40%);
}

h1, h2, h3, h4, h5, h6 {
  font-family: 'Outfit', sans-serif;
  letter-spacing: -0.02em;
}

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

button, input, select, textarea {
  font-family: inherit;
  font-size: 0.95rem;
  outline: none;
}

/* App Container Layout */
.app-container {
  display: flex;
  width: 100vw;
  min-height: 100vh;
}

/* Sidebar */
.sidebar {
  width: var(--sidebar-width);
  background: var(--bg-surface);
  border-right: 1px solid var(--border-subtle);
  display: flex;
  flex-direction: column;
  position: fixed;
  top: 0;
  bottom: 0;
  left: 0;
  z-index: 100;
  backdrop-filter: blur(16px);
  transition: var(--transition);
}

.brand-section {
  padding: 22px 20px;
  display: flex;
  align-items: center;
  gap: 12px;
  border-bottom: 1px solid var(--border-subtle);
}

.brand-logo {
  width: 40px;
  height: 40px;
  border-radius: var(--radius-md);
  background: linear-gradient(135deg, var(--primary), var(--accent-purple));
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: var(--shadow-glow);
  color: #FFF;
  font-weight: 800;
  font-size: 1.25rem;
}

.brand-text h2 {
  font-size: 1.15rem;
  font-weight: 700;
  background: linear-gradient(135deg, #FFF 30%, var(--accent-cyan));
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
}

.brand-text span {
  font-size: 0.72rem;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.08em;
}

.sidebar-nav {
  padding: 20px 14px;
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.nav-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 11px 16px;
  border-radius: var(--radius-md);
  color: var(--text-secondary);
  font-weight: 500;
  font-size: 0.92rem;
  cursor: pointer;
  transition: var(--transition);
}

.nav-item:hover {
  color: var(--text-primary);
  background: rgba(255, 255, 255, 0.04);
}

.nav-item.active {
  background: linear-gradient(90deg, rgba(99, 102, 241, 0.15), rgba(99, 102, 241, 0.03));
  color: var(--primary);
  border-left: 3px solid var(--primary);
  font-weight: 600;
}

.nav-item svg {
  width: 19px;
  height: 19px;
}

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

.user-badge {
  display: flex;
  align-items: center;
  gap: 10px;
}

.user-avatar {
  width: 34px;
  height: 34px;
  border-radius: 50%;
  background: linear-gradient(135deg, #10B981, #06B6D4);
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  font-size: 0.85rem;
  color: #FFF;
}

/* Main Content Area */
.main-wrapper {
  margin-left: var(--sidebar-width);
  flex: 1;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

/* Header */
.top-header {
  height: var(--header-height);
  background: var(--bg-glass);
  backdrop-filter: blur(20px);
  border-bottom: 1px solid var(--border-subtle);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 30px;
  position: sticky;
  top: 0;
  z-index: 90;
}

.search-box {
  position: relative;
  width: 380px;
}

.search-box input {
  width: 100%;
  padding: 10px 14px 10px 42px;
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
  color: var(--text-primary);
  transition: var(--transition);
}

.search-box input:focus {
  border-color: var(--primary);
  background: rgba(255, 255, 255, 0.07);
  box-shadow: 0 0 0 3px var(--primary-glow);
}

.search-box svg {
  position: absolute;
  left: 14px;
  top: 50%;
  transform: translateY(-50%);
  width: 17px;
  height: 17px;
  color: var(--text-muted);
}

.search-badge {
  position: absolute;
  right: 12px;
  top: 50%;
  transform: translateY(-50%);
  font-size: 0.72rem;
  padding: 2px 6px;
  background: rgba(255, 255, 255, 0.1);
  border-radius: 4px;
  color: var(--text-muted);
}

.header-actions {
  display: flex;
  align-items: center;
  gap: 12px;
}

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

.btn-primary {
  background: linear-gradient(135deg, var(--primary), #4F46E5);
  color: #FFF;
  box-shadow: 0 4px 14px var(--primary-glow);
}

.btn-primary:hover {
  background: linear-gradient(135deg, #4F46E5, #4338CA);
  transform: translateY(-1px);
  box-shadow: 0 6px 18px rgba(99, 102, 241, 0.4);
}

.btn-outline {
  background: transparent;
  border: 1px solid var(--border-subtle);
  color: var(--text-primary);
}

.btn-outline:hover {
  background: rgba(255, 255, 255, 0.05);
  border-color: rgba(255, 255, 255, 0.2);
}

.btn-sm {
  padding: 6px 12px;
  font-size: 0.82rem;
  border-radius: var(--radius-sm);
}

.btn-icon {
  width: 38px;
  height: 38px;
  padding: 0;
  border-radius: var(--radius-md);
  display: flex;
  align-items: center;
  justify-content: center;
}

/* Page Content */
.content-body {
  padding: 28px 30px;
  flex: 1;
}

/* KPI Summary Cards Grid */
.stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(210px, 1fr));
  gap: 18px;
  margin-bottom: 28px;
}

.stat-card {
  background: var(--bg-card);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-lg);
  padding: 20px;
  box-shadow: var(--shadow-card);
  display: flex;
  align-items: center;
  justify-content: space-between;
  position: relative;
  overflow: hidden;
  transition: var(--transition);
}

.stat-card:hover {
  transform: translateY(-3px);
  border-color: var(--border-focus);
  background: var(--bg-card-hover);
}

.stat-card::after {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  width: 4px;
  height: 100%;
  background: var(--card-accent, var(--primary));
}

.stat-info h4 {
  font-size: 0.82rem;
  font-weight: 500;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.04em;
  margin-bottom: 6px;
}

.stat-info .stat-value {
  font-size: 1.8rem;
  font-weight: 800;
  color: var(--text-primary);
  line-height: 1.2;
}

.stat-info .stat-sub {
  font-size: 0.78rem;
  color: var(--text-secondary);
  margin-top: 4px;
}

.stat-icon {
  width: 48px;
  height: 48px;
  border-radius: var(--radius-md);
  background: rgba(255, 255, 255, 0.04);
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--card-accent, var(--primary));
}

.stat-icon svg {
  width: 24px;
  height: 24px;
}

/* Control Bar (Filters, Views, Bulk Actions) */
.controls-bar {
  background: var(--bg-card);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-lg);
  padding: 16px 20px;
  margin-bottom: 20px;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
}

.filter-group {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 10px;
}

.custom-select {
  background: var(--bg-surface);
  border: 1px solid var(--border-subtle);
  color: var(--text-primary);
  padding: 8px 14px;
  border-radius: var(--radius-md);
  font-size: 0.86rem;
  cursor: pointer;
  transition: var(--transition);
}

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

.view-switcher {
  display: flex;
  background: var(--bg-surface);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
  padding: 3px;
  gap: 2px;
}

.view-btn {
  padding: 6px 12px;
  border: none;
  background: transparent;
  color: var(--text-secondary);
  border-radius: var(--radius-sm);
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 0.85rem;
  font-weight: 500;
  transition: var(--transition);
}

.view-btn.active {
  background: var(--primary);
  color: #FFF;
  box-shadow: 0 2px 8px var(--primary-glow);
}

/* Bulk Action Floating Bar */
.bulk-bar {
  background: linear-gradient(135deg, #1E1B4B, #312E81);
  border: 1px solid rgba(99, 102, 241, 0.4);
  border-radius: var(--radius-lg);
  padding: 12px 24px;
  margin-bottom: 20px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  box-shadow: var(--shadow-glow);
  animation: slideDown 0.3s ease;
}

@keyframes slideDown {
  from { opacity: 0; transform: translateY(-10px); }
  to { opacity: 1; transform: translateY(0); }
}

.bulk-title {
  font-weight: 600;
  color: #FFF;
  display: flex;
  align-items: center;
  gap: 10px;
}

.bulk-actions {
  display: flex;
  align-items: center;
  gap: 10px;
}

/* Modern Data Table */
.table-card {
  background: var(--bg-card);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-card);
  overflow: hidden;
}

.table-responsive {
  width: 100%;
  overflow-x: auto;
}

.leads-table {
  width: 100%;
  border-collapse: collapse;
  text-align: left;
  font-size: 0.88rem;
}

.leads-table th {
  background: rgba(255, 255, 255, 0.02);
  padding: 14px 16px;
  font-weight: 600;
  color: var(--text-secondary);
  border-bottom: 1px solid var(--border-subtle);
  white-space: nowrap;
}

.leads-table td {
  padding: 14px 16px;
  border-bottom: 1px solid var(--border-subtle);
  color: var(--text-primary);
  vertical-align: middle;
  transition: var(--transition);
}

.leads-table tr:hover td {
  background: rgba(255, 255, 255, 0.02);
}

.lead-name-cell {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.lead-name-title {
  font-weight: 600;
  color: var(--text-primary);
  font-size: 0.94rem;
  cursor: pointer;
}

.lead-name-title:hover {
  color: var(--primary);
}

.lead-address {
  font-size: 0.78rem;
  color: var(--text-muted);
  display: flex;
  align-items: center;
  gap: 4px;
}

/* Badges & Tags */
.badge {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 3px 9px;
  border-radius: 20px;
  font-size: 0.74rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.badge-status-new { background: rgba(56, 189, 248, 0.15); color: var(--status-new); border: 1px solid rgba(56, 189, 248, 0.3); }
.badge-status-contacted { background: rgba(129, 140, 248, 0.15); color: var(--status-contacted); border: 1px solid rgba(129, 140, 248, 0.3); }
.badge-status-interested { background: rgba(251, 191, 36, 0.15); color: var(--status-interested); border: 1px solid rgba(251, 191, 36, 0.3); }
.badge-status-follow_up { background: rgba(251, 146, 60, 0.15); color: var(--status-followup); border: 1px solid rgba(251, 146, 60, 0.3); }
.badge-status-qualified { background: rgba(192, 132, 252, 0.15); color: var(--status-qualified); border: 1px solid rgba(192, 132, 252, 0.3); }
.badge-status-converted { background: rgba(52, 211, 153, 0.15); color: var(--status-converted); border: 1px solid rgba(52, 211, 153, 0.3); }
.badge-status-lost { background: rgba(248, 113, 113, 0.15); color: var(--status-lost); border: 1px solid rgba(248, 113, 113, 0.3); }

.badge-priority-hot { background: rgba(239, 68, 68, 0.15); color: #EF4444; border: 1px solid rgba(239, 68, 68, 0.3); }
.badge-priority-warm { background: rgba(245, 158, 11, 0.15); color: #F59E0B; border: 1px solid rgba(245, 158, 11, 0.3); }
.badge-priority-cold { background: rgba(59, 130, 246, 0.15); color: #3B82F6; border: 1px solid rgba(59, 130, 246, 0.3); }

.badge-cat {
  background: rgba(255, 255, 255, 0.05);
  color: var(--text-secondary);
  border-radius: var(--radius-sm);
  padding: 3px 8px;
  font-size: 0.78rem;
  font-weight: 500;
}

/* Rating Stars */
.rating-pill {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  font-weight: 600;
  font-size: 0.82rem;
  color: #FBBF24;
}

/* Action Buttons in Table */
.action-buttons {
  display: flex;
  align-items: center;
  gap: 6px;
}

.btn-action {
  width: 32px;
  height: 32px;
  border-radius: var(--radius-sm);
  border: none;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: var(--transition);
  color: #FFF;
}

.btn-action svg {
  width: 15px;
  height: 15px;
}

.btn-wa {
  background: rgba(37, 211, 102, 0.15);
  color: var(--wa-green);
  border: 1px solid rgba(37, 211, 102, 0.3);
}

.btn-wa:hover {
  background: var(--wa-green);
  color: #FFF;
  box-shadow: 0 0 12px rgba(37, 211, 102, 0.4);
}

.btn-call {
  background: rgba(56, 189, 248, 0.15);
  color: var(--call-blue);
  border: 1px solid rgba(56, 189, 248, 0.3);
}

.btn-call:hover {
  background: var(--call-blue);
  color: #000;
  box-shadow: 0 0 12px rgba(56, 189, 248, 0.4);
}

.btn-mail {
  background: rgba(129, 140, 248, 0.15);
  color: var(--mail-violet);
  border: 1px solid rgba(129, 140, 248, 0.3);
}

.btn-mail:hover {
  background: var(--mail-violet);
  color: #FFF;
}

.btn-map {
  background: rgba(248, 113, 113, 0.15);
  color: var(--maps-red);
  border: 1px solid rgba(248, 113, 113, 0.3);
}

.btn-map:hover {
  background: var(--maps-red);
  color: #FFF;
}

/* Pagination Bar */
.pagination-bar {
  padding: 16px 20px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  border-top: 1px solid var(--border-subtle);
}

/* Modals */
.modal-overlay {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(0, 0, 0, 0.75);
  backdrop-filter: blur(8px);
  z-index: 1000;
  display: flex;
  align-items: center;
  justify-content: center;
  opacity: 0;
  pointer-events: none;
  transition: var(--transition);
}

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

.modal-dialog {
  background: var(--bg-surface);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-xl);
  width: 90%;
  max-width: 650px;
  box-shadow: var(--shadow-card);
  transform: translateY(20px) scale(0.97);
  transition: var(--transition);
  overflow: hidden;
  max-height: 90vh;
  display: flex;
  flex-direction: column;
}

.modal-overlay.active .modal-dialog {
  transform: translateY(0) scale(1);
}

.modal-header {
  padding: 20px 24px;
  border-bottom: 1px solid var(--border-subtle);
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.modal-body {
  padding: 24px;
  overflow-y: auto;
}

.modal-footer {
  padding: 18px 24px;
  border-top: 1px solid var(--border-subtle);
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 12px;
}

/* Drag & Drop Upload Zone */
.dropzone {
  border: 2px dashed rgba(99, 102, 241, 0.4);
  border-radius: var(--radius-lg);
  padding: 40px 20px;
  text-align: center;
  background: rgba(99, 102, 241, 0.03);
  cursor: pointer;
  transition: var(--transition);
}

.dropzone:hover, .dropzone.dragover {
  border-color: var(--primary);
  background: rgba(99, 102, 241, 0.08);
}

.dropzone-icon {
  width: 56px;
  height: 56px;
  margin: 0 auto 16px;
  border-radius: 50%;
  background: rgba(99, 102, 241, 0.12);
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--primary);
}

/* Lead Slide-over Drawer */
.lead-drawer {
  position: fixed;
  top: 0;
  right: 0;
  width: 520px;
  max-width: 90vw;
  height: 100vh;
  background: var(--bg-surface);
  border-left: 1px solid var(--border-subtle);
  box-shadow: -10px 0 30px rgba(0, 0, 0, 0.5);
  z-index: 1050;
  transform: translateX(100%);
  transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  display: flex;
  flex-direction: column;
}

.lead-drawer.active {
  transform: translateX(0);
}

.drawer-header {
  padding: 22px 24px;
  border-bottom: 1px solid var(--border-subtle);
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
}

.drawer-content {
  flex: 1;
  overflow-y: auto;
  padding: 24px;
  display: flex;
  flex-direction: column;
  gap: 24px;
}

.timeline {
  display: flex;
  flex-direction: column;
  gap: 16px;
  position: relative;
  padding-left: 20px;
  border-left: 2px solid var(--border-subtle);
}

.timeline-item {
  position: relative;
}

.timeline-dot {
  position: absolute;
  left: -27px;
  top: 2px;
  width: 12px;
  height: 12px;
  border-radius: 50%;
  background: var(--primary);
  border: 2px solid var(--bg-surface);
}

/* Toast Notifications */
.toast-container {
  position: fixed;
  bottom: 24px;
  right: 24px;
  z-index: 9999;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.toast {
  background: var(--bg-surface);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
  padding: 14px 18px;
  color: var(--text-primary);
  box-shadow: var(--shadow-card);
  display: flex;
  align-items: center;
  gap: 12px;
  font-size: 0.88rem;
  animation: slideInRight 0.3s ease;
  min-width: 280px;
}

.toast-success { border-left: 4px solid var(--status-converted); }
.toast-error { border-left: 4px solid var(--status-lost); }
.toast-info { border-left: 4px solid var(--primary); }

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

/* Responsive Breakpoints */
@media (max-width: 1024px) {
  .sidebar {
    transform: translateX(-100%);
  }
  .sidebar.mobile-open {
    transform: translateX(0);
  }
  .main-wrapper {
    margin-left: 0;
  }
  .top-header {
    padding: 0 16px;
  }
  .content-body {
    padding: 16px;
  }
  .search-box {
    width: 220px;
  }
}
