/* ==========================================================================
   Google Maps Scraper Studio Pro - Design System & Stylesheet
   ========================================================================== */

:root {
  --bg-main: #0a0d14;
  --bg-sidebar: #0f1422;
  --bg-card: rgba(19, 26, 42, 0.75);
  --bg-card-hover: rgba(27, 37, 58, 0.85);
  --bg-input: #151c2e;
  
  --border-color: rgba(255, 255, 255, 0.08);
  --border-focus: #10b981;
  
  --text-primary: #f1f5f9;
  --text-secondary: #94a3b8;
  --text-muted: #64748b;
  
  --accent-emerald: #10b981;
  --accent-emerald-glow: rgba(16, 185, 129, 0.25);
  --accent-cyan: #06b6d4;
  --accent-cyan-glow: rgba(6, 182, 212, 0.25);
  --accent-amber: #f59e0b;
  --accent-rose: #f43f5e;
  --accent-indigo: #6366f1;

  --radius-sm: 6px;
  --radius-md: 10px;
  --radius-lg: 16px;
  --radius-full: 9999px;

  --transition-fast: 0.15s ease;
  --transition-normal: 0.25s ease;
  --shadow-card: 0 10px 25px -5px rgba(0, 0, 0, 0.4), 0 8px 10px -6px rgba(0, 0, 0, 0.3);
}

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

body {
  font-family: 'Plus Jakarta Sans', -apple-system, BlinkMacSystemFont, sans-serif;
  background-color: var(--bg-main);
  color: var(--text-primary);
  min-height: 100vh;
  overflow-x: hidden;
  background-image: 
    radial-gradient(at 0% 0%, rgba(16, 185, 129, 0.07) 0px, transparent 50%),
    radial-gradient(at 100% 100%, rgba(6, 182, 212, 0.05) 0px, transparent 50%);
  background-attachment: fixed;
}

/* App Container Layout */
.app-container {
  display: grid;
  grid-template-columns: 270px 1fr;
  min-height: 100vh;
}

/* Sidebar Styling */
.sidebar {
  background-color: var(--bg-sidebar);
  border-right: 1px solid var(--border-color);
  padding: 24px 18px;
  display: flex;
  flex-direction: column;
  gap: 24px;
}

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

.logo-icon {
  width: 42px;
  height: 42px;
  background: linear-gradient(135deg, #10b981, #06b6d4);
  border-radius: var(--radius-md);
  display: flex;
  align-items: center;
  justify-content: center;
  color: #fff;
  font-size: 1.25rem;
  box-shadow: 0 4px 14px var(--accent-emerald-glow);
}

.logo-text h2 {
  font-size: 1.15rem;
  font-weight: 700;
  letter-spacing: -0.02em;
  color: #fff;
}

.logo-text span {
  font-size: 0.68rem;
  font-weight: 700;
  color: var(--accent-emerald);
  letter-spacing: 0.1em;
}

/* System Status Pill */
.system-status-card {
  background: rgba(255, 255, 255, 0.03);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  padding: 12px 14px;
}

.status-indicator {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 0.85rem;
  font-weight: 600;
}

.status-dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background-color: var(--accent-amber);
  box-shadow: 0 0 10px var(--accent-amber);
}

.status-dot.online {
  background-color: var(--accent-emerald);
  box-shadow: 0 0 10px var(--accent-emerald);
}

.status-dot.offline {
  background-color: var(--accent-rose);
  box-shadow: 0 0 10px var(--accent-rose);
}

.status-details small {
  color: var(--text-muted);
  font-size: 0.75rem;
}

/* Sidebar Navigation */
.sidebar-nav {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.nav-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 16px;
  color: var(--text-secondary);
  text-decoration: none;
  font-size: 0.9rem;
  font-weight: 500;
  border-radius: var(--radius-md);
  transition: all var(--transition-fast);
}

.nav-item i {
  font-size: 1.1rem;
  width: 20px;
}

.nav-item:hover {
  background-color: rgba(255, 255, 255, 0.05);
  color: #fff;
}

.nav-item.active {
  background: linear-gradient(90deg, rgba(16, 185, 129, 0.18), rgba(6, 182, 212, 0.05));
  color: var(--accent-emerald);
  border: 1px solid rgba(16, 185, 129, 0.3);
  font-weight: 600;
}

.nav-item .badge {
  margin-left: auto;
  background: var(--accent-emerald);
  color: #061a12;
  font-size: 0.7rem;
  font-weight: 700;
  padding: 2px 8px;
  border-radius: var(--radius-full);
}

