/* WINE³ai — World Wide Wine: Grape Varieties Explorer Stylesheet */

:root {
  --primary: #7C2D12;
  --primary-hover: #9A3412;
  --primary-light: #FFEDD5;
  --accent-red: #DC2626;
  --accent-white: #D97706;
  --accent-sparkling: #EAB308;
  --accent-fortified: #854D0E;
  --accent-blue: #2563EB;
  --bg-main: #F8FAFC;
  --panel-bg: rgba(255, 255, 255, 0.98);
  --panel-border: #E2E8F0;
  --text-main: #0F172A;
  --text-muted: #64748B;
  --shadow-sm: 0 1px 2px 0 rgb(0 0 0 / 0.05);
  --shadow-md: 0 4px 6px -1px rgb(0 0 0 / 0.1), 0 2px 4px -2px rgb(0 0 0 / 0.1);
  --shadow-lg: 0 10px 15px -3px rgb(0 0 0 / 0.1), 0 4px 6px -4px rgb(0 0 0 / 0.1);
}

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

body {
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  background-color: var(--bg-main);
  color: var(--text-main);
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}

.app-layout {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

/* Header & Navigation */
.top-nav {
  height: 64px;
  background: var(--panel-bg);
  border-bottom: 1px solid var(--panel-border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 1.5rem;
  box-shadow: var(--shadow-sm);
  position: sticky;
  top: 0;
  z-index: 1000;
  backdrop-filter: blur(8px);
}

.brand {
  display: flex;
  align-items: center;
  gap: 0.65rem;
}

.brand-link {
  display: flex;
  align-items: center;
  text-decoration: none;
}

.brand-logo-img {
  width: 34px;
  height: 34px;
  display: block;
  border-radius: 8px;
  box-shadow: 0 2px 5px rgba(114, 47, 55, 0.2);
  transition: transform 0.2s ease, box-shadow 0.2s ease;
}

.brand-logo-img:hover {
  transform: scale(1.06);
  box-shadow: 0 3px 8px rgba(114, 47, 55, 0.35);
}

.brand-icon {
  font-size: 1.8rem;
  line-height: 1;
}

.brand-title {
  display: flex;
  align-items: baseline;
  font-size: 1.2rem;
  font-weight: 800;
  color: var(--primary);
  line-height: 1.1;
  letter-spacing: 0.2px;
}

.brand-exp {
  color: #D97706;
  font-size: 1rem;
  font-weight: 800;
  vertical-align: super;
  margin-right: 0.15rem;
}

.brand-ai {
  color: #0284C7;
  font-size: 0.78rem;
  font-weight: 700;
  background: rgba(2, 132, 199, 0.1);
  padding: 0.05rem 0.3rem;
  border-radius: 4px;
  border: 1px solid rgba(2, 132, 199, 0.3);
  letter-spacing: 0.5px;
  margin-left: 0.1rem;
}

.brand-subtitle {
  font-size: 0.72rem;
  color: var(--text-muted);
  font-weight: 500;
}

.nav-actions {
  display: flex;
  align-items: center;
  gap: 0.75rem;
}

.btn-link {
  display: flex;
  align-items: center;
  gap: 0.4rem;
  padding: 0.45rem 0.85rem;
  border-radius: 6px;
  font-size: 0.8rem;
  font-weight: 600;
  text-decoration: none;
  transition: all 0.2s ease;
}

.btn-map {
  background: #FEF3C7;
  color: #92400E;
  border: 1px solid #FDE68A;
}

.btn-map:hover {
  background: #FDE68A;
  color: #78350F;
}

.btn-atlas {
  background: #3B82F6;
  color: white;
}

.btn-atlas:hover {
  background: #2563EB;
}

.btn-github {
  background: #24292F;
  color: white;
}

.btn-github:hover {
  background: #000000;
}

.basemap-selector-wrap {
  display: flex;
  align-items: center;
  gap: 0.3rem;
  background: #F1F5F9;
  border: 1px solid #CBD5E1;
  border-radius: 6px;
  padding: 0.25rem 0.5rem;
}

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

.lang-btn {
  background: #F1F5F9;
  border: 1px solid #CBD5E1;
  border-radius: 6px;
  padding: 0.35rem 0.65rem;
  font-size: 0.75rem;
  font-weight: 700;
  cursor: pointer;
  color: var(--text-main);
  transition: all 0.2s;
}

.lang-btn.active {
  background: var(--primary);
  color: white;
  border-color: var(--primary);
}

/* Main Container */
.main-container {
  max-width: 1400px;
  margin: 0 auto;
  padding: 1.5rem;
  display: flex;
  flex-direction: column;
  gap: 1.5rem;
  width: 100%;
}

/* Controls Toolbar */
.controls-toolbar {
  background: #FFFFFF;
  border: 1px solid var(--panel-border);
  border-radius: 12px;
  padding: 1.25rem;
  box-shadow: var(--shadow-sm);
  display: flex;
  flex-direction: column;
  gap: 1rem;
}

.filters-row {
  display: grid;
  grid-template-columns: auto minmax(180px, auto) minmax(170px, auto) minmax(170px, auto) 1fr;
  gap: 1rem;
  align-items: flex-end;
}

@media (max-width: 1100px) {
  .filters-row {
    grid-template-columns: 1fr 1fr;
  }
}

@media (max-width: 640px) {
  .filters-row {
    grid-template-columns: 1fr;
  }
}

.filter-group {
  display: flex;
  flex-direction: column;
  gap: 0.4rem;
}

.filter-label {
  font-size: 0.75rem;
  font-weight: 700;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.segmented-control {
  display: flex;
  background: #F1F5F9;
  border-radius: 8px;
  padding: 0.2rem;
  border: 1px solid #E2E8F0;
}

.seg-btn {
  border: none;
  background: transparent;
  padding: 0.4rem 0.85rem;
  border-radius: 6px;
  font-size: 0.8rem;
  font-weight: 600;
  color: var(--text-muted);
  cursor: pointer;
  transition: all 0.2s;
  white-space: nowrap;
}

.seg-btn.active {
  background: #FFFFFF;
  color: var(--primary);
  box-shadow: var(--shadow-sm);
}

.filter-select {
  padding: 0.5rem 0.75rem;
  border: 1px solid var(--panel-border);
  border-radius: 8px;
  background: #FFFFFF;
  font-size: 0.825rem;
  color: var(--text-main);
  font-weight: 500;
  outline: none;
  cursor: pointer;
}

.filter-select:focus {
  border-color: var(--primary);
}

.search-group {
  position: relative;
}

.search-box {
  position: relative;
  display: flex;
  align-items: center;
}

.search-icon {
  position: absolute;
  left: 0.75rem;
  font-size: 0.85rem;
  color: var(--text-muted);
  pointer-events: none;
}

.search-input {
  width: 100%;
  padding: 0.5rem 0.75rem 0.5rem 2.2rem;
  border: 1px solid var(--panel-border);
  border-radius: 8px;
  font-size: 0.85rem;
  outline: none;
  transition: border-color 0.2s;
}

.search-input:focus {
  border-color: var(--primary);
}

.autocomplete-list {
  position: absolute;
  top: calc(100% + 4px);
  left: 0;
  right: 0;
  background: #FFFFFF;
  border: 1px solid var(--panel-border);
  border-radius: 8px;
  box-shadow: var(--shadow-lg);
  max-height: 280px;
  overflow-y: auto;
  z-index: 1000;
  display: none;
}

.autocomplete-list.active {
  display: block;
}

.autocomplete-item {
  padding: 0.6rem 0.85rem;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-size: 0.85rem;
  border-bottom: 1px solid #F1F5F9;
}

.autocomplete-item:hover, .autocomplete-item.highlighted {
  background: var(--primary-light);
  color: var(--primary);
}

/* Reactive Variety Matrix Section */
.variety-matrix-wrapper {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
  padding-top: 0.85rem;
  border-top: 1px solid #F1F5F9;
}

.matrix-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 0.75rem;
}

.matrix-title-area {
  display: flex;
  align-items: center;
  gap: 0.6rem;
}

.matrix-icon {
  font-size: 1.1rem;
}

.matrix-title {
  font-size: 0.85rem;
  font-weight: 700;
  color: var(--text-main);
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.matrix-counter {
  font-size: 0.75rem;
  font-weight: 600;
  color: #475569;
  background: #F1F5F9;
  padding: 0.2rem 0.65rem;
  border-radius: 12px;
  border: 1px solid #E2E8F0;
}

.matrix-actions {
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.matrix-sort-select {
  background: #F8FAFC;
  border: 1px solid #E2E8F0;
  border-radius: 6px;
  padding: 0.25rem 0.5rem;
  font-size: 0.75rem;
  font-weight: 600;
  color: var(--text-main);
  cursor: pointer;
  outline: none;
  transition: all 0.2s;
}

.matrix-sort-select:hover {
  background: #EDF2F7;
  border-color: #CBD5E1;
}

.btn-matrix-toggle {
  background: #F8FAFC;
  border: 1px solid #E2E8F0;
  border-radius: 6px;
  padding: 0.25rem 0.6rem;
  font-size: 0.75rem;
  font-weight: 600;
  color: var(--text-muted);
  cursor: pointer;
  transition: all 0.2s;
}

.btn-matrix-toggle:hover {
  background: #EDF2F7;
  color: var(--text-main);
  border-color: #CBD5E1;
}

.variety-matrix-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(160px, 1fr));
  gap: 0.5rem;
  max-height: 200px;
  overflow-y: auto;
  padding: 2px;
  scrollbar-width: thin;
  transition: max-height 0.3s ease;
}

.variety-matrix-grid.expanded {
  max-height: 520px;
}

.variety-card {
  background: #F8FAFC;
  border: 1px solid #E2E8F0;
  border-radius: 8px;
  padding: 0.5rem 0.65rem;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  text-align: left;
  cursor: pointer;
  transition: all 0.15s ease;
  min-height: 52px;
}

.variety-card:hover {
  border-color: #CBD5E1;
  background: #F1F5F9;
  transform: translateY(-1px);
  box-shadow: 0 2px 4px rgba(0, 0, 0, 0.04);
}

.variety-card.active {
  border-color: #8B0000;
  background: #FEF2F2;
  box-shadow: 0 0 0 2px rgba(139, 0, 0, 0.15);
}

.variety-card.white.active {
  border-color: #D97706;
  background: #FFFBEB;
  box-shadow: 0 0 0 2px rgba(217, 119, 6, 0.15);
}

.vcard-top {
  display: flex;
  align-items: center;
  gap: 0.45rem;
  margin-bottom: 0.2rem;
}

.vcard-color-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  flex-shrink: 0;
}

.vcard-color-dot.red {
  background: #DC2626;
  box-shadow: 0 0 0 2px rgba(220, 38, 38, 0.2);
}

.vcard-color-dot.white {
  background: #F59E0B;
  box-shadow: 0 0 0 2px rgba(245, 158, 11, 0.2);
}

.vcard-name {
  font-size: 0.8rem;
  font-weight: 700;
  color: var(--text-main);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  flex: 1;
}

.vcard-meta {
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-size: 0.7rem;
  color: #64748B;
  font-weight: 500;
}

.vcard-regions {
  font-weight: 600;
  color: #475569;
}

.vcard-flags {
  font-size: 0.75rem;
  letter-spacing: 1px;
}

.matrix-empty-state {
  grid-column: 1 / -1;
  text-align: center;
  padding: 2rem 1rem;
  color: var(--text-muted);
}

.btn-clear-filters {
  margin-top: 0.75rem;
  background: var(--primary);
  color: #FFFFFF;
  border: none;
  padding: 0.4rem 0.85rem;
  border-radius: 6px;
  font-size: 0.8rem;
  font-weight: 600;
  cursor: pointer;
  transition: opacity 0.2s;
}

.btn-clear-filters:hover {
  opacity: 0.9;
}

/* Hero Banner Card */
.grape-hero-card {
  background: #FFFFFF;
  border: 1px solid var(--panel-border);
  border-radius: 12px;
  padding: 1.5rem;
  box-shadow: var(--shadow-sm);
  display: flex;
  flex-direction: column;
  gap: 1.25rem;
}

.hero-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 1rem;
}

