/**
 * Moon Visibility Map - Styles
 * Modern, responsive design
 */

/* Reset and Base Styles */
* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', 'Roboto', 'Oxygen',
    'Ubuntu', 'Cantarell', 'Fira Sans', 'Droid Sans', 'Helvetica Neue', sans-serif;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
  min-height: 100vh;
  padding: 20px;
}

.container {
  max-width: 1400px;
  margin: 0 auto;
  background: white;
  border-radius: 12px;
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.3);
  overflow: hidden;
}

/* ── Navigation ─────────────────────────────────────────────────────────── */
.site-nav {
  background: #0f172a;
  padding: 0 30px;
  display: flex;
  align-items: center;
  gap: 0;
  flex-wrap: wrap;
}

.site-nav .nav-brand {
  color: #f8fafc;
  font-weight: 700;
  font-size: 1.1rem;
  padding: 16px 20px 16px 0;
  margin-right: 10px;
  border-right: 1px solid #334155;
  text-decoration: none;
  white-space: nowrap;
}

.site-nav a {
  color: #94a3b8;
  text-decoration: none;
  padding: 16px 18px;
  font-size: 0.9rem;
  font-weight: 500;
  border-bottom: 3px solid transparent;
  transition: color 0.2s, border-color 0.2s;
  white-space: nowrap;
}

.site-nav a:hover {
  color: #f8fafc;
  border-bottom-color: #3b82f6;
}

.site-nav a.active {
  color: #fff;
  border-bottom-color: #3b82f6;
}

/* ── Header ──────────────────────────────────────────────────────────────── */
.header {
  background: linear-gradient(135deg, #1e3a8a 0%, #3b82f6 100%);
  color: white;
  padding: 30px;
  text-align: center;
}

.header h1 {
  font-size: 2.5rem;
  margin-bottom: 10px;
  font-weight: 700;
}

.subtitle {
  font-size: 1.1rem;
  opacity: 0.9;
  font-weight: 300;
}

/* ── Method badge (shown inside header for Yallop/Odeh pages) ───────────── */
.method-badge {
  display: inline-block;
  margin-top: 10px;
  padding: 4px 14px;
  border-radius: 999px;
  font-size: 0.8rem;
  font-weight: 700;
  letter-spacing: 0.05em;
  text-transform: uppercase;
  background: rgba(255,255,255,0.2);
  border: 1px solid rgba(255,255,255,0.4);
}

/* Control Panel */
.control-panel {
  padding: 25px 30px;
  background: #f7fcc8;
  border-bottom: 1px solid #e2e8f0;
  display: flex;
  flex-wrap: wrap;
  gap: 15px;
  align-items: center;
  margin: 20px 30px;
  border-radius: 12px;
}

.input-group {
  display: flex;
  flex-direction: column;
  gap: 5px;
}

.input-group label {
  font-size: 0.875rem;
  font-weight: 600;
  color: #475569;
}

.date-input,
.resolution-select {
  padding: 10px 15px;
  border: 2px solid #cbd5e1;
  border-radius: 8px;
  font-size: 1rem;
  transition: all 0.2s;
  background: white;
}

.date-input:focus,
.resolution-select:focus {
  outline: none;
  border-color: #3b82f6;
  box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.1);
}

.generate-btn {
  padding: 12px 30px;
  background: linear-gradient(135deg, #3b82f6 0%, #2563eb 100%);
  color: white;
  border: none;
  border-radius: 8px;
  font-size: 1rem;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.3s;
  box-shadow: 0 4px 12px rgba(59, 130, 246, 0.3);
}

.generate-btn:hover:not(:disabled) {
  transform: translateY(-2px);
  box-shadow: 0 6px 20px rgba(59, 130, 246, 0.4);
}

.generate-btn:active:not(:disabled) {
  transform: translateY(0);
}

.generate-btn:disabled {
  opacity: 0.6;
  cursor: not-allowed;
}

/* Loading Indicator */
.loading {
  display: flex;
  align-items: center;
  gap: 10px;
  color: #3b82f6;
  font-weight: 500;
}

.loading.hidden {
  display: none;
}

.spinner {
  width: 20px;
  height: 20px;
  border: 3px solid #e2e8f0;
  border-top-color: #3b82f6;
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}

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

/* Status Messages */
.status {
  flex: 1 1 100%;
  padding: 12px;
  border-radius: 6px;
  font-size: 0.875rem;
  font-weight: 500;
}

.status.success {
  background: #dcfce7;
  color: #15803d;
  border: 1px solid #86efac;
}

.status.error {
  background: #fee2e2;
  color: #991b1b;
  border: 1px solid #fca5a5;
}

/* Map Container */
.map-wrapper {
  width: 100%;
  height: 600px;
  position: relative;
  background: #e5e7eb;
}

#map {
  width: 100%;
  height: 100%;
  position: relative;
  z-index: 1;
}

