/* 
 * IARI Weather Dashboard — Scoped CSS for IARI Website Integration
 * All selectors prefixed with .weather-dashboard to prevent Bootstrap conflicts
 * Original: public-dashboard/css/style.css
 */

@import url('https://fonts.googleapis.com/css2?family=Inter:wght@300;400;500;600;700&display=swap');

.weather-dashboard {
  --bg-dark: #0f172a;
  --bg-gradient: linear-gradient(135deg, #1e1b4b 0%, #0f172a 50%, #020617 100%);
  --text-primary: #ffffff;
  --text-secondary: rgba(255, 255, 255, 0.7);
  --text-muted: rgba(255, 255, 255, 0.4);
  
  --accent: #38bdf8;
  --status-good: #34d399;
  --status-warn: #fbbf24;
  --status-err: #f87171;
  
  --font-sans: 'Inter', system-ui, -apple-system, sans-serif;
  
  --radius-md: 12px;
  --radius-lg: 24px;

  /* Base styles applied to the dashboard wrapper */
  position: relative;
  font-family: var(--font-sans);
  background: var(--bg-dark);
  background-image: var(--bg-gradient);
  color: var(--text-primary);
  line-height: 1.65;
  -webkit-font-smoothing: antialiased;
  padding-bottom: 24px;
}

.weather-dashboard *, .weather-dashboard *::before, .weather-dashboard *::after { box-sizing: border-box; }

/* Dynamic Background — scoped to dashboard area only */
.weather-dashboard .dynamic-bg {
  position: absolute;
  top: 0; left: 0; right: 0; bottom: 0;
  z-index: 0;
  background-size: cover;
  background-position: center;
  transition: background-image 1.5s ease-in-out;
  filter: blur(5px);
  transform: scale(1.05);
}
.weather-dashboard .dynamic-bg::after {
  content: '';
  position: absolute;
  top: 0; left: 0; right: 0; bottom: 0;
  background: linear-gradient(135deg, rgba(15,23,42,0.6) 0%, rgba(2,6,23,0.85) 100%);
  pointer-events: none;
  transition: background 1.5s ease-in-out;
}

/* Ensure all content sits above the background */
.weather-dashboard .site-header,
.weather-dashboard .main-content {
  position: relative;
  z-index: 1;
}

/* Light Theme Overrides */
.weather-dashboard.theme-light {
  --text-primary: #0f172a;
  --text-secondary: #334155;
}
.weather-dashboard.theme-light .dynamic-bg::after {
  background: linear-gradient(135deg, rgba(255,255,255,0.4) 0%, rgba(240,248,255,0.7) 100%);
}
.weather-dashboard.theme-light .glass-card {
  background: rgba(255, 255, 255, 0.45);
  border: 1px solid rgba(0, 0, 0, 0.1);
  box-shadow: 0 16px 48px rgba(0, 0, 0, 0.1);
}
.weather-dashboard.theme-light .btn-primary {
  background: rgba(0,0,0,0.6);
  color: white; border: 1px solid rgba(0,0,0,0.8);
}
.weather-dashboard.theme-light .glass-btn {
  border: 1px solid rgba(0,0,0,0.15); color: var(--text-secondary);
}
.weather-dashboard.theme-light .glass-btn:hover { background: rgba(0,0,0,0.05); color: var(--text-primary); }
.weather-dashboard.theme-light .glass-btn.active {
  background: rgba(0,0,0,0.1); color: var(--text-primary); border-color: rgba(0,0,0,0.3);
}

.weather-dashboard .container { width: 100%; max-width: 1200px; margin: 0 auto; padding: 0 24px; }
.weather-dashboard h1, .weather-dashboard h2, .weather-dashboard h3, .weather-dashboard p { margin: 0; }
.weather-dashboard a { color: inherit; text-decoration: none; }

/* Buttons */
.weather-dashboard .btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  padding: 8px 16px; font-weight: 600; border-radius: 99px;
  cursor: pointer; transition: all 0.3s ease; border: none;
  font-family: var(--font-sans); font-size: 0.9rem;
}
.weather-dashboard .btn-primary {
  background: rgba(255,255,255,0.1);
  color: white; border: 1px solid rgba(255,255,255,0.2);
  backdrop-filter: blur(8px);
}
.weather-dashboard .btn-primary:hover {
  background: rgba(255,255,255,0.2);
  transform: translateY(-1px);
}
.weather-dashboard .glass-btn {
  background: transparent; border: 1px solid rgba(255,255,255,0.1); color: var(--text-secondary);
}
.weather-dashboard .glass-btn:hover { background: rgba(255,255,255,0.05); color: white; }
.weather-dashboard .glass-btn.active {
  background: rgba(255,255,255,0.15); color: white; border-color: rgba(255,255,255,0.3);
}
.weather-dashboard .btn-sm { padding: 6px 14px; font-size: 0.82rem; }

