:root {
  --bg-primary: #0b0f19;
  --bg-secondary: #111827;
  --bg-tertiary: #1f2937;
  --bg-card: rgba(31, 41, 55, 0.65);
  --bg-card-hover: rgba(37, 49, 66, 0.85);
  --border-color: rgba(255, 255, 255, 0.08);
  --border-glow: rgba(59, 130, 246, 0.4);
  --text-primary: #f9fafb;
  --text-secondary: #9ca3af;
  --text-muted: #6b7280;
  --accent-primary: #3b82f6;
  --accent-gradient: linear-gradient(135deg, #3b82f6 0%, #8b5cf6 50%, #ec4899 100%);
  --accent-yahoo: #ff0033;
  --accent-yahoo-gradient: linear-gradient(135deg, #ff0033 0%, #ff4b4b 100%);
  --success: #10b981;
  --warning: #f59e0b;
  --danger: #ef4444;
  --info: #06b6d4;
  --radius-sm: 8px;
  --radius-md: 12px;
  --radius-lg: 16px;
  --radius-xl: 24px;
  --shadow-sm: 0 2px 8px rgba(0, 0, 0, 0.25);
  --shadow-lg: 0 10px 30px -5px rgba(0, 0, 0, 0.5);
  --font-family: 'Inter', -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", sans-serif;
  --transition: all 0.25s cubic-bezier(0.4, 0, 0.2, 1);
}

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

body {
  font-family: var(--font-family);
  background-color: var(--bg-primary);
  color: var(--text-primary);
  line-height: 1.6;
  min-height: 100vh;
  background-image: 
    radial-gradient(at 10% 10%, rgba(59, 130, 246, 0.12) 0px, transparent 50%),
    radial-gradient(at 90% 90%, rgba(236, 72, 153, 0.08) 0px, transparent 50%),
    radial-gradient(at 50% 50%, rgba(139, 92, 246, 0.05) 0px, transparent 50%);
  background-attachment: fixed;
}

.container {
  max-width: 1280px;
  margin: 0 auto;
  padding: 24px 20px;
}

/* Header */
.app-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding-bottom: 24px;
  border-bottom: 1px solid var(--border-color);
  margin-bottom: 28px;
}

.brand-section {
  display: flex;
  align-items: center;
  gap: 16px;
}

.logo-badge {
  background: var(--accent-yahoo-gradient);
  color: white;
  padding: 8px 14px;
  border-radius: var(--radius-md);
  font-weight: 800;
  font-size: 1.15rem;
  letter-spacing: -0.5px;
  box-shadow: 0 4px 14px rgba(255, 0, 51, 0.4);
}

.brand-info h1 {
  font-size: 1.4rem;
  font-weight: 700;
  letter-spacing: -0.5px;
}

.brand-info p {
  color: var(--text-secondary);
  font-size: 0.85rem;
}

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

.status-tag {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  background: rgba(16, 185, 129, 0.15);
  color: var(--success);
  border: 1px solid rgba(16, 185, 129, 0.3);
  padding: 6px 12px;
  border-radius: 9999px;
  font-size: 0.75rem;
  font-weight: 600;
}

.pulse-dot {
  width: 8px;
  height: 8px;
  background-color: currentColor;
  border-radius: 50%;
  animation: pulse 1.8s infinite ease-in-out;
}

@keyframes pulse {
  0% { transform: scale(0.95); opacity: 0.7; }
  50% { transform: scale(1.2); opacity: 1; }
  100% { transform: scale(0.95); opacity: 0.7; }
}

/* Geo-warning alert banner */
.geo-alert-banner {
  background: linear-gradient(135deg, rgba(245, 158, 11, 0.12) 0%, rgba(239, 68, 68, 0.12) 100%);
  border: 1px solid rgba(245, 158, 11, 0.3);
  border-radius: var(--radius-md);
  padding: 14px 18px;
  margin-bottom: 24px;
  display: flex;
  align-items: flex-start;
  gap: 14px;
}

.geo-alert-icon {
  font-size: 1.5rem;
  line-height: 1;
}

.geo-alert-body h4 {
  font-size: 0.95rem;
  font-weight: 600;
  color: #fbbf24;
  margin-bottom: 4px;
}

.geo-alert-body p {
  font-size: 0.82rem;
  color: var(--text-secondary);
  line-height: 1.45;
}

.geo-alert-body .tips {
  margin-top: 6px;
  font-size: 0.8rem;
  color: #cbd5e1;
}

/* Glassmorphism Card Panels */
.panel {
  background: var(--bg-card);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-lg);
  padding: 24px;
  margin-bottom: 24px;
  box-shadow: var(--shadow-sm);
  transition: var(--transition);
}