/* Mini Stats */
.sidebar-stats {
  background: rgba(0, 0, 0, 0.25);
  border-radius: var(--radius-md);
  padding: 14px;
  border: 1px solid var(--border-color);
}

.sidebar-stats h4 {
  font-size: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--text-muted);
  margin-bottom: 10px;
}

.stat-mini-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}

.stat-mini-item {
  display: flex;
  flex-direction: column;
}

.stat-mini-val {
  font-size: 1.25rem;
  font-weight: 700;
  color: #fff;
}

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

.sidebar-footer {
  margin-top: auto;
  text-align: center;
  color: var(--text-muted);
  font-size: 0.8rem;
}

/* Main Content Area */
.main-content {
  padding: 30px 40px;
  display: flex;
  flex-direction: column;
  gap: 28px;
  max-width: 1400px;
  margin: 0 auto;
  width: 100%;
}

/* Top Bar */
.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.topbar-title h1 {
  font-size: 1.65rem;
  font-weight: 800;
  letter-spacing: -0.02em;
}

.topbar-title p {
  color: var(--text-secondary);
  font-size: 0.9rem;
  margin-top: 4px;
}

/* Card System */
.card {
  background: var(--bg-card);
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-card);
  overflow: hidden;
}

.card-header {
  padding: 20px 24px;
  border-bottom: 1px solid var(--border-color);
  display: flex;
  align-items: center;
}

.card-header h3 {
  font-size: 1.1rem;
  font-weight: 700;
  display: flex;
  align-items: center;
  gap: 10px;
}

.card-body {
  padding: 24px;
}

.grid-2-col {
  display: grid;
  grid-template-columns: 1.2fr 0.8fr;
  gap: 28px;
}

/* Forms & Inputs */
.form-group {
  margin-bottom: 20px;
}

.form-group label {
  display: flex;
  flex-direction: column;
  margin-bottom: 8px;
  font-size: 0.9rem;
  font-weight: 600;
}

.form-group label small {
  font-weight: 400;
  color: var(--text-muted);
  font-size: 0.78rem;
  margin-top: 2px;
}

input[type="text"],
input[type="number"],
textarea,
select {
  width: 100%;
  background: var(--bg-input);
  border: 1px solid var(--border-color);
  color: #fff;
  padding: 12px 16px;
  border-radius: var(--radius-md);
  font-family: inherit;
  font-size: 0.95rem;
  transition: all var(--transition-fast);
}

input:focus,
textarea:focus,
select:focus {
  outline: none;
  border-color: var(--border-focus);
  box-shadow: 0 0 0 3px var(--accent-emerald-glow);
}

.input-with-icon {
  position: relative;
  display: flex;
  align-items: center;
}

.input-with-icon i {
  position: absolute;
  left: 16px;
  color: var(--text-muted);
}

.input-with-icon input {
  padding-left: 44px;
}

/* Tag Input Container */
.tag-input-container {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  background: var(--bg-input);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  padding: 8px 12px;
  min-height: 48px;
}

.tag-item {
  background: rgba(16, 185, 129, 0.15);
  border: 1px solid rgba(16, 185, 129, 0.35);
  color: var(--accent-emerald);
  padding: 4px 10px;
  border-radius: var(--radius-sm);
  font-size: 0.85rem;
  font-weight: 600;
  display: flex;
  align-items: center;
  gap: 6px;
}

.tag-item i {
  cursor: pointer;
  font-size: 0.75rem;
}

.tag-input-container input {
  border: none;
  background: transparent;
  padding: 4px;
  flex: 1;
  min-width: 160px;
  color: #fff;
}

.tag-input-container input:focus {
  box-shadow: none;
}

/* Slider & Custom Range */
.slider-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 10px;
}

.slider-badge {
  background: rgba(6, 182, 212, 0.15);
  color: var(--accent-cyan);
  border: 1px solid rgba(6, 182, 212, 0.3);
  padding: 3px 10px;
  border-radius: var(--radius-full);
  font-size: 0.8rem;
  font-weight: 700;
}

.custom-range {
  width: 100%;
  accent-color: var(--accent-emerald);
  cursor: pointer;
}

.range-markers {
  display: flex;
  justify-content: space-between;
  color: var(--text-muted);
  font-size: 0.75rem;
  margin-top: 6px;
}

/* Features Grid Toggle */
.features-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 14px;
  margin-bottom: 20px;
}

.toggle-card {
  display: flex;
  align-items: center;
  justify-content: space-between;
  background: var(--bg-input);
  border: 1px solid var(--border-color);
  padding: 14px 16px;
  border-radius: var(--radius-md);
  cursor: pointer;
  transition: all var(--transition-fast);
}

