/* ==========================================================================
   Design System Variables & Setup
   ========================================================================== */

:root {
  --font-primary: 'Inter', system-ui, -apple-system, sans-serif;
  --font-accent: 'Outfit', var(--font-primary);

  /* Colors */
  --bg-dark: #020617;
  --bg-slate: #0b1329;
  --card-bg: rgba(15, 23, 42, 0.65);
  --card-border: rgba(59, 130, 246, 0.12);
  --card-border-hover: rgba(59, 130, 246, 0.3);

  --text-white: #f8fafc;
  --text-light: #e2e8f0;
  --text-muted: #94a3b8;
  --text-dark: #475569;

  --primary: #3b82f6;
  --primary-glow: rgba(59, 130, 246, 0.25);
  --primary-hover: #2563eb;
  
  --success: #10b981;
  --success-glow: rgba(16, 185, 129, 0.2);
  --warning: #f59e0b;
  --danger: #ef4444;

  --radius-sm: 8px;
  --radius-md: 14px;
  --radius-lg: 20px;
  
  --transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

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

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

/* Smooth Scrolling */
html {
  scroll-behavior: smooth;
}

/* ==========================================================================
   Background Glow Orbs
   ========================================================================== */

.gradient-bg {
  position: fixed;
  top: 0;
  left: 0;
  width: 100vw;
  height: 100vh;
  z-index: -1;
  overflow: hidden;
  background: radial-gradient(circle at 50% 50%, #070e22 0%, var(--bg-dark) 100%);
}

.glow-orb {
  position: absolute;
  border-radius: 50%;
  filter: blur(120px);
  opacity: 0.15;
  mix-blend-mode: screen;
}

.orb-1 {
  width: 500px;
  height: 500px;
  background: radial-gradient(circle, #3b82f6 0%, rgba(59, 130, 246, 0) 70%);
  top: -10%;
  right: -5%;
  animation: floatOrb 25s infinite alternate ease-in-out;
}

.orb-2 {
  width: 600px;
  height: 600px;
  background: radial-gradient(circle, #8b5cf6 0%, rgba(139, 92, 246, 0) 70%);
  bottom: -15%;
  left: -5%;
  animation: floatOrb 30s infinite alternate-reverse ease-in-out;
}

@keyframes floatOrb {
  0% { transform: translate(0, 0) scale(1); }
  50% { transform: translate(60px, -40px) scale(1.1); }
  100% { transform: translate(-40px, 50px) scale(0.95); }
}

/* ==========================================================================
   App Container & Header
   ========================================================================== */

.app-container {
  max-width: 1400px;
  margin: 0 auto;
  padding: 20px 40px 40px 40px;
  display: flex;
  flex-direction: column;
  min-height: 100vh;
}

.app-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 15px 0 30px 0;
  border-bottom: 1px solid rgba(255, 255, 255, 0.05);
  margin-bottom: 40px;
}

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

/* SVG Icon Styles */
.icon-svg {
  width: 24px;
  height: 24px;
  display: inline-block;
  vertical-align: middle;
}

.logo-svg {
  color: var(--primary);
  width: 28px;
  height: 28px;
  filter: drop-shadow(0 0 8px var(--primary));
  animation: pulseLogo 2.2s infinite ease-in-out;
}

.stat-svg {
  color: var(--primary);
  width: 26px;
  height: 26px;
}

.empty-svg {
  width: 60px;
  height: 60px;
  color: var(--text-dark);
}

.export-svg {
  width: 16px;
  height: 16px;
  color: var(--text-white);
  margin-right: 6px;
}

.logo-text {
  font-family: var(--font-accent);
  font-size: 22px;
  font-weight: 800;
  letter-spacing: -0.5px;
  background: linear-gradient(135deg, #fff 40%, #a5b4fc 100%);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
}

.header-status {
  display: flex;
  align-items: center;
  gap: 8px;
  background: rgba(255, 255, 255, 0.03);
  padding: 8px 16px;
  border-radius: 50px;
  border: 1px solid rgba(255, 255, 255, 0.05);
}

.status-indicator {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background-color: var(--success);
  box-shadow: 0 0 10px var(--success);
}

.status-label {
  font-size: 13px;
  font-weight: 500;
  color: var(--text-light);
}

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

.user-profile {
  display: flex;
  align-items: center;
  gap: 10px;
  background: rgba(255, 255, 255, 0.02);
  border: 1px solid rgba(255, 255, 255, 0.04);
  padding: 6px 12px;
  border-radius: 40px;
  transition: var(--transition);
}

.user-profile:hover {
  border-color: rgba(59, 130, 246, 0.2);
  background: rgba(59, 130, 246, 0.02);
}

.user-avatar {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  border: 1.5px solid var(--primary);
  background-color: rgba(255, 255, 255, 0.05);
}

.user-name {
  font-size: 13px;
  font-weight: 600;
  color: var(--text-light);
  max-width: 120px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.logout-btn {
  background: transparent;
  border: none;
  color: var(--text-muted);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 4px;
  border-radius: 50%;
  transition: var(--transition);
}

.logout-btn:hover {
  color: var(--danger);
  background: rgba(239, 68, 68, 0.1);
}

.logout-icon-svg {
  width: 16px;
  height: 16px;
}

/* ==========================================================================
   Hero Section
   ========================================================================== */

.hero-section {
  text-align: center;
  margin-bottom: 50px;
  animation: fadeInDown 0.8s ease-out;
}

.hero-title {
  font-family: var(--font-accent);
  font-size: 54px;
  font-weight: 800;
  line-height: 1.15;
  letter-spacing: -1.5px;
  margin-bottom: 16px;
  color: var(--text-white);
}

.gradient-text {
  background: linear-gradient(135deg, #60a5fa 0%, #3b82f6 50%, #8b5cf6 100%);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  text-shadow: 0 0 40px rgba(59, 130, 246, 0.15);
}

.hero-subtitle {
  font-size: 17px;
  font-weight: 400;
  line-height: 1.6;
  max-width: 760px;
  margin: 0 auto 40px auto;
  color: var(--text-muted);
}

/* System Stats Cards */
.stats-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 24px;
  max-width: 960px;
  margin: 0 auto;
}

.stat-card {
  display: flex;
  align-items: center;
  gap: 20px;
  background: var(--card-bg);
  border: 1px solid var(--card-border);
  border-radius: var(--radius-md);
  padding: 20px 24px;
  backdrop-filter: blur(12px);
  transition: var(--transition);
  box-shadow: 0 4px 30px rgba(0, 0, 0, 0.2);
}

.stat-card:hover {
  transform: translateY(-4px);
  border-color: var(--card-border-hover);
  box-shadow: 0 10px 30px rgba(59, 130, 246, 0.08);
}

.stat-icon {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 12px;
  background: rgba(255, 255, 255, 0.03);
  border-radius: var(--radius-sm);
  border: 1px solid rgba(255, 255, 255, 0.05);
}

.stat-info {
  text-align: left;
}

.stat-value {
  font-family: var(--font-accent);
  font-size: 26px;
  font-weight: 700;
  color: var(--text-white);
  line-height: 1.2;
}

.stat-label {
  font-size: 13px;
  font-weight: 500;
  color: var(--text-muted);
}

/* ==========================================================================
   Main Workspace Layout
   ========================================================================== */

.main-workspace {
  display: grid;
  grid-template-columns: 460px minmax(0, 1fr);
  gap: 32px;
  align-items: start;
  margin-bottom: 60px;
}

.glass-card {
  background: var(--card-bg);
  border: 1px solid var(--card-border);
  border-radius: var(--radius-lg);
  backdrop-filter: blur(16px);
  box-shadow: 0 8px 32px rgba(0, 0, 0, 0.3);
  overflow: hidden;
  transition: border-color 0.3s;
}

.glass-card:hover {
  border-color: rgba(59, 130, 246, 0.22);
}

.card-header {
  padding: 28px 28px 20px 28px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.04);
}

.card-title {
  font-family: var(--font-accent);
  font-size: 20px;
  font-weight: 700;
  color: var(--text-white);
  margin-bottom: 6px;
}

.card-desc {
  font-size: 13px;
  color: var(--text-muted);
  line-height: 1.4;
}

/* ==========================================================================
   Dashboard Setup Form
   ========================================================================== */

#scraper-form {
  padding: 28px;
  display: flex;
  flex-direction: column;
  gap: 20px;
}

.form-mode-switch {
  display: flex;
  background: rgba(0, 0, 0, 0.3);
  border-radius: var(--radius-sm);
  padding: 4px;
  border: 1px solid rgba(255, 255, 255, 0.03);
}

.mode-btn {
  flex: 1;
  background: transparent;
  border: none;
  padding: 10px;
  font-family: var(--font-primary);
  font-size: 13px;
  font-weight: 600;
  color: var(--text-muted);
  cursor: pointer;
  border-radius: 6px;
  transition: var(--transition);
}

.mode-btn.active {
  background: var(--primary);
  color: var(--text-white);
  box-shadow: 0 4px 12px rgba(59, 130, 246, 0.3);
}

.form-section-fields {
  display: none;
  flex-direction: column;
  gap: 16px;
}

.form-section-fields.active {
  display: flex;
  animation: fadeIn 0.4s ease-out;
}

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

.form-group label {
  font-size: 13px;
  font-weight: 600;
  color: var(--text-light);
  letter-spacing: 0.2px;
}

.form-group input,
.form-group textarea {
  width: 100%;
  background: rgba(0, 0, 0, 0.2);
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: var(--radius-sm);
  padding: 12px 16px;
  color: var(--text-white);
  font-family: var(--font-primary);
  font-size: 14px;
  outline: none;
  transition: var(--transition);
}

.form-group input:focus,
.form-group textarea:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px var(--primary-glow);
  background: rgba(0, 0, 0, 0.35);
}

.field-hint {
  font-size: 11px;
  color: var(--text-muted);
}

.divider-text {
  text-align: center;
  position: relative;
  margin: 10px 0;
}

.divider-text span {
  font-size: 10px;
  font-weight: 700;
  color: var(--text-muted);
  background: #0f172a;
  padding: 4px 12px;
  border-radius: 20px;
  border: 1px solid rgba(255, 255, 255, 0.05);
  position: relative;
  z-index: 2;
}

.divider-text::before {
  content: '';
  position: absolute;
  top: 50%;
  left: 0;
  width: 100%;
  height: 1px;
  background: rgba(255, 255, 255, 0.05);
  z-index: 1;
}

/* Submit Button */
.submit-btn {
  margin-top: 10px;
  width: 100%;
  background: linear-gradient(135deg, var(--primary) 0%, var(--primary-hover) 100%);
  border: none;
  border-radius: var(--radius-sm);
  padding: 14px;
  color: var(--text-white);
  font-family: var(--font-accent);
  font-size: 15px;
  font-weight: 700;
  cursor: pointer;
  transition: var(--transition);
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  box-shadow: 0 4px 15px rgba(59, 130, 246, 0.25);
}

.submit-btn:hover {
  transform: translateY(-2px);
  box-shadow: 0 8px 25px rgba(59, 130, 246, 0.4);
}

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

/* Loading Spinners */
.spinner-mini {
  display: inline-block;
  width: 18px;
  height: 18px;
  border: 2px solid rgba(255, 255, 255, 0.3);
  border-radius: 50%;
  border-top-color: #fff;
  animation: spin 0.8s linear infinite;
}

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

.hidden {
  display: none !important;
}

/* ==========================================================================
   Right Column: Status Tracker & Results
   ========================================================================== */

.status-results-container {
  display: flex;
  flex-direction: column;
  gap: 32px;
  width: 100%;
  max-width: 100%;
  overflow: hidden;
}

/* Empty State Card */
.empty-state {
  padding: 80px 40px;
  text-align: center;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  animation: fadeIn 0.6s ease-out;
}

.empty-icon {
  margin-bottom: 24px;
  opacity: 0.6;
  filter: drop-shadow(0 0 15px var(--primary-glow));
}

.empty-state h3 {
  font-family: var(--font-accent);
  font-size: 22px;
  color: var(--text-white);
  margin-bottom: 12px;
}

.empty-state p {
  color: var(--text-muted);
  max-width: 440px;
  font-size: 14px;
  line-height: 1.6;
}

/* Active Status Tracker Card */
.status-card {
  padding: 30px;
  text-align: center;
  animation: slideInUp 0.5s cubic-bezier(0.18, 0.89, 0.32, 1.28);
}

.status-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 30px;
  padding-bottom: 16px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.04);
}

