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

:root {
  --font-sans: 'Outfit', -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  
  /* Color Palette - Light Theme (Default) */
  --bg-darker: #f8fafc;
  --bg-dark: #f1f5f9;
  --bg-card: rgba(255, 255, 255, 0.7);
  --bg-hover: rgba(241, 245, 249, 0.85);
  
  --border-light: rgba(15, 23, 42, 0.08);
  --border-focus: rgba(6, 182, 212, 0.4);
  
  --text-primary: #0f172a;
  --text-secondary: #475569;
  --text-muted: #64748b;
  
  /* Brand Colors */
  --color-wti: #0891b2;      /* Cyan */
  --color-margin: #d97706;   /* Amber */
  --color-gazole: #475569;   /* Slate/Silver */
  --color-e10: #059669;      /* Emerald */
  --color-sp95: #7c3aed;     /* Violet */
  --color-sp98: #db2777;     /* Pink */
  
  --accent: #4f46e5;         /* Indigo */
  --accent-glow: rgba(79, 70, 229, 0.1);
  --logo-gradient: linear-gradient(135deg, #0f172a 30%, #475569 100%);
  
  --shadow-premium: 0 10px 30px -10px rgba(0, 0, 0, 0.08);
  --shadow-premium-hover: 0 20px 40px -15px rgba(0, 0, 0, 0.15);
  --border-hover: rgba(15, 23, 42, 0.15);
  
  --radial-bg-1: rgba(6, 182, 212, 0.03);
  --radial-bg-2: rgba(99, 102, 241, 0.03);
  --bg-btn-group: rgba(15, 23, 42, 0.05);
  --bg-input: rgba(15, 23, 42, 0.03);
  --bg-station-item: rgba(15, 23, 42, 0.02);
  --bg-station-item-hover: rgba(15, 23, 42, 0.05);
  --bg-breakdown: rgba(15, 23, 42, 0.02);
  --border-dashed: rgba(15, 23, 42, 0.06);
}

body.dark-theme {
  /* Color Palette - Dark Theme Overrides */
  --bg-darker: #050b14;
  --bg-dark: #0a1120;
  --bg-card: rgba(15, 23, 42, 0.65);
  --bg-hover: rgba(30, 41, 59, 0.85);
  
  --border-light: rgba(255, 255, 255, 0.08);
  --border-focus: rgba(6, 182, 212, 0.4);
  
  --text-primary: #f8fafc;
  --text-secondary: #94a3b8;
  --text-muted: #64748b;
  
  /* Brand Colors */
  --color-wti: #06b6d4;      /* Cyan */
  --color-margin: #fbbf24;   /* Amber */
  --color-gazole: #94a3b8;   /* Slate/Silver */
  --color-e10: #10b981;      /* Emerald */
  --color-sp95: #8b5cf6;     /* Violet */
  --color-sp98: #ec4899;     /* Pink */
  
  --accent: #6366f1;         /* Indigo */
  --accent-glow: rgba(99, 102, 241, 0.15);
  --logo-gradient: linear-gradient(135deg, #f8fafc 30%, #94a3b8 100%);
  
  --shadow-premium: 0 8px 32px 0 rgba(0, 0, 0, 0.37);
  --shadow-premium-hover: 0 12px 40px 0 rgba(0, 0, 0, 0.5);
  --border-hover: rgba(255, 255, 255, 0.15);
  
  --radial-bg-1: rgba(6, 182, 212, 0.05);
  --radial-bg-2: rgba(99, 102, 241, 0.05);
  --bg-btn-group: rgba(0, 0, 0, 0.2);
  --bg-input: rgba(0, 0, 0, 0.25);
  --bg-station-item: rgba(255, 255, 255, 0.02);
  --bg-station-item-hover: rgba(255, 255, 255, 0.05);
  --bg-breakdown: rgba(255, 255, 255, 0.02);
  --border-dashed: rgba(255, 255, 255, 0.03);
}

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

body {
  font-family: var(--font-sans);
  background-color: var(--bg-darker);
  background-image: 
    radial-gradient(circle at 10% 20%, var(--radial-bg-1) 0%, transparent 40%),
    radial-gradient(circle at 90% 80%, var(--radial-bg-2) 0%, transparent 40%);
  background-attachment: fixed;
  color: var(--text-primary);
  min-height: 100vh;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  transition: background-color 0.3s ease, color 0.3s ease;
}

.container {
  max-width: 1280px;
  margin: 0 auto;
  padding: 2rem 1.5rem;
}

/* Header & Brand */
header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 2.5rem;
  padding-bottom: 1.5rem;
  border-bottom: 1px solid var(--border-light);
}

.logo-group {
  display: flex;
  align-items: center;
  gap: 0.75rem;
}

.logo-icon {
  font-size: 2.25rem;
  filter: drop-shadow(0 0 10px rgba(6, 182, 212, 0.5));
  animation: float 4s ease-in-out infinite;
}

.logo-text h1 {
  font-size: 1.75rem;
  font-weight: 800;
  letter-spacing: -0.025em;
  background: var(--logo-gradient);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
}

.logo-text span {
  font-size: 0.875rem;
  color: var(--color-wti);
  font-weight: 500;
}

.badge-live {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  background: rgba(16, 185, 129, 0.1);
  border: 1px solid rgba(16, 185, 129, 0.2);
  color: #34d399;
  padding: 0.35rem 0.75rem;
  border-radius: 9999px;
  font-size: 0.813rem;
  font-weight: 600;
}

.badge-live::before {
  content: '';
  width: 8px;
  height: 8px;
  background-color: #10b981;
  border-radius: 50%;
  box-shadow: 0 0 8px #10b981;
  animation: pulse 1.5s infinite;
}

/* Grid & Layout */
.dashboard-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 1.5rem;
  margin-bottom: 2.5rem;
}