/* Header */
.weather-dashboard .site-header {
  padding: 32px 0;
}
.weather-dashboard .header-container {
  display: flex; justify-content: space-between; align-items: center;
  flex-wrap: wrap; gap: 16px;
}
.weather-dashboard .site-title { font-size: 1.5rem; font-weight: 600; letter-spacing: -0.02em; }
.weather-dashboard .site-subtitle { font-size: 0.9rem; color: var(--text-secondary); }
.weather-dashboard .header-actions { display: flex; align-items: center; gap: 16px; }

/* Freshness & Prominent Update */
.weather-dashboard .freshness-indicator {
  font-size: 0.85rem; font-weight: 600; padding: 4px 12px;
  background: rgba(0,0,0,0.3); border-radius: 99px;
  border: 1px solid rgba(255,255,255,0.1);
  color: var(--status-good);
}
.weather-dashboard .freshness-indicator.delayed { color: var(--status-warn); }
.weather-dashboard .freshness-indicator.stale { color: var(--status-err); }

.weather-dashboard .btn-request-update {
  background: var(--accent); color: #0f172a;
  border: none; box-shadow: 0 4px 12px rgba(56, 189, 248, 0.3);
  font-weight: 700;
}
.weather-dashboard .btn-request-update:hover {
  background: #7dd3fc; transform: translateY(-2px);
  box-shadow: 0 6px 16px rgba(56, 189, 248, 0.4);
}

/* Status */
.weather-dashboard .status-badge {
  width: 10px; height: 10px; border-radius: 50%;
  background: var(--text-muted);
}
.weather-dashboard .status-dot.active { background: var(--status-good); box-shadow: 0 0 10px var(--status-good); display: block; width: 100%; height: 100%; border-radius: 50%; }
.weather-dashboard .status-dot.stale { background: var(--status-warn); box-shadow: 0 0 10px var(--status-warn); display: block; width: 100%; height: 100%; border-radius: 50%; }

/* Main Content */
.weather-dashboard .main-content { padding-bottom: 64px; }

/* Glass Card */
.weather-dashboard .glass-card {
  box-sizing: border-box;
  background: linear-gradient(135deg, rgba(255,255,255,0.12), rgba(255,255,255,0.02));
  border: 1px solid rgba(255, 255, 255, 0.15);
  box-shadow: 0 12px 32px rgba(0, 0, 0, 0.3);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border-radius: var(--radius-lg);
  transition: all 0.4s cubic-bezier(0.16, 1, 0.3, 1);
  color: white;
  padding: 24px;
  position: relative;
}

.weather-dashboard .glass-card:hover {
  border: 1px solid rgba(255, 255, 255, 0.25);
  transform: translateY(-2px);
  box-shadow: 0 16px 48px rgba(0, 0, 0, 0.4);
}

/* Bento Grid */
.weather-dashboard .bento-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 24px;
  margin-bottom: 48px;
}
@media (min-width: 1024px) {
  .weather-dashboard .bento-grid { grid-template-columns: 1fr 1.5fr; }
}