.hero-color-badge {
  display: inline-block;
  font-size: 0.72rem;
  font-weight: 700;
  padding: 0.2rem 0.55rem;
  border-radius: 4px;
  text-transform: uppercase;
  margin-bottom: 0.35rem;
  background: #FEE2E2;
  color: #991B1B;
}

.hero-color-badge.white-badge {
  background: #FEF3C7;
  color: #92400E;
}

.hero-grape-name {
  font-size: 2rem;
  font-weight: 800;
  color: var(--primary);
  line-height: 1.1;
  letter-spacing: -0.02em;
}

.hero-origin {
  font-size: 0.85rem;
  color: var(--text-muted);
  font-weight: 500;
  margin-top: 0.2rem;
}

.hero-origin span {
  color: var(--text-main);
  font-weight: 600;
}

.hero-stats {
  display: flex;
  gap: 1rem;
}

.stat-box {
  background: #F8FAFC;
  border: 1px solid #E2E8F0;
  border-radius: 8px;
  padding: 0.65rem 1rem;
  text-align: center;
  min-width: 100px;
}

.stat-number {
  font-size: 1.4rem;
  font-weight: 800;
  color: var(--primary);
  line-height: 1;
}

.stat-label {
  font-size: 0.7rem;
  font-weight: 600;
  color: var(--text-muted);
  text-transform: uppercase;
  margin-top: 0.25rem;
}

