/* ==========================================================================
   HavaScope - Afghan Calendar, Interactive 7-Day Forecast, Google Strip & Alerts
   ========================================================================== */

:root {
  --bg-page: #f1f5f9;
  --bg-card: #ffffff;
  --primary: #1d4ed8;
  --primary-hover: #1e40af;
  --text-main: #0f172a;
  --text-muted: #64748b;
  --border-color: #e2e8f0;
  --hot-color: #dc2626;
  --cold-color: #0284c7;
  --radius: 14px;
  --shadow: 0 4px 16px rgba(15, 23, 42, 0.06);
}

* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

body {
  font-family: 'Inter', 'Vazirmatn', sans-serif;
  background-color: var(--bg-page);
  color: var(--text-main);
  line-height: 1.6;
  overflow-x: hidden;
}

html[dir="rtl"] body {
  font-family: 'Vazirmatn', 'Inter', sans-serif;
}

.container {
  max-width: 1180px;
  margin: 0 auto;
  padding: 0 18px;
}

/* نوار ناوبری بالا */
.navbar {
  background: var(--bg-card);
  border-bottom: 1px solid var(--border-color);
  position: sticky;
  top: 0;
  z-index: 100;
  box-shadow: 0 2px 12px rgba(15, 23, 42, 0.04);
}

.navbar-content {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding-top: 12px;
  padding-bottom: 12px;
}

.navbar-top-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex: 1;
  gap: 12px;
}

.brand {
  display: flex;
  align-items: center;
  gap: 10px;
}

.brand-icon {
  font-size: 1.9rem;
  line-height: 1;
}

.brand-title {
  font-size: 1.3rem;
  font-weight: 700;
  color: var(--primary);
  line-height: 1.2;
}

.brand-subtitle {
  font-size: 0.78rem;
  color: var(--text-muted);
  display: block;
}

.lang-box {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  background: #f8fafc;
  border: 1px solid var(--border-color);
  border-radius: 10px;
  padding: 6px 10px;
}

.lang-box:hover,
.lang-box:focus-within {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(29, 78, 216, 0.12);
}

#language-select {
  border: none;
  background: transparent;
  color: var(--text-main);
  font-family: inherit;
  font-size: 0.88rem;
  font-weight: 600;
  cursor: pointer;
  outline: none;
}

.nav-tabs {
  display: flex;
  align-items: center;
  background: #f1f5f9;
  padding: 4px;
  border-radius: 12px;
  gap: 4px;
}

.tab-btn {
  border: none;
  background: transparent;
  color: var(--text-muted);
  padding: 8px 16px;
  border-radius: 9px;
  font-family: inherit;
  font-size: 0.86rem;
  font-weight: 600;
  cursor: pointer;
  white-space: nowrap;
  transition: all 0.2s ease;
}

.tab-btn.active {
  background: var(--bg-card);
  color: var(--primary);
  box-shadow: 0 2px 6px rgba(15, 23, 42, 0.08);
}

/* محتوای اصلی */
.main-content {
  padding-top: 22px;
  padding-bottom: 48px;
}

.tab-panel {
  display: none;
}

.tab-panel.active {
  display: block;
}

.card {
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--radius);
  padding: 20px;
  margin-bottom: 20px;
  box-shadow: var(--shadow);
}

.card h3 {
  font-size: 1.06rem;
  margin-bottom: 14px;
  color: var(--text-main);
}

.muted-text {
  color: var(--text-muted);
  font-size: 0.88rem;
}

/* جستجو، منوی کشورها و علاقه‌مندی‌ها */
.search-box {
  display: flex;
  gap: 10px;
  margin-bottom: 14px;
}

.search-box input {
  flex: 1.4;
  min-width: 0;
  padding: 12px 16px;
  border: 1px solid var(--border-color);
  border-radius: 10px;
  font-family: inherit;
  font-size: 0.94rem;
  outline: none;
}

.search-box input:focus,
.country-select:focus {
  border-color: var(--primary);
}

.country-select {
  flex: 0.7;
  min-width: 170px;
  padding: 12px 12px;
  border: 1px solid var(--border-color);
  border-radius: 10px;
  background: #f8fafc;
  color: var(--text-main);
  font-family: inherit;
  font-size: 0.9rem;
  font-weight: 600;
  cursor: pointer;
  outline: none;
}

.btn-primary {
  background: var(--primary);
  color: #ffffff;
  border: none;
  padding: 12px 22px;
  border-radius: 10px;
  font-family: inherit;
  font-weight: 600;
  cursor: pointer;
  white-space: nowrap;
}