.toggle-card:hover {
  background: var(--bg-card-hover);
  border-color: rgba(255, 255, 255, 0.15);
}

.toggle-card input[type="checkbox"] {
  display: none;
}

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

.toggle-icon {
  width: 36px;
  height: 36px;
  background: rgba(255, 255, 255, 0.05);
  border-radius: var(--radius-sm);
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--accent-cyan);
}

.toggle-text {
  display: flex;
  flex-direction: column;
}

.toggle-text strong {
  font-size: 0.88rem;
}

.toggle-text span {
  font-size: 0.72rem;
  color: var(--text-muted);
}

.toggle-switch {
  width: 40px;
  height: 22px;
  background: #334155;
  border-radius: var(--radius-full);
  position: relative;
  transition: background var(--transition-fast);
}

.toggle-switch::after {
  content: '';
  position: absolute;
  width: 16px;
  height: 16px;
  background: #fff;
  border-radius: 50%;
  top: 3px;
  left: 3px;
  transition: transform var(--transition-fast);
}

.toggle-card input:checked + .toggle-content + .toggle-switch {
  background: var(--accent-emerald);
}

.toggle-card input:checked + .toggle-content + .toggle-switch::after {
  transform: translateX(18px);
}

/* Advanced Accordion */
.advanced-settings {
  background: rgba(0, 0, 0, 0.2);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  margin-bottom: 20px;
}

.advanced-settings summary {
  padding: 12px 16px;
  cursor: pointer;
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--text-secondary);
}

.advanced-body {
  padding: 16px;
  border-top: 1px solid var(--border-color);
}

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

.btn-primary {
  background: linear-gradient(135deg, #10b981, #059669);
  color: #fff;
  box-shadow: 0 4px 14px var(--accent-emerald-glow);
}

.btn-primary:hover {
  background: linear-gradient(135deg, #059669, #047857);
  transform: translateY(-1px);
}

.btn-secondary {
  background: rgba(255, 255, 255, 0.08);
  color: var(--text-primary);
  border: 1px solid var(--border-color);
}

.btn-secondary:hover {
  background: rgba(255, 255, 255, 0.12);
}

.btn-success {
  background: #10b981;
  color: #061a12;
}

.btn-success:hover {
  background: #059669;
}

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

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

.btn-lg {
  padding: 14px 24px;
  font-size: 1rem;
}

.btn-sm {
  padding: 6px 12px;
  font-size: 0.8rem;
}

.btn-block {
  width: 100%;
}

/* Active Jobs Card */
.active-jobs-list {
  display: flex;
  flex-direction: column;
  gap: 12px;
  margin-bottom: 24px;
}

.job-progress-card {
  background: var(--bg-input);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  padding: 14px;
}

.job-progress-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 8px;
}

.job-title {
  font-weight: 700;
  font-size: 0.92rem;
}

.status-badge {
  padding: 3px 8px;
  border-radius: var(--radius-full);
  font-size: 0.72rem;
  font-weight: 700;
  text-transform: uppercase;
}

.status-badge.working {
  background: rgba(245, 158, 11, 0.15);
  color: var(--accent-amber);
  border: 1px solid rgba(245, 158, 11, 0.3);
  animation: pulse 2s infinite;
}

.status-badge.completed {
  background: rgba(16, 185, 129, 0.15);
  color: var(--accent-emerald);
  border: 1px solid rgba(16, 185, 129, 0.3);
}

.status-badge.failed {
  background: rgba(244, 63, 94, 0.15);
  color: var(--accent-rose);
  border: 1px solid rgba(244, 63, 94, 0.3);
}

.progress-bar-container {
  height: 6px;
  background: rgba(255, 255, 255, 0.06);
  border-radius: var(--radius-full);
  overflow: hidden;
  margin-top: 8px;
}

.progress-bar {
  height: 100%;
  background: linear-gradient(90deg, #10b981, #06b6d4);
  width: 40%;
  animation: progressIndeterminate 1.5s infinite linear;
}

@keyframes progressIndeterminate {
  0% { transform: translateX(-100%); width: 30%; }
  50% { width: 60%; }
  100% { transform: translateX(200%); width: 30%; }
}

@keyframes pulse {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.6; }
}

/* Tips Box */
.tips-box {
  background: rgba(245, 158, 11, 0.05);
  border: 1px solid rgba(245, 158, 11, 0.2);
  border-radius: var(--radius-md);
  padding: 16px;
}

.tips-box h4 {
  font-size: 0.88rem;
  margin-bottom: 8px;
  display: flex;
  align-items: center;
  gap: 8px;
}

.tips-box ul {
  padding-left: 20px;
  color: var(--text-secondary);
  font-size: 0.82rem;
  line-height: 1.5;
}

.tips-box li {
  margin-bottom: 6px;
}

/* TAB 2: Leads Toolbar & Metrics */
.leads-toolbar {
  padding: 20px;
  margin-bottom: 20px;
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.leads-toolbar-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 16px;
}

.current-job-selector {
  display: flex;
  align-items: center;
  gap: 10px;
}

.current-job-selector label {
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--text-secondary);
}

