/* ============================================================
   eSunScope — Carousel Dashboard Theme
   Optimized for 1920x1080, 24/7 large-monitor display
   ============================================================ */

/* --- Root Variables --- */
:root {
  --bg: #0a0e1a;
  --bg2: #111827;
  --surface: rgba(255,255,255,0.035);
  --surface-hover: rgba(255,255,255,0.06);
  --border: rgba(255,255,255,0.06);
  --border-glow: rgba(255,255,255,0.1);

  --text: #e2e8f0;
  --text-dim: #64748b;
  --text-muted: #475569;

  --gold: #f59e0b;
  --teal: #14b8a6;
  --blue: #3b82f6;
  --green: #10b981;
  --red: #ef4444;
  --amber: #f59e0b;
  --purple: #8b5cf6;
  --cyan: #06b6d4;
  --pink: #ec4899;

  --glow-green: rgba(16,185,129,0.4);
  --glow-amber: rgba(245,158,11,0.4);
  --glow-red: rgba(239,68,68,0.4);
  --glow-blue: rgba(59,130,246,0.3);
  --glow-teal: rgba(20,184,166,0.3);

  --topbar-h: 56px;
  --bottombar-h: 48px;
  --slide-transition: 800ms;

  --radius: 14px;
  --radius-sm: 8px;
}

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

html, body {
  height: 100%;
  overflow: hidden;
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  background: var(--bg);
  color: var(--text);
  -webkit-font-smoothing: antialiased;
}

body {
  background: linear-gradient(135deg, #0a0e1a 0%, #111827 40%, #0f172a 70%, #0a0e1a 100%);
  background-size: 400% 400%;
  animation: ambientShift 120s ease infinite;
}

@keyframes ambientShift {
  0%   { background-position: 0% 50%; }
  25%  { background-position: 50% 0%; }
  50%  { background-position: 100% 50%; }
  75%  { background-position: 50% 100%; }
  100% { background-position: 0% 50%; }
}

/* --- App Layout --- */
#app {
  display: grid;
  grid-template-rows: var(--topbar-h) 1fr var(--bottombar-h);
  height: 100vh;
  width: 100vw;
}

/* --- Top Bar --- */
#topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 28px;
  border-bottom: 1px solid var(--border);
  background: rgba(10,14,26,0.85);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  z-index: 10;
}

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

.brand {
  font-size: 1.15rem;
  font-weight: 700;
  letter-spacing: -0.3px;
  color: var(--text);
}
.brand i { color: var(--gold); margin-right: 4px; }

.live-badge {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 0.65rem;
  font-weight: 600;
  letter-spacing: 1.2px;
  text-transform: uppercase;
  color: var(--green);
  background: rgba(16,185,129,0.08);
  padding: 3px 10px;
  border-radius: 20px;
  border: 1px solid rgba(16,185,129,0.2);
}

.pulse-dot {
  width: 7px;
  height: 7px;
  background: var(--green);
  border-radius: 50%;
  animation: pulse 2s ease infinite;
}

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

.topbar-center {
  position: absolute;
  left: 50%;
  transform: translateX(-50%);
  text-align: center;
}

.clock {
  font-size: 1.6rem;
  font-weight: 700;
  letter-spacing: 2px;
  font-variant-numeric: tabular-nums;
  color: var(--text);
}

.date {
  font-size: 0.7rem;
  color: var(--text-dim);
  letter-spacing: 0.5px;
}

.topbar-right {
  text-align: right;
}

.last-updated {
  font-size: 0.7rem;
  color: var(--text-dim);
}

.refresh-timer {
  font-size: 0.7rem;
  color: var(--text-dim);
  display: inline-flex;
  align-items: center;
  gap: 4px;
  margin-right: 14px;
}

.refresh-timer i {
  font-size: 0.6rem;
}

.refresh-count {
  font-weight: 700;
  font-variant-numeric: tabular-nums;
  color: var(--teal);
  min-width: 18px;
  text-align: right;
}

