/* ─── Central Bright - Dashboard Styles ─── */

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

:root {
  --bg-primary: #060714;
  --bg-secondary: #0D0F1E;
  --bg-card: #111328;
  --bg-card-hover: #161838;
  --border-card: rgba(138, 100, 200, 0.12);
  --border-hover: rgba(138, 100, 200, 0.25);

  --text-primary: #F0EFF4;
  --text-secondary: #8B8DA3;
  --text-muted: #565872;

  --accent-purple: #A855F7;
  --accent-blue: #3B82F6;
  --accent-cyan: #06B6D4;
  --accent-pink: #EC4899;
  --accent-green: #10B981;
  --accent-red: #EF4444;
  --accent-orange: #F59E0B;

  --gradient-brand: linear-gradient(135deg, #A855F7 0%, #3B82F6 50%, #06B6D4 100%);
  --gradient-brand-soft: linear-gradient(135deg, rgba(168,85,247,0.15) 0%, rgba(59,130,246,0.15) 50%, rgba(6,182,212,0.15) 100%);
  --gradient-purple-pink: linear-gradient(135deg, #A855F7, #EC4899);

  --sidebar-width: 260px;
  --header-height: 64px;
  --radius: 12px;
  --radius-sm: 8px;
  --transition: 0.2s ease;
}

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

body {
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
  background: var(--bg-primary);
  color: var(--text-primary);
  min-height: 100vh;
  overflow-x: hidden;
}

/* ─── Scrollbar ─── */
::-webkit-scrollbar { width: 6px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: rgba(138,100,200,0.2); border-radius: 3px; }
::-webkit-scrollbar-thumb:hover { background: rgba(138,100,200,0.4); }

/* ─── Layout ─── */
.app-layout {
  display: flex;
  min-height: 100vh;
}

/* ─── Sidebar ─── */
.sidebar {
  width: var(--sidebar-width);
  background: var(--bg-secondary);
  border-right: 1px solid var(--border-card);
  display: flex;
  flex-direction: column;
  position: fixed;
  top: 0;
  left: 0;
  bottom: 0;
  z-index: 100;
  transition: transform var(--transition);
}

.sidebar-brand {
  padding: 20px 24px;
  display: flex;
  align-items: center;
  gap: 12px;
  border-bottom: 1px solid var(--border-card);
}

.sidebar-brand img {
  height: 36px;
  width: auto;
}

.sidebar-brand h1 {
  font-size: 16px;
  font-weight: 700;
  background: var(--gradient-brand);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  letter-spacing: -0.3px;
}

.sidebar-brand span {
  font-size: 10px;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 1.5px;
  display: block;
  margin-top: 1px;
}

.sidebar-nav {
  padding: 16px 12px;
  flex: 1;
  overflow-y: auto;
}

.nav-section-title {
  font-size: 10px;
  font-weight: 600;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 1.5px;
  padding: 12px 12px 8px;
}

.nav-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 12px;
  border-radius: var(--radius-sm);
  color: var(--text-secondary);
  text-decoration: none;
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  transition: all var(--transition);
  margin-bottom: 2px;
}

.nav-item:hover {
  background: rgba(138, 100, 200, 0.08);
  color: var(--text-primary);
}

.nav-item.active {
  background: var(--gradient-brand-soft);
  color: var(--accent-purple);
  font-weight: 600;
}

.nav-item svg {
  width: 18px;
  height: 18px;
  flex-shrink: 0;
  opacity: 0.7;
}

.nav-item.active svg { opacity: 1; }

.sidebar-footer {
  padding: 16px 20px;
  border-top: 1px solid var(--border-card);
}

.sidebar-user {
  display: flex;
  align-items: center;
  gap: 10px;
}

.sidebar-user-avatar {
  width: 34px;
  height: 34px;
  border-radius: 50%;
  background: var(--gradient-brand);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 13px;
  font-weight: 700;
  color: white;
}

.sidebar-user-info {
  flex: 1;
}

.sidebar-user-info strong {
  font-size: 13px;
  display: block;
}

.sidebar-user-info span {
  font-size: 11px;
  color: var(--text-muted);
}

/* ─── Main Content ─── */
.main-content {
  margin-left: var(--sidebar-width);
  flex: 1;
  min-height: 100vh;
}

/* ─── Header ─── */
.header {
  height: var(--header-height);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 32px;
  border-bottom: 1px solid var(--border-card);
  background: rgba(6, 7, 20, 0.8);
  backdrop-filter: blur(12px);
  position: sticky;
  top: 0;
  z-index: 50;
}

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

.header-left h2 {
  font-size: 18px;
  font-weight: 700;
  letter-spacing: -0.3px;
}

.header-left .date-badge {
  font-size: 12px;
  color: var(--text-muted);
  background: rgba(138,100,200,0.08);
  padding: 4px 12px;
  border-radius: 20px;
}

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

.btn-refresh {
  background: none;
  border: 1px solid var(--border-card);
  color: var(--text-secondary);
  padding: 7px 14px;
  border-radius: var(--radius-sm);
  font-size: 12px;
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 6px;
  transition: all var(--transition);
}

.btn-refresh:hover {
  border-color: var(--accent-purple);
  color: var(--accent-purple);
}

.btn-refresh.loading svg {
  animation: spin 1s linear infinite;
}

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

.status-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--accent-green);
  box-shadow: 0 0 8px var(--accent-green);
}

