/* ═══════════════════════════════════════════
   Power Digital Cases — Modern UI
   ═══════════════════════════════════════════ */

:root {
  --primary: #0f4c81;
  --primary-light: #e8f4fd;
  --accent: #00c9a7;
  --accent-dark: #00a88c;
  --bg: #f8fafc;
  --surface: #ffffff;
  --text: #1a202c;
  --text-secondary: #64748b;
  --border: #e2e8f0;
  --shadow-sm: 0 1px 2px rgba(0,0,0,0.05);
  --shadow: 0 4px 6px -1px rgba(0,0,0,0.07), 0 2px 4px -2px rgba(0,0,0,0.05);
  --shadow-lg: 0 10px 25px -5px rgba(0,0,0,0.08), 0 8px 10px -6px rgba(0,0,0,0.04);
  --shadow-xl: 0 20px 40px -10px rgba(0,0,0,0.12);
  --radius: 8px;
  --radius-sm: 6px;
  --radius-lg: 8px;
  --font: 'Inter', 'Noto Sans SC', -apple-system, BlinkMacSystemFont, sans-serif;
  --transition: 0.25s cubic-bezier(0.4, 0, 0.2, 1);
}

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

html { scroll-behavior: smooth; }

body {
  font-family: var(--font);
  background: var(--bg);
  color: var(--text);
  line-height: 1.65;
  -webkit-font-smoothing: antialiased;
  overflow-x: hidden;
}

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

/* ─── Navbar ─── */
.navbar {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  z-index: 900;
  background: rgba(255,255,255,0.85);
  backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--border);
  height: 60px;
}
.nav-inner {
  max-width: 1280px;
  margin: 0 auto;
  padding: 0 24px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  height: 100%;
}
.nav-brand {
  font-weight: 700;
  font-size: 1.15em;
  color: var(--primary);
  text-decoration: none;
}
.nav-links {
  display: flex;
  gap: 28px;
}
.nav-links a {
  text-decoration: none;
  color: var(--text-secondary);
  font-size: 0.9em;
  font-weight: 500;
  transition: color var(--transition);
}
.nav-links a:hover {
  color: var(--primary);
}

/* ─── Hero ─── */
.hero {
  background: #0b3558;
  border-bottom: 5px solid var(--accent);
  padding: 112px 0 64px;
  text-align: center;
  color: #fff;
  position: relative;
}
.hero-content {
  position: relative;
  z-index: 1;
}
.hero h1 {
  font-size: 2.75em;
  font-weight: 700;
  line-height: 1.2;
  margin-bottom: 16px;
  letter-spacing: 0;
}
.hero-kicker,
.section-kicker {
  margin-bottom: 8px;
  color: var(--accent);
  font-size: 0.76em;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.08em;
}
.hero-sub {
  font-size: 1.15em;
  opacity: 0.9;
  margin-bottom: 36px;
  font-weight: 300;
}
.hero-stats {
  display: flex;
  justify-content: center;
  gap: 48px;
  flex-wrap: wrap;
}
.hero-stat {
  text-align: center;
}
.hero-stat .num {
  font-size: 2.2em;
  font-weight: 700;
  line-height: 1.1;
}
.hero-stat .label {
  font-size: 0.85em;
  opacity: 0.8;
  margin-top: 4px;
}

/* ─── Section Titles ─── */
.section-title {
  font-size: 1.6em;
  font-weight: 700;
  margin-bottom: 8px;
  color: var(--text);
}
.section-sub {
  color: var(--text-secondary);
  margin-bottom: 24px;
  font-size: 0.95em;
}
.section-heading-row {
  display: flex;
  align-items: end;
  justify-content: space-between;
  gap: 28px;
  margin-bottom: 24px;
}
.section-heading-row .section-title,
.section-heading-row .section-sub { margin-bottom: 0; }