/* Ensure Leaflet tiles render properly */
.leaflet-container {
  background: #dfe6e9;
}

.leaflet-tile-pane {
  z-index: 2;
}

.leaflet-overlay-pane {
  z-index: 4;
}

.leaflet-marker-pane {
  z-index: 6;
}

.leaflet-popup-pane {
  z-index: 7;
}

/* Legend */
.legend {
  position: absolute;
  bottom: 30px;
  right: 30px;
  background: white;
  padding: 20px;
  border-radius: 8px;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
  z-index: 1000;
  min-width: 260px;
}

.legend.hidden {
  display: none;
}

.legend h3 {
  font-size: 1.1rem;
  margin-bottom: 15px;
  color: #1e293b;
  border-bottom: 2px solid #e2e8f0;
  padding-bottom: 8px;
}

.legend-item {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 10px;
  font-size: 0.9rem;
}

.legend-color {
  width: 20px;
  height: 20px;
  border-radius: 50%;
  border: 2px solid rgba(0, 0, 0, 0.1);
}

.legend-info {
  margin-top: 12px;
  padding-top: 12px;
  border-top: 1px solid #e2e8f0;
  font-style: italic;
  color: #64748b;
}

/* Popup Styles */
.popup-content h4 {
  font-size: 1rem;
  margin-bottom: 10px;
  color: #1e293b;
  border-bottom: 2px solid #e2e8f0;
  padding-bottom: 5px;
}

.popup-content table {
  width: 100%;
  font-size: 0.85rem;
}

.popup-content td {
  padding: 4px 8px;
}

.popup-content td:first-child {
  color: #64748b;
}

/* Disclaimer */
.disclaimer {
  padding: 25px 30px;
  background: #fef3c7;
  border-left: 4px solid #f59e0b;
  margin: 20px 30px;
  border-radius: 8px;
}

.disclaimer h3 {
  font-size: 1.2rem;
  color: #92400e;
  margin-bottom: 12px;
}

.disclaimer p {
  color: #78350f;
  line-height: 1.6;
  margin-bottom: 10px;
}

.disclaimer-note {
  font-size: 0.9rem;
  font-style: italic;
  margin-top: 10px;
}

/* Footer */
.footer {
  padding: 20px 30px;
  background: #f1f5f9;
  text-align: center;
  color: #64748b;
  font-size: 0.875rem;
  border-top: 1px solid #e2e8f0;
}

.footer a {
  color: #3b82f6;
  text-decoration: none;
  font-weight: 500;
}

.footer a:hover {
  text-decoration: underline;
}

/* ── Responsive Design ───────────────────────────────────────────────────── */
@media (max-width: 768px) {
  body {
    padding: 10px;
  }

  .site-nav {
    padding: 0 15px;
  }

  .header h1 {
    font-size: 1.8rem;
  }

  .subtitle {
    font-size: 0.95rem;
  }

  .control-panel {
    padding: 20px;
  }

  .map-wrapper {
    height: 400px;
  }

  .legend {
    bottom: 10px;
    right: 10px;
    left: 10px;
    min-width: auto;
  }

  .disclaimer {
    margin: 15px 20px;
    padding: 20px;
  }

  .edu-grid {
    grid-template-columns: 1fr;
  }

  .edu-content {
    padding: 24px 20px 20px;
  }
}

@media (max-width: 480px) {
  .header h1 {
    font-size: 1.5rem;
  }

  .control-panel {
    flex-direction: column;
    align-items: stretch;
  }

  .generate-btn {
    width: 100%;
  }

  .site-nav a {
    padding: 12px 10px;
    font-size: 0.8rem;
  }
}

/* ── Education Page ──────────────────────────────────────────────────────── */
.edu-content {
  padding: 40px 40px 20px;
}

.edu-intro {
  text-align: center;
  max-width: 700px;
  margin: 0 auto 40px;
  color: #475569;
  font-size: 1.05rem;
  line-height: 1.7;
}

.edu-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 24px;
  margin-bottom: 40px;
}