.hero-description {
  font-size: 0.95rem;
  color: #334155;
  line-height: 1.6;
}

.hero-synonyms-wrap {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  flex-wrap: wrap;
  margin-top: 0.5rem;
  padding-top: 0.75rem;
  border-top: 1px solid #F1F5F9;
}

.synonyms-title {
  font-size: 0.78rem;
  font-weight: 700;
  color: var(--text-muted);
}

.synonyms-chips {
  display: flex;
  gap: 0.35rem;
  flex-wrap: wrap;
}

.syn-chip {
  background: #F1F5F9;
  border: 1px solid #E2E8F0;
  border-radius: 4px;
  padding: 0.15rem 0.5rem;
  font-size: 0.75rem;
  font-weight: 500;
  color: #475569;
}

/* Analytics Grid & Charts */
.analytics-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1.5rem;
}

.chart-card {
  background: #FFFFFF;
  border: 1px solid var(--panel-border);
  border-radius: 12px;
  padding: 1.25rem;
  box-shadow: var(--shadow-sm);
  display: flex;
  flex-direction: column;
}

.chart-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  margin-bottom: 1.25rem;
}

.chart-title {
  font-size: 1.05rem;
  font-weight: 700;
  color: var(--text-main);
}

.chart-subtitle {
  font-size: 0.75rem;
  color: var(--text-muted);
}

