/* Copyright (C) 2023 Raymond Sun - All Rights Reserved
 * You may not use, distribute and modify this code without the author's written permission.
 */

/**
 * Vibe Dashboard - Light/Dark Theme Styles
 */

/* ============================================
   LIGHT MODE (Default)
   ============================================ */

#vibemeter-box-content {
  display: none;
  min-height: 80vh;
  padding: 24px;
  border-radius: 8px;
}

#vibe-dashboard.light-mode,
#vibe-dashboard:not(.dark-mode) {
  --vibe-bg-primary: #f8fafc;
  --vibe-bg-card: #ffffff;
  --vibe-bg-hover: #f1f5f9;
  --vibe-border: #e2e8f0;
  --vibe-text-primary: #1e293b;
  --vibe-text-muted: #64748b;
  --vibe-text-dim: #94a3b8;
  --vibe-control-bg: #ffffff;
  --vibe-control-border: #cbd5e1;
  --vibe-ticker-bg: rgba(0, 0, 0, 0.05);
  --vibe-shadow: rgba(0, 0, 0, 0.1);
  --vibe-needle-fill: #334155;
  --vibe-needle-center-fill: #f8fafc;
  --vibe-needle-center-stroke: #334155;
}

/* ============================================
   DARK MODE
   ============================================ */

#vibe-dashboard.dark-mode {
  --vibe-bg-primary: #0f172a;
  --vibe-bg-card: #1e293b;
  --vibe-bg-hover: #334155;
  --vibe-border: #475569;
  --vibe-text-primary: #e2e8f0;
  --vibe-text-muted: #94a3b8;
  --vibe-text-dim: #64748b;
  --vibe-control-bg: #1e293b;
  --vibe-control-border: #475569;
  --vibe-ticker-bg: rgba(0, 0, 0, 0.3);
  --vibe-shadow: rgba(0, 0, 0, 0.4);
  --vibe-needle-fill: #e2e8f0;
  --vibe-needle-center-fill: #0f172a;
  --vibe-needle-center-stroke: #e2e8f0;
}

/* Vibe Colors (same for both modes) - 4 tier system */
:root {
  --vibe-accelerated: #10b981;
  --vibe-light-touch: #3b82f6;
  --vibe-inactive: #94a3b8;   /* Gray - no AI-specific action yet */
  --vibe-cautious: #f59e0b;
  --vibe-restrictive: #ef4444;
}

/* ============================================
   MAIN CONTAINER
   ============================================ */

#vibe-dashboard {
  max-width: 1600px;
  margin: 0 auto;
  background: var(--vibe-bg-primary);
  border-radius: 8px;
  padding: 24px;
  transition: background-color 0.3s ease, color 0.3s ease;
}

/* ============================================
   HEADER
   ============================================ */

.vibe-header {
  text-align: center;
  margin-bottom: 24px;
  padding-bottom: 20px;
  border-bottom: 1px solid var(--vibe-border);
}

.vibe-title {
  color: var(--vibe-text-primary);
  font-size: 24px;
  font-weight: 700;
  letter-spacing: 2px;
  margin: 0 0 8px 0;
  text-transform: uppercase;
}

.vibe-subtitle {
  color: var(--vibe-text-muted);
  font-size: 14px;
  margin: 0 0 20px 0;
  text-align: left;
}

/* Legend */
.vibe-legend {
  display: flex;
  justify-content: center;
  gap: 16px;
  flex-wrap: wrap;
  max-width: 1200px;
  margin: 0 auto;
}

.legend-item {
  display: flex;
  align-items: flex-start;
  gap: 8px;
  padding: 8px 12px;
  background: var(--vibe-bg-card);
  border: 1px solid var(--vibe-border);
  border-radius: 6px;
  min-width: 200px;
  max-width: 220px;
  flex: 1;
}

.legend-dot {
  width: 12px;
  height: 12px;
  border-radius: 50%;
  flex-shrink: 0;
  margin-top: 2px;
}