.edu-card {
  background: #f8fafc;
  border: 1px solid #e2e8f0;
  border-radius: 12px;
  padding: 28px;
  transition: transform 0.2s, box-shadow 0.2s;
}

.edu-card:hover {
  transform: translateY(-3px);
  box-shadow: 0 8px 24px rgba(0,0,0,0.08);
}

.edu-card-icon {
  font-size: 2.4rem;
  margin-bottom: 14px;
}

.edu-card h3 {
  font-size: 1.15rem;
  color: #1e293b;
  margin-bottom: 12px;
  font-weight: 700;
}

.edu-card p {
  color: #475569;
  line-height: 1.65;
  font-size: 0.95rem;
  margin-bottom: 10px;
}

.edu-card ul {
  list-style: none;
  padding: 0;
  margin: 10px 0 0;
}

.edu-card ul li {
  padding: 5px 0 5px 20px;
  position: relative;
  color: #475569;
  font-size: 0.92rem;
}

.edu-card ul li::before {
  content: '›';
  position: absolute;
  left: 4px;
  color: #3b82f6;
  font-weight: 700;
}

.edu-highlight {
  background: linear-gradient(135deg, #eff6ff 0%, #dbeafe 100%);
  border: 1px solid #bfdbfe;
  border-radius: 12px;
  padding: 28px;
  margin-bottom: 30px;
}

.edu-highlight h3 {
  color: #1e40af;
  font-size: 1.2rem;
  margin-bottom: 10px;
}

.edu-highlight p {
  color: #1e3a8a;
  line-height: 1.65;
}

/* ── Method table (Yallop/Odeh classification codes) ────────────────────── */
.method-table-wrap {
  overflow-x: auto;
  margin: 16px 0;
}

.method-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.93rem;
}

.method-table th {
  background: #1e3a8a;
  color: white;
  padding: 12px 16px;
  text-align: left;
  font-weight: 600;
}

.method-table td {
  padding: 11px 16px;
  border-bottom: 1px solid #e2e8f0;
  color: #334155;
}

.method-table tr:nth-child(even) td {
  background: #f8fafc;
}

.method-table tr:hover td {
  background: #eff6ff;
}

.code-badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 28px;
  height: 28px;
  border-radius: 50%;
  font-weight: 700;
  font-size: 0.85rem;
  color: white;
}

