/* ==========================================================================
   LIQUID DESIGN SYSTEM & DESIGN TOKENS
   ========================================================================== */
:root {
  color-scheme: light dark;
  /* Fonts */
  --font-heading: 'Outfit', sans-serif;
  --font-body: 'Plus Jakarta Sans', sans-serif;

  /* Theme: Dark Mode (Default) */
  --bg-color: #0b0f19;
  --text-primary: #f8fafc;
  --text-secondary: #94a3b8;
  
  --glass-bg: rgba(15, 23, 42, 0.45);
  --glass-border: rgba(255, 255, 255, 0.08);
  --glass-highlight: rgba(255, 255, 255, 0.03);
  --glass-shadow: rgba(0, 0, 0, 0.5);
  
  --input-bg: rgba(15, 23, 42, 0.6);
  --input-border: rgba(255, 255, 255, 0.12);
  --input-focus: rgba(99, 102, 241, 0.4);
  
  /* Primary & Accent Gradients (Liquid-themed) */
  --primary-gradient: linear-gradient(135deg, #6366f1 0%, #a855f7 50%, #ec4899 100%);
  --accent-blue: #38bdf8;
  --accent-purple: #c084fc;
  --accent-pink: #f472b6;
  
  /* Status Colors */
  --status-new-bg: rgba(99, 102, 241, 0.15);
  --status-new-text: #818cf8;
  --status-contacted-bg: rgba(56, 189, 248, 0.15);
  --status-contacted-text: #38bdf8;
  --status-qualified-bg: rgba(34, 211, 238, 0.15);
  --status-qualified-text: #22d3ee;
  --status-proposal-bg: rgba(251, 191, 36, 0.15);
  --status-proposal-text: #fbbf24;
  --status-won-bg: rgba(52, 211, 153, 0.15);
  --status-won-text: #34d399;
  --status-lost-bg: rgba(248, 113, 113, 0.15);
  --status-lost-text: #f87171;

  --border-radius-lg: 24px;
  --border-radius-md: 14px;
  --border-radius-sm: 8px;
  --transition-smooth: all 0.4s cubic-bezier(0.16, 1, 0.3, 1);
}

/* Light Theme Variables */
html[data-theme="light"] {
  --bg-color: #f1f5f9;
  --text-primary: #0f172a;
  --text-secondary: #475569;
  
  --glass-bg: rgba(255, 255, 255, 0.55);
  --glass-border: rgba(0, 0, 0, 0.08);
  --glass-highlight: rgba(255, 255, 255, 0.5);
  --glass-shadow: rgba(15, 23, 42, 0.08);
  
  --input-bg: rgba(255, 255, 255, 0.8);
  --input-border: rgba(0, 0, 0, 0.12);
  --input-focus: rgba(99, 102, 241, 0.25);
  
  --accent-blue: #0284c7;
  --accent-purple: #7c3aed;
  --accent-pink: #db2777;
  
  --status-new-bg: rgba(99, 102, 241, 0.1);
  --status-new-text: #4f46e5;
  --status-contacted-bg: rgba(14, 165, 233, 0.1);
  --status-contacted-text: #0284c7;
  --status-qualified-bg: rgba(6, 182, 212, 0.1);
  --status-qualified-text: #0891b2;
  --status-proposal-bg: rgba(217, 119, 6, 0.1);
  --status-proposal-text: #b45309;
  --status-won-bg: rgba(16, 185, 129, 0.1);
  --status-won-text: #059669;
  --status-lost-bg: rgba(220, 38, 38, 0.1);
  --status-lost-text: #dc2626;
}

/* ==========================================================================
   RESET & BASE STYLES
   ========================================================================== */
* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
  -webkit-tap-highlight-color: transparent;
}

body {
  font-family: var(--font-body);
  background-color: var(--bg-color);
  color: var(--text-primary);
  min-height: 100vh;
  overflow-x: hidden;
  position: relative;
  transition: background-color 0.5s ease;
}

/* ==========================================================================
   LIQUID DYNAMIC BACKGROUND
   ========================================================================== */
.liquid-bg {
  position: fixed;
  top: 0;
  left: 0;
  width: 100vw;
  height: 100vh;
  z-index: -1;
  overflow: hidden;
  filter: blur(80px);
  opacity: 0.8;
  pointer-events: none;
}