/* Hero Card */
.weather-dashboard .bento-hero {
  display: flex; flex-direction: column; justify-content: space-between;
  min-height: 360px;
}
.weather-dashboard .hero-top { display: flex; justify-content: space-between; align-items: flex-start; }
.weather-dashboard .icon-large { font-size: 2.5rem; }
.weather-dashboard .nowcast-label { font-size: 1rem; font-weight: 500; }
.weather-dashboard .hero-middle { margin-top: auto; margin-bottom: 24px; }
.weather-dashboard .hero-temp { font-size: 6rem; font-weight: 300; line-height: 1; letter-spacing: -0.05em; }
.weather-dashboard .hero-desc { font-size: 0.95rem; line-height: 1.4; font-weight: 400; margin-top: 12px; color: var(--text-secondary); }
.weather-dashboard .hero-bottom { display: flex; gap: 16px; font-size: 1.1rem; color: var(--text-secondary); }

/* Widgets Grid */
.weather-dashboard .widgets-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
}
@media (min-width: 640px) {
  .weather-dashboard .widgets-grid { grid-template-columns: repeat(3, 1fr); }
}
@media (min-width: 1024px) {
  .weather-dashboard .widgets-grid { gap: 24px; }
}

.weather-dashboard .widget {
  display: flex; flex-direction: column; justify-content: space-between;
  padding: 16px 20px; min-height: 160px;
}
.weather-dashboard .widget.scroll-target { cursor: pointer; }
.weather-dashboard .widget.scroll-target:hover { border-color: rgba(255, 255, 255, 0.4); }
.weather-dashboard .widget-header {
  font-size: 0.8rem; font-weight: 600; letter-spacing: 0.05em;
  color: var(--text-muted); display: flex; align-items: center; gap: 6px;
}
.weather-dashboard .widget-value {
  font-size: 2.2rem; font-weight: 500; margin: 12px 0;
}
.weather-dashboard .widget-footer {
  font-size: 0.8rem; color: var(--text-secondary); line-height: 1.4;
}

/* Chart Container & Tabs */
.weather-dashboard .unified-chart-container {
  padding: 24px; position: relative; margin-top: 24px;
}

.weather-dashboard .chart-controls {
  display: flex; gap: 8px; flex-wrap: wrap;
}

.weather-dashboard .chart-tabs {
  position: relative; display: flex; width: fit-content; margin: 0 auto 32px auto;
  padding: 4px; border-radius: 99px;
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid rgba(255, 255, 255, 0.1);
  list-style: none;
}

.weather-dashboard .chart-tab {
  position: relative; z-index: 10;
  padding: 8px 24px; cursor: pointer;
  font-size: 0.9rem; font-weight: 600; text-transform: uppercase;
  color: white; transition: color 0.3s;
  mix-blend-mode: difference;
}

.weather-dashboard .tab-cursor {
  position: absolute; z-index: 0;
  height: calc(100% - 8px); top: 4px; border-radius: 99px;
  background: white;
  transition: all 0.4s cubic-bezier(0.25, 1, 0.5, 1);
  opacity: 0; pointer-events: none;
}

.weather-dashboard .chart-views { position: relative; width: 100%; min-height: 350px; }
.weather-dashboard .chart-view { 
  visibility: hidden; position: absolute; opacity: 0;
  top: 0; left: 0; right: 0; width: 100%;
}
.weather-dashboard .chart-view.active { 
  visibility: visible; position: relative; opacity: 1;
  animation: wd-fadeIn 0.4s ease; 
}
.weather-dashboard .echart-container { width: 100%; height: 350px; }

@keyframes wd-fadeIn {
  from { opacity: 0; transform: translateY(5px); }
  to { opacity: 1; transform: translateY(0); }
}

/* Detail Sections */
.weather-dashboard .detail-section { margin-top: 48px; scroll-margin-top: 40px; }
.weather-dashboard .detail-section h2 { font-size: 1.3rem; font-weight: 600; margin-bottom: 16px; display: flex; align-items: center; gap: 8px; }
.weather-dashboard .detail-grid { display: grid; grid-template-columns: 1fr; gap: 16px; }
@media (min-width: 640px) { .weather-dashboard .detail-grid { grid-template-columns: repeat(2, 1fr); } }
@media (min-width: 1024px) { .weather-dashboard .detail-grid { grid-template-columns: repeat(3, 1fr); } }