@media (min-width: 1024px) {
  .dashboard-grid {
    grid-template-columns: 1fr 1.8fr;
  }
}

/* Cards & Glassmorphism */
.card {
  background: var(--bg-card);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border: 1px solid var(--border-light);
  border-radius: 1rem;
  padding: 1.5rem;
  box-shadow: var(--shadow-premium);
  transition: transform 0.3s ease, border-color 0.3s ease, box-shadow 0.3s ease, background-color 0.3s ease;
}

.card:hover {
  border-color: var(--border-hover);
  box-shadow: var(--shadow-premium-hover);
}

.card-title {
  font-size: 1.125rem;
  font-weight: 600;
  margin-bottom: 1.25rem;
  display: flex;
  justify-content: space-between;
  align-items: center;
  color: var(--text-primary);
}

/* Stats Widget */
.stats-row {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 1rem;
  margin-bottom: 1.5rem;
}

@media (min-width: 640px) {
  .stats-row {
    grid-template-columns: repeat(4, 1fr);
  }
}

.stat-box {
  background: var(--bg-station-item);
  border: 1px solid var(--border-light);
  border-radius: 0.75rem;
  padding: 1rem;
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
}

.stat-label {
  font-size: 0.75rem;
  font-weight: 500;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--text-secondary);
}

.stat-value {
  font-size: 1.5rem;
  font-weight: 700;
  color: var(--text-primary);
}

.stat-box.wti { border-left: 3px solid var(--color-wti); }
.stat-box.gazole { border-left: 3px solid var(--color-gazole); }
.stat-box.e10 { border-left: 3px solid var(--color-e10); }
.stat-box.margin { border-left: 3px solid var(--color-margin); }

/* Filters & Controls */
.controls-bar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-wrap: wrap;
  gap: 1rem;
  margin-bottom: 1.25rem;
  padding-bottom: 0.75rem;
  border-bottom: 1px solid var(--border-light);
}

.button-group {
  display: flex;
  background: var(--bg-btn-group);
  border: 1px solid var(--border-light);
  padding: 0.25rem;
  border-radius: 0.5rem;
  gap: 0.25rem;
  transition: background-color 0.3s ease;
}

.btn-filter {
  background: transparent;
  border: none;
  color: var(--text-secondary);
  font-family: var(--font-sans);
  font-size: 0.813rem;
  font-weight: 600;
  padding: 0.375rem 0.75rem;
  border-radius: 0.375rem;
  cursor: pointer;
  transition: all 0.2s ease;
}

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

.btn-filter.active {
  background: var(--accent);
  color: #fff;
  box-shadow: 0 0 10px rgba(99, 102, 241, 0.4);
}

/* Search autocomplete */
.search-container {
  position: relative;
  width: 100%;
}

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

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

.search-input {
  width: 100%;
  background: var(--bg-input);
  border: 1px solid var(--border-light);
  border-radius: 0.75rem;
  padding: 0.875rem 1rem 0.875rem 2.75rem;
  color: var(--text-primary);
  font-family: var(--font-sans);
  font-size: 0.938rem;
  outline: none;
  transition: all 0.25s ease;
}

.search-input:focus {
  border-color: var(--color-wti);
  box-shadow: 0 0 0 3px rgba(6, 182, 212, 0.15);
}