.panel:hover {
  border-color: rgba(255, 255, 255, 0.12);
}

/* Search Controls */
.search-form-grid {
  display: flex;
  gap: 12px;
  align-items: center;
}

.input-wrapper {
  position: relative;
  flex: 1;
}

.input-icon {
  position: absolute;
  left: 16px;
  top: 50%;
  transform: translateY(-50%);
  color: var(--text-muted);
  pointer-events: none;
}

.search-input {
  width: 100%;
  background: var(--bg-secondary);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  color: var(--text-primary);
  font-size: 1rem;
  padding: 14px 16px 14px 44px;
  outline: none;
  transition: var(--transition);
}

.search-input:focus {
  border-color: var(--accent-primary);
  box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.25);
  background: rgba(17, 24, 39, 0.95);
}

.page-select-wrapper {
  display: flex;
  align-items: center;
  background: var(--bg-secondary);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  padding: 0 12px;
  height: 50px;
}

.page-select-label {
  font-size: 0.8rem;
  color: var(--text-muted);
  margin-right: 8px;
}

.page-select {
  background: transparent;
  color: var(--text-primary);
  border: none;
  outline: none;
  font-size: 0.9rem;
  font-weight: 600;
  cursor: pointer;
}

.page-select option {
  background: var(--bg-secondary);
  color: var(--text-primary);
}

.btn-scrape {
  background: var(--accent-yahoo-gradient);
  color: white;
  border: none;
  border-radius: var(--radius-md);
  padding: 0 26px;
  height: 50px;
  font-weight: 700;
  font-size: 0.95rem;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  box-shadow: 0 4px 16px rgba(255, 0, 51, 0.35);
  transition: var(--transition);
  white-space: nowrap;
}

.btn-scrape:hover {
  transform: translateY(-1px);
  box-shadow: 0 6px 20px rgba(255, 0, 51, 0.5);
  filter: brightness(1.08);
}

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

.btn-scrape:disabled {
  opacity: 0.6;
  cursor: not-allowed;
  transform: none;
}

/* Quick keywords chips */
.suggestion-chips {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 14px;
}

.chips-label {
  font-size: 0.78rem;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.5px;
  font-weight: 600;
}

.chip {
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid var(--border-color);
  color: var(--text-secondary);
  padding: 4px 10px;
  border-radius: 9999px;
  font-size: 0.78rem;
  cursor: pointer;
  transition: var(--transition);
}

.chip:hover {
  background: rgba(59, 130, 246, 0.15);
  border-color: rgba(59, 130, 246, 0.3);
  color: var(--text-primary);
}

/* Settings Toggle & Accordion */
.settings-toggle-bar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-top: 18px;
  padding-top: 16px;
  border-top: 1px solid var(--border-color);
}

.mode-toggle {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 0.85rem;
}

.btn-link {
  background: none;
  border: none;
  color: var(--accent-primary);
  cursor: pointer;
  font-size: 0.85rem;
  font-weight: 600;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  transition: var(--transition);
}

.btn-link:hover {
  color: #60a5fa;
  text-decoration: underline;
}

