/* =============================================
   MeteoFX Dashboard — style.css
   Motyw: precision dark / clean light
   ============================================= */

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

:root {
  --font-display: 'DM Sans', sans-serif;
  --font-mono:    'IBM Plex Mono', monospace;

  /* Dark theme (default) */
  --bg:         #0d0f12;
  --bg-surface: #141720;
  --bg-card:    #181c24;
  --bg-hover:   #1e2330;
  --border:     rgba(255,255,255,0.07);
  --border-md:  rgba(255,255,255,0.12);

  --text-primary:   #e8eaf0;
  --text-secondary: #7a8099;
  --text-tertiary:  #4a5068;

  --accent:     #4f9cf9;
  --accent-dim: rgba(79,156,249,0.15);
  --accent-2:   #3dd68c;
  --accent-3:   #f5a623;
  --danger:     #f56565;
  --danger-dim: rgba(245,101,101,0.12);

  --kpi-glow: rgba(79,156,249,0.08);

  --radius-sm: 6px;
  --radius-md: 10px;
  --radius-lg: 14px;
  --radius-xl: 18px;

  --chart-line:  #4f9cf9;
  --chart-bar:   #3dd68c;
  --chart-grid:  rgba(255,255,255,0.05);

  --transition: 0.18s ease;
}

[data-theme="light"] {
  --bg:         #f0f2f7;
  --bg-surface: #ffffff;
  --bg-card:    #ffffff;
  --bg-hover:   #f5f6fa;
  --border:     rgba(0,0,0,0.07);
  --border-md:  rgba(0,0,0,0.12);

  --text-primary:   #111827;
  --text-secondary: #5a6375;
  --text-tertiary:  #9aa0ae;

  --accent:     #2563eb;
  --accent-dim: rgba(37,99,235,0.1);
  --accent-2:   #059669;
  --accent-3:   #d97706;
  --danger:     #dc2626;
  --danger-dim: rgba(220,38,38,0.08);

  --kpi-glow: rgba(37,99,235,0.05);

  --chart-line:  #2563eb;
  --chart-bar:   #059669;
  --chart-grid:  rgba(0,0,0,0.05);
}

/* ── Typography ── */
body {
  font-family: var(--font-display);
  background: var(--bg);
  color: var(--text-primary);
  font-size: 14px;
  line-height: 1.5;
  min-height: 100vh;
  -webkit-font-smoothing: antialiased;
}
.mono { font-family: var(--font-mono); }

/* ── Layout ── */
.main-grid {
  max-width: 1280px;
  margin: 0 auto;
  padding: 0 20px 40px;
  display: flex;
  flex-direction: column;
  gap: 14px;
}

/* =============================================
   TOP BAR
   ============================================= */
.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 0 20px;
  height: 56px;
  background: var(--bg-surface);
  border-bottom: 0.5px solid var(--border);
  position: sticky;
  top: 0;
  z-index: 100;
  margin-bottom: 6px;
}

.topbar-left {
  display: flex;
  align-items: center;
  gap: 14px;
  flex-shrink: 0;
}

.topbar-logo {
  font-size: 16px;
  font-weight: 500;
  color: var(--text-primary);
  display: flex;
  align-items: center;
  gap: 8px;
  letter-spacing: -0.01em;
}
.topbar-logo svg { color: var(--accent); }
.topbar-logo .accent { color: var(--accent); }

.topbar-divider {
  width: 1px;
  height: 18px;
  background: var(--border-md);
}

.topbar-subtitle {
  font-size: 12px;
  color: var(--text-tertiary);
  font-family: var(--font-mono);
}

.topbar-right {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-shrink: 0;
}

.refresh-status {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 4px 10px;
  background: var(--accent-dim);
  border-radius: var(--radius-sm);
  border: 0.5px solid rgba(79,156,249,0.2);
}

.icon-btn {
  width: 34px;
  height: 34px;
  border-radius: var(--radius-sm);
  border: 0.5px solid var(--border-md);
  background: transparent;
  color: var(--text-secondary);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background var(--transition), color var(--transition);
}
.icon-btn:hover {
  background: var(--bg-hover);
  color: var(--text-primary);
}

