/* =========================================================================
   energy.css
   Energy Analytics Dashboard — Aelyra Lab Private Limited
   Theme: Emerald enterprise / glassmorphism / soft shadows
   ========================================================================= */

:root {
  --primary: #10B981;
  --primary-dark: #0B8F63;
  --secondary: #34D399;
  --bg: #F8FAFC;
  --card: #FFFFFF;
  --text-main: #0F172A;
  --text-muted: #64748B;
  --border: #E2E8F0;
  --radius: 18px;
  --shadow-sm: 0 2px 8px rgba(15, 23, 42, 0.04);
  --shadow-md: 0 8px 24px rgba(16, 185, 129, 0.10);
  --shadow-lg: 0 16px 40px rgba(15, 23, 42, 0.10);
  --glass-bg: rgba(255, 255, 255, 0.65);
  --glass-border: rgba(255, 255, 255, 0.35);
  --success: #10B981;
  --warning: #F59E0B;
  --danger: #EF4444;
  --font-display: 'Inter', -apple-system, sans-serif;
}

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

html { scroll-behavior: smooth; }

body {
  font-family: var(--font-display);
  background: var(--bg);
  color: var(--text-main);
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}

body::before {
  content: '';
  position: fixed;
  inset: 0;
  background:
    radial-gradient(circle at 10% 10%, rgba(16, 185, 129, 0.06), transparent 40%),
    radial-gradient(circle at 90% 20%, rgba(52, 211, 153, 0.08), transparent 40%);
  pointer-events: none;
  z-index: 0;
}

a { color: inherit; text-decoration: none; }

/* ---------------------------------------------------------------------- */
/* Navbar                                                                  */
/* ---------------------------------------------------------------------- */
.navbar {
  position: sticky;
  top: 0;
  z-index: 100;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 32px;
  background: var(--glass-bg);
  backdrop-filter: blur(16px) saturate(180%);
  -webkit-backdrop-filter: blur(16px) saturate(180%);
  border-bottom: 1px solid var(--glass-border);
  box-shadow: var(--shadow-sm);
}

.navbar-brand {
  display: flex;
  align-items: center;
  gap: 12px;
}

.navbar-logo {
  width: 42px;
  height: 42px;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  overflow: hidden;
  background: transparent !important;
  border-radius: 0 !important;
  box-shadow: none !important;
}

.navbar-logo img {
  width: 140% !important;
  height: 140% !important;
  object-fit: contain !important;
  object-position: center 22% !important;
  padding: 0 !important;
  display: block !important;
}
.navbar-titles h1 {
  font-size: 17px;
  font-weight: 700;
  letter-spacing: -0.01em;
}

.navbar-titles span {
  font-size: 12px;
  color: var(--text-muted);
  font-weight: 500;
}

.navbar-right {
  display: flex;
  align-items: center;
  gap: 20px;
}

.live-clock {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  font-variant-numeric: tabular-nums;
}

.live-clock .time {
  font-size: 18px;
  font-weight: 700;
  color: var(--primary-dark);
}

.live-clock .date {
  font-size: 11px;
  color: var(--text-muted);
}

.live-dot {
  width: 9px;
  height: 9px;
  border-radius: 50%;
  background: var(--primary);
  box-shadow: 0 0 0 0 rgba(16, 185, 129, 0.6);
  animation: pulse 1.8s infinite;
  display: inline-block;
  margin-right: 6px;
}

@keyframes pulse {
  0%   { box-shadow: 0 0 0 0 rgba(16, 185, 129, 0.55); }
  70%  { box-shadow: 0 0 0 8px rgba(16, 185, 129, 0); }
  100% { box-shadow: 0 0 0 0 rgba(16, 185, 129, 0); }
}

/* ---------------------------------------------------------------------- */
/* Layout                                                                  */
/* ---------------------------------------------------------------------- */
.dashboard-container {
  max-width: 1440px;
  margin: 0 auto;
  padding: 28px 32px 60px;
  position: relative;
  z-index: 1;
}

.section-title {
  font-size: 15px;
  font-weight: 700;
  color: var(--text-main);
  margin: 32px 0 14px;
  display: flex;
  align-items: center;
  gap: 8px;
}

.section-title i { color: var(--primary); }

/* ---------------------------------------------------------------------- */
/* Filter bar                                                              */
/* ---------------------------------------------------------------------- */
.filter-bar {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  align-items: center;
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px 20px;
  box-shadow: var(--shadow-sm);
  margin-top: 20px;
}