.weather-dashboard .detail-item {
  background: linear-gradient(135deg, rgba(255,255,255,0.12), rgba(255,255,255,0.02));
  border: 1px solid rgba(255, 255, 255, 0.15);
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  padding: 16px;
  border-radius: var(--radius-md);
  display: flex; flex-direction: column; gap: 4px;
}
.weather-dashboard .detail-label { font-size: 0.8rem; color: var(--text-muted); text-transform: uppercase; letter-spacing: 0.05em; font-weight: 600; }
.weather-dashboard .detail-val { font-size: 1.4rem; font-weight: 500; }
.weather-dashboard .detail-desc { font-size: 0.85rem; color: var(--text-secondary); margin-top: 4px; }

/* Section Header Flex */
.weather-dashboard .section-header-flex {
  display: flex; justify-content: space-between; align-items: center;
  flex-wrap: wrap; gap: 16px;
}

/* Animations */
@keyframes wd-fadeInUp {
  from { opacity: 0; transform: translateY(20px); }
  to { opacity: 1; transform: translateY(0); }
}
.weather-dashboard .bento-hero { animation: wd-fadeInUp 0.8s ease backwards; }
.weather-dashboard .widget:nth-child(1) { animation: wd-fadeInUp 0.8s 0.1s ease backwards; }
.weather-dashboard .widget:nth-child(2) { animation: wd-fadeInUp 0.8s 0.15s ease backwards; }
.weather-dashboard .widget:nth-child(3) { animation: wd-fadeInUp 0.8s 0.2s ease backwards; }
.weather-dashboard .widget:nth-child(4) { animation: wd-fadeInUp 0.8s 0.25s ease backwards; }
.weather-dashboard .widget:nth-child(5) { animation: wd-fadeInUp 0.8s 0.3s ease backwards; }
.weather-dashboard .widget:nth-child(6) { animation: wd-fadeInUp 0.8s 0.35s ease backwards; }
.weather-dashboard .charts-section { animation: wd-fadeInUp 0.8s 0.4s ease backwards; margin-top: 32px; }

/* ── ET₀ Info Button & Methodology Tooltip ─────────────────── */
.weather-dashboard .et0-info-btn {
  display: inline-flex; align-items: center; justify-content: center;
  width: 22px; height: 22px; border-radius: 50%;
  background: rgba(56, 189, 248, 0.15);
  border: 1px solid rgba(56, 189, 248, 0.3);
  color: var(--accent);
  font-size: 0.85rem; cursor: pointer;
  transition: background 0.2s, border-color 0.2s;
  flex-shrink: 0;
  margin-left: 4px;
}
.weather-dashboard .et0-info-btn:hover {
  background: rgba(56, 189, 248, 0.28); border-color: var(--accent);
}

.weather-dashboard .et0-method-tooltip {
  font-size: 0.82rem; line-height: 1.6;
  color: var(--text-secondary);
  background: rgba(15, 23, 42, 0.75);
  border: 1px solid rgba(56, 189, 248, 0.2);
  border-radius: var(--radius-md);
  padding: 14px 16px;
  margin-bottom: 16px;
  backdrop-filter: blur(8px);
}
.weather-dashboard .et0-method-tooltip strong { color: var(--text-primary); }

/* ── ET₀ Research Companion Card ───────────────────────────── */
.weather-dashboard .et0-research-card {
  margin-top: 20px;
  background: rgba(56, 189, 248, 0.04);
  border: 1px solid rgba(56, 189, 248, 0.18);
  border-radius: var(--radius-md);
  padding: 14px 18px;
  backdrop-filter: blur(8px);
}

.weather-dashboard .et0-research-header {
  display: flex; justify-content: space-between; align-items: center;
  margin-bottom: 12px;
}
.weather-dashboard .et0-research-title {
  font-size: 0.78rem; font-weight: 700;
  letter-spacing: 0.07em; text-transform: uppercase;
  color: var(--accent);
}

/* Source badge */
.weather-dashboard .et0-source-badge {
  font-size: 0.72rem; font-weight: 600; letter-spacing: 0.03em;
  padding: 3px 9px; border-radius: 99px;
  background: rgba(56, 189, 248, 0.15);
  border: 1px solid rgba(56, 189, 248, 0.4);
  color: var(--accent);
}
.weather-dashboard .et0-source-badge--estimate {
  background: rgba(251, 191, 36, 0.12);
  border-color: rgba(251, 191, 36, 0.4);
  color: var(--status-warn);
}