.btn-chart-reset {
  background: #F1F5F9;
  border: 1px solid #CBD5E1;
  border-radius: 6px;
  padding: 0.25rem 0.5rem;
  font-size: 0.7rem;
  font-weight: 700;
  cursor: pointer;
  color: var(--text-main);
  transition: all 0.2s;
}

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

/* Donut Chart Component */
.donut-wrapper {
  display: flex;
  align-items: center;
  gap: 1.5rem;
  flex: 1;
}

.donut-container {
  position: relative;
  width: 220px;
  height: 220px;
  flex-shrink: 0;
}

.donut-svg {
  width: 100%;
  height: 100%;
  transform: rotate(-90deg);
}

.donut-slice {
  cursor: pointer;
  transition: opacity 0.2s, stroke-width 0.2s;
}

.donut-slice:hover {
  opacity: 0.85;
}

.donut-center-info {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  text-align: center;
  pointer-events: none;
}

.center-count {
  display: block;
  font-size: 1.75rem;
  font-weight: 800;
  color: var(--primary);
  line-height: 1;
}

.center-label {
  display: block;
  font-size: 0.7rem;
  font-weight: 600;
  color: var(--text-muted);
  text-transform: uppercase;
  margin-top: 0.2rem;
}

.donut-legend {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 0.4rem;
  max-height: 220px;
  overflow-y: auto;
  padding-right: 0.25rem;
}

.legend-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0.35rem 0.5rem;
  border-radius: 6px;
  cursor: pointer;
  font-size: 0.8rem;
  transition: background 0.2s;
}

.legend-row:hover, .legend-row.active {
  background: #F1F5F9;
}

.legend-left {
  display: flex;
  align-items: center;
  gap: 0.45rem;
}

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

.legend-pct {
  font-weight: 700;
  color: var(--text-main);
}

/* Progress & Breakdown Bars */
.breakdown-container {
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  flex: 1;
}