.status-badge {
  background: var(--primary-glow);
  color: #93c5fd;
  border: 1px solid rgba(59, 130, 246, 0.3);
  font-size: 12px;
  font-weight: 700;
  padding: 6px 14px;
  border-radius: 50px;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  animation: pulseBadge 1.5s infinite alternate ease-in-out;
}

.status-job-id {
  font-size: 13px;
  color: var(--text-muted);
}

.status-body {
  padding: 10px 0;
}

.pulse-loader {
  position: relative;
  width: 80px;
  height: 80px;
  margin: 0 auto 24px auto;
}

.loader-circle {
  width: 100%;
  height: 100%;
  border-radius: 50%;
  border: 3px solid transparent;
  border-top-color: var(--primary);
  border-bottom-color: var(--primary);
  animation: spin 1.2s linear infinite;
}

.loader-glow {
  position: absolute;
  top: 5px;
  left: 5px;
  right: 5px;
  bottom: 5px;
  border-radius: 50%;
  background: radial-gradient(circle, var(--primary) 0%, rgba(59, 130, 246, 0) 70%);
  opacity: 0.3;
  animation: pulseGlow 1.5s infinite alternate ease-in-out;
}

.status-message-title {
  font-family: var(--font-accent);
  font-size: 20px;
  color: var(--text-white);
  margin-bottom: 10px;
}

