/* === CSS Variables === */
:root {
  --indigo-950: #1e1b4b;
  --indigo-900: #312e81;
  --indigo-800: #3730a3;
  --indigo-700: #4338ca;
  --indigo-600: #4f46e5;
  --indigo-500: #6366f1;
  --indigo-400: #818cf8;
  --indigo-100: #e0e7ff;
  --indigo-50: #eef2ff;
  --cream: #fdf6e3;
  --cream-dark: #f5eedc;
  --terracotta: #c2410c;
  --terracotta-light: #ea580c;
  --green-600: #16a34a;
  --green-100: #dcfce7;
  --yellow-600: #ca8a04;
  --yellow-100: #fef9c3;
  --orange-600: #ea580c;
  --orange-100: #ffedd5;
  --red-600: #dc2626;
  --red-100: #fee2e2;
  --gray-100: #f3f4f6;
  --gray-200: #e5e7eb;
  --gray-300: #d1d5db;
  --gray-500: #6b7280;
  --gray-600: #4b5563;
  --gray-700: #374151;
  --gray-800: #1f2937;
  --gray-900: #111827;
  --white: #ffffff;
  --shadow-sm: 0 1px 2px rgba(0,0,0,0.05);
  --shadow: 0 1px 3px rgba(0,0,0,0.1), 0 1px 2px rgba(0,0,0,0.06);
  --shadow-md: 0 4px 6px rgba(0,0,0,0.1), 0 2px 4px rgba(0,0,0,0.06);
  --shadow-lg: 0 10px 15px rgba(0,0,0,0.1), 0 4px 6px rgba(0,0,0,0.05);
  --radius: 12px;
  --radius-sm: 8px;
  --transition: 0.2s ease;
}

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

html {
  font-size: 16px;
  -webkit-text-size-adjust: 100%;
  -webkit-tap-highlight-color: transparent;
}

body {
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
  background: var(--cream);
  color: var(--gray-800);
  line-height: 1.6;
  min-height: 100vh;
  overflow-x: hidden;
}

h1, h2, h3, h4 {
  font-family: 'Playfair Display', Georgia, serif;
  font-weight: 700;
  line-height: 1.3;
}

/* === Header === */
.header {
  background: var(--indigo-950);
  color: var(--white);
  padding: 0 16px;
  height: 56px;
  display: flex;
  align-items: center;
  position: sticky;
  top: 0;
  z-index: 100;
  box-shadow: var(--shadow-md);
}

.header-brand {
  font-family: 'Playfair Display', Georgia, serif;
  font-size: 1.25rem;
  font-weight: 700;
  flex: 1;
  display: flex;
  align-items: center;
  gap: 6px;
}

.header-back {
  background: none;
  border: none;
  color: var(--white);
  font-size: 1.5rem;
  cursor: pointer;
  padding: 8px;
  margin-left: -8px;
  margin-right: 4px;
  border-radius: 50%;
  display: none;
  align-items: center;
  justify-content: center;
  transition: background var(--transition);
  min-width: 40px;
  min-height: 40px;
}

.header-back:hover { background: rgba(255,255,255,0.1); }
.header-back.visible { display: flex; }

.header-offline {
  font-size: 0.75rem;
  background: var(--terracotta);
  padding: 2px 8px;
  border-radius: 12px;
  display: none;
}

.header-offline.visible { display: inline-block; }

/* === Main Container === */
.container {
  max-width: 640px;
  margin: 0 auto;
  padding: 0;
  min-height: calc(100vh - 56px);
}

/* === Country List View === */
.view { display: none; }
.view.active { display: block; }

.search-bar {
  padding: 16px;
  background: var(--white);
  border-bottom: 1px solid var(--gray-200);
  position: sticky;
  top: 56px;
  z-index: 50;
}

.search-input {
  width: 100%;
  padding: 12px 16px 12px 44px;
  border: 2px solid var(--gray-200);
  border-radius: var(--radius);
  font-size: 1rem;
  font-family: 'Inter', sans-serif;
  background: var(--gray-100);
  transition: border-color var(--transition), background var(--transition);
  outline: none;
}

.search-input:focus {
  border-color: var(--indigo-600);
  background: var(--white);
}

.search-icon {
  position: absolute;
  left: 30px;
  top: 50%;
  transform: translateY(-50%);
  color: var(--gray-500);
  font-size: 1.1rem;
  pointer-events: none;
}