.progress-section {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.progress-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.progress-title {
  font-size: 0.825rem;
  font-weight: 700;
  color: var(--text-main);
}

.progress-meta {
  font-size: 0.75rem;
  color: var(--text-muted);
}

.multi-progress-bar {
  height: 14px;
  background: #E2E8F0;
  border-radius: 7px;
  overflow: hidden;
  display: flex;
  width: 100%;
}

.bar-segment {
  height: 100%;
  transition: width 0.4s ease;
}

.seg-still { background: #991B1B; }
.seg-sparkling { background: #EAB308; }
.seg-fortified { background: #854D0E; }
.seg-mono { background: #7C2D12; }
.seg-blend { background: #3B82F6; }

.progress-legend {
  display: flex;
  gap: 1rem;
  flex-wrap: wrap;
  font-size: 0.72rem;
  color: var(--text-muted);
}

.legend-item {
  display: flex;
  align-items: center;
  gap: 0.3rem;
}

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

.dot-still { background: #991B1B; }
.dot-sparkling { background: #EAB308; }
.dot-fortified { background: #854D0E; }
.dot-mono { background: #7C2D12; }
.dot-blend { background: #3B82F6; }

.benchmark-highlight {
  display: flex;
  align-items: flex-start;
  gap: 0.65rem;
  background: #FFFBEB;
  border: 1px solid #FDE68A;
  border-radius: 8px;
  padding: 0.75rem;
  margin-top: 1.25rem;
}

.benchmark-icon {
  font-size: 1.2rem;
  line-height: 1;
}

.benchmark-highlight strong {
  font-size: 0.8rem;
  color: #92400E;
}

.benchmark-highlight p {
  font-size: 0.75rem;
  color: #78350F;
  margin-top: 0.15rem;
  line-height: 1.4;
}

/* Map Section Card */
.map-section-card {
  background: #FFFFFF;
  border: 1px solid var(--panel-border);
  border-radius: 12px;
  overflow: hidden;
  box-shadow: var(--shadow-sm);
  display: flex;
  flex-direction: column;
}

.card-header-bar {
  padding: 1.25rem;
  border-bottom: 1px solid var(--panel-border);
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.section-title {
  font-size: 1.1rem;
  font-weight: 700;
  color: var(--text-main);
}

.section-subtitle {
  font-size: 0.75rem;
  color: var(--text-muted);
}

.map-legend-pills {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  flex-wrap: wrap;
}

.pill-marker {
  font-size: 0.75rem;
  font-weight: 700;
  padding: 0.3rem 0.65rem;
  border-radius: 20px;
  background: #FEF2F2;
  color: #991B1B;
  border: 1px solid #FCA5A5;
}

.active-polygon-badge {
  display: inline-flex;
  align-items: center;
  gap: 0.45rem;
  padding: 0.25rem 0.65rem;
  border-radius: 20px;
  background: #EFF6FF;
  border: 1px solid #93C5FD;
  color: #1E40AF;
  font-size: 0.75rem;
  font-weight: 700;
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.05);
  animation: fadeIn 0.2s ease-in-out;
}

.btn-clear-polygon {
  background: #DBEAFE;
  border: none;
  color: #1E40AF;
  width: 18px;
  height: 18px;
  border-radius: 50%;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 0.7rem;
  cursor: pointer;
  transition: all 0.15s ease;
  padding: 0;
  line-height: 1;
}

.btn-clear-polygon:hover {
  background: #1E40AF;
  color: #FFFFFF;
}

/* MapLibre Rich Popup for Appellations */
.maplibregl-popup-content {
  border-radius: 10px;
  box-shadow: 0 10px 25px -5px rgba(0, 0, 0, 0.15), 0 8px 10px -6px rgba(0, 0, 0, 0.1);
  padding: 0;
  border: 1px solid var(--panel-border);
  overflow: hidden;
}

.maplibregl-popup-close-button {
  padding: 4px 8px;
  color: var(--text-muted);
  font-size: 1.1rem;
}

.grape-popup-content {
  font-family: inherit;
  padding: 0.85rem;
  min-width: 230px;
  max-width: 290px;
}

.popup-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem;
  margin-bottom: 0.4rem;
}

.popup-cat {
  font-size: 0.68rem;
  font-weight: 800;
  color: #FFFFFF;
  padding: 0.15rem 0.45rem;
  border-radius: 4px;
  text-transform: uppercase;
  letter-spacing: 0.03em;
}

.popup-country {
  font-size: 0.72rem;
  font-weight: 600;
  color: var(--text-muted);
}

.popup-title {
  font-size: 1.05rem;
  font-weight: 800;
  color: var(--text-main);
  margin: 0.2rem 0 0.5rem 0;
  line-height: 1.25;
}

.popup-role-box {
  background: var(--bg-soft);
  border-radius: 6px;
  padding: 0.45rem 0.6rem;
  margin-bottom: 0.65rem;
  border: 1px solid var(--panel-border);
}

.popup-role-badge {
  display: inline-block;
  font-size: 0.75rem;
  font-weight: 700;
  color: var(--primary);
}

.popup-styles {
  font-size: 0.72rem;
  color: var(--text-muted);
  margin-top: 0.25rem;
}

.popup-actions {
  display: flex;
  gap: 0.4rem;
  flex-wrap: wrap;
}

.btn-popup-action {
  display: inline-flex;
  align-items: center;
  gap: 0.25rem;
  padding: 0.35rem 0.6rem;
  background: var(--primary);
  color: #FFFFFF;
  border-radius: 6px;
  text-decoration: none;
  font-size: 0.72rem;
  font-weight: 600;
  transition: background 0.15s ease;
}

.btn-popup-action:hover {
  background: var(--primary-hover);
  color: #FFFFFF;
}

.btn-popup-action.secondary {
  background: var(--bg-soft);
  color: var(--text-main);
  border: 1px solid var(--panel-border);
}

.btn-popup-action.secondary:hover {
  background: var(--panel-border);
}

.map-wrapper {
  height: 480px;
  width: 100%;
  position: relative;
}

.grape-map-canvas {
  width: 100%;
  height: 100%;
}

/* Regions Directory Table */
.regions-table-section {
  background: #FFFFFF;
  border: 1px solid var(--panel-border);
  border-radius: 12px;
  padding: 1.25rem;
  box-shadow: var(--shadow-sm);
  display: flex;
  flex-direction: column;
  gap: 1rem;
}

.table-header-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 1rem;
}

.table-search-wrap {
  display: flex;
  align-items: center;
  gap: 0.75rem;
}

.table-search-input {
  padding: 0.45rem 0.75rem;
  border: 1px solid var(--panel-border);
  border-radius: 6px;
  font-size: 0.8rem;
  width: 240px;
}

.table-counter-badge {
  background: #F1F5F9;
  border: 1px solid #CBD5E1;
  border-radius: 6px;
  padding: 0.35rem 0.6rem;
  font-size: 0.75rem;
  font-weight: 700;
  color: var(--text-main);
  white-space: nowrap;
}

.table-responsive {
  overflow-x: auto;
}

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

.regions-table th {
  background: #F8FAFC;
  padding: 0.75rem 1rem;
  font-weight: 700;
  color: var(--text-muted);
  border-bottom: 2px solid var(--panel-border);
  font-size: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  white-space: nowrap;
}

.regions-table td {
  padding: 0.75rem 1rem;
  border-bottom: 1px solid #F1F5F9;
  vertical-align: middle;
}

.regions-table tr:hover td {
  background: #F8FAFC;
}

.td-cat-badge {
  display: inline-block;
  padding: 0.15rem 0.45rem;
  border-radius: 4px;
  font-size: 0.72rem;
  font-weight: 700;
  color: white;
  background: var(--primary);
  white-space: nowrap;
}

.td-role-tag {
  display: inline-block;
  padding: 0.15rem 0.45rem;
  border-radius: 4px;
  font-size: 0.75rem;
  font-weight: 600;
  background: #F1F5F9;
  color: #334155;
  white-space: nowrap;
}

.td-role-tag.benchmark {
  background: #FEF3C7;
  color: #92400E;
  font-weight: 700;
}

.td-role-tag.dominant {
  background: #FEE2E2;
  color: #991B1B;
  font-weight: 700;
}

.td-actions {
  display: flex;
  gap: 0.35rem;
  white-space: nowrap;
}

.btn-table-action {
  padding: 0.25rem 0.5rem;
  border-radius: 4px;
  border: 1px solid #CBD5E1;
  background: #FFFFFF;
  font-size: 0.75rem;
  font-weight: 600;
  color: var(--text-main);
  text-decoration: none;
  cursor: pointer;
  transition: all 0.2s;
}

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

/* Footer */
.app-footer {
  margin-top: auto;
  background: #FFFFFF;
  border-top: 1px solid var(--panel-border);
  padding: 1.25rem 1.5rem;
  font-size: 0.8rem;
  color: var(--text-muted);
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 1rem;
}

.footer-link {
  color: var(--primary);
  text-decoration: none;
  font-weight: 600;
}

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

/* Responsive adjustments */
@media (max-width: 960px) {
  .analytics-grid {
    grid-template-columns: 1fr;
  }
  .filters-row {
    grid-template-columns: 1fr 1fr;
  }
  .donut-wrapper {
    flex-direction: column;
  }
}

@media (max-width: 640px) {
  .filters-row {
    grid-template-columns: 1fr;
  }
  .top-nav {
    padding: 0 1rem;
  }
  .main-container {
    padding: 1rem;
  }
  .hero-header {
    flex-direction: column;
  }
  .hero-stats {
    width: 100%;
    justify-content: space-between;
  }
  .stat-box {
    flex: 1;
    min-width: 0;
  }
}

/* ==========================================================================
   WINE³ai — Periodic Table & "Le Nez du Vin" Aroma Engine Styles
   ========================================================================== */

/* View Mode Switcher Banner */
.view-switch-banner {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  margin-top: 1rem;
  padding: 0.85rem 1.25rem;
  background: linear-gradient(135deg, #0f172a 0%, #1e293b 100%);
  border-radius: 14px;
  border: 1px solid rgba(255, 255, 255, 0.1);
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.15);
  color: #fff;
}

.view-switch-tabs {
  display: flex;
  gap: 0.5rem;
  background: rgba(15, 23, 42, 0.6);
  padding: 0.35rem;
  border-radius: 10px;
  border: 1px solid rgba(255, 255, 255, 0.08);
}

.view-tab-btn {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  background: transparent;
  border: none;
  color: #94a3b8;
  font-family: inherit;
  font-size: 0.85rem;
  font-weight: 600;
  padding: 0.55rem 0.95rem;
  border-radius: 8px;
  cursor: pointer;
  transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
}

.view-tab-btn:hover {
  color: #f1f5f9;
  background: rgba(255, 255, 255, 0.05);
}

.view-tab-btn.active {
  background: linear-gradient(135deg, #7c2d12 0%, #9a3412 100%);
  color: #ffffff;
  box-shadow: 0 2px 8px rgba(124, 45, 18, 0.4);
}

.tab-badge {
  font-size: 0.7rem;
  background: rgba(255, 255, 255, 0.2);
  color: #fff;
  padding: 0.15rem 0.45rem;
  border-radius: 999px;
  font-weight: 700;
  letter-spacing: 0.3px;
}

.tab-badge.secondary {
  background: rgba(255, 255, 255, 0.1);
  color: #cbd5e1;
}

/* Aroma Filter by Le Nez du Vin */
.aroma-filter-box {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  flex-wrap: wrap;
}

.aroma-filter-label-wrap {
  display: flex;
  align-items: center;
  gap: 0.4rem;
  font-size: 0.82rem;
  font-weight: 600;
  color: #cbd5e1;
}

.aroma-filter-icon {
  font-size: 1.15rem;
}

.aroma-select-wrap {
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.aroma-filter-select {
  background: #0f172a;
  color: #f8fafc;
  border: 1px solid #334155;
  border-radius: 8px;
  padding: 0.45rem 0.85rem;
  font-family: inherit;
  font-size: 0.82rem;
  font-weight: 500;
  outline: none;
  cursor: pointer;
  transition: border-color 0.2s ease, box-shadow 0.2s ease;
  max-width: 290px;
}

.aroma-filter-select:focus {
  border-color: #f59e0b;
  box-shadow: 0 0 0 3px rgba(245, 158, 11, 0.2);
}

.btn-clear-aroma {
  background: rgba(239, 68, 68, 0.2);
  color: #fca5a5;
  border: 1px solid rgba(239, 68, 68, 0.3);
  border-radius: 6px;
  padding: 0.35rem 0.65rem;
  font-size: 0.75rem;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s ease;
}

.btn-clear-aroma:hover {
  background: rgba(239, 68, 68, 0.35);
  color: #fff;
}

/* Periodic Table Wrapper */
.periodic-table-wrapper {
  margin-top: 1rem;
  background: #0b1120;
  border-radius: 16px;
  border: 1px solid #1e293b;
  padding: 1.5rem;
  color: #f8fafc;
  box-shadow: 0 8px 32px rgba(0, 0, 0, 0.25);
  transition: all 0.3s ease;
}

.periodic-header {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-start;
  justify-content: space-between;
  gap: 1.25rem;
  margin-bottom: 1.5rem;
  padding-bottom: 1.25rem;
  border-bottom: 1px solid rgba(255, 255, 255, 0.08);
}

.periodic-title-area {
  max-width: 650px;
}

.periodic-title-main {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  margin-bottom: 0.35rem;
}

.periodic-badge {
  font-size: 0.7rem;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 1px;
  background: linear-gradient(135deg, #f59e0b, #d97706);
  color: #0f172a;
  padding: 0.2rem 0.5rem;
  border-radius: 5px;
}

.periodic-title {
  font-size: 1.25rem;
  font-weight: 800;
  color: #ffffff;
  letter-spacing: -0.3px;
}

.periodic-desc {
  font-size: 0.85rem;
  color: #94a3b8;
  line-height: 1.45;
}

.periodic-legend-summary {
  display: flex;
  gap: 0.65rem;
  flex-wrap: wrap;
}

.legend-macro-tag {
  display: flex;
  align-items: center;
  gap: 0.4rem;
  font-size: 0.75rem;
  font-weight: 700;
  padding: 0.35rem 0.75rem;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid rgba(255, 255, 255, 0.1);
}

.legend-macro-tag .macro-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
}

.legend-macro-tag.w1 { color: #38bdf8; border-color: rgba(56, 189, 248, 0.3); }
.legend-macro-tag.w1 .macro-dot { background-color: #38bdf8; box-shadow: 0 0 6px #38bdf8; }

.legend-macro-tag.w2 { color: #f87171; border-color: rgba(248, 113, 113, 0.3); }
.legend-macro-tag.w2 .macro-dot { background-color: #f87171; box-shadow: 0 0 6px #f87171; }

.legend-macro-tag.w3 { color: #c084fc; border-color: rgba(192, 132, 252, 0.3); }
.legend-macro-tag.w3 .macro-dot { background-color: #c084fc; box-shadow: 0 0 6px #c084fc; }

/* Active Aroma Feedback Banner */
.aroma-feedback-banner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  background: linear-gradient(90deg, rgba(245, 158, 11, 0.15) 0%, rgba(217, 119, 6, 0.08) 100%);
  border: 1px solid rgba(245, 158, 11, 0.35);
  border-radius: 10px;
  padding: 0.65rem 1rem;
  margin-bottom: 1.25rem;
  animation: fadeInDown 0.3s ease;
}

.aroma-feedback-content {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  font-size: 0.85rem;
  font-weight: 600;
  color: #fde68a;
}

.aroma-feedback-icon {
  font-size: 1.25rem;
}

.btn-aroma-feedback-reset {
  background: #f59e0b;
  color: #0f172a;
  border: none;
  font-family: inherit;
  font-size: 0.75rem;
  font-weight: 700;
  padding: 0.35rem 0.75rem;
  border-radius: 6px;
  cursor: pointer;
  transition: background 0.2s ease, transform 0.1s ease;
}

.btn-aroma-feedback-reset:hover {
  background: #fbbf24;
  transform: scale(1.03);
}

/* Scroll wrap for responsive table */
.periodic-grid-scroll-wrap {
  overflow-x: auto;
  padding-bottom: 0.75rem;
  scrollbar-width: thin;
  scrollbar-color: #334155 #0b1120;
}

.periodic-grid-scroll-wrap::-webkit-scrollbar {
  height: 8px;
}
.periodic-grid-scroll-wrap::-webkit-scrollbar-track {
  background: #0b1120;
}
.periodic-grid-scroll-wrap::-webkit-scrollbar-thumb {
  background: #334155;
  border-radius: 4px;
}

/* The Periodic Table 9-Column Grid */
.periodic-grid {
  display: grid;
  grid-template-columns: repeat(9, minmax(136px, 1fr));
  gap: 0.65rem;
  min-width: 1224px; /* Ensures columns maintain ideal width when horizontally scrolling */
}

/* Group Column Header */
.periodic-col-header {
  background: rgba(15, 23, 42, 0.8);
  border-radius: 10px;
  padding: 0.65rem 0.5rem;
  border-top: 3px solid var(--group-col, #38bdf8);
  border-left: 1px solid rgba(255, 255, 255, 0.06);
  border-right: 1px solid rgba(255, 255, 255, 0.06);
  border-bottom: 1px solid rgba(255, 255, 255, 0.06);
  text-align: center;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  min-height: 88px;
}

.pcol-number {
  font-size: 0.7rem;
  font-weight: 800;
  color: var(--group-col, #38bdf8);
  letter-spacing: 0.5px;
}

.pcol-title {
  font-size: 0.74rem;
  font-weight: 700;
  color: #f1f5f9;
  line-height: 1.25;
  margin: 0.2rem 0;
}

.pcol-subtitle {
  font-size: 0.62rem;
  color: #64748b;
  line-height: 1.2;
}

/* Periodic Chemical Element Tile */
.periodic-tile {
  background: #111827;
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: 10px;
  padding: 0.5rem 0.45rem;
  cursor: pointer;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  min-height: 120px;
  position: relative;
  transition: all 0.22s cubic-bezier(0.4, 0, 0.2, 1);
  box-shadow: 0 2px 4px rgba(0, 0, 0, 0.2);
  user-select: none;
}

.periodic-tile:hover {
  transform: translateY(-4px) scale(1.03);
  z-index: 20;
  box-shadow: 0 10px 20px -3px rgba(0, 0, 0, 0.5), 0 0 14px var(--group-glow, rgba(56, 189, 248, 0.4));
  border-color: var(--group-color, #38bdf8);
  background: #1e293b;
}

.periodic-tile.active {
  border: 2px solid #fbbf24;
  box-shadow: 0 0 16px rgba(251, 191, 36, 0.5), inset 0 0 8px rgba(251, 191, 36, 0.2);
  background: #1e293b;
  transform: scale(1.02);
  z-index: 15;
}

/* When aroma filter is active: highlight matching vs dim non-matching */
.periodic-tile.dimmed {
  opacity: 0.22;
  filter: grayscale(80%);
  transform: scale(0.97);
}

.periodic-tile.highlighted {
  opacity: 1;
  border: 2px solid #f59e0b;
  box-shadow: 0 0 14px rgba(245, 158, 11, 0.6);
  background: #1a2234;
  animation: pulseTile 2s infinite ease-in-out;
}

@keyframes pulseTile {
  0%, 100% {
    box-shadow: 0 0 12px rgba(245, 158, 11, 0.5);
  }
  50% {
    box-shadow: 0 0 20px rgba(245, 158, 11, 0.85);
  }
}

/* Tile Header: Atomic Number & Mass */
.ptile-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  line-height: 1;
}

.ptile-z {
  font-size: 0.68rem;
  font-weight: 800;
  color: #94a3b8;
}

.ptile-mass {
  font-size: 0.65rem;
  font-weight: 700;
  color: #64748b;
  background: rgba(255, 255, 255, 0.05);
  padding: 0.1rem 0.25rem;
  border-radius: 4px;
}

/* Center Chemical Symbol */
.ptile-symbol-wrap {
  text-align: center;
  margin: 0.25rem 0;
}

.ptile-symbol {
  font-size: 1.85rem;
  font-weight: 800;
  letter-spacing: -0.5px;
  line-height: 1;
  color: var(--group-color, #f1f5f9);
  text-shadow: 0 2px 8px rgba(0, 0, 0, 0.4);
}

/* Variety Name */
.ptile-name {
  font-size: 0.72rem;
  font-weight: 600;
  color: #e2e8f0;
  text-align: center;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  margin-bottom: 0.3rem;
}

/* Bottom Bar: Mini Aroma Icons */
.ptile-aromas {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.2rem;
  font-size: 0.75rem;
  min-height: 18px;
}

.ptile-aroma-icon {
  display: inline-block;
  cursor: help;
  transition: transform 0.15s ease;
}

.ptile-aroma-icon:hover {
  transform: scale(1.3);
}

/* Country flag badge */
.ptile-flag {
  position: absolute;
  bottom: 0.3rem;
  right: 0.35rem;
  font-size: 0.7rem;
  opacity: 0.75;
}

/* Aromas Chips in Grape Hero Card */
.hero-aromas-wrap {
  margin-top: 0.75rem;
  padding-top: 0.75rem;
  border-top: 1px dashed var(--panel-border);
}

.aromas-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 0.45rem;
  margin-top: 0.35rem;
}

.aroma-chip {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  font-size: 0.78rem;
  font-weight: 600;
  padding: 0.25rem 0.65rem;
  border-radius: 999px;
  background: #fef3c7;
  color: #78350f;
  border: 1px solid #fde68a;
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.04);
  cursor: pointer;
  transition: all 0.2s ease;
}

.aroma-chip:hover {
  background: #fde68a;
  transform: translateY(-1px);
  box-shadow: 0 2px 4px rgba(0, 0, 0, 0.08);
}

.aroma-chip-num {
  font-size: 0.68rem;
  font-weight: 800;
  background: rgba(120, 53, 15, 0.15);
  color: #78350f;
  padding: 0.1rem 0.3rem;
  border-radius: 4px;
}

.aroma-chip-chem {
  font-size: 0.68rem;
  color: #92400e;
  font-style: italic;
  margin-left: 0.2rem;
  opacity: 0.85;
}