/* =============================================
   SEARCH
   ============================================= */
.search-wrap {
  position: relative;
  display: flex;
  align-items: center;
  gap: 8px;
  flex: 1;
  max-width: 340px;
  background: var(--bg-card);
  border: 0.5px solid var(--border-md);
  border-radius: var(--radius-md);
  padding: 0 12px;
  transition: border-color var(--transition);
}
.search-wrap:focus-within {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-dim);
}
.search-wrap svg { color: var(--text-tertiary); flex-shrink: 0; }

.search-input {
  flex: 1;
  background: transparent;
  border: none;
  outline: none;
  font-family: var(--font-display);
  font-size: 13px;
  color: var(--text-primary);
  height: 38px;
}
.search-input::placeholder { color: var(--text-tertiary); }

.search-dropdown {
  position: absolute;
  top: calc(100% + 6px);
  left: 0;
  right: 0;
  background: var(--bg-card);
  border: 0.5px solid var(--border-md);
  border-radius: var(--radius-md);
  overflow: hidden;
  z-index: 200;
  box-shadow: 0 8px 32px rgba(0,0,0,0.3);
}
.search-result-item {
  padding: 10px 14px;
  font-size: 13px;
  cursor: pointer;
  border-bottom: 0.5px solid var(--border);
  transition: background var(--transition);
}
.search-result-item:last-child { border-bottom: none; }
.search-result-item:hover { background: var(--bg-hover); }
.search-result-item .city-name { color: var(--text-primary); font-weight: 500; }
.search-result-item .city-country { color: var(--text-tertiary); font-size: 11px; margin-top: 1px; }

/* =============================================
   ERROR BANNER
   ============================================= */
.error-banner {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 14px;
  background: var(--danger-dim);
  border: 0.5px solid var(--danger);
  border-radius: var(--radius-md);
  color: var(--danger);
  font-size: 13px;
}
.error-banner button {
  margin-left: auto;
  background: none;
  border: none;
  color: var(--danger);
  cursor: pointer;
  font-size: 14px;
  padding: 2px 6px;
  border-radius: 4px;
}
.error-banner button:hover { background: var(--danger-dim); }

/* =============================================
   KPI ROW
   ============================================= */
.kpi-row {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 12px;
}

.kpi-card {
  background: var(--bg-card);
  border: 0.5px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 16px 18px;
  position: relative;
  overflow: hidden;
  transition: border-color var(--transition), transform var(--transition);
}
.kpi-card:hover {
  border-color: var(--border-md);
  transform: translateY(-1px);
}
.kpi-card::before {
  content: '';
  position: absolute;
  inset: 0;
  background: var(--kpi-glow);
  opacity: 0;
  transition: opacity var(--transition);
  pointer-events: none;
}
.kpi-card:hover::before { opacity: 1; }

.kpi-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 10px;
}
.kpi-label {
  font-size: 11px;
  font-weight: 500;
  color: var(--text-tertiary);
  text-transform: uppercase;
  letter-spacing: 0.08em;
}
.kpi-header svg { color: var(--text-tertiary); }

.kpi-value {
  font-family: var(--font-mono);
  font-size: 26px;
  font-weight: 500;
  color: var(--text-primary);
  line-height: 1;
  margin-bottom: 6px;
  letter-spacing: -0.02em;
  min-height: 26px;
}
.kpi-meta {
  font-size: 11px;
  color: var(--text-tertiary);
  font-family: var(--font-mono);
}

/* =============================================
   CHARTS ROW
   ============================================= */
.charts-row {
  display: grid;
  grid-template-columns: 3fr 2fr;
  gap: 12px;
}

.chart-card {
  background: var(--bg-card);
  border: 0.5px solid var(--border);
  border-radius: var(--radius-xl);
  padding: 20px;
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.chart-card-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 12px;
}

.chart-title {
  font-size: 14px;
  font-weight: 500;
  color: var(--text-primary);
  line-height: 1.3;
}
.chart-sub {
  font-size: 11px;
  color: var(--text-tertiary);
  font-family: var(--font-mono);
  margin-top: 3px;
}