.blob {
  position: absolute;
  border-radius: 50%;
  mix-blend-mode: screen;
}

.blob-1 {
  width: 500px;
  height: 500px;
  background: radial-gradient(circle, rgba(99, 102, 241, 0.35) 0%, rgba(168, 85, 247, 0.05) 70%);
  top: -10%;
  left: -10%;
  animation: float-around 25s infinite alternate ease-in-out;
}

.blob-2 {
  width: 600px;
  height: 600px;
  background: radial-gradient(circle, rgba(236, 72, 153, 0.25) 0%, rgba(56, 189, 248, 0.05) 75%);
  bottom: -20%;
  right: -10%;
  animation: float-around 35s infinite alternate-reverse ease-in-out;
}

.blob-3 {
  width: 400px;
  height: 400px;
  background: radial-gradient(circle, rgba(168, 85, 247, 0.25) 0%, rgba(99, 102, 241, 0) 70%);
  top: 40%;
  left: 50%;
  animation: float-around 30s infinite alternate ease-in-out;
}

@keyframes float-around {
  0% {
    transform: translate(0, 0) scale(1) rotate(0deg);
  }
  33% {
    transform: translate(80px, 120px) scale(1.15) rotate(120deg);
  }
  66% {
    transform: translate(-100px, 60px) scale(0.9) rotate(240deg);
  }
  100% {
    transform: translate(0, 0) scale(1) rotate(360deg);
  }
}

/* ==========================================================================
   APP CONTAINER & GRID LAYOUT
   ========================================================================== */
.app-container {
  width: 100%;
  max-width: 98%;
  margin: 0 auto;
  padding: 24px 32px;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

/* Header */
.app-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 32px;
  padding: 16px 24px;
  background: var(--glass-bg);
  backdrop-filter: blur(25px);
  -webkit-backdrop-filter: blur(25px);
  border: 1px solid var(--glass-border);
  border-radius: var(--border-radius-md);
  box-shadow: 0 8px 32px var(--glass-shadow);
}

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

.logo-icon {
  font-size: 1.8rem;
  filter: drop-shadow(0 0 10px rgba(99, 102, 241, 0.6));
  animation: pulse-liquid 3s infinite ease-in-out;
}

@keyframes pulse-liquid {
  0%, 100% { transform: scale(1); filter: drop-shadow(0 0 10px rgba(99, 102, 241, 0.6)); }
  50% { transform: scale(1.1) translateY(-2px); filter: drop-shadow(0 0 20px rgba(168, 85, 247, 0.9)); }
}

.logo h1 {
  font-family: var(--font-heading);
  font-weight: 800;
  font-size: 1.6rem;
  background: var(--primary-gradient);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  letter-spacing: -0.5px;
}

.nav-controls {
  display: flex;
  align-items: center;
  gap: 12px;
}

/* Navigation Buttons */
.nav-btn {
  background: transparent;
  color: var(--text-secondary);
  border: 1px solid transparent;
  padding: 10px 18px;
  border-radius: 30px;
  font-family: var(--font-heading);
  font-weight: 600;
  font-size: 0.95rem;
  display: flex;
  align-items: center;
  gap: 8px;
  cursor: pointer;
  transition: var(--transition-smooth);
}

.nav-btn .icon {
  width: 18px;
  height: 18px;
  fill: currentColor;
}

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

.nav-btn.active {
  color: #fff;
  background: var(--primary-gradient);
  box-shadow: 0 4px 20px rgba(99, 102, 241, 0.4);
}

/* Theme Toggle Button */
.theme-toggle-btn {
  background: transparent;
  border: 1px solid var(--glass-border);
  color: var(--text-primary);
  width: 40px;
  height: 40px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: var(--transition-smooth);
}

.theme-toggle-btn:hover {
  background: rgba(255, 255, 255, 0.08);
  transform: scale(1.05);
}

.theme-toggle-btn .icon {
  width: 20px;
  height: 20px;
  fill: currentColor;
}

/* ==========================================================================
   GLASS CARDS & COMPONENT BASES
   ========================================================================== */