.badge-A { background: #15803d; }
.badge-B { background: #22c55e; }
.badge-C { background: #eab308; }
.badge-D { background: #f97316; }
.badge-E { background: #ef4444; }

.text-badge {
  display: inline-block;
  padding: 2px 10px;
  border-radius: 999px;
  font-weight: 600;
  font-size: 0.8rem;
  color: white;
}

.text-badge-NE { background: #22c55e; }
.text-badge-OA { background: #eab308; }
.text-badge-NV { background: #ef4444; }

/* ── Info section panels (Yallop/Odeh pages) ─────────────────────────────── */
.info-section {
  padding: 24px 30px;
  border-bottom: 1px solid #e2e8f0;
  background: #f8fafc;
}

.info-section h2 {
  font-size: 1.15rem;
  color: #1e293b;
  margin-bottom: 10px;
  font-weight: 700;
}

.info-section p {
  color: #475569;
  line-height: 1.65;
  font-size: 0.93rem;
  margin-bottom: 6px;
}

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

/* ─────────────────────────────────────────────────
   Hijri Date Picker Styles
───────────────────────────────────────────────── */

/* Toggle button group */
.date-type-group {
  flex-direction: column;
  align-items: flex-start;
}

.date-toggle {
  display: flex;
  border-radius: 8px;
  overflow: hidden;
  border: 2px solid #c7d7f0;
  width: fit-content;
}

.toggle-btn {
  padding: 7px 20px;
  border: none;
  background: #f0f4fb;
  color: #4b5e82;
  font-size: 0.88rem;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.18s, color 0.18s;
  letter-spacing: 0.02em;
}

.toggle-btn:focus {
  outline: 2px solid #3b82f6;
  outline-offset: -2px;
}

.toggle-btn.active {
  background: #1e40af;
  color: #fff;
}

.toggle-btn:not(.active):hover {
  background: #dbeafe;
  color: #1e40af;
}

/* Hijri select elements (reuse .date-input sizing) */
#hijri-panel {
  flex-direction: column;
  align-items: flex-start;
  gap: 6px;
}

#hijri-panel label {
  font-size: 0.85rem;
  color: #475569;
  font-weight: 600;
  margin-bottom: 0;
}

#hijri-year,
#hijri-month {
  width: 100%;
  max-width: 220px;
}

.hijri-day-note {
  font-size: 0.82rem;
  color: #64748b;
  margin: 4px 0 0;
  font-style: italic;
}

/* Utility: hidden */
.hidden {
  display: none !important;
}

/* Hijri info banner (shown between control panel and map) */
.hijri-info {
  background: #eff6ff;
  border: 1.5px solid #93c5fd;
  border-radius: 8px;
  padding: 9px 16px;
  margin: 0 0 14px;
  font-size: 0.9rem;
  color: #1e40af;
  display: flex;
  align-items: center;
  gap: 8px;
}

.hijri-info::before {
  content: '🗓️';
  font-size: 1rem;
}

/* ── Three-column Comparison Layout ─────────────────────────────────────────── */

#comparison-section {
  border-top: 1px solid #e2e8f0;
  padding: 0 0 8px;
}

/* ── Shared legend bar ──────────────────────────────────────────────────────── */

.shared-legend {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 6px 20px;
  padding: 12px 20px;
  background: #f8fafc;
  border-bottom: 1px solid #e2e8f0;
  font-size: 0.85rem;
  color: #334155;
}

.shared-legend-title {
  font-weight: 700;
  color: #1e293b;
  white-space: nowrap;
}

.shared-legend-item {
  display: flex;
  align-items: center;
  gap: 6px;
  white-space: nowrap;
}

.shared-legend-item .legend-color {
  width: 13px;
  height: 13px;
  border-radius: 50%;
  border: 1.5px solid rgba(0,0,0,0.12);
  flex-shrink: 0;
}

.shared-legend-note {
  margin-left: auto;
  font-style: italic;
  color: #94a3b8;
  font-size: 0.78rem;
  white-space: nowrap;
}

/* ── Grid ───────────────────────────────────────────────────────────────────── */

.comparison-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 12px;
  padding: 12px 16px 16px;
}

/* ── Each column ─────────────────────────────────────────────────────────────── */

.map-col {
  display: flex;
  flex-direction: column;
  border-radius: 10px;
  overflow: hidden;
  border: 1px solid #cbd5e1;
  box-shadow: 0 2px 8px rgba(0,0,0,0.07);
  background: #fff;
}

/* Selected (centre) column — highlighted */
.map-col--selected {
  border: 2px solid #3b82f6;
  box-shadow: 0 4px 18px rgba(59,130,246,0.18);
}

/* ── Column header bar ───────────────────────────────────────────────────────── */

.map-col-header {
  padding: 10px 14px 11px;
  background: #1e293b;
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.map-col-header--selected {
  background: linear-gradient(135deg, #1e40af 0%, #2563eb 100%);
}

.col-tag {
  font-size: 0.66rem;
  font-weight: 700;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: #94a3b8;
}

.map-col-header--selected .col-tag {
  color: #93c5fd;
}

.col-date {
  font-size: 0.9rem;
  font-weight: 600;
  color: #f1f5f9;
}

/* ── Map container inside each column ───────────────────────────────────────── */

.map-wrapper-col {
  flex: 1;
  height: 420px;
  background: #dfe6e9;
}

.map-wrapper-col > div[id^="map-"] {
  width: 100%;
  height: 100%;
}

/* ── Responsive: tablet/mobile (stack to single column) ─────────────────────── */

@media (max-width: 960px) {
  .comparison-grid {
    grid-template-columns: 1fr;
    gap: 16px;
    padding: 12px;
  }

  .map-wrapper-col {
    height: 380px;
  }

  .shared-legend-note {
    margin-left: 0;
  }
}

@media (max-width: 480px) {
  .comparison-grid {
    padding: 8px;
    gap: 12px;
  }

  .map-wrapper-col {
    height: 300px;
  }

  .shared-legend {
    font-size: 0.78rem;
    gap: 5px 12px;
    padding: 10px 14px;
  }
}

/* ── Two-finger gesture hint overlay ─────────────────────────────────────── */
.map-gesture-hint {
  position: absolute;
  inset: 0;
  background: rgba(0, 0, 0, 0.50);
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.95rem;
  font-weight: 600;
  letter-spacing: 0.02em;
  pointer-events: none;
  opacity: 0;
  transition: opacity 0.25s ease;
  z-index: 1000;
  text-align: center;
  padding: 1rem;
  border-radius: inherit;
}

.map-gesture-hint.visible {
  opacity: 1;
}