.btn-primary:hover {
  background: var(--primary-hover);
}

.btn-outline {
  background: transparent;
  border: 1px solid var(--primary);
  color: var(--primary);
  padding: 6px 12px;
  border-radius: 8px;
  font-family: inherit;
  font-size: 0.82rem;
  font-weight: 600;
  cursor: pointer;
  white-space: nowrap;
}

.favorites-bar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
}

.fav-label {
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--text-muted);
}

.favorites-list {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.fav-chip {
  background: #e0f2fe;
  color: #0369a1;
  border: none;
  padding: 5px 12px;
  border-radius: 20px;
  font-family: inherit;
  font-size: 0.82rem;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.15s ease;
}

.fav-chip:hover {
  background: #bae6fd;
}

.status-banner {
  background: #fef3c7;
  color: #92400e;
  padding: 12px 16px;
  border-radius: 10px;
  margin-bottom: 16px;
  font-weight: 500;
}

.hidden {
  display: none;
}

/* وضعیت فعلی */
.current-grid {
  display: grid;
  grid-template-columns: 1.2fr 1fr;
  gap: 20px;
}

.current-main {
  background: linear-gradient(135deg, #1e3a8a, #2563eb);
  color: #ffffff;
}

.current-main .muted-text {
  color: #dbeafe;
  font-size: 0.94rem;
  margin-top: 4px;
}

.current-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.weather-big-icon {
  font-size: 3.3rem;
}

.current-temp-row {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 14px;
  margin-top: 18px;
}

.big-temp {
  font-size: 3.1rem;
  font-weight: 700;
  line-height: 1;
}

.weather-badge {
  background: rgba(255, 255, 255, 0.2);
  padding: 6px 14px;
  border-radius: 20px;
  font-size: 0.92rem;
  font-weight: 600;
}

.metrics-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 12px;
}

.metric-item {
  background: #f8fafc;
  padding: 12px;
  border-radius: 10px;
  border: 1px solid var(--border-color);
  display: flex;
  flex-direction: column;
}

.metric-label {
  font-size: 0.8rem;
  color: var(--text-muted);
}

.metric-value {
  font-size: 1.12rem;
  font-weight: 700;
  margin-top: 4px;
}

/* پیش‌بینی ۷ روزه تعاملی (با قابلیت کلیک) */
.daily-header-row {
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  align-items: center;
  gap: 8px;
  margin-bottom: 14px;
}

.daily-header-row h3 {
  margin-bottom: 0;
}

.selected-day-badge {
  background: #eff6ff;
  color: var(--primary);
  border: 1px solid #bfdbfe;
  font-size: 0.82rem;
  font-weight: 700;
  padding: 4px 12px;
  border-radius: 20px;
}

.daily-grid {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  gap: 10px;
}

.day-card {
  background: #f8fafc;
  border: 2px solid var(--border-color);
  border-radius: 12px;
  padding: 12px 8px;
  text-align: center;
  cursor: pointer;
  transition: all 0.2s ease;
}

.day-card:hover {
  border-color: #93c5fd;
  transform: translateY(-2px);
}

.day-card.active-day {
  background: #eff6ff;
  border-color: var(--primary);
  box-shadow: 0 4px 12px rgba(29, 78, 216, 0.14);
}

.day-name {
  font-weight: 700;
  font-size: 0.88rem;
}

.day-subdate {
  font-size: 0.74rem;
  color: var(--text-muted);
  margin-top: 2px;
}

.day-icon {
  font-size: 1.75rem;
  margin: 6px 0;
}

.day-temps {
  font-size: 0.86rem;
  font-weight: 600;
}

.temp-max-txt {
  color: var(--hot-color);
}

.temp-min-txt {
  color: var(--cold-color);
}

/* نمودار و نوار ساعتی شبیه گوگل */
.chart-wrapper {
  position: relative;
  height: 220px;
  width: 100%;
  margin-bottom: 16px;
}

.hourly-strip {
  display: flex;
  gap: 10px;
  overflow-x: auto;
  padding: 8px 4px 12px 4px;
  scrollbar-width: thin;
}

.hour-pill {
  min-width: 78px;
  background: #f8fafc;
  border: 1px solid var(--border-color);
  border-radius: 12px;
  padding: 10px 8px;
  text-align: center;
  flex-shrink: 0;
}

.hour-pill.now-pill {
  background: #eff6ff;
  border: 2px solid var(--primary);
}

.hour-time {
  font-size: 0.8rem;
  font-weight: 700;
  color: var(--text-main);
}

.hour-pill.now-pill .hour-time {
  color: var(--primary);
}

.hour-icon {
  font-size: 1.55rem;
  margin: 6px 0;
}

.hour-temp {
  font-size: 0.95rem;
  font-weight: 700;
}

.hour-precip {
  font-size: 0.74rem;
  color: #0284c7;
  font-weight: 600;
  margin-top: 4px;
}

/* کارت هشدارهای اضطراری و زلزله / سونامی */
.alerts-header {
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  align-items: center;
  gap: 8px;
  margin-bottom: 14px;
}

.alerts-header h3 {
  margin-bottom: 0;
}

.alert-region-badge {
  background: #f1f5f9;
  color: var(--text-muted);
  font-size: 0.78rem;
  font-weight: 600;
  padding: 4px 10px;
  border-radius: 20px;
}

.alerts-list {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.alert-item {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  padding: 14px;
  border-radius: 12px;
  border-inline-start: 5px solid #22c55e;
  background: #f0fdf4;
  color: #14532d;
}

.alert-item.warning {
  border-inline-start-color: #f59e0b;
  background: #fffbeb;
  color: #78350f;
}

.alert-item.danger {
  border-inline-start-color: #dc2626;
  background: #fef2f2;
  color: #7f1d1d;
}

.alert-icon {
  font-size: 1.5rem;
  line-height: 1.2;
}

.alert-title {
  font-weight: 700;
  font-size: 0.94rem;
  display: block;
  margin-bottom: 2px;
}

.alert-desc {
  font-size: 0.85rem;
  opacity: 0.92;
}

/* بخش آمار زبان R */
.r-kpi-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 16px;
}

.kpi-card {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.kpi-card.hot {
  border-top: 4px solid var(--hot-color);
}

.kpi-card.cold {
  border-top: 4px solid var(--cold-color);
}

.kpi-label {
  font-size: 0.82rem;
  color: var(--text-muted);
  font-weight: 600;
}

.kpi-value {
  font-size: 1.55rem;
  font-weight: 700;
}

.kpi-sub {
  font-size: 0.78rem;
  color: var(--text-muted);
}

.r-tests-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 20px;
}

.table-responsive {
  width: 100%;
  overflow-x: auto;
}

.data-table {
  width: 100%;
  border-collapse: collapse;
  margin-bottom: 12px;
  font-size: 0.86rem;
}

.data-table th,
.data-table td {
  border: 1px solid var(--border-color);
  padding: 8px 10px;
  text-align: start;
}

.data-table th {
  background: #f1f5f9;
  font-weight: 700;
}

.test-result-note {
  font-size: 0.85rem;
  background: #eff6ff;
  color: #1e3a8a;
  padding: 10px 12px;
  border-radius: 8px;
}

.code-header {
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  align-items: center;
  gap: 10px;
  margin-bottom: 10px;
}

.code-block {
  background: #0f172a;
  color: #e2e8f0;
  padding: 16px;
  border-radius: 10px;
  overflow-x: auto;
  font-family: Consolas, monospace;
  font-size: 0.84rem;
  direction: ltr;
  text-align: left;
}

.footer {
  text-align: center;
  padding: 20px 0;
  color: var(--text-muted);
  font-size: 0.85rem;
  border-top: 1px solid var(--border-color);
  background: var(--bg-card);
}

/* تنظیمات واکنش‌گرا */
@media (max-width: 960px) {
  .navbar-content {
    flex-direction: column;
    align-items: stretch;
    gap: 12px;
  }
  .nav-tabs {
    width: 100%;
  }
  .tab-btn {
    flex: 1;
    text-align: center;
  }
  .current-grid,
  .r-tests-grid {
    grid-template-columns: 1fr;
  }
  .r-kpi-grid {
    grid-template-columns: repeat(2, 1fr);
  }
  .daily-grid {
    grid-template-columns: repeat(4, 1fr);
  }
}

@media (max-width: 600px) {
  .container {
    padding: 0 12px;
  }
  .brand-subtitle {
    display: none;
  }
  .search-box {
    flex-direction: column;
  }
  .btn-primary,
  .country-select {
    width: 100%;
  }
  .big-temp {
    font-size: 2.5rem;
  }
  .daily-grid {
    grid-template-columns: repeat(2, 1fr);
  }
  .r-kpi-grid {
    grid-template-columns: 1fr;
  }
}