.glass-card {
  background: var(--glass-bg);
  backdrop-filter: blur(25px);
  -webkit-backdrop-filter: blur(25px);
  border: 1px solid var(--glass-border);
  box-shadow: 0 16px 48px var(--glass-shadow);
  border-radius: var(--border-radius-lg);
  padding: 32px;
  position: relative;
  overflow: hidden;
  transition: var(--transition-smooth);
}

.glass-card::before {
  content: "";
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 100%;
  background: linear-gradient(135deg, var(--glass-highlight) 0%, transparent 100%);
  pointer-events: none;
}

/* Tab Switching Animations */
.tab-content {
  display: none;
  opacity: 0;
  transform: translateY(15px);
  transition: opacity 0.5s ease, transform 0.5s ease;
}

.tab-content.active-tab {
  display: block;
  opacity: 1;
  transform: translateY(0);
}

/* Form Styles */
.card-header {
  margin-bottom: 28px;
}

.card-header h2 {
  font-family: var(--font-heading);
  font-weight: 700;
  font-size: 1.8rem;
  letter-spacing: -0.5px;
  margin-bottom: 6px;
}

.card-header p {
  color: var(--text-secondary);
  font-size: 0.95rem;
  line-height: 1.5;
}

.form-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 20px 24px;
}

.form-section-title {
  grid-column: 1 / -1;
  font-family: var(--font-heading);
  font-weight: 700;
  font-size: 1.1rem;
  color: var(--accent-blue);
  border-bottom: 1px solid var(--glass-border);
  padding-bottom: 8px;
  margin-top: 16px;
}

.form-group {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.form-group.full-width {
  grid-column: 1 / -1;
}

.form-group label {
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--text-primary);
  opacity: 0.9;
  letter-spacing: 0.2px;
}

.required {
  color: var(--accent-pink);
}

/* Liquid Styled Inputs */
input[type="text"],
input[type="email"],
input[type="tel"],
input[type="number"],
select,
textarea {
  font-family: var(--font-body);
  background: var(--input-bg);
  border: 1px solid var(--input-border);
  color: var(--text-primary);
  padding: 14px 16px;
  border-radius: var(--border-radius-md);
  font-size: 0.95rem;
  outline: none;
  transition: var(--transition-smooth);
}

input[type="text"]:focus,
input[type="email"]:focus,
input[type="tel"]:focus,
input[type="number"]:focus,
select:focus,
textarea:focus {
  border-color: rgba(99, 102, 241, 0.8);
  box-shadow: 0 0 0 4px var(--input-focus);
  transform: translateY(-1px);
}

select {
  appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' fill='none' viewBox='0 0 24 24' stroke='%2394a3b8'%3E%3Cpath stroke-linecap='round' stroke-linejoin='round' stroke-width='2' d='M19 9l-7 7-7-7'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 16px center;
  background-size: 16px;
  padding-right: 40px;
}

textarea {
  resize: vertical;
}

/* Error States */
.form-group.has-error input,
.form-group.has-error select {
  border-color: var(--status-lost-text);
  box-shadow: 0 0 0 3px rgba(239, 68, 68, 0.15);
}

.error-msg {
  color: var(--status-lost-text);
  font-size: 0.75rem;
  margin-top: 4px;
  display: none;
  font-weight: 500;
}

.form-group.has-error .error-msg {
  display: block;
}

/* Liquid Submit Button */
.form-actions {
  grid-column: 1 / -1;
  display: flex;
  justify-content: flex-end;
  margin-top: 24px;
}

.submit-btn {
  position: relative;
  overflow: hidden;
  background: var(--primary-gradient);
  color: #fff;
  border: none;
  padding: 16px 36px;
  border-radius: 30px;
  font-family: var(--font-heading);
  font-weight: 700;
  font-size: 1.05rem;
  cursor: pointer;
  box-shadow: 0 10px 25px rgba(99, 102, 241, 0.3);
  transition: var(--transition-smooth);
}

.submit-btn span {
  position: relative;
  z-index: 2;
}

.submit-btn:hover {
  transform: translateY(-2px);
  box-shadow: 0 14px 35px rgba(168, 85, 247, 0.5);
}

.submit-btn:active {
  transform: translateY(1px);
}

/* ==========================================================================
   SEARCH TAB & REAL-TIME FILTERS
   ========================================================================== */