/* ─── Dashboard ─── */
.dashboard-section {
  padding: 64px 0;
}
.dashboard-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 24px;
  margin-top: 24px;
}
.chart-card {
  background: var(--surface);
  border-radius: var(--radius);
  padding: 24px;
  box-shadow: var(--shadow);
  border: 1px solid var(--border);
}
.chart-card h3 {
  font-size: 1em;
  font-weight: 600;
  margin-bottom: 16px;
  color: var(--text);
}
.chart-container {
  position: relative;
  height: 220px;
}

/* ─── Map ─── */
.map-section {
  padding: 64px 0;
  background: linear-gradient(180deg, var(--bg) 0%, #eef2f7 100%);
}
#world-map {
  width: 100%;
  height: 500px;
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-lg);
  overflow: hidden;
}
#map-legend {
  display: flex;
  justify-content: center;
  gap: 24px;
  margin-top: 16px;
  font-size: 0.85em;
  color: var(--text-secondary);
}
.legend-item {
  display: flex;
  align-items: center;
  gap: 6px;
}
.legend-dot {
  width: 12px;
  height: 12px;
  border-radius: 50%;
}

/* ─── Search & Filters ─── */
.search-section {
  padding: 48px 0 24px;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
}
.search-bar {
  margin-bottom: 20px;
}
#search-input {
  width: 100%;
  padding: 16px 24px;
  font-size: 16px;
  border: 2px solid var(--border);
  border-radius: var(--radius);
  outline: none;
  transition: border-color var(--transition), box-shadow var(--transition);
  background: var(--surface);
  font-family: var(--font);
}
#search-input:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 4px rgba(15,76,129,0.1);
}
.filters-bar {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  align-items: center;
  margin-bottom: 16px;
}
.filter-group {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 0.85em;
  color: var(--text-secondary);
  font-weight: 500;
  white-space: nowrap;
}
.filter-group span {
  font-size: 0.85em;
  color: var(--text-secondary);
  font-weight: 500;
  white-space: nowrap;
}
.filter-group select {
  padding: 8px 12px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  font-size: 0.88em;
  background: var(--surface);
  cursor: pointer;
  font-family: var(--font);
  transition: border-color var(--transition);
}

.view-switcher-wrap { padding-top: 24px; }
.view-switcher {
  display: inline-flex;
  gap: 4px;
  padding: 4px;
  background: #e9eef3;
  border-radius: var(--radius);
}
.view-switcher button {
  min-width: 88px;
  padding: 9px 16px;
  border: 0;
  border-radius: var(--radius-sm);
  background: transparent;
  color: var(--text-secondary);
  font: 600 0.9em var(--font);
  cursor: pointer;
}
.view-switcher button[aria-selected="true"] {
  background: var(--surface);
  color: var(--primary);
  box-shadow: var(--shadow-sm);
}
.view-panel { padding-top: 20px; }
.view-panel[hidden] { display: none; }
.filter-group select:focus {
  outline: none;
  border-color: var(--primary);
}
.btn-reset {
  padding: 8px 18px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--surface);
  cursor: pointer;
  font-size: 0.88em;
  color: var(--text-secondary);
  font-family: var(--font);
  font-weight: 500;
  transition: all var(--transition);
}
.btn-reset:hover {
  background: var(--primary-light);
  color: var(--primary);
  border-color: var(--primary);
}

/* ─── Tag Cloud ─── */
.tags-section { padding: 8px 0 16px; }
.tag-cloud { display: flex; flex-wrap: wrap; gap: 8px; }
.tag {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 6px 14px;
  background: var(--surface);
  color: var(--primary);
  border: 1px solid var(--border);
  border-radius: 20px;
  font-size: 0.82em;
  font-weight: 500;
  cursor: pointer;
  transition: all var(--transition);
}
.tag:hover {
  background: var(--primary-light);
  border-color: var(--primary);
  transform: translateY(-1px);
  box-shadow: var(--shadow-sm);
}
.tag.active {
  background: var(--primary);
  color: #fff;
  border-color: var(--primary);
}
.tag .count {
  font-size: 0.8em;
  opacity: 0.7;
}
.stats {
  padding: 8px 0;
  color: var(--text-secondary);
  font-size: 0.88em;
  font-weight: 500;
}

