/* ============================================================
   Dazzling EBikes — Global Stylesheet
   Design: eco-friendly, clean, minimalistic
   Palette: #8BC34A primary, #C8E6C9 light, #33691E dark accent
   ============================================================ */

/* --- Reset & Base --- */
*, *::before, *::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

:root {
  --green-primary:  #8BC34A;
  --green-light:    #C8E6C9;
  --green-dark:     #33691E;
  --green-mid:      #558B2F;
  --green-pale:     #F1F8E9;
  --white:          #ffffff;
  --charcoal:       #333333;
  --charcoal-light: #555555;
  --grey-light:     #f5f5f5;
  --grey-border:    #e0e0e0;
  --shadow-sm:      0 2px 8px rgba(0,0,0,0.08);
  --shadow-md:      0 4px 20px rgba(0,0,0,0.12);
  --shadow-lg:      0 8px 32px rgba(0,0,0,0.16);
  --radius-sm:      8px;
  --radius-md:      12px;
  --radius-lg:      20px;
  --font-base:      'Segoe UI', system-ui, -apple-system, sans-serif;
  --transition:     all 0.3s ease;
}

html {
  font-size: 16px;
  scroll-behavior: smooth;
}

body {
  font-family: var(--font-base);
  color: var(--charcoal);
  background: var(--white);
  line-height: 1.6;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

a {
  color: var(--green-mid);
  text-decoration: none;
}

a:hover {
  color: var(--green-dark);
  text-decoration: underline;
}

img {
  max-width: 100%;
  height: auto;
}

/* --- Utility --- */
.container {
  max-width: 1200px;
  margin: 0 auto;
  padding: 0 24px;
}

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  overflow: hidden;
  clip: rect(0,0,0,0);
  white-space: nowrap;
  border: 0;
}

/* ============================================================
   NAVBAR
   ============================================================ */
.navbar {
  background: var(--white);
  border-bottom: 2px solid var(--green-light);
  position: sticky;
  top: 0;
  z-index: 100;
  box-shadow: var(--shadow-sm);
}

.navbar .container {
  display: flex;
  align-items: center;
  justify-content: space-between;
  height: 68px;
}

.navbar-brand {
  display: flex;
  align-items: center;
  gap: 12px;
  font-size: 1.4rem;
  font-weight: 700;
  color: var(--green-dark);
  text-decoration: none;
}

.navbar-brand:hover {
  text-decoration: none;
  color: var(--green-dark);
}

.navbar-brand .logo {
  width: 44px;
  height: 44px;
  background: var(--green-primary);
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.4rem;
  flex-shrink: 0;
  overflow: hidden;
}

.navbar-brand .logo img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.navbar-brand .brand-text {
  line-height: 1.2;
}