.chart-controls {
  display: flex;
  gap: 4px;
  flex-shrink: 0;
}
.ctrl-btn {
  font-family: var(--font-mono);
  font-size: 11px;
  padding: 4px 9px;
  border-radius: var(--radius-sm);
  border: 0.5px solid var(--border-md);
  background: transparent;
  color: var(--text-secondary);
  cursor: pointer;
  transition: all var(--transition);
}
.ctrl-btn:hover {
  background: var(--bg-hover);
  color: var(--text-primary);
}
.ctrl-btn.active {
  background: var(--accent-dim);
  border-color: var(--accent);
  color: var(--accent);
}

.chart-wrap {
  position: relative;
  width: 100%;
  height: 180px;
  display: flex;
  align-items: center;
  justify-content: center;
}
.chart-wrap canvas {
  position: absolute;
  inset: 0;
  width: 100% !important;
  height: 100% !important;
}

/* ── Spinner ── */
.spinner {
  width: 28px;
  height: 28px;
  border: 2px solid var(--border-md);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin 0.7s linear infinite;
  position: absolute;
  z-index: 10;
}
@keyframes spin { to { transform: rotate(360deg); } }

.spinner.hidden { display: none; }

/* ── Forecast row ── */
.forecast-row {
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  gap: 8px;
}

.forecast-day {
  background: var(--bg-surface);
  border: 0.5px solid var(--border);
  border-radius: var(--radius-md);
  padding: 10px 8px;
  text-align: center;
  font-size: 12px;
}
.forecast-day .fd-name {
  color: var(--text-tertiary);
  font-size: 10px;
  font-family: var(--font-mono);
  margin-bottom: 6px;
  text-transform: uppercase;
}
.forecast-day .fd-icon {
  width: 28px;
  height: 28px;
  margin: 4px auto;
  display: flex;
  align-items: center;
  justify-content: center;
}
.forecast-day .fd-icon svg {
  width: 24px;
  height: 24px;
}
.forecast-day .fd-temp {
  font-family: var(--font-mono);
  font-weight: 500;
  color: var(--text-primary);
}
.forecast-day .fd-temp-min {
  color: var(--text-tertiary);
  font-size: 11px;
}

/* =============================================
   BOTTOM ROW
   ============================================= */
.bottom-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
}

.panel-card {
  background: var(--bg-card);
  border: 0.5px solid var(--border);
  border-radius: var(--radius-xl);
  padding: 20px;
}

.panel-title {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 13px;
  font-weight: 500;
  color: var(--text-primary);
  margin-bottom: 16px;
}
.panel-title svg { color: var(--accent); }

/* ── Alert fields ── */
.alert-field {
  margin-bottom: 14px;
}
.field-label {
  display: block;
  font-size: 11px;
  color: var(--text-secondary);
  margin-bottom: 8px;
}
.slider-row {
  display: flex;
  align-items: center;
  gap: 12px;
}
input[type="range"] {
  flex: 1;
  appearance: none;
  height: 4px;
  background: var(--border-md);
  border-radius: 2px;
  outline: none;
  cursor: pointer;
}
input[type="range"]::-webkit-slider-thumb {
  appearance: none;
  width: 14px;
  height: 14px;
  border-radius: 50%;
  background: var(--accent);
  border: 2px solid var(--bg-card);
  cursor: pointer;
  transition: transform var(--transition);
}
input[type="range"]::-webkit-slider-thumb:hover {
  transform: scale(1.2);
}
.alert-val {
  font-size: 13px;
  font-weight: 500;
  color: var(--accent);
  min-width: 44px;
  text-align: right;
}