.search-panel {
  margin-bottom: 24px;
  padding: 24px;
}

.search-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 20px;
}

.search-header h2 {
  font-family: var(--font-heading);
  font-size: 1.5rem;
  font-weight: 700;
}

.leads-count-badge {
  background: rgba(255, 255, 255, 0.08);
  border: 1px solid var(--glass-border);
  padding: 6px 14px;
  border-radius: 20px;
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--accent-blue);
}

.filters-row {
  display: grid;
  grid-template-columns: 2fr 1fr 1fr;
  gap: 16px;
}

.search-input-wrapper {
  position: relative;
  width: 100%;
}

.search-input-wrapper input {
  width: 100%;
  padding-left: 48px;
}

.search-field-icon {
  position: absolute;
  left: 16px;
  top: 50%;
  transform: translateY(-50%);
  width: 20px;
  height: 20px;
  fill: var(--text-secondary);
  pointer-events: none;
}

.filter-select-wrapper {
  position: relative;
}

.filter-select-wrapper select {
  width: 100%;
}

/* Leads List Containers */
.leads-list-container {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(320px, 1fr));
  gap: 20px;
  min-height: 200px;
}

/* Lead Cards (Liquid Style) */
.lead-card {
  position: relative;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  cursor: pointer;
  padding: 20px 22px !important;
}

.lead-card:hover {
  transform: translateY(-4px);
  box-shadow: 0 20px 40px rgba(0, 0, 0, 0.35);
  border-color: rgba(255, 255, 255, 0.2);
}

.lead-card-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  margin-bottom: 16px;
}

.lead-title-area {
  max-width: 70%;
}