.legend-dot.accelerated { background: var(--vibe-accelerated); }
.legend-dot.light-touch { background: var(--vibe-light-touch); }
.legend-dot.inactive { background: var(--vibe-inactive); }
.legend-dot.cautious { background: var(--vibe-cautious); }
.legend-dot.restrictive { background: var(--vibe-restrictive); }

.legend-text {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.legend-label {
  color: var(--vibe-text-primary);
  font-size: 12px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.legend-desc {
  color: var(--vibe-text-muted);
  font-size: 10px;
  line-height: 1.3;
  text-transform: none;
  letter-spacing: 0;
}

/* ============================================
   CONTROLS BAR
   ============================================ */

.vibe-controls {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 20px;
  padding: 12px 16px;
  background: var(--vibe-bg-card);
  border: 1px solid var(--vibe-border);
  border-radius: 8px;
  flex-wrap: wrap;
  gap: 12px;
}

/* Search Container */
.search-container {
  display: flex;
  align-items: center;
  position: relative;
  flex: 1;
  max-width: 300px;
}

.search-input {
  width: 100%;
  padding: 8px 32px 8px 12px;
  font-size: 13px;
  border: 1px solid var(--vibe-control-border);
  border-radius: 6px;
  background: var(--vibe-control-bg);
  color: var(--vibe-text-primary);
  transition: border-color 0.2s ease, box-shadow 0.2s ease;
}

.search-input::placeholder {
  color: var(--vibe-text-muted);
}

.search-input:hover {
  border-color: var(--vibe-light-touch);
}

.search-input:focus {
  outline: none;
  border-color: var(--vibe-light-touch);
  box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.2);
}

.search-clear-btn {
  position: absolute;
  right: 8px;
  top: 50%;
  transform: translateY(-50%);
  background: none;
  border: none;
  color: var(--vibe-text-muted);
  font-size: 18px;
  cursor: pointer;
  padding: 0 4px;
  line-height: 1;
  opacity: 0.6;
  transition: opacity 0.2s ease, color 0.2s ease;
}

.search-clear-btn:hover {
  opacity: 1;
  color: var(--vibe-text-primary);
}

.sort-container {
  display: flex;
  align-items: center;
  gap: 8px;
}

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

.sort-select {
  padding: 8px 12px;
  font-size: 13px;
  border: 1px solid var(--vibe-control-border);
  border-radius: 6px;
  background: var(--vibe-control-bg);
  color: var(--vibe-text-primary);
  cursor: pointer;
  min-width: 180px;
  transition: border-color 0.2s ease, box-shadow 0.2s ease;
}

.sort-select:hover {
  border-color: var(--vibe-light-touch);
}

.sort-select:focus {
  outline: none;
  border-color: var(--vibe-light-touch);
  box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.2);
}

.theme-toggle {
  display: flex;
  align-items: center;
}

.theme-toggle-btn {
  padding: 8px 16px;
  font-size: 13px;
  font-weight: 500;
  border: 1px solid var(--vibe-control-border);
  border-radius: 6px;
  background: var(--vibe-control-bg);
  color: var(--vibe-text-primary);
  cursor: pointer;
  transition: all 0.2s ease;
}

.theme-toggle-btn:hover {
  background: var(--vibe-bg-hover);
  border-color: var(--vibe-text-dim);
}

/* Map coloring toggle */
.map-toggle {
  display: flex;
  align-items: center;
}

.map-toggle-btn {
  padding: 8px 16px;
  font-size: 13px;
  font-weight: 500;
  border: 1px solid var(--vibe-control-border);
  border-radius: 6px;
  background: var(--vibe-control-bg);
  color: var(--vibe-text-primary);
  cursor: pointer;
  transition: all 0.2s ease;
}

.map-toggle-btn:hover {
  background: var(--vibe-bg-hover);
  border-color: var(--vibe-text-dim);
}

.map-toggle-btn.active {
  background: var(--vibe-light-touch);
  color: #fff;
  border-color: var(--vibe-light-touch);
}