/* ─── Dashboard Grid ─── */
.dashboard {
  padding: 24px 32px;
}

.dashboard-section {
  margin-bottom: 28px;
}

.section-title {
  font-size: 13px;
  font-weight: 600;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 1.5px;
  margin-bottom: 14px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  cursor: pointer;
  user-select: none;
  padding: 6px 0;
}

.section-title:hover {
  color: var(--text-secondary);
}

.section-title .collapse-icon {
  width: 16px;
  height: 16px;
  transition: transform 0.25s ease;
  opacity: 0.5;
}

.section-title:hover .collapse-icon {
  opacity: 0.8;
}

.dashboard-section.collapsed .section-title .collapse-icon {
  transform: rotate(-90deg);
}

.section-body {
  overflow: hidden;
  transition: max-height 0.3s ease, opacity 0.2s ease;
  max-height: 2000px;
  opacity: 1;
}

.dashboard-section.collapsed .section-body {
  max-height: 0;
  opacity: 0;
  margin-bottom: 0;
}

/* ─── KPI Cards Row ─── */
.kpi-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 16px;
}

.kpi-card {
  background: var(--bg-card);
  border: 1px solid var(--border-card);
  border-radius: var(--radius);
  padding: 20px;
  transition: all var(--transition);
  position: relative;
  overflow: hidden;
}

.kpi-card::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 2px;
  background: var(--gradient-brand);
  opacity: 0;
  transition: opacity var(--transition);
}

.kpi-card:hover {
  border-color: var(--border-hover);
  background: var(--bg-card-hover);
}

.kpi-card:hover::before { opacity: 1; }

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

.kpi-label {
  font-size: 12px;
  color: var(--text-secondary);
  font-weight: 500;
}

.kpi-icon {
  width: 36px;
  height: 36px;
  border-radius: var(--radius-sm);
  display: flex;
  align-items: center;
  justify-content: center;
}

.kpi-icon svg {
  width: 18px;
  height: 18px;
}

.kpi-icon.purple { background: rgba(168,85,247,0.12); color: var(--accent-purple); }
.kpi-icon.blue { background: rgba(59,130,246,0.12); color: var(--accent-blue); }
.kpi-icon.green { background: rgba(16,185,129,0.12); color: var(--accent-green); }
.kpi-icon.pink { background: rgba(236,72,153,0.12); color: var(--accent-pink); }
.kpi-icon.cyan { background: rgba(6,182,212,0.12); color: var(--accent-cyan); }
.kpi-icon.orange { background: rgba(245,158,11,0.12); color: var(--accent-orange); }

.kpi-value {
  font-size: 28px;
  font-weight: 800;
  letter-spacing: -1px;
  margin-bottom: 4px;
  line-height: 1;
}

.kpi-change {
  font-size: 12px;
  font-weight: 500;
  display: inline-flex;
  align-items: center;
  gap: 3px;
}

.kpi-change.up { color: var(--accent-green); }
.kpi-change.down { color: var(--accent-red); }
.kpi-change.neutral { color: var(--text-muted); }

/* ─── Charts Grid ─── */
.charts-grid {
  display: grid;
  grid-template-columns: 2fr 1fr;
  gap: 16px;
}

.chart-card {
  background: var(--bg-card);
  border: 1px solid var(--border-card);
  border-radius: var(--radius);
  padding: 20px;
}

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

.chart-card-title {
  font-size: 14px;
  font-weight: 600;
}

.chart-tabs {
  display: flex;
  gap: 4px;
}

.chart-tab {
  padding: 4px 10px;
  font-size: 11px;
  border-radius: 6px;
  border: none;
  background: transparent;
  color: var(--text-muted);
  cursor: pointer;
  transition: all var(--transition);
}

.chart-tab.active {
  background: rgba(168,85,247,0.12);
  color: var(--accent-purple);
}

.chart-container {
  height: 240px;
  position: relative;
}

/* ─── Table ─── */
.table-card {
  background: var(--bg-card);
  border: 1px solid var(--border-card);
  border-radius: var(--radius);
  overflow: hidden;
}