.lead-name {
  font-family: var(--font-heading);
  font-weight: 700;
  font-size: 1.15rem;
  line-height: 1.3;
  margin-bottom: 4px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.lead-company {
  color: var(--text-secondary);
  font-size: 0.85rem;
  font-weight: 500;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* Fluid Status Badge */
.status-badge {
  padding: 4px 12px;
  border-radius: 20px;
  font-size: 0.75rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  backdrop-filter: blur(5px);
}

.status-new { background: var(--status-new-bg); color: var(--status-new-text); }
.status-contacted { background: var(--status-contacted-bg); color: var(--status-contacted-text); }
.status-qualified { background: var(--status-qualified-bg); color: var(--status-qualified-text); }
.status-proposal { background: var(--status-proposal-bg); color: var(--status-proposal-text); }
.status-closed_won { background: var(--status-won-bg); color: var(--status-won-text); }
.status-closed_lost { background: var(--status-lost-bg); color: var(--status-lost-text); }

.lead-card-body {
  margin-bottom: 16px;
}

.lead-meta-item {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 0.85rem;
  color: var(--text-secondary);
  margin-bottom: 8px;
}

.lead-meta-item:last-child {
  margin-bottom: 0;
}

.lead-meta-icon {
  width: 16px;
  height: 16px;
  fill: var(--text-secondary);
}

.lead-card-footer {
  border-top: 1px solid var(--glass-border);
  padding-top: 12px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 0.8rem;
  color: var(--text-secondary);
  opacity: 0.8;
}

.plant-badge {
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid var(--glass-border);
  padding: 2px 8px;
  border-radius: 6px;
  font-size: 0.75rem;
  font-weight: 500;
  text-transform: capitalize;
}

/* ==========================================================================
   INTERACTIVE FEEDBACKS & LOADING STATES
   ========================================================================== */
.loading-state,
.empty-state {
  grid-column: 1 / -1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 60px 20px;
  text-align: center;
  color: var(--text-secondary);
}

.spinner {
  width: 40px;
  height: 40px;
  border: 4px solid var(--glass-border);
  border-top-color: var(--accent-blue);
  border-radius: 50%;
  animation: spin 1s infinite linear;
  margin-bottom: 16px;
}

@keyframes spin {
  to { transform: rotate(360deg); }
}

/* Toasts */
.toast {
  position: fixed;
  bottom: 24px;
  left: 50%;
  transform: translateX(-50%) translateY(100px);
  padding: 14px 28px;
  background: var(--primary-gradient);
  color: #fff;
  border-radius: 30px;
  box-shadow: 0 10px 30px rgba(99, 102, 241, 0.4);
  font-family: var(--font-heading);
  font-weight: 600;
  font-size: 0.95rem;
  z-index: 1000;
  transition: transform 0.5s cubic-bezier(0.175, 0.885, 0.32, 1.275), opacity 0.5s ease;
  opacity: 0;
  text-align: center;
}

.toast.show {
  transform: translateX(-50%) translateY(0);
  opacity: 1;
}

/* ==========================================================================
   MODAL COMPONENT
   ========================================================================== */
.modal-overlay {
  position: fixed;
  top: 0;
  left: 0;
  width: 100vw;
  height: 100vh;
  background: rgba(11, 15, 25, 0.6);
  backdrop-filter: blur(15px);
  -webkit-backdrop-filter: blur(15px);
  z-index: 2000;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 16px;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.4s ease;
}

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

.modal-content {
  width: 100%;
  max-width: 600px;
  max-height: 90vh;
  overflow-y: auto;
  border-radius: var(--border-radius-lg);
  padding: 36px;
  position: relative;
  transform: scale(0.9);
  transition: transform 0.4s cubic-bezier(0.16, 1, 0.3, 1);
}

.modal-overlay.show .modal-content {
  transform: scale(1);
}

.close-modal-btn {
  position: absolute;
  top: 20px;
  right: 20px;
  background: transparent;
  border: none;
  color: var(--text-primary);
  font-size: 2rem;
  cursor: pointer;
  line-height: 1;
  width: 40px;
  height: 40px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 50%;
  transition: var(--transition-smooth);
}

.close-modal-btn:hover {
  background: rgba(255, 255, 255, 0.08);
}

/* Detailed Lead View Inside Modal */
.modal-lead-title {
  margin-bottom: 24px;
}

.modal-lead-title h3 {
  font-family: var(--font-heading);
  font-size: 1.8rem;
}

/* Media Queries for responsive headers */
@media (max-width: 768px) {
  .app-header {
    flex-direction: column;
    align-items: flex-start;
    gap: 16px;
    padding: 16px;
  }
  .logo h1 {
    font-size: 1.3rem;
  }
  .card-header h2, .search-header h2, .modal-lead-title h3 {
    font-size: 1.4rem;
  }
  .nav-controls {
    width: 100%;
    flex-wrap: wrap;
    justify-content: space-between;
  }
}

.modal-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 24px;
  margin-bottom: 24px;
}

.modal-section {
  grid-column: 1 / -1;
}

.modal-label {
  font-size: 0.8rem;
  text-transform: uppercase;
  letter-spacing: 1px;
  color: var(--text-secondary);
  margin-bottom: 6px;
  font-weight: 700;
}

.modal-value {
  font-size: 1.05rem;
  color: var(--text-primary);
  font-weight: 500;
}

.modal-value-text {
  font-size: 0.95rem;
  color: var(--text-primary);
  line-height: 1.6;
  background: rgba(255, 255, 255, 0.03);
  padding: 16px;
  border-radius: var(--border-radius-md);
  border: 1px solid var(--glass-border);
}

/* ==========================================================================
   APP FOOTER
   ========================================================================== */
.app-footer {
  margin-top: auto;
  padding: 40px 0 16px 0;
  text-align: center;
  font-size: 0.85rem;
  color: var(--text-secondary);
  opacity: 0.6;
}

/* ==========================================================================
   ADMIN DASHBOARD STYLES
   ========================================================================== */
.dashboard-container { max-width: 1400px; padding: 24px 32px; }

/* Alerts */
.alerts-section { margin-bottom: 24px; }
.alert-card.warning-glow { border-color: rgba(244, 63, 94, 0.4); box-shadow: 0 0 20px rgba(244, 63, 94, 0.2); }
.alert-card h3 { color: #f43f5e; font-family: var(--font-heading); margin-bottom: 8px; display: flex; align-items: center; }
.alert-item { background: rgba(255,255,255,0.05); padding: 12px 16px; margin-top: 8px; border-radius: var(--border-radius-sm); border-left: 4px solid #f43f5e; display: flex; justify-content: space-between; align-items: center; }
.alert-action { background: #f43f5e; color: #fff; text-decoration: none; padding: 6px 12px; border-radius: 4px; font-size: 0.8rem; font-weight: bold; }

/* KPIs */
.kpi-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: 24px; margin-bottom: 32px; }
.kpi-card { padding: 24px; text-align: center; }
.kpi-title { font-size: 1rem; color: var(--text-secondary); text-transform: uppercase; font-weight: 600; letter-spacing: 1px; margin-bottom: 8px; }
.kpi-value { font-size: 3rem; font-family: var(--font-heading); font-weight: 800; background: var(--primary-gradient); -webkit-background-clip: text; -webkit-text-fill-color: transparent; }

/* Charts */
.charts-grid { display: grid; grid-template-columns: 1fr 2fr; gap: 24px; margin-bottom: 32px; }
.chart-container { padding: 24px; display: flex; flex-direction: column; }
.chart-container h3 { font-family: var(--font-heading); margin-bottom: 16px; font-size: 1.2rem; }
.canvas-wrapper { position: relative; height: 300px; width: 100%; flex-grow: 1; }

/* Table Section */
.table-section { padding: 24px; }
.table-header { display: flex; justify-content: space-between; align-items: center; margin-bottom: 20px; }
.table-actions { display: flex; gap: 12px; }
.table-search, .table-select { background: var(--input-bg); border: 1px solid var(--input-border); color: var(--text-primary); padding: 10px 14px; border-radius: var(--border-radius-sm); outline: none; }
.table-responsive { overflow-x: auto; }
.leads-table { width: 100%; border-collapse: collapse; text-align: left; }
.leads-table th, .leads-table td { padding: 16px; border-bottom: 1px solid var(--glass-border); }
.leads-table th { font-family: var(--font-heading); font-size: 0.9rem; color: var(--text-secondary); font-weight: 700; text-transform: uppercase; letter-spacing: 0.5px; }
.leads-table tbody tr:hover { background: rgba(255, 255, 255, 0.03); }

/* ==========================================================================
   RESPONSIVE MEDIA QUERIES (MOBILE FIRST + WEB COEXISTENCE)
   ========================================================================== */
@media (max-width: 768px) {
  .form-grid {
    grid-template-columns: 1fr;
  }
  
  .filters-row {
    grid-template-columns: 1fr;
  }
  
  .leads-list-container {
    grid-template-columns: 1fr;
  }
  
  .form-actions {
    flex-direction: column;
    align-items: stretch;
  }
  
  .app-header {
    flex-direction: column;
    gap: 16px;
    padding: 16px;
    align-items: stretch;
    text-align: center;
  }
  
  .logo {
    justify-content: center;
  }
  
  .nav-controls {
    justify-content: center;
    width: 100%;
    flex-wrap: wrap;
    gap: 8px;
  }
  
  #user-profile {
    width: 100%;
    justify-content: center;
    margin-bottom: 4px;
  }
  
  .nav-btn {
    flex: 1 1 auto;
    justify-content: center;
    padding: 10px 12px;
    font-size: 0.82rem;
  }
  
  .glass-card {
    padding: 20px;
  }
  
  .modal-grid {
    grid-template-columns: 1fr;
  }
  
  .modal-content {
    padding: 20px 16px;
    max-height: 92vh;
    width: 95%;
  }
  
  .modal-actions {
    flex-direction: column;
    gap: 8px;
  }
  
  .modal-btn {
    width: 100%;
  }
}

/* Light Theme Specific Adjustments */
html[data-theme="light"] .blob {
  mix-blend-mode: multiply;
  opacity: 0.15;
}
html[data-theme="light"] select {
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' fill='none' viewBox='0 0 24 24' stroke='%23475569'%3E%3Cpath stroke-linecap='round' stroke-linejoin='round' stroke-width='2' d='M19 9l-7 7-7-7'/%3E%3C/svg%3E");
}
html[data-theme="light"] .leads-count-badge {
  background: rgba(0, 0, 0, 0.05);
}
html[data-theme="light"] .lead-card:hover {
  box-shadow: 0 15px 30px rgba(15, 23, 42, 0.08);
  border-color: rgba(0, 0, 0, 0.15);
}
html[data-theme="light"] .leads-table tbody tr:hover {
  background: rgba(0, 0, 0, 0.02);
}
html[data-theme="light"] .modal-value-text {
  background: rgba(0, 0, 0, 0.02);
}

/* ── ULTIMATE ANTI-INVERSION HACKS FOR AGGRESSIVE MOBILE BROWSERS ── */
/* Some mobile browsers ignore meta tags. We use background-image to force them to skip inversion. */
html[data-theme="light"], 
html[data-theme="light"] body {
  background-color: transparent !important;
  background-image: linear-gradient(0deg, #f1f5f9, #f1f5f9) !important;
}
html[data-theme="light"] .glass-card,
html[data-theme="light"] .card {
  background-color: transparent !important;
  background-image: linear-gradient(0deg, #ffffff, #ffffff) !important;
}
html[data-theme="light"] .form-input,
html[data-theme="light"] select {
  background-color: transparent !important;
  background-image: linear-gradient(0deg, #ffffff, #ffffff) !important;
}

/* Mobile Input Text Styling Fixes */
@media (max-width: 768px) {
  input[type="text"],
  input[type="email"],
  input[type="tel"],
  input[type="number"],
  input[type="date"],
  input[type="datetime-local"],
  select,
  textarea,
  .modal-form-input,
  .form-input,
  .filter-input,
  .filter-select,
  .location-select {
    font-size: 16px !important;
    width: 100% !important;
    max-width: 100% !important;
    box-sizing: border-box !important;
    padding: 12px 14px !important;
    line-height: 1.4 !important;
    min-height: 44px !important;
    border-radius: 8px !important;
  }

  .form-group {
    width: 100% !important;
    margin-bottom: 16px !important;
  }
}

/* ── CHATBOT CONVERSATION UI STYLES ── */
.chat-container {
  display: flex;
  flex-direction: column;
  height: 100%;
  background: var(--bg-card);
}
.chat-header {
  padding: 16px 20px;
  background: var(--bg-card);
  border-bottom: 1px solid var(--glass-border);
  display: flex;
  align-items: center;
  gap: 14px;
}
.chat-body {
  flex: 1;
  padding: 20px;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 14px;
  background: var(--bg-input, rgba(15, 23, 42, 0.4));
  scrollbar-width: thin;
}
.chat-bubble {
  max-width: 80%;
  padding: 12px 16px;
  border-radius: 14px;
  font-size: 0.9rem;
  line-height: 1.5;
  position: relative;
  box-shadow: 0 2px 8px rgba(0,0,0,0.1);
  word-break: break-word;
}
.chat-bubble-external {
  align-self: flex-start;
  background: var(--bg-card);
  color: var(--text-primary);
  border: 1px solid var(--glass-border);
  border-top-left-radius: 2px;
}
.chat-bubble-internal {
  align-self: center;
  width: 92%;
  max-width: 92%;
  background: rgba(245, 158, 11, 0.1);
  border: 1px solid rgba(245, 158, 11, 0.35);
  color: var(--text-primary);
  border-radius: 10px;
}
.chat-bubble-staff {
  align-self: flex-end;
  background: linear-gradient(135deg, #6366f1, #4f46e5);
  color: #ffffff;
  border-top-right-radius: 2px;
}
.chat-meta {
  font-size: 0.72rem;
  opacity: 0.85;
  margin-bottom: 4px;
  display: flex;
  align-items: center;
  gap: 6px;
}
.chat-input-bar {
  padding: 16px 20px;
  background: var(--bg-card);
  border-top: 1px solid var(--glass-border);
  display: flex;
  flex-direction: column;
  gap: 10px;
}
.chat-scope-toggle {
  display: flex;
  gap: 8px;
}
.chat-scope-btn {
  padding: 5px 14px;
  border-radius: 20px;
  font-size: 0.78rem;
  font-weight: 600;
  cursor: pointer;
  border: 1px solid var(--glass-border);
  background: transparent;
  color: var(--text-secondary);
  transition: all 0.2s ease;
}
.chat-scope-btn.active-internal {
  background: rgba(239, 68, 68, 0.15);
  color: #ef4444;
  border-color: rgba(239, 68, 68, 0.4);
}
.chat-scope-btn.active-external {
  background: rgba(59, 130, 246, 0.15);
  color: #3b82f6;
  border-color: rgba(59, 130, 246, 0.4);
}