.map-toggle-btn.active:hover {
  background: #2563eb;
  border-color: #2563eb;
}

/* ============================================
   GRID LAYOUT
   ============================================ */

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

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

@media (min-width: 1600px) {
  .vibe-grid {
    grid-template-columns: repeat(5, 1fr);
  }
}

/* ============================================
   CARD STYLING
   ============================================ */

.vibe-card {
  background: var(--vibe-bg-card);
  border: 1px solid var(--vibe-border);
  border-radius: 8px;
  padding: 16px;
  transition: transform 0.2s ease, box-shadow 0.2s ease, border-color 0.2s ease;
  overflow: hidden;
  cursor: pointer;
  position: relative;
}

.vibe-card:hover {
  transform: translateY(-2px);
  box-shadow: 0 8px 24px var(--vibe-shadow);
  border-color: var(--vibe-text-dim);
}

.vibe-card:active {
  transform: translateY(0);
  box-shadow: 0 2px 8px var(--vibe-shadow);
}

/* Click hint on hover */
.vibe-card::after {
  content: 'Click to view profile';
  position: absolute;
  bottom: 8px;
  right: 12px;
  font-size: 9px;
  color: var(--vibe-text-dim);
  opacity: 0;
  transition: opacity 0.2s ease;
  pointer-events: none;
}

.vibe-card:hover::after {
  opacity: 1;
}

/* Card hover glow based on vibe */
.vibe-card[data-vibe="accelerated"]:hover {
  border-color: var(--vibe-accelerated);
  box-shadow: 0 8px 24px rgba(16, 185, 129, 0.2);
}

.vibe-card[data-vibe="lightTouch"]:hover {
  border-color: var(--vibe-light-touch);
  box-shadow: 0 8px 24px rgba(59, 130, 246, 0.2);
}

.vibe-card[data-vibe="inactive"]:hover {
  border-color: var(--vibe-inactive);
  box-shadow: 0 8px 24px rgba(148, 163, 184, 0.2);
}

.vibe-card[data-vibe="cautious"]:hover {
  border-color: var(--vibe-cautious);
  box-shadow: 0 8px 24px rgba(245, 158, 11, 0.2);
}

.vibe-card[data-vibe="restrictive"]:hover {
  border-color: var(--vibe-restrictive);
  box-shadow: 0 8px 24px rgba(239, 68, 68, 0.2);
}

/* Card Header */
.card-header {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 12px;
}

.country-flag {
  font-size: 24px;
  line-height: 1;
}