/* --- Carousel --- */
#carousel {
  position: relative;
  overflow: hidden;
}

.slide {
  position: absolute;
  inset: 0;
  opacity: 0;
  transition: opacity var(--slide-transition) ease-in-out;
  pointer-events: none;
  overflow-y: auto;
  padding: 20px 28px;
}

.slide.active {
  opacity: 1;
  pointer-events: auto;
}

.slide-content {
  height: 100%;
}

/* --- Bottom Bar --- */
#bottombar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 28px;
  border-top: 1px solid var(--border);
  background: rgba(10,14,26,0.85);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  z-index: 10;
}

.carousel-nav {
  display: flex;
  gap: 6px;
}

.carousel-dot {
  width: 36px;
  height: 30px;
  display: flex;
  align-items: center;
  justify-content: center;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: transparent;
  color: var(--text-muted);
  font-size: 0.8rem;
  cursor: pointer;
  transition: all 250ms;
}

.carousel-dot:hover {
  background: var(--surface-hover);
  color: var(--text-dim);
  border-color: var(--border-glow);
}

.carousel-dot.active {
  background: rgba(20,184,166,0.1);
  border-color: rgba(20,184,166,0.35);
  color: var(--teal);
  box-shadow: 0 0 12px rgba(20,184,166,0.15);
}

.carousel-info {
  display: flex;
  align-items: center;
  gap: 12px;
}

.carousel-progress {
  width: 100px;
  height: 3px;
  background: var(--border);
  border-radius: 2px;
  overflow: hidden;
}

.carousel-progress-fill {
  height: 100%;
  width: 0%;
  background: linear-gradient(90deg, var(--teal), var(--cyan));
  border-radius: 2px;
  transition: width 1s linear;
}

#timerText {
  font-size: 0.7rem;
  color: var(--text-dim);
  font-variant-numeric: tabular-nums;
  min-width: 28px;
}

#pauseBtn {
  width: 28px;
  height: 28px;
  display: flex;
  align-items: center;
  justify-content: center;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: transparent;
  color: var(--text-dim);
  font-size: 0.7rem;
  cursor: pointer;
  transition: all 200ms;
}

#pauseBtn:hover {
  background: var(--surface-hover);
  color: var(--text);
}

/* --- Loading Overlay --- */
.loading-overlay {
  position: fixed;
  inset: 0;
  background: var(--bg);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 100;
  transition: opacity 600ms ease;
}

.loading-overlay.hidden {
  opacity: 0;
  pointer-events: none;
}

.loader {
  text-align: center;
}

.loader-ring {
  width: 48px;
  height: 48px;
  border: 3px solid var(--border);
  border-top-color: var(--teal);
  border-radius: 50%;
  animation: spin 1s linear infinite;
  margin: 0 auto 16px;
}

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

.loader-text {
  font-size: 0.85rem;
  color: var(--text-dim);
  letter-spacing: 0.5px;
}

/* ============================================================
   GLASS CARD — shared component
   ============================================================ */
.glass {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
}

.glass:hover {
  border-color: var(--border-glow);
}

/* ============================================================
   SLIDE 1: OVERVIEW
   ============================================================ */
.kpi-row {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 16px;
  margin-bottom: 16px;
}

.kpi-card {
  padding: 18px 20px;
  display: flex;
  align-items: center;
  gap: 16px;
  transition: border-color 300ms, box-shadow 300ms;
}

.kpi-card:hover {
  box-shadow: 0 4px 24px rgba(0,0,0,0.2);
}

.kpi-icon {
  width: 48px;
  height: 48px;
  border-radius: 12px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.2rem;
  flex-shrink: 0;
}

.kpi-icon.capacity  { background: rgba(59,130,246,0.12); color: var(--blue); }
.kpi-icon.today     { background: rgba(20,184,166,0.12); color: var(--teal); }
.kpi-icon.month     { background: rgba(139,92,246,0.12); color: var(--purple); }
.kpi-icon.alerts    { background: rgba(239,68,68,0.12);  color: var(--red); }