.search-bar-inner { position: relative; }

.country-list {
  list-style: none;
  padding: 8px 16px 16px;
}

.country-item {
  display: flex;
  align-items: center;
  padding: 14px 16px;
  background: var(--white);
  border-radius: var(--radius-sm);
  margin-bottom: 6px;
  cursor: pointer;
  transition: background var(--transition), transform var(--transition);
  box-shadow: var(--shadow-sm);
  gap: 12px;
}

.country-item:hover {
  background: var(--indigo-50);
  transform: translateY(-1px);
  box-shadow: var(--shadow);
}

.country-item:active { transform: scale(0.99); }

.country-flag {
  font-size: 2rem;
  line-height: 1;
  flex-shrink: 0;
}

.country-info { flex: 1; min-width: 0; }

.country-name {
  font-weight: 600;
  font-size: 1rem;
  color: var(--gray-900);
}

.country-meta {
  font-size: 0.8rem;
  color: var(--gray-500);
  margin-top: 2px;
}

.country-status {
  font-size: 1.1rem;
  flex-shrink: 0;
}

.no-results {
  text-align: center;
  padding: 48px 16px;
  color: var(--gray-500);
}

.no-results-emoji { font-size: 3rem; margin-bottom: 12px; }

/* === Country Detail View === */
.country-hero {
  background: var(--indigo-950);
  color: var(--white);
  padding: 20px 16px 16px;
  text-align: center;
}

.country-hero-flag { font-size: 3.5rem; margin-bottom: 4px; }
.country-hero-name { font-size: 1.5rem; margin-bottom: 8px; }

.country-hero-actions {
  display: flex;
  justify-content: center;
  gap: 8px;
  margin-top: 12px;
}

.btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 10px 20px;
  border-radius: var(--radius-sm);
  font-size: 0.875rem;
  font-weight: 600;
  font-family: 'Inter', sans-serif;
  cursor: pointer;
  border: none;
  transition: all var(--transition);
  min-height: 44px;
}

.btn-primary {
  background: var(--indigo-600);
  color: var(--white);
}

.btn-primary:hover { background: var(--indigo-500); }

.btn-primary.downloaded {
  background: var(--green-600);
}

.btn-outline {
  background: transparent;
  color: var(--white);
  border: 2px solid rgba(255,255,255,0.3);
}

.btn-outline:hover { border-color: rgba(255,255,255,0.6); }

/* === Tabs === */
.tabs-wrapper {
  position: sticky;
  top: 56px;
  z-index: 40;
  background: var(--white);
  border-bottom: 1px solid var(--gray-200);
}

.tabs-scroll {
  display: flex;
  overflow-x: auto;
  scrollbar-width: none;
  -webkit-overflow-scrolling: touch;
  padding: 0 8px;
}

.tabs-scroll::-webkit-scrollbar { display: none; }

.tab-btn {
  flex-shrink: 0;
  padding: 12px 14px;
  background: none;
  border: none;
  border-bottom: 3px solid transparent;
  font-size: 0.8rem;
  font-weight: 500;
  font-family: 'Inter', sans-serif;
  color: var(--gray-500);
  cursor: pointer;
  white-space: nowrap;
  transition: all var(--transition);
  display: flex;
  align-items: center;
  gap: 4px;
}

.tab-btn:hover { color: var(--gray-700); }

.tab-btn.active {
  color: var(--indigo-600);
  border-bottom-color: var(--indigo-600);
  font-weight: 600;
}

/* === Tab Content === */
.tab-content { display: none; padding: 16px; }
.tab-content.active { display: block; }

/* === Emergency Numbers === */
.emergency-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
  margin-bottom: 16px;
}

.emergency-card {
  background: var(--white);
  border-radius: var(--radius);
  padding: 20px 16px;
  text-align: center;
  box-shadow: var(--shadow);
  text-decoration: none;
  color: inherit;
  transition: all var(--transition);
  border: 2px solid transparent;
}

.emergency-card:hover {
  transform: translateY(-2px);
  box-shadow: var(--shadow-md);
}