.autocomplete-dropdown {
  position: absolute;
  top: 100%;
  left: 0;
  width: 100%;
  background: var(--bg-dark);
  border: 1px solid var(--border-light);
  border-radius: 0.75rem;
  margin-top: 0.5rem;
  max-height: 250px;
  overflow-y: auto;
  z-index: 50;
  box-shadow: 0 10px 25px -5px rgba(0,0,0,0.5);
  display: none;
}

.autocomplete-item {
  padding: 0.75rem 1rem;
  cursor: pointer;
  transition: background 0.15s ease;
  display: flex;
  justify-content: space-between;
  align-items: center;
  border-bottom: 1px solid var(--border-light);
}

.autocomplete-item:hover {
  background: var(--bg-hover);
}

.autocomplete-item span.cp {
  color: var(--color-wti);
  font-weight: 600;
  font-size: 0.875rem;
}

.autocomplete-item span.city {
  color: var(--text-primary);
  font-size: 0.875rem;
}

/* Station listing and details */
.station-list {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
  max-height: 400px;
  overflow-y: auto;
  padding-right: 0.25rem;
}

.station-item {
  background: var(--bg-station-item);
  border: 1px solid var(--border-light);
  border-radius: 0.75rem;
  padding: 1rem;
  cursor: pointer;
  transition: all 0.2s ease, background-color 0.2s ease;
  position: relative;
}

.station-item:hover {
  background: var(--bg-station-item-hover);
  border-color: var(--border-hover);
}

.station-item.active {
  border-color: var(--accent);
  background: rgba(99, 102, 241, 0.05);
  box-shadow: inset 0 0 10px rgba(99, 102, 241, 0.1);
}

.station-item-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  margin-bottom: 0.35rem;
}

.station-brand {
  font-weight: 600;
  color: var(--text-primary);
  font-size: 0.938rem;
}

.station-price-tag {
  background: var(--bg-btn-group);
  padding: 0.2rem 0.5rem;
  border-radius: 0.25rem;
  font-size: 0.813rem;
  font-weight: 700;
  color: var(--color-e10);
}

.station-address {
  font-size: 0.75rem;
  color: var(--text-secondary);
}

/* Station Details Section */
.station-detail-view {
  display: grid;
  grid-template-columns: 1fr;
  gap: 1.5rem;
  margin-top: 1.5rem;
}

@media (min-width: 768px) {
  .station-detail-view {
    grid-template-columns: 1fr 1fr;
  }
}

.latency-badge {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  background: rgba(251, 191, 36, 0.1);
  border: 1px solid rgba(251, 191, 36, 0.2);
  color: #fbbf24;
  padding: 0.5rem 1rem;
  border-radius: 0.5rem;
  font-weight: 600;
  font-size: 0.875rem;
  margin-top: 0.5rem;
}

.latency-value {
  font-size: 1.25rem;
  font-weight: 800;
  color: var(--color-margin);
}

/* Custom Scrollbars */
::-webkit-scrollbar {
  width: 6px;
  height: 6px;
}
::-webkit-scrollbar-track {
  background: rgba(0, 0, 0, 0.1);
}
::-webkit-scrollbar-thumb {
  background: var(--border-light);
  border-radius: 3px;
}
::-webkit-scrollbar-thumb:hover {
  background: var(--text-muted);
}

/* Animations */
@keyframes float {
  0% { transform: translateY(0px); }
  50% { transform: translateY(-5px); }
  100% { transform: translateY(0px); }
}

@keyframes pulse {
  0% { transform: scale(0.9); opacity: 0.5; }
  50% { transform: scale(1.1); opacity: 1; }
  100% { transform: scale(0.9); opacity: 0.5; }
}

.intro-desc {
  color: var(--text-secondary);
  font-size: 0.938rem;
  max-width: 600px;
  margin-bottom: 2rem;
}

.footer {
  text-align: center;
  padding: 2.5rem 0;
  color: var(--text-muted);
  font-size: 0.813rem;
  border-top: 1px solid var(--border-light);
  margin-top: 3rem;
}

.footer a {
  color: var(--color-wti);
  text-decoration: none;
}

.footer a:hover {
  text-decoration: underline;
}

.empty-state {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 3rem 1.5rem;
  text-align: center;
  color: var(--text-secondary);
  background: rgba(255, 255, 255, 0.01);
  border: 1px dashed var(--border-light);
  border-radius: 0.75rem;
}

.empty-state-icon {
  font-size: 2.5rem;
  margin-bottom: 1rem;
  color: var(--text-muted);
}

.rankings-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 1.5rem;
}