.kpi-body { flex: 1; }

.kpi-value {
  font-size: 1.8rem;
  font-weight: 800;
  line-height: 1.1;
  letter-spacing: -0.5px;
  font-variant-numeric: tabular-nums;
}

.kpi-label {
  font-size: 0.72rem;
  color: var(--text-dim);
  text-transform: uppercase;
  letter-spacing: 0.8px;
  margin-top: 2px;
}

.overview-charts {
  display: grid;
  grid-template-columns: 1fr 340px;
  gap: 16px;
  height: calc(100% - 110px);
  min-height: 340px;
}

.chart-panel {
  padding: 18px 20px;
  display: flex;
  flex-direction: column;
}

.chart-panel h3 {
  font-size: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 1px;
  color: var(--text-dim);
  margin-bottom: 12px;
  font-weight: 600;
}

.chart-body {
  flex: 1;
  min-height: 0;
}

/* Status Pie */
.status-summary {
  display: flex;
  flex-direction: column;
  gap: 10px;
  margin-top: 12px;
}

.status-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 8px 12px;
  border-radius: var(--radius-sm);
  background: rgba(255,255,255,0.02);
}

.status-row-left {
  display: flex;
  align-items: center;
  gap: 10px;
}

.status-dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
}

.status-dot.green  { background: var(--green); box-shadow: 0 0 8px var(--glow-green); }
.status-dot.amber  { background: var(--amber); box-shadow: 0 0 8px var(--glow-amber); }
.status-dot.red    { background: var(--red);   box-shadow: 0 0 8px var(--glow-red); }

.status-label {
  font-size: 0.8rem;
  color: var(--text-dim);
}

.status-count {
  font-size: 1.3rem;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
}

/* ============================================================
   SLIDE 2: PLANT GRID
   ============================================================ */
.plants-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 16px;
}

.plants-header h2 {
  font-size: 0.85rem;
  text-transform: uppercase;
  letter-spacing: 1px;
  color: var(--text-dim);
  font-weight: 600;
}

.plants-header-right {
  display: flex;
  align-items: center;
  gap: 16px;
}

.plants-header-right > span {
  font-size: 0.72rem;
  color: var(--text-muted);
}

.plant-search-wrap {
  position: relative;
  display: flex;
  align-items: center;
}

.plant-search-icon {
  position: absolute;
  left: 12px;
  font-size: 0.72rem;
  color: var(--text-muted);
  pointer-events: none;
}

.plant-search-input {
  background: rgba(255,255,255,0.04);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text);
  font-size: 0.78rem;
  padding: 7px 34px 7px 34px;
  width: 220px;
  outline: none;
  transition: border-color 200ms, box-shadow 200ms;
  font-family: inherit;
}

.plant-search-input::placeholder {
  color: var(--text-muted);
}

.plant-search-input:focus {
  border-color: rgba(20,184,166,0.5);
  box-shadow: 0 0 0 3px rgba(20,184,166,0.1);
}

.plant-search-clear {
  position: absolute;
  right: 6px;
  width: 22px;
  height: 22px;
  display: flex;
  align-items: center;
  justify-content: center;
  border: none;
  border-radius: 50%;
  background: rgba(255,255,255,0.06);
  color: var(--text-dim);
  font-size: 0.6rem;
  cursor: pointer;
  transition: background 150ms, color 150ms;
}

.plant-search-clear:hover {
  background: rgba(239,68,68,0.15);
  color: var(--red);
}

.plant-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  grid-template-rows: repeat(3, 1fr);
  gap: 12px;
  height: calc(100% - 44px);
}

.plant-card {
  padding: 16px 18px;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  transition: border-color 300ms, transform 200ms, box-shadow 200ms;
  cursor: pointer;
  text-decoration: none;
  color: inherit;
}

a.plant-card:hover {
  transform: translateY(-2px);
  box-shadow: 0 8px 24px rgba(0,0,0,0.25);
}