.table-card-header {
  padding: 16px 20px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  border-bottom: 1px solid var(--border-card);
}

.table-card-title {
  font-size: 14px;
  font-weight: 600;
}

.data-table {
  width: 100%;
  border-collapse: collapse;
}

.data-table th {
  padding: 10px 20px;
  text-align: left;
  font-size: 11px;
  font-weight: 600;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.5px;
  border-bottom: 1px solid var(--border-card);
}

.data-table td {
  padding: 12px 20px;
  font-size: 13px;
  border-bottom: 1px solid rgba(138,100,200,0.06);
}

.data-table tr:hover td {
  background: rgba(138,100,200,0.04);
}

.status-badge {
  display: inline-block;
  padding: 3px 10px;
  border-radius: 20px;
  font-size: 11px;
  font-weight: 600;
}

.status-badge.active { background: rgba(16,185,129,0.12); color: var(--accent-green); }
.status-badge.on-hold { background: rgba(245,158,11,0.12); color: var(--accent-orange); }
.status-badge.cancelled { background: rgba(239,68,68,0.12); color: var(--accent-red); }
.status-badge.pending-cancel { background: rgba(245,158,11,0.12); color: var(--accent-orange); }

/* ─── Monitoring Grid ─── */
.monitor-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
}

.monitor-card {
  background: var(--bg-card);
  border: 1px solid var(--border-card);
  border-radius: var(--radius);
  padding: 20px;
  display: flex;
  flex-direction: column;
}

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

.monitor-card-title {
  font-size: 14px;
  font-weight: 600;
  display: flex;
  align-items: center;
  gap: 8px;
}

.temp-display {
  text-align: center;
  padding: 20px 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  flex: 1;
}

.temp-value {
  font-size: 56px;
  font-weight: 800;
  letter-spacing: -2px;
  background: var(--gradient-brand);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
}

.temp-unit {
  font-size: 22px;
  font-weight: 400;
}

.humidity-value {
  font-size: 16px;
  color: var(--text-secondary);
  margin-top: 4px;
}

.camera-feed {
  width: 100%;
  border-radius: var(--radius-sm);
  background: var(--bg-primary);
  min-height: 200px;
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
}

.camera-feed img {
  width: 100%;
  height: auto;
  border-radius: var(--radius-sm);
}

.camera-placeholder {
  text-align: center;
  color: var(--text-muted);
  padding: 40px;
}

.camera-placeholder svg {
  width: 48px;
  height: 48px;
  margin-bottom: 12px;
  opacity: 0.3;
}

/* ─── Ads Grid ─── */
.ads-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
}

.ads-card {
  background: var(--bg-card);
  border: 1px solid var(--border-card);
  border-radius: var(--radius);
  padding: 20px;
}

.ads-card-header {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 16px;
}

.ads-logo {
  width: 28px;
  height: 28px;
}

.ads-metrics {
  display: grid;
  grid-template-columns: 1fr 1fr 1fr;
  gap: 12px;
}

.ads-metric {
  text-align: center;
}

.ads-metric-value {
  font-size: 20px;
  font-weight: 700;
}

.ads-metric-label {
  font-size: 11px;
  color: var(--text-muted);
  margin-top: 2px;
}

/* ─── Loading Skeleton ─── */
.skeleton {
  background: linear-gradient(90deg, var(--bg-card) 25%, var(--bg-card-hover) 50%, var(--bg-card) 75%);
  background-size: 200% 100%;
  animation: shimmer 1.5s infinite;
  border-radius: var(--radius-sm);
}

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

/* ─── Not Configured Badge ─── */
.not-configured {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 30px;
  text-align: center;
  color: var(--text-muted);
}

.not-configured svg {
  width: 32px;
  height: 32px;
  margin-bottom: 10px;
  opacity: 0.3;
}

.not-configured p {
  font-size: 12px;
  max-width: 200px;
}

/* ─── AC Toggle Switch ─── */
#ai-toggle:checked + span {
  background: var(--accent-purple) !important;
  border-color: var(--accent-purple) !important;
}

#ai-toggle:checked ~ #ai-toggle-dot {
  transform: translateX(20px);
  background: white !important;
}

.ac-power-on {
  border-color: var(--accent-green) !important;
  color: var(--accent-green) !important;
  box-shadow: 0 0 15px rgba(16,185,129,0.3) !important;
}

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

@media (max-width: 768px) {
  .sidebar { transform: translateX(-100%); }
  .sidebar.open { transform: translateX(0); }
  .main-content { margin-left: 0; }
  .kpi-grid { grid-template-columns: 1fr; }
  .monitor-grid { grid-template-columns: 1fr !important; }
  .ads-grid { grid-template-columns: 1fr; }
  .dashboard { padding: 16px; }
  .header { padding: 0 16px; }
}