.custom-select {
  min-width: 260px;
}

.leads-metrics {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
}

.metric-pill {
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid var(--border-color);
  padding: 6px 12px;
  border-radius: var(--radius-full);
  font-size: 0.8rem;
  color: var(--text-secondary);
}

.metric-pill strong {
  color: #fff;
}

.export-actions {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

.leads-filters-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  flex-wrap: wrap;
  border-top: 1px solid var(--border-color);
  padding-top: 16px;
}

.search-box {
  position: relative;
  flex: 1;
  min-width: 260px;
}

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

.search-box input {
  padding-left: 40px;
  padding-top: 8px;
  padding-bottom: 8px;
  font-size: 0.88rem;
}

.quick-filter-chips {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

.filter-chip {
  background: var(--bg-input);
  border: 1px solid var(--border-color);
  color: var(--text-secondary);
  padding: 6px 12px;
  border-radius: var(--radius-full);
  font-size: 0.8rem;
  font-weight: 600;
  cursor: pointer;
  transition: all var(--transition-fast);
}

.filter-chip:hover {
  background: var(--bg-card-hover);
  color: #fff;
}

.filter-chip.active {
  background: var(--accent-emerald);
  color: #061a12;
  border-color: var(--accent-emerald);
}

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

.leads-table,
.history-table {
  width: 100%;
  border-collapse: collapse;
  text-align: left;
}

.leads-table th,
.history-table th {
  background: rgba(0, 0, 0, 0.2);
  padding: 14px 18px;
  font-size: 0.78rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--text-muted);
  border-bottom: 1px solid var(--border-color);
  font-weight: 700;
}

.leads-table td,
.history-table td {
  padding: 14px 18px;
  font-size: 0.88rem;
  border-bottom: 1px solid var(--border-color);
  vertical-align: middle;
}

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

.lead-title-cell {
  font-weight: 700;
  color: #fff;
}

.social-links-grid {
  display: flex;
  gap: 8px;
}

.social-icon-btn {
  width: 28px;
  height: 28px;
  border-radius: var(--radius-sm);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 0.85rem;
  text-decoration: none;
  transition: transform var(--transition-fast);
}

.social-icon-btn:hover {
  transform: scale(1.15);
}

.social-icon-btn.instagram { background: #e1306c; color: #fff; }
.social-icon-btn.facebook { background: #1877f2; color: #fff; }
.social-icon-btn.linkedin { background: #0a66c2; color: #fff; }
.social-icon-btn.disabled { background: rgba(255, 255, 255, 0.05); color: var(--text-muted); pointer-events: none; opacity: 0.4; }

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

/* Tab Management */
.tab-content {
  display: none;
}

.tab-content.active {
  display: block;
}

.empty-state {
  text-align: center;
  padding: 30px;
  color: var(--text-muted);
}

.empty-state i {
  margin-bottom: 12px;
  color: var(--text-secondary);
}

/* Utilities */
.text-accent { color: var(--accent-emerald); }
.text-cyan { color: var(--accent-cyan); }
.text-amber { color: var(--accent-amber); }
.text-rose { color: var(--accent-rose); }
.text-center { text-align: center; }
.py-5 { padding-top: 3rem; padding-bottom: 3rem; }
.flex-between { display: flex; justify-content: space-between; align-items: center; }

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

.toast {
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  backdrop-filter: blur(12px);
  padding: 14px 20px;
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-card);
  color: #fff;
  font-size: 0.88rem;
  font-weight: 500;
  display: flex;
  align-items: center;
  gap: 12px;
  animation: slideIn 0.3s ease;
}

.toast.success { border-left: 4px solid var(--accent-emerald); }
.toast.error { border-left: 4px solid var(--accent-rose); }
.toast.info { border-left: 4px solid var(--accent-cyan); }

@keyframes slideIn {
  from { transform: translateX(100%); opacity: 0; }
  to { transform: translateX(0); opacity: 1; }
}

/* Responsive */
@media (max-width: 1024px) {
  .app-container {
    grid-template-columns: 1fr;
  }
  .sidebar {
    display: none; /* Mobile navigation can be enhanced */
  }
  .grid-2-col {
    grid-template-columns: 1fr;
  }
}