.status-message-detail {
  font-size: 14px;
  color: var(--text-muted);
  max-width: 480px;
  margin: 0 auto;
  line-height: 1.5;
}

/* ==========================================================================
   Results Table & Exports
   ========================================================================== */

.results-card {
  animation: fadeIn 0.6s ease-out;
}

.results-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 24px 28px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.04);
}

.export-btn {
  background: var(--success);
  border: none;
  border-radius: var(--radius-sm);
  padding: 10px 20px;
  color: var(--text-white);
  font-family: var(--font-accent);
  font-size: 14px;
  font-weight: 700;
  cursor: pointer;
  transition: var(--transition);
  display: flex;
  align-items: center;
  gap: 8px;
  box-shadow: 0 4px 12px var(--success-glow);
}

.export-btn:hover {
  transform: translateY(-2px);
  background: #059669;
  box-shadow: 0 6px 18px rgba(16, 185, 129, 0.4);
}

.export-btn:active {
  transform: translateY(0);
}

/* Table Design */
.table-responsive {
  width: 100%;
  overflow-x: auto;
  border-radius: 0 0 var(--radius-lg) var(--radius-lg);
}

/* Custom scrollbar for horizontal responsive scroll */
.table-responsive::-webkit-scrollbar {
  height: 8px;
}
.table-responsive::-webkit-scrollbar-track {
  background: rgba(0, 0, 0, 0.2);
  border-radius: 4px;
}
.table-responsive::-webkit-scrollbar-thumb {
  background: rgba(59, 130, 246, 0.2);
  border-radius: 4px;
}
.table-responsive::-webkit-scrollbar-thumb:hover {
  background: rgba(59, 130, 246, 0.45);
}