.country-name {
  flex: 1;
  color: var(--vibe-text-primary);
  font-size: 14px;
  font-weight: 600;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* ============================================
   VIBE BADGE
   ============================================ */

.vibe-badge {
  padding: 2px 8px;
  border-radius: 4px;
  font-size: 9px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  white-space: nowrap;
}

.vibe-badge.accelerated {
  background: var(--vibe-accelerated);
  color: #000;
}

.vibe-badge.light-touch {
  background: var(--vibe-light-touch);
  color: #fff;
}

.vibe-badge.inactive {
  background: var(--vibe-inactive);
  color: #fff;
}

.vibe-badge.cautious {
  background: var(--vibe-cautious);
  color: #000;
}

.vibe-badge.restrictive {
  background: var(--vibe-restrictive);
  color: #fff;
}

/* ============================================
   GAUGE
   ============================================ */

.gauge-container {
  display: flex;
  justify-content: center;
  align-items: center;
  padding: 8px 0;
}

.vibe-gauge {
  width: 100%;
  max-width: 180px;
  height: auto;
}

/* Gauge Needle Animation */
.gauge-needle {
  transition: transform 0.8s cubic-bezier(0.4, 0, 0.2, 1);
}

.gauge-segment {
  opacity: 0.9;
}

.gauge-inner {
  color: var(--vibe-text-dim);
}

.gauge-tick {
  stroke: var(--vibe-text-dim);
}

.needle-fill {
  fill: var(--vibe-needle-fill);
}

.needle-center {
  fill: var(--vibe-needle-center-fill);
  stroke: var(--vibe-needle-center-stroke);
  stroke-width: 2;
}

.gauge-score {
  fill: var(--vibe-text-primary);
  font-family: 'Monaco', 'Menlo', 'Courier New', monospace;
}

.gauge-label {
  fill: var(--vibe-text-muted);
  font-family: 'Monaco', 'Menlo', 'Courier New', monospace;
}

/* ============================================
   STREET TALK TICKER
   ============================================ */

.street-talk-ticker {
  background: var(--vibe-ticker-bg);
  border-radius: 4px;
  padding: 8px 12px;
  margin-top: 12px;
  overflow: hidden;
  height: 36px;
  position: relative;
}

.ticker-track {
  display: inline-block;
  white-space: nowrap;
  animation: scroll-ticker 20s linear infinite;
  padding-left: 100%;
}

.ticker-item {
  color: var(--vibe-text-muted);
  font-size: 11px;
  line-height: 1.4;
}

.ticker-item strong {
  color: var(--vibe-text-primary);
  font-weight: 600;
}

@keyframes scroll-ticker {
  0% {
    transform: translateX(0);
  }
  100% {
    transform: translateX(-100%);
  }
}

/* Pause ticker on hover */
.street-talk-ticker:hover .ticker-track {
  animation-play-state: paused;
}

/* ============================================
   MOBILE RESPONSIVE
   ============================================ */

@media (max-width: 768px) {
  #vibe-dashboard {
    padding: 16px;
  }

  .vibe-title {
    font-size: 18px;
    letter-spacing: 1px;
  }

  .vibe-subtitle {
    font-size: 12px;
  }

  .vibe-legend {
    gap: 8px;
  }

  .legend-item {
    min-width: 150px;
    max-width: 100%;
    padding: 6px 10px;
  }

  .legend-label {
    font-size: 11px;
  }

  .legend-desc {
    font-size: 9px;
  }

  .vibe-controls {
    flex-direction: column;
    align-items: stretch;
  }

  .search-container {
    max-width: 100%;
  }

  .search-input {
    width: 100%;
  }

  .sort-container {
    justify-content: space-between;
  }

  .sort-select {
    flex: 1;
  }

  .theme-toggle,
  .map-toggle {
    justify-content: center;
  }

  .theme-toggle-btn,
  .map-toggle-btn {
    width: 100%;
  }

  .vibe-grid {
    grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
    gap: 12px;
  }

  .vibe-card {
    padding: 12px;
  }

  .country-flag {
    font-size: 20px;
  }

  .country-name {
    font-size: 13px;
  }

  .vibe-badge {
    font-size: 8px;
    padding: 2px 6px;
  }

  .ticker-item {
    font-size: 10px;
  }
}

@media (max-width: 480px) {
  .vibe-grid {
    grid-template-columns: 1fr;
  }

  .vibe-legend {
    flex-direction: column;
    gap: 6px;
    align-items: stretch;
  }

  .legend-item {
    max-width: 100%;
  }
}

/* ============================================
   NO RESULTS MESSAGE
   ============================================ */

.no-results {
  grid-column: 1 / -1;
  text-align: center;
  padding: 60px 20px;
  color: var(--vibe-text-muted);
}

.no-results p {
  margin: 0 0 8px 0;
  font-size: 16px;
}

.no-results strong {
  color: var(--vibe-text-primary);
}

.no-results-hint {
  font-size: 13px;
  opacity: 0.7;
}

/* ============================================
   ANIMATIONS
   ============================================ */

/* Loading State */
.vibe-card.loading {
  opacity: 0.6;
  pointer-events: none;
}

.vibe-card.loading .gauge-needle {
  animation: pulse-needle 1.5s ease-in-out infinite;
}

@keyframes pulse-needle {
  0%, 100% {
    opacity: 0.5;
  }
  50% {
    opacity: 1;
  }
}

/* Smooth fade-in for cards */
.vibe-card {
  animation: fadeInCard 0.3s ease-out;
}

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