@media (min-width: 1024px) {
  .rankings-grid {
    grid-template-columns: 1fr 1fr;
  }
}

.ranking-table th, .ranking-table td {
  padding: 0.625rem 0.5rem;
  border-bottom: 1px solid var(--border-light);
}

.ranking-table tr:hover {
  background: var(--bg-station-item-hover);
}

/* Price Breakdown Component */
.price-breakdown-container {
  margin-top: 1.25rem;
  padding: 1.25rem;
  background: var(--bg-breakdown);
  border: 1px solid var(--border-light);
  border-radius: 0.75rem;
  backdrop-filter: blur(8px);
}

.price-breakdown-title {
  font-size: 0.813rem;
  font-weight: 600;
  color: var(--text-secondary);
  margin-bottom: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  display: flex;
  align-items: center;
  gap: 0.35rem;
}

.breakdown-bar {
  display: flex;
  height: 16px;
  border-radius: 9999px;
  overflow: hidden;
  background: rgba(0, 0, 0, 0.3);
  margin-bottom: 1rem;
  border: 1px solid rgba(255, 255, 255, 0.05);
  box-shadow: inset 0 2px 4px rgba(0, 0, 0, 0.5);
}

.breakdown-segment {
  height: 100%;
  transition: width 0.4s cubic-bezier(0.4, 0, 0.2, 1);
  position: relative;
  border-right: 1px solid rgba(0, 0, 0, 0.15);
}

.breakdown-segment:last-child {
  border-right: none;
}

.breakdown-segment.wti { background: var(--color-wti); }
.breakdown-segment.ticpe { background: var(--color-sp95); }
.breakdown-segment.tva { background: var(--color-sp98); }
.breakdown-segment.distributor { background: var(--color-margin); }

.breakdown-legend {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 0.5rem 1rem;
}

@media (min-width: 640px) {
  .breakdown-legend {
    grid-template-columns: repeat(4, 1fr);
  }
}

.legend-item {
  font-size: 0.75rem;
  color: var(--text-secondary);
  display: flex;
  align-items: center;
  gap: 0.35rem;
}

.legend-item span {
  font-weight: 600;
  color: var(--text-primary);
}

.legend-item .dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  display: inline-block;
  flex-shrink: 0;
}

.legend-item .dot.wti { background-color: var(--color-wti); box-shadow: 0 0 6px var(--color-wti); }
.legend-item .dot.ticpe { background-color: var(--color-sp95); box-shadow: 0 0 6px var(--color-sp95); }
.legend-item .dot.tva { background-color: var(--color-sp98); box-shadow: 0 0 6px var(--color-sp98); }
.legend-item .dot.distributor { background-color: var(--color-margin); box-shadow: 0 0 6px var(--color-margin); }

/* Station list local filter input */
.station-filter-wrapper {
  width: 100%;
  padding: 0 0.1rem;
}

.station-filter-input {
  width: 100%;
  background: var(--bg-input);
  border: 1px solid var(--border-light);
  border-radius: 0.5rem;
  padding: 0.5rem 0.75rem;
  color: var(--text-primary);
  font-family: var(--font-sans);
  font-size: 0.813rem;
  outline: none;
  transition: all 0.25s ease;
}

.station-filter-input:focus {
  border-color: var(--color-wti);
  box-shadow: 0 0 0 2px rgba(6, 182, 212, 0.15);
  background: var(--bg-hover);
}

/* Enhancements to Station List Items */
.station-item-modifier {
  font-size: 0.75rem;
  color: var(--text-secondary);
  font-weight: 500;
  margin-top: -0.1rem;
  margin-bottom: 0.25rem;
}

.station-item-details {
  display: flex;
  flex-direction: column;
  gap: 0.15rem;
  border-top: 1px dashed var(--border-dashed);
  padding-top: 0.4rem;
  margin-top: 0.4rem;
}

.station-item-detail-row {
  display: flex;
  align-items: center;
  gap: 0.35rem;
  font-size: 0.75rem;
  color: var(--text-muted);
}

.station-item-detail-icon {
  font-size: 0.813rem;
  flex-shrink: 0;
}

/* Theme Toggle Button */
.btn-theme-toggle {
  background: var(--bg-card);
  border: 1px solid var(--border-light);
  color: var(--text-primary);
  width: 38px;
  height: 38px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  font-size: 1.125rem;
  transition: all 0.25s ease;
  box-shadow: var(--shadow-premium);
  outline: none;
}

.btn-theme-toggle:hover {
  border-color: var(--accent);
  transform: scale(1.05);
  background: var(--bg-hover);
}