.navbar-brand .brand-tagline {
  font-size: 0.65rem;
  font-weight: 400;
  color: var(--charcoal-light);
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.navbar-nav {
  display: flex;
  align-items: center;
  gap: 20px;
}

.nav-link {
  font-size: 0.9rem;
  font-weight: 500;
  color: var(--charcoal);
  transition: var(--transition);
  padding: 6px 12px;
  border-radius: var(--radius-sm);
}

.nav-link:hover {
  color: var(--green-dark);
  background: var(--green-pale);
  text-decoration: none;
}

.nav-link.stats-link {
  display: flex;
  align-items: center;
  gap: 6px;
  background: var(--green-pale);
  border: 1px solid var(--green-light);
}

.nav-link.stats-link::before {
  content: '';
  width: 8px;
  height: 8px;
  background: var(--green-primary);
  border-radius: 50%;
  animation: pulse 2s infinite;
}

/* Language Dropdown */
.lang-select {
  appearance: none;
  background: var(--white);
  border: 1.5px solid var(--green-light);
  border-radius: var(--radius-sm);
  padding: 8px 32px 8px 12px;
  font-size: 0.9rem;
  color: var(--charcoal);
  cursor: pointer;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='8' viewBox='0 0 12 8'%3E%3Cpath fill='%23558B2F' d='M6 8L0 0h12z'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 10px center;
  transition: var(--transition);
  font-family: var(--font-base);
}

.lang-select:hover, .lang-select:focus {
  border-color: var(--green-primary);
  outline: none;
  box-shadow: 0 0 0 3px rgba(139,195,74,0.2);
}

/* Translation loading state */
.translating {
  opacity: 0.5;
  transition: opacity 0.3s ease;
  pointer-events: none;
}

/* ============================================================
   HERO SECTION
   ============================================================ */
.hero {
  position: relative;
  width: 100%;
  height: 480px;
  overflow: hidden;
  background: linear-gradient(135deg, var(--green-dark) 0%, var(--green-primary) 50%, var(--green-light) 100%);
}

.hero-media {
  width: 100%;
  height: 100%;
  object-fit: cover;
  position: absolute;
  inset: 0;
}

.hero-overlay {
  position: absolute;
  inset: 0;
  background: linear-gradient(
    to right,
    rgba(30, 60, 20, 0.78) 0%,
    rgba(30, 60, 20, 0.4) 60%,
    transparent 100%
  );
  display: flex;
  align-items: center;
}

.hero-content {
  padding: 0 60px;
  max-width: 600px;
  color: var(--white);
}

.hero-geo {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 16px;
}

.hero-flag {
  font-size: 2.2rem;
  line-height: 1;
}

.hero-welcome {
  font-size: 1rem;
  opacity: 0.9;
  font-weight: 400;
}

.hero-tagline {
  font-size: 3rem;
  font-weight: 800;
  line-height: 1.1;
  margin-bottom: 16px;
  text-shadow: 0 2px 8px rgba(0,0,0,0.3);
}

.hero-sub {
  font-size: 1.1rem;
  opacity: 0.88;
  font-weight: 300;
  max-width: 420px;
}

.hero-cta {
  margin-top: 28px;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  background: var(--green-primary);
  color: var(--white);
  padding: 14px 28px;
  border-radius: var(--radius-sm);
  font-weight: 600;
  font-size: 1rem;
  transition: var(--transition);
  box-shadow: 0 4px 16px rgba(139,195,74,0.4);
}

.hero-cta:hover {
  background: var(--green-mid);
  transform: translateY(-2px);
  box-shadow: 0 6px 20px rgba(139,195,74,0.5);
  text-decoration: none;
  color: var(--white);
}

/* ============================================================
   AI RECOMMENDATION SECTION
   ============================================================ */
.section-recommend {
  background: var(--green-pale);
  padding: 60px 0;
  border-bottom: 1px solid var(--green-light);
}

.section-header {
  text-align: center;
  margin-bottom: 36px;
}

.section-header h2 {
  font-size: 1.8rem;
  font-weight: 700;
  color: var(--green-dark);
  margin-bottom: 8px;
}

.section-header p {
  color: var(--charcoal-light);
  font-size: 0.95rem;
}

.recommend-card {
  background: var(--white);
  border-radius: var(--radius-md);
  padding: 32px 40px;
  box-shadow: var(--shadow-md);
  max-width: 760px;
  margin: 0 auto;
  border-left: 4px solid var(--green-primary);
  min-height: 120px;
  display: flex;
  align-items: flex-start;
  gap: 20px;
}

.recommend-icon {
  font-size: 2.4rem;
  flex-shrink: 0;
  margin-top: 2px;
}

.recommend-body {
  flex: 1;
}

.recommend-body .geo-badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  background: var(--green-pale);
  border: 1px solid var(--green-light);
  border-radius: 20px;
  padding: 4px 12px;
  font-size: 0.8rem;
  color: var(--green-dark);
  margin-bottom: 12px;
  font-weight: 500;
}

#recommendation-text {
  font-size: 1.05rem;
  color: var(--charcoal);
  line-height: 1.7;
}

/* Spinner */
.spinner-wrapper {
  display: flex;
  align-items: center;
  gap: 12px;
  color: var(--charcoal-light);
  font-size: 0.95rem;
}

.spinner {
  width: 28px;
  height: 28px;
  border: 3px solid var(--green-light);
  border-top-color: var(--green-primary);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
  flex-shrink: 0;
}

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

/* ============================================================
   PRODUCT CARDS
   ============================================================ */