.plant-card.status-online  { border-left: 3px solid var(--green); }
.plant-card.status-warning { border-left: 3px solid var(--amber); }
.plant-card.status-offline { border-left: 3px solid var(--red); }

.plant-card-top {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
}

.plant-name {
  font-size: 0.78rem;
  font-weight: 600;
  color: var(--text);
  line-height: 1.3;
  max-width: 200px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.plant-status-badge {
  font-size: 0.6rem;
  font-weight: 600;
  letter-spacing: 0.5px;
  text-transform: uppercase;
  padding: 2px 8px;
  border-radius: 12px;
  white-space: nowrap;
}

.badge-online  { background: rgba(16,185,129,0.1);  color: var(--green); }
.badge-warning { background: rgba(245,158,11,0.1);  color: var(--amber); }
.badge-offline { background: rgba(239,68,68,0.1);   color: var(--red); }

.plant-metrics {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
  margin-top: 10px;
}

.plant-metric {
  display: flex;
  flex-direction: column;
}

.plant-metric-value {
  font-size: 1.2rem;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
  line-height: 1.2;
}

.plant-metric-label {
  font-size: 0.6rem;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.plant-card-bottom {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-top: 8px;
  padding-top: 8px;
  border-top: 1px solid var(--border);
}

.plant-capacity {
  font-size: 0.65rem;
  color: var(--text-muted);
}

.plant-vendor {
  font-size: 0.58rem;
  color: var(--text-muted);
  padding: 1px 6px;
  border: 1px solid var(--border);
  border-radius: 4px;
}

.plant-grid-empty {
  grid-column: 1 / -1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 12px;
  color: var(--text-muted);
  font-size: 0.85rem;
}

.plant-grid-empty i {
  font-size: 1.8rem;
  opacity: 0.3;
}

.plant-grid-empty p {
  font-size: 0.8rem;
}

.plant-grid-empty strong {
  color: var(--text-dim);
}

/* ============================================================
   SLIDE 3: HEALTH & ALERTS
   ============================================================ */
.health-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  grid-template-rows: 1fr 1fr;
  gap: 14px;
  height: 100%;
}

.health-panel {
  padding: 16px 18px;
  display: flex;
  flex-direction: column;
}

.health-panel h3 {
  font-size: 0.72rem;
  text-transform: uppercase;
  letter-spacing: 0.8px;
  color: var(--text-dim);
  font-weight: 600;
  margin-bottom: 12px;
  display: flex;
  align-items: center;
  gap: 8px;
}

.health-panel h3 i {
  font-size: 0.8rem;
}

.health-panel h3 .count-badge {
  font-size: 0.65rem;
  font-weight: 700;
  padding: 1px 7px;
  border-radius: 10px;
  margin-left: auto;
}

.count-badge.red   { background: rgba(239,68,68,0.15);  color: var(--red); }
.count-badge.amber { background: rgba(245,158,11,0.15); color: var(--amber); }
.count-badge.green { background: rgba(16,185,129,0.15); color: var(--green); }

.health-list {
  flex: 1;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.health-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 12px;
  border-radius: var(--radius-sm);
  background: rgba(255,255,255,0.02);
  transition: background 200ms;
}

.health-item:hover {
  background: rgba(255,255,255,0.04);
}

.health-item-dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  flex-shrink: 0;
}

.health-item-body {
  flex: 1;
  min-width: 0;
}