.settings-panel {
  display: none;
  background: rgba(17, 24, 39, 0.7);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  padding: 18px;
  margin-top: 14px;
  animation: fadeIn 0.2s ease-in-out;
}

.settings-panel.open {
  display: block;
}

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

.settings-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
  gap: 16px;
}

.setting-card {
  background: rgba(31, 41, 55, 0.5);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-sm);
  padding: 14px;
}

.setting-header {
  font-size: 0.85rem;
  font-weight: 600;
  color: #e5e7eb;
  margin-bottom: 8px;
  display: flex;
  align-items: center;
  gap: 6px;
}

.switch-label {
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-size: 0.82rem;
  color: var(--text-secondary);
  cursor: pointer;
  margin-bottom: 8px;
}

.switch-label:last-child {
  margin-bottom: 0;
}

.switch-input {
  accent-color: var(--accent-primary);
  width: 16px;
  height: 16px;
  cursor: pointer;
}

.input-field-sm {
  width: 100%;
  background: var(--bg-secondary);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-sm);
  color: var(--text-primary);
  font-size: 0.82rem;
  padding: 8px 10px;
  outline: none;
  transition: var(--transition);
}

.input-field-sm:focus {
  border-color: var(--accent-primary);
}

.proxy-input-group {
  display: flex;
  gap: 8px;
  margin-top: 6px;
}

.btn-secondary {
  background: rgba(255, 255, 255, 0.08);
  border: 1px solid var(--border-color);
  color: var(--text-primary);
  border-radius: var(--radius-sm);
  padding: 6px 14px;
  font-size: 0.8rem;
  font-weight: 600;
  cursor: pointer;
  white-space: nowrap;
  transition: var(--transition);
}

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

/* Console Log Terminal */
.terminal-panel {
  background: #080c14;
  border: 1px solid #1e293b;
  border-radius: var(--radius-md);
  margin-bottom: 24px;
  overflow: hidden;
  box-shadow: 0 4px 20px rgba(0, 0, 0, 0.4);
}

.terminal-header {
  background: #0f172a;
  padding: 10px 16px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  border-bottom: 1px solid #1e293b;
}

.terminal-title {
  display: flex;
  align-items: center;
  gap: 8px;
  font-family: monospace;
  font-size: 0.8rem;
  color: #94a3b8;
}

.terminal-dots {
  display: flex;
  gap: 6px;
}

.terminal-dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
}