.filter-bar select,
.filter-bar input {
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 9px 12px;
  font-size: 13px;
  font-family: inherit;
  color: var(--text-main);
  background: #fff;
  transition: border-color .2s, box-shadow .2s;
}

.filter-bar select:focus,
.filter-bar input:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(16, 185, 129, 0.15);
}

.filter-bar .search-wrap {
  position: relative;
  flex: 1;
  min-width: 180px;
}

.filter-bar .search-wrap i {
  position: absolute;
  left: 12px;
  top: 50%;
  transform: translateY(-50%);
  color: var(--text-muted);
  font-size: 13px;
}

.filter-bar .search-wrap input { padding-left: 32px; width: 100%; }

.export-group { display: flex; gap: 8px; margin-left: auto; }

.btn {
  border: none;
  border-radius: 10px;
  padding: 9px 16px;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  transition: transform .15s, box-shadow .15s, background .15s;
}

.btn:active { transform: scale(0.96); }

.btn-primary {
  background: linear-gradient(135deg, var(--primary), var(--secondary));
  color: #fff;
  box-shadow: var(--shadow-md);
}

.btn-primary:hover { box-shadow: 0 10px 28px rgba(16,185,129,0.28); }

.btn-outline {
  background: #fff;
  border: 1px solid var(--border);
  color: var(--text-main);
}

.btn-outline:hover { border-color: var(--primary); color: var(--primary-dark); }

/* ---------------------------------------------------------------------- */
/* KPI cards                                                               */
/* ---------------------------------------------------------------------- */
.kpi-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 18px;
  margin-top: 8px;
}

.kpi-card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px;
  position: relative;
  overflow: hidden;
  box-shadow: var(--shadow-sm);
  transition: transform .25s ease, box-shadow .25s ease;
}

.kpi-card:hover {
  transform: translateY(-4px);
  box-shadow: var(--shadow-lg);
}

.kpi-card::after {
  content: '';
  position: absolute;
  right: -30px;
  top: -30px;
  width: 100px;
  height: 100px;
  border-radius: 50%;
  background: radial-gradient(circle, rgba(16,185,129,0.10), transparent 70%);
}

.kpi-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 14px;
}

.kpi-icon {
  width: 42px;
  height: 42px;
  border-radius: 12px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 18px;
  color: #fff;
  background: linear-gradient(135deg, var(--primary), var(--secondary));
}

.kpi-trend {
  font-size: 12px;
  font-weight: 700;
  padding: 3px 9px;
  border-radius: 20px;
  display: flex;
  align-items: center;
  gap: 4px;
}

.kpi-trend.up { color: var(--success); background: rgba(16,185,129,0.12); }
.kpi-trend.down { color: var(--danger); background: rgba(239,68,68,0.12); }

.kpi-value {
  font-size: 26px;
  font-weight: 800;
  letter-spacing: -0.02em;
  color: var(--text-main);
  font-variant-numeric: tabular-nums;
}

.kpi-label {
  font-size: 12.5px;
  color: var(--text-muted);
  font-weight: 600;
  margin-top: 3px;
}

.kpi-sparkline { margin-top: 12px; height: 34px; }

/* ---------------------------------------------------------------------- */
/* Panels & Cards                                                          */
/* ---------------------------------------------------------------------- */
.grid-2 { display: grid; grid-template-columns: 2fr 1fr; gap: 18px; }
.grid-3 { display: grid; grid-template-columns: repeat(3, 1fr); gap: 18px; }
.grid-half { display: grid; grid-template-columns: 1fr 1fr; gap: 18px; }

.panel {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 22px;
  box-shadow: var(--shadow-sm);
}

.panel-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 16px;
}

.panel-header h3 {
  font-size: 14.5px;
  font-weight: 700;
}

.panel-header .badge {
  font-size: 11px;
  font-weight: 700;
  color: var(--primary-dark);
  background: rgba(16,185,129,0.10);
  padding: 4px 10px;
  border-radius: 20px;
}

.chart-wrap { position: relative; height: 280px; }
.chart-wrap.tall { height: 340px; }

/* ---------------------------------------------------------------------- */
/* Weather + AQI panels                                                    */
/* ---------------------------------------------------------------------- */
.weather-hero {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 18px 0;
  border-bottom: 1px dashed var(--border);
  margin-bottom: 16px;
}

.weather-temp { font-size: 42px; font-weight: 800; color: var(--text-main); }
.weather-cond { color: var(--text-muted); font-size: 13px; font-weight: 600; margin-top: 4px; }
.weather-icon { font-size: 48px; color: var(--primary); }

