@import '../../css/variables.css';

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

html { height: 100%; }

/* Smooth theme transitions (only during active theme change) */
html.theme-transition,
html.theme-transition *,
html.theme-transition *::before,
html.theme-transition *::after {
  transition: background-color 0.3s ease, color 0.3s ease, border-color 0.3s ease, box-shadow 0.3s ease, background 0.3s ease !important;
}

body {
  min-height: 100%;
  font-family: var(--font-family, 'Inter', sans-serif);
  font-size: 15px;
  line-height: 1.5;
  color: var(--text, #e7f1f7);
  background: var(--bg, #0b1f2a);
  -webkit-font-smoothing: antialiased;
}

a { color: var(--brand, #e63b3b); text-decoration: none; }
a:hover { color: var(--text, #e7f1f7); }

/* Layout */
.page-wrap {
  max-width: 1200px;
  margin: 0 auto;
  padding: 0 16px;
}

/* Header */
.ll-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 0;
  border-bottom: 1px solid var(--separator, rgba(255,255,255,0.08));
  flex-wrap: wrap;
  gap: 8px;
}

.ll-header-left {
  display: flex;
  align-items: center;
  gap: 16px;
}

.ll-header-left img {
  height: 28px;
  width: auto;
  background: var(--logo-bg);
  padding: var(--logo-padding);
  border-radius: 6px;
}

.ll-header-left a.back-btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 8px 18px;
  font-size: 13px;
  font-weight: 600;
  color: #fff;
  background: var(--brand-gradient, linear-gradient(135deg, #e63b3b, #c41e3a));
  border-radius: 8px;
  text-decoration: none;
  transition: opacity 0.15s, transform 0.15s;
}

.ll-header-left a.back-btn:hover {
  opacity: 0.9;
  transform: translateY(-1px);
  color: #fff;
}

.lang-buttons {
  display: flex;
  gap: 4px;
  align-items: center;
}

.lang-btn {
  padding: 6px 14px;
  border: 1px solid var(--border-color, rgba(255,255,255,0.15));
  border-radius: 6px;
  background: transparent;
  color: var(--muted, #8faab8);
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.15s;
}

.lang-btn.active,
.lang-btn:hover {
  background: var(--brand, #e63b3b);
  color: #fff;
  border-color: var(--brand, #e63b3b);
}

/* Theme Toggle */
.theme-toggle {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 34px;
  height: 34px;
  border-radius: 50%;
  background: var(--card, #122736);
  border: 1px solid var(--border-color, rgba(255,255,255,0.15));
  color: var(--muted, #8faab8);
  cursor: pointer;
  padding: 0;
  transition: all 0.15s;
  margin-left: 4px;
}

.theme-toggle:hover {
  color: var(--text, #e7f1f7);
  border-color: var(--border-color-hover, rgba(255,255,255,0.3));
  transform: translateY(-1px);
}

.theme-toggle svg {
  width: 18px;
  height: 18px;
  pointer-events: none;
}

.theme-icon.sun { display: none; }
.theme-icon.moon { display: block; }
[data-theme="dark"] .theme-icon.sun { display: block; }
[data-theme="dark"] .theme-icon.moon { display: none; }

/* Search */
.search-wrap {
  position: relative;
  margin: 20px 0 16px;
}

.search-input {
  width: 100%;
  padding: 14px 20px;
  font-size: 16px;
  border: 2px solid var(--border-color, rgba(255,255,255,0.1));
  border-radius: 12px;
  background: var(--hover-overlay, rgba(255,255,255,0.04));
  color: var(--text, #e7f1f7);
  outline: none;
  transition: border-color 0.2s;
}

.search-input::placeholder {
  color: var(--muted, #8faab8);
}

.search-input:focus {
  border-color: var(--brand, #e63b3b);
}

.search-results {
  position: absolute;
  top: 100%;
  left: 0;
  right: 0;
  background: var(--card, #122736);
  border: 1px solid var(--border-color, rgba(255,255,255,0.1));
  border-radius: 8px;
  margin-top: 4px;
  max-height: 320px;
  overflow-y: auto;
  z-index: 100;
  display: none;
  box-shadow: var(--shadow-lg, 0 12px 32px rgba(0,0,0,0.4));
}

.search-item {
  padding: 10px 16px;
  cursor: pointer;
  font-size: 14px;
  transition: background 0.1s;
}

.search-item:hover {
  background: var(--hover-overlay, rgba(255,255,255,0.06));
}

.search-item.no-result {
  color: var(--muted, #8faab8);
  cursor: default;
}

/* Continent Tabs */
.continent-tabs {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
  margin-bottom: 16px;
}

.continent-tab {
  padding: 8px 16px;
  border: 1px solid var(--border-color, rgba(255,255,255,0.12));
  border-radius: 8px;
  background: transparent;
  color: var(--muted, #8faab8);
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.15s;
}

.continent-tab.active,
.continent-tab:hover {
  background: var(--brand-gradient, linear-gradient(135deg, #e63b3b, #c41e3a));
  color: #fff;
  border-color: transparent;
}

/* Main Grid */
.main-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 20px;
  margin-bottom: 20px;
}

@media (min-width: 900px) {
  .main-grid {
    grid-template-columns: 3fr 2fr;
  }
}

/* Map Panel */
.map-panel {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

/* View Tabs */
.view-tabs {
  display: flex;
  gap: 4px;
  flex-wrap: wrap;
}

.view-tab {
  padding: 6px 12px;
  border: 1px solid var(--border-color, rgba(255,255,255,0.1));
  border-radius: 6px;
  background: transparent;
  color: var(--muted, #8faab8);
  font-size: 12px;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.15s;
}

.view-tab:hover {
  background: var(--hover-overlay, rgba(255, 255, 255, 0.06));
  border-color: var(--border-color-hover, rgba(255, 255, 255, 0.12));
}

.view-tab.active {
  background: var(--hover-overlay, rgba(255, 255, 255, 0.06));
  color: var(--brand, #e63b3b);
  border-color: var(--brand, #e63b3b);
}

.view-tab.active:hover {
  background: var(--hover-overlay, rgba(255, 255, 255, 0.06));
}

/* Map Container */
.map-container {
  background: var(--card, #122736);
  border-radius: 12px;
  padding: 12px;
  position: relative;
  min-height: 360px;
  display: flex;
  align-items: center;
  justify-content: center;
  border: 1px solid var(--border-color, rgba(255,255,255,0.06));
  overflow: hidden;
}

.map-container svg {
  width: 100%;
  height: 100%;
  max-height: 580px;
  display: block;
  margin: 0 auto;
}

.map-container svg path,
.map-container svg polygon {
  stroke: var(--separator, rgba(255,255,255,0.2));
  stroke-width: 0.5;
}

.map-container svg text {
  display: none;
}

.map-container.loading {
  opacity: 0.5;
}

/* Tooltip */
.map-tooltip {
  position: absolute;
  display: none;
  pointer-events: none;
  background: rgba(0,0,0,0.85);
  color: #fff;
  padding: 6px 12px;
  border-radius: 6px;
  font-size: 13px;
  font-weight: 500;
  z-index: 200;
  white-space: nowrap;
}

/* Legend */
.legend {
  background: var(--surface, rgba(0,0,0,0.25));
  border-radius: 8px;
  padding: 10px 14px;
  font-size: 12px;
}

.legend strong {
  display: block;
  margin-bottom: 6px;
  font-size: 13px;
  color: var(--text, #e7f1f7);
}

.legend-item {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 2px 0;
  color: var(--muted, #8faab8);
}

.legend-swatch {
  width: 14px;
  height: 14px;
  border-radius: 3px;
  flex-shrink: 0;
  border: 1px solid var(--border-color, rgba(255,255,255,0.15));
}

/* Detail Panel */
.detail-panel {
  background: var(--card, #122736);
  border-radius: 12px;
  padding: 24px;
  border: 1px solid var(--border-color, rgba(255,255,255,0.06));
  min-height: 400px;
}

.detail-panel .placeholder-text {
  color: var(--muted, #8faab8);
  text-align: center;
  padding: 60px 20px;
  font-size: 15px;
}

.detail-loading {
  display: flex;
  justify-content: center;
  padding: 60px 0;
}

.detail-title {
  font-size: 22px;
  margin-bottom: 16px;
  padding-bottom: 12px;
  border-bottom: 1px solid var(--separator, rgba(255,255,255,0.08));
}

.detail-subtitle {
  font-size: 15px;
  margin: 16px 0 8px;
  color: var(--muted, #8faab8);
}

.detail-subtitle small {
  font-weight: 400;
  opacity: 0.7;
}

.detail-grid {
  display: grid;
  gap: 0;
}

.detail-row {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  padding: 8px 0;
  border-bottom: 1px solid var(--hover-overlay, rgba(255,255,255,0.04));
  gap: 12px;
}

.detail-label {
  font-size: 13px;
  color: var(--muted, #8faab8);
  flex-shrink: 0;
}

.detail-value {
  font-size: 14px;
  font-weight: 600;
  text-align: right;
}

#trend-chart {
  width: 100%;
  margin-top: 8px;
  border-radius: 8px;
}

/* Spinner */
.spinner {
  width: 32px;
  height: 32px;
  border: 3px solid var(--spinner-track, rgba(255,255,255,0.1));
  border-top-color: var(--brand, #e63b3b);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}

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

/* Footer */
.ll-footer {
  padding: 20px 0;
  border-top: 1px solid var(--separator, rgba(255,255,255,0.08));
  margin-top: 20px;
  display: flex;
  flex-wrap: wrap;
  gap: 16px;
  align-items: center;
  justify-content: space-between;
  font-size: 13px;
  color: var(--muted, #8faab8);
}

.ll-footer a {
  color: var(--muted, #8faab8);
  transition: color 0.15s;
}

.ll-footer a:hover {
  color: var(--text, #e7f1f7);
}

.footer-links {
  display: flex;
  gap: 16px;
  flex-wrap: wrap;
}

/* Disclaimer Modal */
.modal-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: var(--modal-backdrop, rgba(0,0,0,0.7));
  z-index: 1000;
  align-items: center;
  justify-content: center;
  padding: 16px;
}

.modal-box {
  background: var(--card, #122736);
  border-radius: 12px;
  padding: 24px;
  max-width: 480px;
  width: 100%;
  border: 1px solid var(--border-color, rgba(255,255,255,0.1));
}

.modal-box h3 {
  margin-bottom: 12px;
}

.modal-box p {
  color: var(--muted, #8faab8);
  font-size: 14px;
  line-height: 1.6;
}

.modal-close {
  margin-top: 16px;
  padding: 8px 20px;
  background: var(--brand, #e63b3b);
  color: #fff;
  border: none;
  border-radius: 6px;
  cursor: pointer;
  font-weight: 600;
}

/* Mobile */
@media (max-width: 768px) {
  .ll-header { gap: 12px; }
  .search-input { padding: 12px 16px; font-size: 15px; }
  .detail-panel { padding: 16px; }
  .detail-title { font-size: 18px; }
  .continent-tab { padding: 6px 12px; font-size: 12px; }
  .map-container { padding: 8px; min-height: 220px; }
}

/* High Contrast */
@media (forced-colors: active) {
  .continent-tab.active,
  .view-tab.active,
  .lang-btn.active {
    border: 2px solid CanvasText;
  }
}

/* Reduced Motion */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.01ms !important;
    transition-duration: 0.01ms !important;
  }
}