.dot-red { background: #ef4444; }
.dot-yellow { background: #f59e0b; }
.dot-green { background: #10b981; }

.terminal-body {
  padding: 14px;
  font-family: 'JetBrains Mono', 'Fira Code', 'Courier New', monospace;
  font-size: 0.78rem;
  color: #cbd5e1;
  max-height: 220px;
  overflow-y: auto;
  line-height: 1.5;
}

.log-line {
  margin-bottom: 4px;
  white-space: pre-wrap;
  word-break: break-all;
}

.log-INFO { color: #38bdf8; }
.log-CONFIG { color: #a78bfa; }
.log-EVASION { color: #f472b6; font-weight: 600; }
.log-NAVIGATE { color: #fbbf24; }
.log-SIMULATE { color: #34d399; }
.log-EXTRACT { color: #2dd4bf; font-weight: 600; }
.log-SUCCESS { color: #4ade80; font-weight: 700; }
.log-WARN { color: #fb923c; }
.log-ERROR { color: #f87171; font-weight: 700; }

/* Metrics Stats Grid */
.stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 16px;
  margin-bottom: 24px;
}

.stat-box {
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  padding: 16px;
  text-align: center;
}

.stat-label {
  font-size: 0.75rem;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.5px;
  font-weight: 600;
  margin-bottom: 4px;
}

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

.stat-value.highlight {
  background: var(--accent-gradient);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
}

/* Related Searches Bar */
.related-searches-box {
  background: rgba(31, 41, 55, 0.4);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  padding: 14px 18px;
  margin-bottom: 20px;
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 8px;
}

.related-title {
  font-size: 0.8rem;
  font-weight: 600;
  color: var(--text-secondary);
  display: flex;
  align-items: center;
  gap: 6px;
}

/* Results Toolbar */
.results-toolbar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 16px;
  gap: 12px;
  flex-wrap: wrap;
}

.results-filter-input {
  background: var(--bg-secondary);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-sm);
  color: var(--text-primary);
  font-size: 0.85rem;
  padding: 8px 14px;
  width: 240px;
  outline: none;
}

.results-filter-input:focus {
  border-color: var(--accent-primary);
}

.view-controls {
  display: flex;
  align-items: center;
  gap: 8px;
}

.btn-icon {
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid var(--border-color);
  color: var(--text-secondary);
  border-radius: var(--radius-sm);
  padding: 6px 12px;
  font-size: 0.8rem;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  transition: var(--transition);
}

.btn-icon.active, .btn-icon:hover {
  background: rgba(59, 130, 246, 0.15);
  border-color: rgba(59, 130, 246, 0.3);
  color: var(--text-primary);
}

.export-group {
  display: flex;
  align-items: center;
  gap: 6px;
}

/* Card View */
.results-cards-grid {
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.serp-card {
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  padding: 18px 20px;
  transition: var(--transition);
  position: relative;
}

.serp-card:hover {
  background: var(--bg-card-hover);
  border-color: rgba(59, 130, 246, 0.3);
  transform: translateY(-1px);
  box-shadow: var(--shadow-sm);
}

.card-top {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 6px;
}

.rank-badge {
  background: rgba(59, 130, 246, 0.15);
  color: #60a5fa;
  font-weight: 700;
  font-size: 0.75rem;
  padding: 2px 8px;
  border-radius: 9999px;
  border: 1px solid rgba(59, 130, 246, 0.3);
}

.display-url {
  font-size: 0.78rem;
  color: #10b981;
  text-decoration: none;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.serp-title {
  font-size: 1.15rem;
  font-weight: 600;
  margin-bottom: 8px;
}

.serp-title a {
  color: #60a5fa;
  text-decoration: none;
  transition: var(--transition);
}

.serp-title a:hover {
  color: #93c5fd;
  text-decoration: underline;
}

.serp-snippet {
  font-size: 0.88rem;
  color: #d1d5db;
  line-height: 1.5;
  margin-bottom: 12px;
}

.sitelinks-list {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 8px;
  padding-top: 8px;
  border-top: 1px dashed rgba(255, 255, 255, 0.08);
}

.sitelink-item {
  font-size: 0.78rem;
  color: #38bdf8;
  background: rgba(56, 189, 248, 0.08);
  border: 1px solid rgba(56, 189, 248, 0.2);
  padding: 4px 10px;
  border-radius: var(--radius-sm);
  text-decoration: none;
  transition: var(--transition);
}

.sitelink-item:hover {
  background: rgba(56, 189, 248, 0.18);
  color: #7dd3fc;
}

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

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

.serp-table th {
  background: rgba(17, 24, 39, 0.8);
  padding: 12px 14px;
  color: var(--text-muted);
  font-weight: 600;
  border-bottom: 1px solid var(--border-color);
  white-space: nowrap;
}

.serp-table td {
  padding: 12px 14px;
  border-bottom: 1px solid var(--border-color);
  vertical-align: top;
}

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

/* Empty & Loading States */
.empty-state {
  text-align: center;
  padding: 48px 20px;
  color: var(--text-muted);
}

.empty-icon {
  font-size: 2.8rem;
  margin-bottom: 12px;
  opacity: 0.7;
}

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

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

/* Responsive */
@media (max-width: 768px) {
  .search-form-grid {
    flex-direction: column;
    align-items: stretch;
  }
  .app-header {
    flex-direction: column;
    align-items: flex-start;
    gap: 12px;
  }
  .results-toolbar {
    flex-direction: column;
    align-items: stretch;
  }
  .results-filter-input {
    width: 100%;
  }
}