.leads-table {
  width: 100%;
  min-width: 900px; /* Forces scrollbar on smaller screens instead of shrinking */
  border-collapse: collapse;
  text-align: left;
}

.leads-table th {
  background: rgba(255, 255, 255, 0.015);
  font-family: var(--font-accent);
  font-size: 13px;
  font-weight: 600;
  color: var(--text-muted);
  padding: 16px 24px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.04);
  letter-spacing: 0.3px;
}

.leads-table td {
  padding: 16px 24px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.03);
  font-size: 14px;
  color: var(--text-light);
  white-space: nowrap;
}

.leads-table tr:last-child td {
  border-bottom: none;
}

.leads-table tbody tr {
  transition: background 0.2s;
}

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

.leads-table td a {
  color: var(--primary);
  text-decoration: none;
  font-weight: 500;
  transition: color 0.2s;
}

.leads-table td a:hover {
  color: #60a5fa;
  text-decoration: underline;
}

/* Custom styles for columns */
.leads-table td.email-col {
  color: var(--success);
  font-weight: 500;
}

.leads-table td.phone-col {
  color: #a78bfa;
}

.leads-table td.empty-table-cell {
  white-space: normal;
  text-align: center;
  padding: 60px 30px;
  color: var(--text-muted);
  line-height: 1.6;
}

/* ==========================================================================
   Footer
   ========================================================================== */

.app-footer {
  text-align: center;
  padding: 40px 0 20px 0;
  border-top: 1px solid rgba(255, 255, 255, 0.05);
  margin-top: auto;
}

.app-footer p {
  font-size: 13px;
  color: var(--text-dark);
}

/* ==========================================================================
   Keyframes Animations
   ========================================================================== */

@keyframes fadeIn {
  from { opacity: 0; }
  to { opacity: 1; }
}

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

@keyframes slideInUp {
  from {
    opacity: 0;
    transform: translateY(30px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

@keyframes pulseLogo {
  0%, 100% { filter: drop-shadow(0 0 10px rgba(59, 130, 246, 0.4)); }
  50% { filter: drop-shadow(0 0 20px rgba(59, 130, 246, 0.8)); }
}

@keyframes pulseBadge {
  0% { box-shadow: 0 0 5px rgba(59, 130, 246, 0.2); }
  100% { box-shadow: 0 0 15px rgba(59, 130, 246, 0.6); }
}

@keyframes pulseGlow {
  0% { transform: scale(0.9); opacity: 0.2; }
  100% { transform: scale(1.15); opacity: 0.4; }
}

/* ==========================================================================
   Responsive Breakpoints
   ========================================================================== */

@media (max-width: 1150px) {
  .main-workspace {
    grid-template-columns: 1fr;
  }
  
  .stats-grid {
    grid-template-columns: 1fr;
    max-width: 460px;
  }
}

@media (max-width: 768px) {
  .app-container {
    padding: 10px 20px 20px 20px;
  }
  
  .hero-title {
    font-size: 38px;
  }
  
  .stat-card {
    padding: 16px;
  }
  
  .leads-table th, .leads-table td {
    padding: 12px 16px;
  }
}
