/* ============================================================
   Sicuro Group — ME Airspace Tracker Dashboard
   ============================================================ */

:root {
  --sg-dark: #1a1a2e;
  --sg-navy: #16213e;
  --sg-blue: #0F73C7;
  --sg-accent: #0D6EFD;
  --sg-white: #f8f9fa;
  --sg-gray: #6c757d;
  --sg-light: #e9ecef;

  --status-closed: #dc3545;
  --status-partial: #fd7e14;
  --status-restricted: #ffc107;
  --status-open: #28a745;
  --status-unknown: #6c757d;

  --radius: 6px;
  --shadow: 0 2px 8px rgba(0,0,0,0.12);
  --shadow-lg: 0 4px 20px rgba(0,0,0,0.15);
}

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

body {
  font-family: 'Raleway', -apple-system, BlinkMacSystemFont, sans-serif;
  background: #f0f2f5;
  color: #1a1a2e;
  min-height: 100vh;
}

/* HEADER */
.header {
  background: linear-gradient(135deg, var(--sg-dark) 0%, var(--sg-navy) 50%, #0a2d52 100%);
  color: white;
  padding: 16px 24px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  box-shadow: var(--shadow-lg);
}

.header-left { display: flex; align-items: center; gap: 12px; }
.header-center { text-align: center; flex: 1; }
.header-center h1 { font-size: 1.3rem; font-weight: 700; letter-spacing: -0.5px; }
.header-center .subtitle { font-size: 0.75rem; color: rgba(255,255,255,0.6); margin-top: 2px; }
.header-right { display: flex; align-items: center; gap: 16px; }

.logo {
  display: flex;
  align-items: center;
  text-decoration: none;
}
.logo-img {
  height: 40px;
  width: auto;
  object-fit: contain;
  filter: brightness(0) invert(1);
}

.last-refresh { display: flex; flex-direction: column; align-items: flex-end; font-size: 0.75rem; }
.refresh-label { color: rgba(255,255,255,0.5); font-size: 0.65rem; }
.refresh-time { font-weight: 600; font-variant-numeric: tabular-nums; }

.btn-refresh {
  background: rgba(255,255,255,0.1);
  border: 1px solid rgba(255,255,255,0.2);
  color: white;
  padding: 8px 16px;
  border-radius: var(--radius);
  cursor: pointer;
  font-size: 0.8rem;
  font-weight: 500;
  font-family: 'Raleway', sans-serif;
  display: flex;
  align-items: center;
  gap: 6px;
  transition: all 0.2s;
}
.btn-refresh:hover { background: rgba(255,255,255,0.2); }
.btn-refresh.loading svg { animation: spin 1s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

/* ALERT BANNER */
.alert-banner {
  background: var(--status-closed);
  color: white;
  padding: 10px 24px;
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 0.85rem;
  font-weight: 500;
}
.alert-icon { font-size: 1.2rem; }
.alert-close {
  margin-left: auto;
  background: none;
  border: none;
  color: white;
  font-size: 1.2rem;
  cursor: pointer;
}

/* SUMMARY BAR */
.summary-bar {
  background: white;
  padding: 12px 24px;
  display: flex;
  align-items: center;
  gap: 32px;
  border-bottom: 1px solid var(--sg-light);
  box-shadow: 0 1px 3px rgba(0,0,0,0.05);
}
.summary-item { display: flex; align-items: center; gap: 8px; }
.summary-count {
  font-size: 1.6rem;
  font-weight: 800;
  color: var(--sg-blue);
  font-variant-numeric: tabular-nums;
}
.summary-item.closed .summary-count { color: var(--status-closed); }
.summary-item.partial .summary-count { color: var(--status-partial); }
.summary-item.open .summary-count { color: var(--status-open); }
.summary-item.borders-open .summary-count { color: var(--status-open); }
.summary-label { font-size: 0.75rem; color: var(--sg-gray); font-weight: 500; }
.summary-time {
  margin-left: auto;
  text-align: right;
  font-variant-numeric: tabular-nums;
}
.summary-time span:first-child { font-size: 1.1rem; font-weight: 700; display: block; }
.tz-label { font-size: 0.65rem; color: var(--sg-gray); }

/* TABS */
.tabs {
  background: white;
  padding: 0 24px;
  display: flex;
  gap: 0;
  border-bottom: 2px solid var(--sg-light);
}
.tab {
  background: none;
  border: none;
  padding: 12px 20px;
  font-size: 0.85rem;
  font-weight: 500;
  font-family: 'Raleway', sans-serif;
  color: var(--sg-gray);
  cursor: pointer;
  border-bottom: 2px solid transparent;
  margin-bottom: -2px;
  transition: all 0.2s;
}
.tab:hover { color: var(--sg-dark); }
.tab.active {
  color: var(--sg-blue);
  border-bottom-color: var(--sg-blue);
  font-weight: 600;
}

/* TAB CONTENT */
.tab-content { display: none; padding: 20px 24px; }
.tab-content.active { display: block; }

.disclaimer {
  background: #fff3cd;
  border: 1px solid #ffc107;
  border-radius: var(--radius);
  padding: 10px 16px;
  font-size: 0.78rem;
  color: #664d03;
  margin-bottom: 16px;
}
.disclaimer a { color: #664d03; font-weight: 600; }

.section-intro {
  font-size: 0.85rem;
  color: var(--sg-gray);
  margin-bottom: 16px;
}

/* COUNTRY GRID */
.country-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(380px, 1fr));
  gap: 16px;
}

.country-card {
  background: white;
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  overflow: hidden;
  transition: box-shadow 0.2s;
}
.country-card:hover { box-shadow: var(--shadow-lg); }

.card-header {
  padding: 14px 16px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  border-bottom: 1px solid var(--sg-light);
}
.card-country {
  font-size: 1rem;
  font-weight: 700;
}
.card-fir {
  font-size: 0.7rem;
  font-weight: 600;
  color: var(--sg-gray);
  letter-spacing: 1px;
  font-family: 'SF Mono', 'Consolas', monospace;
}

.status-badge {
  padding: 4px 12px;
  border-radius: 20px;
  font-size: 0.7rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}
.status-CLOSED { background: var(--status-closed); color: white; }
.status-PARTIAL_RESTRICTED { background: var(--status-partial); color: white; }
.status-RESTRICTED { background: var(--status-partial); color: white; }
.status-OPEN { background: var(--status-open); color: white; }

.card-body { padding: 14px 16px; }

.card-notes {
  font-size: 0.8rem;
  line-height: 1.5;
  color: #333;
  margin-bottom: 8px;
}

.card-notam-expiry {
  font-size: 0.75rem;
  color: var(--status-closed);
  font-weight: 600;
  margin-bottom: 8px;
}

.card-meta {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 8px 16px;
  background: #f8f9fa;
  border-top: 1px solid var(--sg-light);
  font-size: 0.7rem;
  color: var(--sg-gray);
}

.card-sources a {
  color: var(--sg-blue);
  text-decoration: none;
  font-weight: 500;
  margin-right: 8px;
}
.card-sources a:hover { text-decoration: underline; }

.card-update-time {
  font-variant-numeric: tabular-nums;
  display: flex;
  align-items: center;
  gap: 6px;
}
.source-tag {
  font-size: 0.6rem;
  font-weight: 600;
  padding: 2px 6px;
  border-radius: 8px;
  background: #e1eefa;
  color: var(--sg-blue);
  text-transform: uppercase;
  letter-spacing: 0.3px;
}
.source-tag.ground {
  background: #155724;
  color: #fff;
  font-size: 0.65rem;
  padding: 3px 8px;
}
.source-tag.flight {
  background: #1a3a5c;
  color: #b8d4f0;
  font-size: 0.65rem;
  padding: 3px 8px;
}

.verify-label {
  font-size: 0.65rem;
  font-weight: 600;
  color: #999;
  margin-right: 4px;
  text-transform: uppercase;
  letter-spacing: 0.3px;
}

.loading-message {
  text-align: center;
  padding: 40px 20px;
  font-size: 0.9rem;
  color: var(--sg-gray);
  font-weight: 500;
  grid-column: 1 / -1;
}

.data-explainer {
  font-size: 0.75rem;
  color: #666;
  text-align: center;
  padding: 8px 20px;
  margin-bottom: 12px;
  line-height: 1.4;
}

.flight-summary {
  font-size: 0.75rem;
  color: #555;
  margin-bottom: 6px;
  line-height: 1.4;
}

.stale-badge {
  font-size: 0.6rem;
  font-weight: 500;
  color: #856404;
  background: #fff3cd;
  padding: 1px 6px;
  border-radius: 8px;
  margin-left: 4px;
}

.card-flights {
  margin-top: 8px;
  padding-top: 8px;
  border-top: 1px dashed var(--sg-light);
}
.card-flights-label {
  font-size: 0.7rem;
  font-weight: 600;
  color: var(--sg-gray);
  text-transform: uppercase;
  letter-spacing: 0.5px;
  margin-bottom: 4px;
}
.flight-stats {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-bottom: 6px;
}
.flight-stat {
  font-size: 0.7rem;
  font-weight: 600;
  padding: 2px 8px;
  border-radius: 10px;
  background: #f0f2f5;
  color: var(--sg-gray);
}
.flight-stat.active { background: #d4edda; color: #155724; }
.flight-stat.cancelled { background: #f8d7da; color: #721c24; }
.flight-stat.rate { background: #fff3cd; color: #856404; }

.flight-item {
  font-size: 0.75rem;
  padding: 3px 0;
  display: flex;
  align-items: center;
  gap: 8px;
}
.flight-item.cancelled { opacity: 0.7; }
.flight-item.cancelled .flight-status-label { color: var(--status-closed); font-weight: 600; }
.flight-item.active .flight-status-label { color: var(--status-open); font-weight: 600; }
.flight-item.scheduled .flight-status-label { color: #856404; font-weight: 500; }
.flight-id { font-weight: 500; min-width: 80px; }
.flight-status-label { font-size: 0.65rem; text-transform: uppercase; letter-spacing: 0.3px; }
.flight-dest { color: #888; font-size: 0.7rem; }
.flight-time { color: #666; font-size: 0.65rem; margin-left: auto; }

.delay-badge {
  background: var(--status-partial);
  color: white;
  font-size: 0.65rem;
  padding: 1px 5px;
  border-radius: 8px;
  font-weight: 600;
  margin-left: 4px;
}

/* Status indicator pulse */
.pulse {
  display: inline-block;
  width: 8px;
  height: 8px;
  border-radius: 50%;
  margin-right: 6px;
}
.pulse-closed { background: var(--status-closed); animation: pulse-red 2s infinite; }
.pulse-partial { background: var(--status-partial); animation: pulse-orange 2s infinite; }
.pulse-open { background: var(--status-open); }
@keyframes pulse-red { 0%, 100% { opacity: 1; } 50% { opacity: 0.4; } }
@keyframes pulse-orange { 0%, 100% { opacity: 1; } 50% { opacity: 0.5; } }

/* BORDER GRID */
.border-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(340px, 1fr));
  gap: 16px;
}

.border-card {
  background: white;
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 16px;
}
.border-card h3 {
  font-size: 0.95rem;
  font-weight: 700;
  margin-bottom: 4px;
}
.border-crossings {
  font-size: 0.78rem;
  color: var(--sg-gray);
  margin-bottom: 8px;
}
.border-notes {
  font-size: 0.8rem;
  line-height: 1.5;
  color: #333;
  margin-top: 8px;
}
.border-update {
  font-size: 0.7rem;
  color: var(--sg-gray);
  margin-top: 8px;
}

/* SOCIAL GRID */
.social-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(340px, 1fr));
  gap: 16px;
}
.social-card {
  background: white;
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 16px;
}
.social-card h3 {
  font-size: 0.95rem;
  font-weight: 700;
  margin-bottom: 12px;
  display: flex;
  align-items: center;
  gap: 8px;
}
.social-card .x-logo {
  width: 16px;
  height: 16px;
  background: #000;
  border-radius: 3px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  color: white;
  font-size: 10px;
  font-weight: 800;
}
.social-links {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-bottom: 12px;
}
.social-links a {
  font-size: 0.78rem;
  color: var(--sg-blue);
  text-decoration: none;
  background: #e1eefa;
  padding: 4px 10px;
  border-radius: 20px;
  font-weight: 500;
}
.social-links a:hover { background: #c7dffa; }

.embed-container {
  max-height: 400px;
  overflow-y: auto;
  border: 1px solid var(--sg-light);
  border-radius: var(--radius);
}

/* ADMIN PANEL */
.admin-panel { max-width: 800px; }
.admin-panel h2 { font-size: 1.2rem; margin-bottom: 8px; }
.admin-panel > p { font-size: 0.85rem; color: var(--sg-gray); margin-bottom: 20px; }

.admin-section {
  background: white;
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 20px;
  margin-bottom: 16px;
}
.admin-section h3 { font-size: 0.95rem; font-weight: 700; margin-bottom: 12px; }

.admin-form {
  display: flex;
  flex-direction: column;
  gap: 10px;
}
.admin-form select,
.admin-form input,
.admin-form textarea {
  padding: 8px 12px;
  border: 1px solid #E7EBF0;
  border-radius: 7px;
  font-size: 0.85rem;
  font-family: 'Raleway', sans-serif;
  color: #333;
}
.admin-form select:focus,
.admin-form input:focus,
.admin-form textarea:focus {
  outline: none;
  border-color: var(--sg-blue);
  box-shadow: 0 0 0 2px rgba(15, 115, 199, 0.15);
}
.admin-form textarea { resize: vertical; min-height: 60px; }

.btn-submit {
  background: var(--sg-blue);
  color: white;
  border: none;
  padding: 10px 20px;
  border-radius: var(--radius);
  font-size: 0.85rem;
  font-weight: 600;
  font-family: 'Raleway', sans-serif;
  cursor: pointer;
  transition: background 0.2s;
  align-self: flex-start;
}
.btn-submit:hover { background: #0a5fa3; }

/* Login gate */
.admin-login {
  display: flex;
  justify-content: center;
  align-items: center;
  min-height: 400px;
}
.login-card {
  background: var(--sg-card);
  border: 1px solid var(--sg-border);
  border-radius: 12px;
  padding: 40px;
  max-width: 380px;
  width: 100%;
  text-align: center;
}
.login-icon {
  color: var(--sg-blue);
  margin-bottom: 16px;
}
.login-card h2 {
  font-size: 1.2rem;
  margin-bottom: 8px;
}
.login-card > p {
  font-size: 0.82rem;
  color: var(--sg-gray);
  margin-bottom: 24px;
}
.login-form {
  display: flex;
  flex-direction: column;
  gap: 10px;
}
.login-form input {
  background: var(--sg-surface);
  border: 1px solid var(--sg-border);
  border-radius: var(--radius);
  padding: 10px 14px;
  font-size: 0.9rem;
  color: var(--sg-text);
  font-family: 'Raleway', sans-serif;
}
.login-form input:focus {
  outline: none;
  border-color: var(--sg-blue);
}
.login-error {
  background: rgba(220, 53, 69, 0.12);
  color: #dc3545;
  font-size: 0.82rem;
  padding: 8px 12px;
  border-radius: var(--radius);
  text-align: left;
}
.admin-header-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 8px;
}
.admin-header-row h2 {
  margin: 0;
}
.btn-logout {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  background: transparent;
  border: 1px solid var(--sg-border);
  color: var(--sg-gray);
  padding: 6px 14px;
  border-radius: var(--radius);
  font-size: 0.8rem;
  font-family: 'Raleway', sans-serif;
  cursor: pointer;
  transition: all 0.2s;
}
.btn-logout:hover {
  border-color: #dc3545;
  color: #dc3545;
}

.existing-notes {
  margin-top: 12px;
  font-size: 0.85rem;
}

/* FOOTER */
.footer {
  background: var(--sg-dark);
  color: rgba(255,255,255,0.6);
  padding: 14px 24px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 0.72rem;
  margin-top: 20px;
}
.footer-left { display: flex; align-items: center; gap: 10px; }
.footer-logo-img {
  height: 24px;
  width: auto;
  object-fit: contain;
  filter: brightness(0) invert(1);
  opacity: 0.7;
}

/* RESPONSIVE */
@media (max-width: 768px) {
  .header { flex-direction: column; gap: 8px; text-align: center; }
  .header-right { justify-content: center; }
  .logo-img { height: 32px; }
  .summary-bar { flex-wrap: wrap; gap: 16px; }
  .country-grid, .border-grid, .social-grid { grid-template-columns: 1fr; }
  .tabs { overflow-x: auto; }
  .footer { flex-direction: column; gap: 8px; text-align: center; }
}

/* Loading states */
.skeleton {
  background: linear-gradient(90deg, #f0f0f0 25%, #e0e0e0 50%, #f0f0f0 75%);
  background-size: 200% 100%;
  animation: shimmer 1.5s infinite;
  border-radius: 4px;
}
@keyframes shimmer { to { background-position: -200% 0; } }

/* ============================================================
   ADVISORIES BANNER
   ============================================================ */
.advisories-banner {
  margin: 0 24px 0;
  padding: 12px 20px;
  border-radius: var(--radius);
  font-size: 13px;
  line-height: 1.6;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px 16px;
}
.advisories-clear {
  background: rgba(40, 167, 69, 0.1);
  border: 1px solid rgba(40, 167, 69, 0.25);
  color: #1a7a35;
}
.advisories-critical {
  background: rgba(192, 57, 43, 0.1);
  border: 1px solid rgba(192, 57, 43, 0.3);
  color: #922b21;
}
.advisories-warning {
  background: rgba(230, 126, 34, 0.1);
  border: 1px solid rgba(230, 126, 34, 0.3);
  color: #935116;
}
.advisories-info {
  background: rgba(41, 128, 185, 0.1);
  border: 1px solid rgba(41, 128, 185, 0.25);
  color: #1a5276;
}
.advisories-icon { display: flex; align-items: center; }
.advisories-header {
  display: flex;
  align-items: center;
  gap: 8px;
  width: 100%;
  font-size: 14px;
}
.advisories-sources {
  margin-left: auto;
  font-size: 12px;
  opacity: 0.85;
}
.advisories-sources a {
  color: inherit;
  text-decoration: underline;
}
.advisory-item {
  width: 100%;
  padding: 6px 0 4px 24px;
  border-top: 1px solid rgba(0,0,0,0.06);
  font-size: 13px;
}
.advisory-meta {
  display: block;
  font-size: 11px;
  opacity: 0.7;
  margin-top: 2px;
}

/* ============================================================
   HEALTH BAR
   ============================================================ */
.health-bar {
  margin: 0 24px;
  padding: 6px 16px;
  background: var(--sg-navy);
  border-radius: var(--radius);
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-size: 12px;
  color: rgba(255,255,255,0.8);
}
.health-sources {
  display: flex;
  gap: 16px;
  align-items: center;
}
.health-dot-wrap {
  display: flex;
  align-items: center;
  gap: 5px;
  cursor: default;
}
.health-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  display: inline-block;
}
.health-countdown {
  font-size: 11px;
  opacity: 0.7;
}

/* ============================================================
   SOURCE DOTS (per card)
   ============================================================ */
.card-source-dots {
  display: flex;
  gap: 6px;
  margin-bottom: 6px;
}
.source-dot {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 22px;
  height: 22px;
  border-radius: 50%;
  font-size: 10px;
  font-weight: 700;
  font-family: 'Raleway', sans-serif;
  cursor: default;
}
.dot-active {
  background: rgba(40, 167, 69, 0.15);
  color: #27ae60;
  border: 1.5px solid #27ae60;
}
.dot-inactive {
  background: rgba(108, 117, 125, 0.1);
  color: #999;
  border: 1.5px solid #ccc;
}
.dot-override {
  background: rgba(253, 126, 20, 0.15);
  color: #e67e22;
  border: 1.5px solid #e67e22;
}

/* ============================================================
   FLIGHT DISCLAIMER
   ============================================================ */
.flight-disclaimer {
  font-size: 10px;
  color: var(--sg-gray);
  font-style: italic;
  margin-top: 6px;
  padding-top: 4px;
  border-top: 1px solid rgba(0,0,0,0.06);
}