.section-products {
  padding: 72px 0;
}

.section-products .section-header {
  margin-bottom: 48px;
}

.products-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
  gap: 28px;
}

.product-card {
  background: var(--white);
  border-radius: var(--radius-md);
  overflow: hidden;
  box-shadow: var(--shadow-sm);
  border: 1px solid var(--grey-border);
  transition: var(--transition);
  display: flex;
  flex-direction: column;
}

.product-card:hover {
  transform: translateY(-6px);
  box-shadow: var(--shadow-lg);
  border-color: var(--green-light);
}

.product-image {
  width: 100%;
  height: 200px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 4rem;
  position: relative;
  overflow: hidden;
}

.product-image.color-alpine {
  background: linear-gradient(135deg, #2E7D32, #66BB6A);
}

.product-image.color-city {
  background: linear-gradient(135deg, #1565C0, #42A5F5);
}

.product-image.color-trail {
  background: linear-gradient(135deg, #6D4C41, #A1887F);
}

.product-image.color-urban {
  background: linear-gradient(135deg, #4A148C, #9C27B0);
}

.product-badge {
  position: absolute;
  top: 12px;
  right: 12px;
  background: var(--green-primary);
  color: var(--white);
  padding: 4px 10px;
  border-radius: 20px;
  font-size: 0.72rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.product-info {
  padding: 20px 24px 24px;
  flex: 1;
  display: flex;
  flex-direction: column;
}

.product-name {
  font-size: 1.15rem;
  font-weight: 700;
  color: var(--charcoal);
  margin-bottom: 6px;
}

.product-tagline {
  font-size: 0.85rem;
  color: var(--charcoal-light);
  margin-bottom: 16px;
  line-height: 1.5;
  flex: 1;
}

.product-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-top: auto;
}

.product-price {
  font-size: 1.4rem;
  font-weight: 800;
  color: var(--green-dark);
}

.product-price .currency {
  font-size: 0.9rem;
  font-weight: 400;
  color: var(--charcoal-light);
  margin-left: 2px;
}

.product-btn {
  background: var(--green-pale);
  color: var(--green-dark);
  border: 1.5px solid var(--green-light);
  border-radius: var(--radius-sm);
  padding: 8px 16px;
  font-size: 0.85rem;
  font-weight: 600;
  cursor: pointer;
  transition: var(--transition);
  font-family: var(--font-base);
}

.product-btn:hover {
  background: var(--green-primary);
  color: var(--white);
  border-color: var(--green-primary);
}

/* ============================================================
   FOOTER
   ============================================================ */
.footer {
  background: var(--green-dark);
  color: rgba(255,255,255,0.85);
  padding: 48px 0 28px;
  margin-top: auto;
}

.footer-top {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 40px;
  margin-bottom: 36px;
  flex-wrap: wrap;
}

.footer-brand {
  max-width: 280px;
}

.footer-logo {
  font-size: 1.3rem;
  font-weight: 700;
  color: var(--white);
  margin-bottom: 8px;
}

.footer-desc {
  font-size: 0.85rem;
  opacity: 0.8;
  line-height: 1.6;
}

.footer-badges {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.footer-badges h4 {
  color: var(--white);
  font-size: 0.85rem;
  text-transform: uppercase;
  letter-spacing: 0.8px;
  margin-bottom: 4px;
  opacity: 0.7;
}

.cf-badge-row {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.cf-badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  background: rgba(255,255,255,0.1);
  border: 1px solid rgba(255,255,255,0.2);
  border-radius: 20px;
  padding: 5px 12px;
  font-size: 0.78rem;
  color: rgba(255,255,255,0.9);
  transition: var(--transition);
  text-decoration: none;
}

.cf-badge:hover {
  background: rgba(139,195,74,0.25);
  border-color: var(--green-primary);
  color: var(--white);
  text-decoration: none;
}

.cf-badge .dot {
  width: 6px;
  height: 6px;
  background: var(--green-primary);
  border-radius: 50%;
}

.footer-bottom {
  border-top: 1px solid rgba(255,255,255,0.15);
  padding-top: 20px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 12px;
}

.footer-bottom p {
  font-size: 0.82rem;
  opacity: 0.65;
}

.footer-edge-badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  background: rgba(255,255,255,0.08);
  border: 1px solid rgba(255,255,255,0.15);
  border-radius: 20px;
  padding: 6px 14px;
  font-size: 0.78rem;
  color: rgba(255,255,255,0.85);
}

.footer-edge-badge::before {
  content: '⚡';
}

/* ============================================================
   STATS DASHBOARD — specific styles
   ============================================================ */
.stats-layout {
  background: var(--grey-light);
  flex: 1;
  padding: 40px 0 60px;
}

/* Stats Header */
.stats-header {
  background: var(--white);
  border-bottom: 2px solid var(--green-light);
  padding: 20px 0;
  margin-bottom: 36px;
}

.stats-header .container {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 16px;
}

.stats-header-left h1 {
  font-size: 1.6rem;
  font-weight: 700;
  color: var(--green-dark);
}

.stats-header-left p {
  font-size: 0.9rem;
  color: var(--charcoal-light);
  margin-top: 4px;
}

.live-indicator {
  display: flex;
  align-items: center;
  gap: 8px;
  background: var(--green-pale);
  border: 1px solid var(--green-light);
  border-radius: 20px;
  padding: 8px 16px;
  font-size: 0.9rem;
  font-weight: 600;
  color: var(--green-dark);
}

.live-dot {
  width: 10px;
  height: 10px;
  background: var(--green-primary);
  border-radius: 50%;
  animation: pulse 2s infinite;
}

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

/* Connection Status */
.connection-status {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 0.82rem;
  font-weight: 500;
  padding: 6px 14px;
  border-radius: 20px;
  border: 1px solid var(--grey-border);
  background: var(--white);
  transition: var(--transition);
}

.connection-status.connected {
  color: var(--green-dark);
  border-color: var(--green-light);
  background: var(--green-pale);
}

.connection-status.reconnecting {
  color: #E65100;
  border-color: #FFE0B2;
  background: #FFF3E0;
}

.connection-status.disconnected {
  color: #B71C1C;
  border-color: #FFCDD2;
  background: #FFEBEE;
}

.status-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: currentColor;
}

.connection-status.connected .status-dot { animation: pulse 2s infinite; }

/* Stats Grid */
.stats-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 28px;
  margin-bottom: 28px;
}

/* Total Counter Card */
.counter-card {
  background: var(--white);
  border-radius: var(--radius-md);
  padding: 36px 32px;
  box-shadow: var(--shadow-sm);
  border: 1px solid var(--grey-border);
  text-align: center;
  border-top: 4px solid var(--green-primary);
}

.counter-label {
  font-size: 0.85rem;
  text-transform: uppercase;
  letter-spacing: 1px;
  color: var(--charcoal-light);
  margin-bottom: 12px;
  font-weight: 600;
}

.counter-number {
  font-size: 4.5rem;
  font-weight: 900;
  color: var(--green-dark);
  line-height: 1;
  font-variant-numeric: tabular-nums;
  transition: transform 0.2s ease;
}

.counter-number.bumping {
  transform: scale(1.08);
  color: var(--green-primary);
}

.counter-sub {
  font-size: 0.8rem;
  color: var(--charcoal-light);
  margin-top: 8px;
}

/* Quick Stats */
.quick-stats {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
  align-content: start;
}

.quick-stat {
  background: var(--white);
  border-radius: var(--radius-sm);
  padding: 20px;
  box-shadow: var(--shadow-sm);
  border: 1px solid var(--grey-border);
  text-align: center;
}

.quick-stat .qs-number {
  font-size: 2rem;
  font-weight: 800;
  color: var(--green-dark);
  line-height: 1;
}

.quick-stat .qs-label {
  font-size: 0.78rem;
  color: var(--charcoal-light);
  margin-top: 6px;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

/* Table Cards */
.table-card {
  background: var(--white);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-sm);
  border: 1px solid var(--grey-border);
  overflow: hidden;
  margin-bottom: 28px;
}

.table-card-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 20px 24px;
  border-bottom: 1px solid var(--grey-border);
  background: var(--grey-light);
}

.table-card-header h3 {
  font-size: 1rem;
  font-weight: 700;
  color: var(--charcoal);
}

.table-card-badge {
  font-size: 0.75rem;
  background: var(--green-pale);
  color: var(--green-dark);
  padding: 3px 10px;
  border-radius: 12px;
  font-weight: 600;
  border: 1px solid var(--green-light);
}

.stats-table {
  width: 100%;
  border-collapse: collapse;
}

.stats-table th {
  padding: 12px 16px;
  text-align: left;
  font-size: 0.78rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: var(--charcoal-light);
  background: var(--grey-light);
  border-bottom: 1px solid var(--grey-border);
}

.stats-table td {
  padding: 12px 16px;
  font-size: 0.88rem;
  color: var(--charcoal);
  border-bottom: 1px solid rgba(0,0,0,0.04);
  vertical-align: middle;
}

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

.stats-table tr:hover td {
  background: var(--green-pale);
}

.stats-table tr.new-row-highlight {
  animation: rowHighlight 1.5s ease forwards;
}

@keyframes rowHighlight {
  0% { background: rgba(139,195,74,0.3); }
  100% { background: transparent; }
}

.rank-badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 26px;
  height: 26px;
  border-radius: 50%;
  font-size: 0.78rem;
  font-weight: 700;
}