.health-item-title {
  font-size: 0.78rem;
  font-weight: 500;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.health-item-meta {
  font-size: 0.62rem;
  color: var(--text-muted);
  margin-top: 1px;
}

.health-item-value {
  font-size: 0.85rem;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
  flex-shrink: 0;
}

/* Status summary bar in health slide */
.status-bar-container {
  margin-top: 8px;
}

.status-bar {
  display: flex;
  height: 8px;
  border-radius: 4px;
  overflow: hidden;
  gap: 2px;
  margin-bottom: 6px;
}

.status-bar-seg {
  height: 100%;
  border-radius: 4px;
  transition: width 600ms ease;
}

.status-bar-seg.green  { background: var(--green); }
.status-bar-seg.amber  { background: var(--amber); }
.status-bar-seg.red    { background: var(--red); }

/* ============================================================
   SLIDE 4: PLANT SPOTLIGHT
   ============================================================ */
.spotlight-layout {
  display: grid;
  grid-template-columns: 1fr 1fr 1fr;
  grid-template-rows: auto 1fr auto;
  gap: 16px;
  height: 100%;
}

.spotlight-header {
  grid-column: 1 / -1;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.spotlight-title {
  font-size: 0.85rem;
  text-transform: uppercase;
  letter-spacing: 1px;
  color: var(--text-dim);
  font-weight: 600;
}

.spotlight-counter {
  font-size: 0.72rem;
  color: var(--text-muted);
  font-variant-numeric: tabular-nums;
}

.spotlight-hero {
  grid-column: 1 / -1;
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 16px;
}

.spotlight-metric {
  padding: 24px;
  text-align: center;
}

.spotlight-metric-label {
  font-size: 0.72rem;
  text-transform: uppercase;
  letter-spacing: 1px;
  color: var(--text-dim);
  margin-bottom: 8px;
}

.spotlight-metric-value {
  font-size: 2.6rem;
  font-weight: 800;
  line-height: 1;
  font-variant-numeric: tabular-nums;
}

.spotlight-metric-unit {
  font-size: 0.85rem;
  font-weight: 500;
  color: var(--text-dim);
  margin-left: 4px;
}

.spotlight-details {
  grid-column: 1 / -1;
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 12px;
}

.spotlight-detail-card {
  padding: 14px 16px;
  text-align: center;
}

.spotlight-detail-value {
  font-size: 1.4rem;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
}

.spotlight-detail-label {
  font-size: 0.62rem;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: var(--text-muted);
  margin-top: 4px;
}

.spotlight-footer {
  grid-column: 1 / -1;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 16px;
}

.spotlight-plant-name {
  font-size: 1rem;
  font-weight: 600;
}

.spotlight-vendor-badge {
  font-size: 0.65rem;
  padding: 3px 10px;
  border-radius: 12px;
  background: rgba(255,255,255,0.05);
  border: 1px solid var(--border);
  color: var(--text-dim);
}

.spotlight-status-dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
}

/* ============================================================
   UTILITY & ANIMATIONS
   ============================================================ */
.text-green  { color: var(--green); }
.text-amber  { color: var(--amber); }
.text-red    { color: var(--red); }
.text-blue   { color: var(--blue); }
.text-teal   { color: var(--teal); }
.text-purple { color: var(--purple); }
.text-dim    { color: var(--text-dim); }

@keyframes fadeInUp {
  from { opacity: 0; transform: translateY(12px); }
  to   { opacity: 1; transform: translateY(0); }
}

.animate-in {
  animation: fadeInUp 500ms ease both;
}

/* staggered children */
.stagger > *:nth-child(1) { animation-delay: 0ms; }
.stagger > *:nth-child(2) { animation-delay: 60ms; }
.stagger > *:nth-child(3) { animation-delay: 120ms; }
.stagger > *:nth-child(4) { animation-delay: 180ms; }
.stagger > *:nth-child(5) { animation-delay: 240ms; }
.stagger > *:nth-child(6) { animation-delay: 300ms; }
.stagger > *:nth-child(7) { animation-delay: 360ms; }
.stagger > *:nth-child(8) { animation-delay: 420ms; }
.stagger > *:nth-child(9) { animation-delay: 480ms; }
.stagger > *:nth-child(10) { animation-delay: 540ms; }
.stagger > *:nth-child(11) { animation-delay: 600ms; }
.stagger > *:nth-child(12) { animation-delay: 660ms; }

/* Scrollbar */
::-webkit-scrollbar { width: 4px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--border); border-radius: 2px; }