.metric-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 12px;
}

.metric-item {
  background: #F8FAFC;
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 12px 14px;
  display: flex;
  align-items: center;
  gap: 10px;
}

.metric-item i { color: var(--primary); font-size: 16px; width: 20px; text-align: center; }

.metric-item .val { font-weight: 700; font-size: 14px; }
.metric-item .lbl { font-size: 11px; color: var(--text-muted); }

.aqi-badge {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 10px 18px;
  border-radius: 14px;
  font-weight: 800;
  font-size: 22px;
  color: #fff;
  margin-bottom: 16px;
}

.aqi-good { background: linear-gradient(135deg,#10B981,#34D399); }
.aqi-satisfactory { background: linear-gradient(135deg,#84CC16,#A3E635); }
.aqi-moderate { background: linear-gradient(135deg,#F59E0B,#FBBF24); }
.aqi-poor { background: linear-gradient(135deg,#F97316,#FB923C); }
.aqi-verypoor { background: linear-gradient(135deg,#EF4444,#F87171); }
.aqi-severe { background: linear-gradient(135deg,#7F1D1D,#B91C1C); }

/* ---------------------------------------------------------------------- */
/* Map                                                                     */
/* ---------------------------------------------------------------------- */
#india-map {
  height: 460px;
  border-radius: var(--radius);
  overflow: hidden;
  border: 1px solid var(--border);
  box-shadow: var(--shadow-sm);
}

.leaflet-popup-content-wrapper {
  border-radius: 14px !important;
  box-shadow: var(--shadow-lg) !important;
}

.map-popup h4 { font-size: 14px; margin-bottom: 8px; color: var(--primary-dark); }
.map-popup table { width: 100%; font-size: 12px; border-collapse: collapse; }
.map-popup td { padding: 3px 0; color: var(--text-muted); }
.map-popup td:last-child { text-align: right; font-weight: 700; color: var(--text-main); }

/* ---------------------------------------------------------------------- */
/* Loading & animations                                                    */
/* ---------------------------------------------------------------------- */
.skeleton {
  background: linear-gradient(90deg, #EEF2F6 25%, #F8FAFC 37%, #EEF2F6 63%);
  background-size: 400% 100%;
  animation: shimmer 1.4s ease infinite;
  border-radius: 8px;
}

@keyframes shimmer {
  0% { background-position: 100% 50%; }
  100% { background-position: 0 50%; }
}

.fade-in { animation: fadeIn .5s ease both; }
@keyframes fadeIn {
  from { opacity: 0; transform: translateY(8px); }
  to { opacity: 1; transform: translateY(0); }
}

/* ---------------------------------------------------------------------- */
/* Toast (export feedback)                                                 */
/* ---------------------------------------------------------------------- */
.toast {
  position: fixed;
  bottom: 24px;
  right: 24px;
  background: var(--text-main);
  color: #fff;
  padding: 12px 20px;
  border-radius: 12px;
  font-size: 13px;
  font-weight: 600;
  box-shadow: var(--shadow-lg);
  z-index: 1000;
  display: flex;
  align-items: center;
  gap: 8px;
  transform: translateY(20px);
  opacity: 0;
  transition: all .3s ease;
}

.toast.show { transform: translateY(0); opacity: 1; }
.toast i { color: var(--secondary); }

/* ---------------------------------------------------------------------- */
/* Footer                                                                  */
/* ---------------------------------------------------------------------- */
.dashboard-footer {
  text-align: center;
  padding: 24px 0 8px;
  color: var(--text-muted);
  font-size: 12px;
}

/* ---------------------------------------------------------------------- */
/* Responsive                                                              */
/* ---------------------------------------------------------------------- */
@media (max-width: 1200px) {
  .kpi-grid { grid-template-columns: repeat(2, 1fr); }
  .grid-2 { grid-template-columns: 1fr; }
  .grid-3 { grid-template-columns: repeat(2, 1fr); }
}

@media (max-width: 768px) {
  .navbar { padding: 12px 16px; }
  .dashboard-container { padding: 18px 14px 40px; }
  .kpi-grid { grid-template-columns: 1fr 1fr; gap: 12px; }
  .grid-3 { grid-template-columns: 1fr; }
  .grid-half { grid-template-columns: 1fr; }
  .export-group { margin-left: 0; width: 100%; }
  .navbar-titles span { display: none; }
  #india-map { height: 320px; }
}

@media (max-width: 480px) {
  .kpi-grid { grid-template-columns: 1fr; }
  .weather-temp { font-size: 32px; }
}