.rank-1 { background: #FFD700; color: #5D4037; }
.rank-2 { background: #C0C0C0; color: #333; }
.rank-3 { background: #CD7F32; color: #fff; }
.rank-other { background: var(--grey-light); color: var(--charcoal-light); }

.country-cell {
  display: flex;
  align-items: center;
  gap: 8px;
}

.country-flag-cell {
  font-size: 1.2rem;
  line-height: 1;
}

.progress-bar-wrapper {
  display: flex;
  align-items: center;
  gap: 10px;
}

.progress-bar {
  flex: 1;
  height: 8px;
  background: var(--grey-border);
  border-radius: 4px;
  overflow: hidden;
  max-width: 120px;
}

.progress-bar-fill {
  height: 100%;
  background: linear-gradient(90deg, var(--green-primary), var(--green-mid));
  border-radius: 4px;
  transition: width 0.6s ease;
}

.visit-count {
  font-weight: 700;
  color: var(--green-dark);
  font-variant-numeric: tabular-nums;
  min-width: 32px;
  text-align: right;
}

.ua-truncate {
  max-width: 200px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-size: 0.78rem;
  color: var(--charcoal-light);
}

.timestamp-cell {
  font-size: 0.78rem;
  color: var(--charcoal-light);
  white-space: nowrap;
}

.empty-state {
  text-align: center;
  padding: 48px 24px;
  color: var(--charcoal-light);
}

.empty-state .empty-icon {
  font-size: 3rem;
  margin-bottom: 12px;
}

.empty-state p {
  font-size: 0.9rem;
}

/* ============================================================
   RESPONSIVE
   ============================================================ */
@media (max-width: 900px) {
  .stats-grid {
    grid-template-columns: 1fr;
  }

  .quick-stats {
    grid-template-columns: repeat(4, 1fr);
  }
}

@media (max-width: 768px) {
  .navbar .container {
    height: auto;
    padding: 12px 20px;
    flex-wrap: wrap;
    gap: 12px;
  }

  .hero {
    height: 380px;
  }

  .hero-content {
    padding: 0 24px;
  }

  .hero-tagline {
    font-size: 2rem;
  }

  .hero-sub {
    font-size: 0.95rem;
  }

  .recommend-card {
    padding: 24px 20px;
  }

  .products-grid {
    grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  }

  .footer-top {
    flex-direction: column;
  }

  .footer-bottom {
    flex-direction: column;
    text-align: center;
  }
}

@media (max-width: 520px) {
  .hero {
    height: 320px;
  }

  .hero-tagline {
    font-size: 1.6rem;
  }

  .counter-number {
    font-size: 3.2rem;
  }

  .quick-stats {
    grid-template-columns: repeat(2, 1fr);
  }

  .stats-table th:nth-child(n+4),
  .stats-table td:nth-child(n+4) {
    display: none;
  }
}