/* Three-value grid */
.weather-dashboard .et0-research-grid {
  display: grid;
  grid-template-columns: 1fr 1fr 1fr;
  gap: 10px;
  margin-bottom: 12px;
}
@media (max-width: 640px) {
  .weather-dashboard .et0-research-grid { grid-template-columns: 1fr 1fr; }
}

.weather-dashboard .et0-research-item {
  display: flex; flex-direction: column; gap: 3px;
}
.weather-dashboard .et0-research-label {
  font-size: 0.72rem; color: var(--text-muted);
  text-transform: uppercase; letter-spacing: 0.04em; font-weight: 600;
}
.weather-dashboard .et0-research-val {
  font-size: 1.05rem; font-weight: 500; color: var(--text-primary);
}

/* Freshness row */
.weather-dashboard .et0-freshness-row {
  display: flex; flex-wrap: wrap; gap: 16px;
  border-top: 1px solid rgba(255,255,255,0.07);
  padding-top: 10px;
}
.weather-dashboard .et0-freshness-item {
  display: flex; align-items: center; gap: 5px;
  font-size: 0.78rem; color: var(--text-secondary);
}
.weather-dashboard .et0-freshness-item i { color: var(--text-muted); font-size: 0.85rem; }
.weather-dashboard .et0-freshness-label { color: var(--text-muted); }
.weather-dashboard .et0-freshness-val { font-weight: 500; color: var(--text-secondary); }

/* ── Toast / Snackbar Notification ────────────────────────── */
.weather-dashboard .wd-toast {
  position: fixed;
  bottom: 32px; left: 50%; transform: translateX(-50%) translateY(100px);
  z-index: 9999;
  padding: 12px 24px;
  border-radius: 12px;
  font-family: var(--font-sans);
  font-size: 0.88rem; font-weight: 500;
  color: white;
  background: rgba(15, 23, 42, 0.92);
  border: 1px solid rgba(255,255,255,0.15);
  backdrop-filter: blur(12px);
  box-shadow: 0 8px 32px rgba(0,0,0,0.3);
  opacity: 0;
  transition: transform 0.4s cubic-bezier(0.16, 1, 0.3, 1), opacity 0.4s ease;
  pointer-events: none;
  max-width: 420px;
  text-align: center;
}
.weather-dashboard .wd-toast.wd-toast--visible {
  transform: translateX(-50%) translateY(0);
  opacity: 1;
  pointer-events: auto;
}
.weather-dashboard .wd-toast.wd-toast--error {
  border-color: rgba(248,113,113,0.4);
  background: rgba(127,29,29,0.88);
}
.weather-dashboard .wd-toast.wd-toast--success {
  border-color: rgba(52,211,153,0.4);
  background: rgba(6,78,59,0.88);
}
.weather-dashboard .wd-toast.wd-toast--info {
  border-color: rgba(56,189,248,0.4);
}

/* ── Widget Hover Derivation Tooltips ─────────────────────── */
.weather-dashboard .widget {
  position: relative;
}
.weather-dashboard .widget[data-derivation]::after {
  content: attr(data-derivation);
  position: absolute;
  bottom: calc(100% + 8px); left: 50%; transform: translateX(-50%) scale(0.95);
  z-index: 100;
  padding: 8px 12px;
  border-radius: 8px;
  font-size: 0.74rem; font-weight: 400; line-height: 1.5;
  color: var(--text-secondary);
  background: rgba(15, 23, 42, 0.95);
  border: 1px solid rgba(255,255,255,0.12);
  backdrop-filter: blur(8px);
  white-space: pre-line;
  width: max-content;
  max-width: 280px;
  text-align: left;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.2s ease, transform 0.2s ease;
}
.weather-dashboard .widget[data-derivation]:hover::after {
  opacity: 1;
  transform: translateX(-50%) scale(1);
}

/* Ensure scroll-target widgets show pointer cursor */
.weather-dashboard .widget.scroll-target { cursor: pointer; }