/* ─── Case Grid ─── */
.case-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(min(100%, 340px), 1fr));
  gap: 20px;
  padding: 16px 0 64px;
}
.load-more-wrap { display: flex; justify-content: center; padding: 0 0 64px; }
.load-more {
  min-width: 180px;
  padding: 11px 18px;
  border: 1px solid var(--primary);
  border-radius: var(--radius-sm);
  background: var(--surface);
  color: var(--primary);
  font: 600 0.9em var(--font);
  cursor: pointer;
}
.load-more:hover { background: var(--primary-light); }
.case-card {
  background: var(--surface);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 24px;
  cursor: pointer;
  transition: all var(--transition);
  border: 1px solid var(--border);
  position: relative;
  overflow: hidden;
}
.case-card::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 3px;
  background: linear-gradient(90deg, var(--primary), var(--accent));
  opacity: 0;
  transition: opacity var(--transition);
}
.case-card:hover {
  box-shadow: var(--shadow-lg);
  transform: translateY(-3px);
  border-color: transparent;
}
.case-card:hover::before {
  opacity: 1;
}
.card-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 10px;
}
.case-card .country {
  display: inline-block;
  font-size: 0.76em;
  padding: 3px 10px;
  background: #ecfdf5;
  color: #059669;
  border-radius: 6px;
  font-weight: 500;
}
.confidence {
  display: inline-block;
  font-size: 0.74em;
  padding: 3px 10px;
  border-radius: 6px;
  font-weight: 600;
}
.conf-high { background: #ecfdf5; color: #059669; }
.conf-mid { background: #fefce8; color: #a16207; }
.conf-low { background: #fef2f2; color: #dc2626; }
.conf-none { background: #f1f5f9; color: #64748b; }
.case-card h3 {
  font-size: 1.05em;
  margin-bottom: 6px;
  line-height: 1.45;
  font-weight: 600;
}
.case-card .company {
  color: var(--text-secondary);
  font-size: 0.88em;
  margin-bottom: 10px;
}
.case-card .summary {
  font-size: 0.88em;
  color: var(--text-secondary);
  margin-bottom: 12px;
  display: -webkit-box;
  -webkit-line-clamp: 3;
  -webkit-box-orient: vertical;
  overflow: hidden;
  line-height: 1.55;
}
.card-tags { display: flex; flex-wrap: wrap; gap: 6px; }
.card-tags span {
  font-size: 0.74em;
  padding: 3px 10px;
  background: #f1f5f9;
  border-radius: 6px;
  color: var(--text-secondary);
  font-weight: 500;
}
.case-card .meta {
  display: flex;
  justify-content: space-between;
  margin-top: 12px;
  padding-top: 12px;
  border-top: 1px solid var(--border);
  font-size: 0.8em;
  color: var(--text-secondary);
}

/* ─── No Result ─── */
.no-result { text-align: center; padding: 80px 0; color: var(--text-secondary); font-size: 1.1em; }

/* ─── Footer ─── */
footer {
  background: #1a202c;
  color: #a0aec0;
  padding: 48px 0 24px;
}
.footer-grid {
  display: grid;
  grid-template-columns: 2fr 1fr 1fr;
  gap: 32px;
  margin-bottom: 32px;
}
.footer-grid h3 { color: #fff; font-size: 1.2em; margin-bottom: 8px; }
.footer-grid h4 { color: #e2e8f0; font-size: 1em; margin-bottom: 8px; }
.footer-grid p { font-size: 0.9em; line-height: 1.7; }
.footer-bottom {
  border-top: 1px solid #2d3748;
  padding-top: 20px;
  text-align: center;
  font-size: 0.85em;
}

/* ─── Modal ─── */
.modal { position: fixed; top: 0; left: 0; width: 100%; height: 100%; z-index: 1000; }
.modal[hidden] { display: none; }
.modal-overlay { position: absolute; top: 0; left: 0; width: 100%; height: 100%; background: rgba(0,0,0,0.5); backdrop-filter: blur(4px); }
.modal-content {
  position: relative;
  max-width: 720px;
  margin: 40px auto;
  background: #fff;
  border-radius: var(--radius-lg);
  padding: 36px;
  max-height: 85vh;
  overflow-y: auto;
  box-shadow: var(--shadow-xl);
}
.modal-close {
  position: absolute;
  top: 16px;
  right: 20px;
  font-size: 28px;
  background: none;
  border: none;
  cursor: pointer;
  color: var(--text-secondary);
  line-height: 1;
  transition: color var(--transition);
}
.modal-close:hover { color: var(--text); }
.modal-content h2 { margin-bottom: 8px; font-size: 1.5em; font-weight: 700; }
.modal-content .modal-company { color: var(--text-secondary); margin-bottom: 20px; font-size: 1em; }
.modal-content .modal-detail { line-height: 1.85; margin: 16px 0; white-space: pre-line; font-size: 0.95em; }
.modal-content .modal-source { margin-top: 16px; }
.modal-content .modal-source a { color: var(--primary); word-break: break-all; text-decoration: none; }
.modal-content .modal-source a:hover { text-decoration: underline; }
.modal-content .modal-tags { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 12px; }
.modal-content .modal-tags span {
  padding: 4px 14px;
  background: var(--primary-light);
  color: var(--primary);
  border-radius: 20px;
  font-size: 0.85em;
  font-weight: 500;
}
.modal-meta {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
  gap: 12px;
  margin: 16px 0;
  padding: 16px;
  background: var(--bg);
  border-radius: var(--radius);
}
.modal-meta .meta-item label { display: block; font-size: 0.78em; color: var(--text-secondary); text-transform: uppercase; letter-spacing: 0.5px; }
.modal-meta .meta-item span { font-weight: 600; font-size: 0.95em; }

/* ─── Leaflet Popup ─── */
.leaflet-popup-content-wrapper {
  border-radius: var(--radius-sm) !important;
  box-shadow: var(--shadow-lg) !important;
}
.popup-title { font-weight: 700; font-size: 1em; margin-bottom: 4px; }
.popup-count { font-size: 0.85em; color: var(--text-secondary); }
.popup-tags { margin-top: 6px; font-size: 0.8em; color: var(--primary); }

/* ─── Responsive ─── */
@media (max-width: 1024px) {
  .dashboard-grid { grid-template-columns: 1fr; }
}
@media (max-width: 768px) {
  .container, .nav-inner { padding-left: 16px; padding-right: 16px; }
  .hero { padding: 96px 0 48px; }
  .hero h1 { font-size: 2em; }
  .hero-stats { gap: 24px; }
  .hero-stat .num { font-size: 1.6em; }
  .case-grid { grid-template-columns: 1fr; }
  .footer-grid { grid-template-columns: 1fr; }
  .nav-links { display: none; }
  #world-map { height: 350px; }
  .modal-content { width: calc(100% - 24px); margin: 12px auto; padding: 24px 18px; max-height: calc(100vh - 24px); }
  .dashboard-grid { grid-template-columns: 1fr; }
  .section-heading-row { display: block; }
  .section-heading-row .section-sub { margin-top: 8px; }
  .filters-bar { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .filter-group { display: grid; gap: 4px; white-space: normal; }
  .filter-group select { width: 100%; min-width: 0; }
  .btn-reset { align-self: end; }
  .view-switcher { display: grid; grid-template-columns: repeat(3, 1fr); width: 100%; }
  .view-switcher button { min-width: 0; }
  .case-card .meta { flex-direction: column; gap: 4px; }
  #map-legend { flex-wrap: wrap; }
}