.emergency-card.police { border-color: #2563eb; }
.emergency-card.ambulance { border-color: var(--terracotta); }
.emergency-card.fire { border-color: #dc2626; }
.emergency-card.universal { border-color: var(--green-600); }

.emergency-icon { font-size: 2rem; margin-bottom: 8px; }

.emergency-label {
  font-size: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--gray-500);
  font-weight: 600;
  margin-bottom: 4px;
}

.emergency-number {
  font-size: 1.75rem;
  font-weight: 700;
  color: var(--gray-900);
  font-family: 'Inter', sans-serif;
}

.emergency-card.universal .emergency-number { color: var(--green-600); }

.emergency-note {
  background: var(--yellow-100);
  border-left: 4px solid var(--yellow-600);
  padding: 12px 16px;
  border-radius: 0 var(--radius-sm) var(--radius-sm) 0;
  font-size: 0.875rem;
  line-height: 1.5;
}

/* === Section Cards === */
.section-card {
  background: var(--white);
  border-radius: var(--radius);
  padding: 16px;
  margin-bottom: 12px;
  box-shadow: var(--shadow-sm);
}

.section-card h3 {
  font-size: 1rem;
  margin-bottom: 12px;
  display: flex;
  align-items: center;
  gap: 8px;
}

.section-card p {
  font-size: 0.875rem;
  margin-bottom: 8px;
  line-height: 1.6;
}

.section-card p:last-child { margin-bottom: 0; }

/* === Embassy List === */
.embassy-item {
  background: var(--white);
  border-radius: var(--radius);
  padding: 16px;
  margin-bottom: 12px;
  box-shadow: var(--shadow-sm);
  border-left: 4px solid var(--indigo-600);
}

.embassy-name {
  font-weight: 700;
  font-size: 1rem;
  margin-bottom: 4px;
  color: var(--gray-900);
}

.embassy-type {
  display: inline-block;
  font-size: 0.7rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  padding: 2px 8px;
  border-radius: 12px;
  background: var(--indigo-100);
  color: var(--indigo-700);
  font-weight: 600;
  margin-bottom: 8px;
}

.embassy-detail {
  display: flex;
  align-items: flex-start;
  gap: 8px;
  font-size: 0.875rem;
  margin-bottom: 6px;
  color: var(--gray-600);
}

.embassy-detail-icon { flex-shrink: 0; width: 20px; text-align: center; }

.embassy-phone {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  color: var(--indigo-600);
  text-decoration: none;
  font-weight: 600;
  font-size: 1rem;
  padding: 8px 16px;
  background: var(--indigo-50);
  border-radius: var(--radius-sm);
  margin-top: 8px;
  min-height: 48px;
  transition: background var(--transition);
}

.embassy-phone:hover { background: var(--indigo-100); }

/* === Advisory Levels === */
.advisory-card {
  background: var(--white);
  border-radius: var(--radius);
  padding: 16px;
  margin-bottom: 12px;
  box-shadow: var(--shadow-sm);
}

.advisory-level {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 8px 16px;
  border-radius: var(--radius-sm);
  font-weight: 700;
  font-size: 1rem;
  margin-bottom: 12px;
}

.advisory-level-1 { background: var(--green-100); color: #15803d; }
.advisory-level-2 { background: var(--yellow-100); color: #a16207; }
.advisory-level-3 { background: var(--orange-100); color: #c2410c; }
.advisory-level-4 { background: var(--red-100); color: #dc2626; }

.advisory-source {
  font-size: 0.75rem;
  color: var(--gray-500);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  font-weight: 600;
  margin-bottom: 4px;
}

.advisory-summary {
  font-size: 0.875rem;
  color: var(--gray-600);
  line-height: 1.6;
  margin-bottom: 8px;
}

.advisory-link {
  color: var(--indigo-600);
  text-decoration: none;
  font-size: 0.875rem;
  font-weight: 500;
}

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

/* === Scam Cards === */
.scam-card {
  background: var(--white);
  border-radius: var(--radius);
  padding: 16px;
  margin-bottom: 12px;
  box-shadow: var(--shadow-sm);
  border-left: 4px solid var(--terracotta);
}

.scam-name {
  font-weight: 700;
  font-size: 1rem;
  margin-bottom: 2px;
}

.scam-city {
  font-size: 0.75rem;
  color: var(--gray-500);
  margin-bottom: 8px;
}

.scam-desc {
  font-size: 0.875rem;
  color: var(--gray-600);
  margin-bottom: 8px;
  line-height: 1.5;
}

.scam-avoid {
  background: var(--green-100);
  border-radius: var(--radius-sm);
  padding: 10px 12px;
  font-size: 0.8rem;
  color: #15803d;
  line-height: 1.5;
}

.scam-avoid strong {
  display: block;
  margin-bottom: 2px;
}

/* === Phrase List === */
.phrase-item {
  background: var(--white);
  border-radius: var(--radius-sm);
  padding: 12px 16px;
  margin-bottom: 8px;
  box-shadow: var(--shadow-sm);
}

.phrase-english {
  font-size: 0.75rem;
  color: var(--gray-500);
  text-transform: uppercase;
  letter-spacing: 0.03em;
  font-weight: 600;
}

.phrase-local {
  font-size: 1.125rem;
  font-weight: 700;
  color: var(--gray-900);
  margin: 2px 0;
}

.phrase-phonetic {
  font-size: 0.875rem;
  color: var(--indigo-600);
  font-style: italic;
}

/* === Medication Status === */
.med-status {
  display: inline-block;
  padding: 2px 10px;
  border-radius: 12px;
  font-size: 0.7rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.med-status.banned { background: var(--red-100); color: #dc2626; }
.med-status.restricted { background: var(--orange-100); color: #c2410c; }
.med-status.allowed { background: var(--green-100); color: #15803d; }

.med-item {
  background: var(--white);
  border-radius: var(--radius-sm);
  padding: 12px 16px;
  margin-bottom: 8px;
  box-shadow: var(--shadow-sm);
}

.med-name {
  font-weight: 700;
  margin-bottom: 4px;
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}

.med-note {
  font-size: 0.875rem;
  color: var(--gray-600);
  line-height: 1.5;
}

/* === Safety Ratings === */
.risk-badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 6px 14px;
  border-radius: 20px;
  font-weight: 600;
  font-size: 0.875rem;
}

.risk-very-low { background: var(--green-100); color: #15803d; }
.risk-low { background: #d1fae5; color: #047857; }
.risk-moderate { background: var(--yellow-100); color: #a16207; }
.risk-high { background: var(--orange-100); color: #c2410c; }
.risk-very-high { background: var(--red-100); color: #dc2626; }

.safety-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
  margin: 16px 0;
}

.safety-metric {
  background: var(--white);
  border-radius: var(--radius-sm);
  padding: 12px;
  box-shadow: var(--shadow-sm);
}

.safety-metric-label {
  font-size: 0.7rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--gray-500);
  font-weight: 600;
  margin-bottom: 4px;
}

/* === Practical Info === */
.practical-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}

.practical-item {
  background: var(--white);
  border-radius: var(--radius-sm);
  padding: 14px;
  box-shadow: var(--shadow-sm);
}

.practical-label {
  font-size: 0.7rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--gray-500);
  font-weight: 600;
  margin-bottom: 4px;
}

.practical-value {
  font-size: 1rem;
  font-weight: 600;
  color: var(--gray-900);
}

.practical-item.full-width {
  grid-column: 1 / -1;
}

/* === Healthcare === */
.health-rating {
  display: inline-block;
  padding: 4px 12px;
  border-radius: 20px;
  font-size: 0.8rem;
  font-weight: 600;
  text-transform: capitalize;
}

.health-rating.excellent { background: var(--green-100); color: #15803d; }
.health-rating.good { background: #d1fae5; color: #047857; }
.health-rating.adequate { background: var(--yellow-100); color: #a16207; }
.health-rating.limited { background: var(--orange-100); color: #c2410c; }
.health-rating.poor { background: var(--red-100); color: #dc2626; }

.vaccine-list {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-top: 8px;
}

.vaccine-tag {
  background: var(--indigo-50);
  color: var(--indigo-700);
  padding: 4px 10px;
  border-radius: 16px;
  font-size: 0.8rem;
  font-weight: 500;
}

/* === Disaster tags === */
.disaster-list {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-top: 8px;
}

.disaster-tag {
  background: var(--orange-100);
  color: var(--orange-600);
  padding: 4px 10px;
  border-radius: 16px;
  font-size: 0.8rem;
  font-weight: 500;
  text-transform: capitalize;
}

/* === Connectivity === */
.connectivity-card {
  background: var(--white);
  border-radius: var(--radius);
  padding: 16px;
  margin-bottom: 12px;
  box-shadow: var(--shadow-sm);
}

.connectivity-card h4 {
  font-family: 'Inter', sans-serif;
  font-size: 0.875rem;
  font-weight: 600;
  color: var(--gray-900);
  margin-bottom: 6px;
  display: flex;
  align-items: center;
  gap: 6px;
}

.connectivity-card p {
  font-size: 0.875rem;
  color: var(--gray-600);
  line-height: 1.5;
}

/* === Cultural taboos === */
.taboo-list {
  list-style: none;
  padding: 0;
}

.taboo-list li {
  padding: 8px 0 8px 28px;
  border-bottom: 1px solid var(--gray-100);
  font-size: 0.875rem;
  position: relative;
}

.taboo-list li::before {
  content: '⛔';
  position: absolute;
  left: 0;
  top: 8px;
  font-size: 0.8rem;
}

.taboo-list li:last-child { border-bottom: none; }

/* === Install Banner === */
.install-banner {
  background: linear-gradient(135deg, var(--indigo-900), var(--indigo-950));
  color: var(--white);
  padding: 16px;
  margin: 16px;
  border-radius: var(--radius);
  display: none;
  align-items: center;
  gap: 12px;
}

.install-banner.visible { display: flex; }

.install-banner-text { flex: 1; }
.install-banner-text strong { display: block; margin-bottom: 2px; }
.install-banner-text small { opacity: 0.7; font-size: 0.8rem; }

.install-banner .btn {
  flex-shrink: 0;
  background: var(--white);
  color: var(--indigo-950);
}

.install-dismiss {
  background: none;
  border: none;
  color: rgba(255,255,255,0.6);
  font-size: 1.25rem;
  cursor: pointer;
  padding: 4px;
}

/* === Footer === */
.footer {
  text-align: center;
  padding: 32px 16px;
  color: var(--gray-500);
  font-size: 0.75rem;
}

.footer a { color: var(--indigo-600); text-decoration: none; }

/* === Loading State === */
.loading {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 64px 16px;
  color: var(--gray-500);
}

.spinner {
  width: 32px;
  height: 32px;
  border: 3px solid var(--gray-200);
  border-top-color: var(--indigo-600);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
  margin-bottom: 12px;
}

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

/* === Responsive === */
@media (min-width: 480px) {
  .emergency-grid { grid-template-columns: repeat(2, 1fr); }
}

@media (min-width: 640px) {
  .container { padding: 0 16px; }
  .tab-content { padding: 20px; }
}

/* Safe area for notch phones */
@supports (padding-top: env(safe-area-inset-top)) {
  .header {
    padding-top: env(safe-area-inset-top);
    height: calc(56px + env(safe-area-inset-top));
  }
}

/* Hospitals */
.hospital-item { padding: 12px 0; border-bottom: 1px solid var(--gray-200); }
.hospital-item:last-child { border-bottom: none; }
.hospital-name { font-weight: 600; font-size: 0.95rem; }
.hospital-meta { font-size: 0.8rem; color: var(--gray-500); margin: 2px 0 4px; }
.hospital-phone { display: inline-block; font-size: 0.85rem; color: var(--primary); text-decoration: none; margin-bottom: 4px; }
.hospital-flags { display: flex; gap: 6px; flex-wrap: wrap; margin: 4px 0; }
.hospital-flag { font-size: 0.7rem; padding: 2px 6px; border-radius: 4px; background: var(--gray-100); color: var(--gray-700); }
.hospital-flag.english { background: #dbeafe; color: #1d4ed8; }
.hospital-flag.intl { background: #d1fae5; color: #065f46; }
.hospital-notes { font-size: 0.8rem; color: var(--gray-600); margin-top: 4px; }

/* Disaster protocols */
.protocol-item { padding: 12px 0; border-bottom: 1px solid var(--gray-200); }
.protocol-item:last-child { border-bottom: none; }
.protocol-type { font-weight: 600; font-size: 0.9rem; text-transform: capitalize; margin-bottom: 6px; }
.protocol-section { font-size: 0.85rem; margin: 6px 0; }
.protocol-section ul { margin: 4px 0 0 16px; padding: 0; }
.protocol-section li { margin-bottom: 3px; }
.protocol-resources { font-size: 0.75rem; color: var(--gray-500); margin-top: 6px; }