/* Stagger animation for grid items */
.vibe-card:nth-child(1) { animation-delay: 0.02s; }
.vibe-card:nth-child(2) { animation-delay: 0.04s; }
.vibe-card:nth-child(3) { animation-delay: 0.06s; }
.vibe-card:nth-child(4) { animation-delay: 0.08s; }
.vibe-card:nth-child(5) { animation-delay: 0.1s; }
.vibe-card:nth-child(6) { animation-delay: 0.12s; }
.vibe-card:nth-child(7) { animation-delay: 0.14s; }
.vibe-card:nth-child(8) { animation-delay: 0.16s; }
.vibe-card:nth-child(9) { animation-delay: 0.18s; }
.vibe-card:nth-child(10) { animation-delay: 0.2s; }

/* ============================================
   CONFIDENCE INDICATOR
   Shows data reliability for normalized scoring
   ============================================ */

.confidence-indicator {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 6px 0;
  margin-top: 4px;
}

.confidence-bar {
  flex: 1;
  height: 4px;
  background: var(--vibe-ticker-bg);
  border-radius: 2px;
  overflow: hidden;
}

.confidence-fill {
  height: 100%;
  border-radius: 2px;
  transition: width 0.5s ease-out;
}

.confidence-label {
  font-size: 9px;
  font-weight: 500;
  text-transform: uppercase;
  letter-spacing: 0.3px;
  white-space: nowrap;
  min-width: 85px;
  text-align: right;
}

/* Confidence levels */
.confidence-indicator.confidence-high .confidence-fill {
  background: linear-gradient(90deg, var(--vibe-light-touch), #10b981);
}

.confidence-indicator.confidence-high .confidence-label {
  color: #10b981;
}

.confidence-indicator.confidence-medium .confidence-fill {
  background: linear-gradient(90deg, var(--vibe-cautious), var(--vibe-light-touch));
}

.confidence-indicator.confidence-medium .confidence-label {
  color: var(--vibe-cautious);
}

.confidence-indicator.confidence-low .confidence-fill {
  background: linear-gradient(90deg, var(--vibe-restrictive), var(--vibe-cautious));
}

.confidence-indicator.confidence-low .confidence-label {
  color: var(--vibe-text-muted);
}

/* Tooltip styling on hover */
.confidence-indicator[title] {
  cursor: help;
}

/* Mobile adjustments */
@media (max-width: 768px) {
  .confidence-label {
    font-size: 8px;
    min-width: 75px;
  }

  .confidence-bar {
    height: 3px;
  }
}

/* ============================================
   EU MEMBER STATE FOOTNOTE
   Shows that EU AI Act applies to member states
   ============================================ */

.eu-footnote {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 6px 8px;
  margin: 8px 0;
  background: linear-gradient(135deg, rgba(0, 51, 153, 0.08), rgba(255, 204, 0, 0.08));
  border: 1px solid rgba(0, 51, 153, 0.2);
  border-radius: 6px;
  font-size: 9px;
  color: var(--vibe-text-muted);
  cursor: help;
}

.eu-footnote .eu-flag {
  font-size: 12px;
  flex-shrink: 0;
}

.eu-footnote .eu-text {
  line-height: 1.3;
  font-style: italic;
}

/* Dark mode adjustments */
.dark-mode .eu-footnote {
  background: linear-gradient(135deg, rgba(0, 51, 153, 0.15), rgba(255, 204, 0, 0.1));
  border-color: rgba(0, 51, 153, 0.3);
}

/* Mobile adjustments */
@media (max-width: 768px) {
  .eu-footnote {
    padding: 4px 6px;
    font-size: 8px;
  }

  .eu-footnote .eu-flag {
    font-size: 10px;
  }
}

/* ============================================
   SVG MAP VIBE COLORING
   Styles for vibe color overlay on world map
   ============================================ */

.svgMap-country {
  transition: fill 0.3s ease;
}

.svgMap-country.vibe-colored {
  stroke: rgba(255, 255, 255, 0.5);
  stroke-width: 0.5;
}