.alert-status {
  display: flex;
  align-items: center;
  gap: 7px;
  padding: 8px 10px;
  background: var(--bg-surface);
  border: 0.5px solid var(--border);
  border-radius: var(--radius-sm);
  margin-top: 4px;
}
.hint-text {
  font-size: 10px;
  color: var(--text-tertiary);
  font-family: var(--font-mono);
  margin-top: 8px;
}
.test-btn {
  margin-top: 10px;
  width: 100%;
  padding: 8px 0;
  border-radius: var(--radius-sm);
  border: 0.5px dashed var(--border-md);
  background: transparent;
  color: var(--text-secondary);
  font-family: var(--font-mono);
  font-size: 11px;
  cursor: pointer;
  transition: all var(--transition);
}
.test-btn:hover {
  background: var(--accent-dim);
  border-color: var(--accent);
  color: var(--accent);
}

/* ── Status list ── */
.status-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.status-item {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 8px 0;
  border-bottom: 0.5px solid var(--border);
}
.status-item:last-child { border-bottom: none; }
.status-name {
  font-size: 12px;
  color: var(--text-secondary);
}
.status-badge {
  font-family: var(--font-mono);
  font-size: 10px;
  padding: 3px 8px;
  border-radius: 99px;
  font-weight: 500;
}
.status-ok { background: rgba(61,214,140,0.12); color: #3dd68c; }
.status-error { background: var(--danger-dim); color: var(--danger); }
.status-loading { background: rgba(79,156,249,0.1); color: var(--accent); }
.status-inactive { background: var(--bg-surface); color: var(--text-tertiary); border: 0.5px solid var(--border); }

.divider {
  height: 0.5px;
  background: var(--border);
  margin: 14px 0;
}

.refresh-info {
  display: flex;
  align-items: center;
  gap: 6px;
  color: var(--text-tertiary);
}
.refresh-info svg { color: var(--text-tertiary); }
.dimmed { margin-left: auto; }

/* =============================================
   SKELETON LOADING
   ============================================= */
@keyframes shimmer {
  0%   { opacity: 0.4; }
  50%  { opacity: 0.9; }
  100% { opacity: 0.4; }
}

.skeleton {
  color: transparent !important;
  background: var(--bg-hover);
  border-radius: 4px;
  animation: shimmer 1.4s ease-in-out infinite;
  user-select: none;
  pointer-events: none;
}
.skeleton-block {
  background: var(--bg-hover) !important;
  animation: shimmer 1.4s ease-in-out infinite;
}

/* =============================================
   PULSE DOT
   ============================================= */
.pulse-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--accent-2);
  position: relative;
  flex-shrink: 0;
}
.pulse-dot::after {
  content: '';
  position: absolute;
  inset: -3px;
  border-radius: 50%;
  border: 1.5px solid var(--accent-2);
  animation: pulse-ring 2s ease-out infinite;
  opacity: 0;
}
.pulse-dot.small { width: 7px; height: 7px; }
.pulse-dot.error { background: var(--danger); }
.pulse-dot.error::after { border-color: var(--danger); }

@keyframes pulse-ring {
  0%   { transform: scale(1); opacity: 0.6; }
  80%  { transform: scale(2.2); opacity: 0; }
  100% { opacity: 0; }
}

/* =============================================
   RESPONSIVE
   ============================================= */
@media (max-width: 900px) {
  .charts-row { grid-template-columns: 1fr; }
  .kpi-row { grid-template-columns: repeat(2, 1fr); }
}

@media (max-width: 600px) {
  .topbar { padding: 0 12px; height: auto; flex-wrap: wrap; padding: 10px 12px; gap: 8px; }
  .topbar-subtitle { display: none; }
  .search-wrap { max-width: 100%; order: 3; flex: 1 0 100%; }
  .main-grid { padding: 0 12px 30px; }
  .kpi-row { grid-template-columns: repeat(2, 1fr); }
  .bottom-row { grid-template-columns: 1fr; }
  .forecast-row { grid-template-columns: repeat(5, 1fr); }
  .chart-card-header { flex-direction: column; gap: 8px; }
}

@media (max-width: 380px) {
  .kpi-row { grid-template-columns: 1fr 1fr; }
  .forecast-row { grid-template-columns: repeat(3, 1fr); }
}

/* =============================================
   THEME TRANSITION
   ============================================= */
body, .topbar, .kpi-card, .chart-card, .panel-card {
  transition: background var(--transition), border-color var(--transition), color var(--transition);
}
