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

:root {
  /* Dark Theme (Default) */
  --bg: #0b0f19;
  --panel: rgba(22, 28, 45, 0.6);
  --glass-border: rgba(255, 255, 255, 0.08);
  --text: #f8fafc;
  --muted: #94a3b8;
  --primary: #3b82f6;

  --card-blue: linear-gradient(135deg, #1e3a8a, #3b82f6);
  --card-purple: linear-gradient(135deg, #4c1d95, #8b5cf6);
  --card-green: linear-gradient(135deg, #064e3b, #10b981);
  --card-orange: linear-gradient(135deg, #78350f, #f59e0b);

  --shadow-panel: 0 8px 32px rgba(0, 0, 0, 0.2);
  --scrollbar-thumb: rgba(255, 255, 255, 0.1);
  --scrollbar-hover: rgba(255, 255, 255, 0.2);
}

[data-theme="light"] {
  /* Premium Light Theme */
  --bg: #f1f5f9;
  --panel: rgba(255, 255, 255, 0.75);
  --glass-border: rgba(0, 0, 0, 0.06);
  --text: #0f172a;
  --muted: #64748b;
  --primary: #2563eb;

  --card-blue: linear-gradient(135deg, #60a5fa, #3b82f6);
  --card-purple: linear-gradient(135deg, #c084fc, #8b5cf6);
  --card-green: linear-gradient(135deg, #34d399, #10b981);
  --card-orange: linear-gradient(135deg, #fbbf24, #f59e0b);

  --shadow-panel: 0 10px 40px rgba(0, 0, 0, 0.04);
  --scrollbar-thumb: rgba(0, 0, 0, 0.15);
  --scrollbar-hover: rgba(0, 0, 0, 0.25);
}

* {
  box-sizing: border-box;
  font-family: 'Inter', sans-serif;
  margin: 0;
  padding: 0;
}

/* Custom Scrollbar */
::-webkit-scrollbar {
  width: 6px;
}

::-webkit-scrollbar-track {
  background: transparent;
}

::-webkit-scrollbar-thumb {
  background: var(--scrollbar-thumb);
  border-radius: 10px;
}

::-webkit-scrollbar-thumb:hover {
  background: var(--scrollbar-hover);
}

body {
  background-color: var(--bg);
  color: var(--text);
  display: flex;
  height: 100vh;
  overflow: hidden;
  transition: background-color 0.3s ease;
}

h1,
h2,
h3,
h4 {
  font-family: 'Plus Jakarta Sans', sans-serif;
}

/* SIDEBAR BASE */
.sidebar {
  width: 260px;
  background: var(--panel);
  border-right: 1px solid var(--glass-border);
  padding: 24px;
  display: flex;
  flex-direction: column;
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  z-index: 10;
}

.brand {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 40px;
}

.logo-icon {
  width: 40px;
  height: 40px;
  background: linear-gradient(135deg, #ec4899, #3b82f6);
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  color: white;
  font-size: 20px;
  box-shadow: 0 0 15px rgba(236, 72, 153, 0.5);
}

.brand h2 {
  font-size: 16px;
}

.brand p {
  font-size: 11px;
  color: var(--muted);
}

.sidebar nav {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.sidebar nav a {
  color: var(--muted);
  text-decoration: none;
  padding: 12px 16px;
  border-radius: 12px;
  font-size: 14px;
  font-weight: 500;
  display: flex;
  align-items: center;
  gap: 12px;
  transition: all 0.3s;
}

.sidebar nav a i {
  width: 20px;
  text-align: center;
}

.sidebar nav a:hover {
  background: rgba(0, 0, 0, 0.05);
  color: var(--text);
}

[data-theme="dark"] .sidebar nav a:hover {
  background: rgba(255, 255, 255, 0.05);
}

.sidebar nav a.active {
  background: var(--primary);
  color: white;
  box-shadow: 0 4px 15px rgba(59, 130, 246, 0.4);
}

.sidebar-bottom {
  margin-top: auto;
  display: flex;
  flex-direction: column;
  gap: 15px;
}

/* SIDEBAR THEME BUTTON */
.sidebar-btn {
  background: var(--bg);
  border: 1px solid var(--glass-border);
  color: var(--text);
  padding: 12px 16px;
  border-radius: 12px;
  display: flex;
  align-items: center;
  gap: 12px;
  cursor: pointer;
  transition: all 0.3s;
  font-size: 14px;
  font-weight: 500;
  width: 100%;
}

.sidebar-btn:hover {
  background: rgba(0, 0, 0, 0.05);
}

[data-theme="dark"] .sidebar-btn:hover {
  background: rgba(255, 255, 255, 0.08);
}

.promo-card {
  background: linear-gradient(135deg, #1e1b4b, #4c1d95);
  padding: 20px;
  border-radius: 16px;
  text-align: center;
  color: white;
}

.promo-card i {
  font-size: 24px;
  margin-bottom: 10px;
  color: #f472b6;
}

.promo-card h4 {
  font-size: 14px;
}

.user-profile {
  display: flex;
  align-items: center;
  gap: 12px;
  padding-top: 15px;
  border-top: 1px solid var(--glass-border);
  cursor: pointer;
}

.avatar {
  width: 40px;
  height: 40px;
  background: var(--primary);
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: bold;
  color: white;
}

.user-profile p:first-child {
  font-size: 14px;
  font-weight: 600;
}

.user-profile p:last-child {
  font-size: 11px;
  color: var(--muted);
}

/* MAIN CONTENT */
.main {
  flex: 1;
  display: flex;
  flex-direction: column;
  height: 100vh;
  overflow: hidden;
}

.content-scroll {
  flex: 1;
  overflow-y: auto;
  padding: 30px 30px 30px 30px;
}

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

.greeting {
  font-size: 28px;
  margin-bottom: 5px;
}

.highlight {
  color: var(--primary);
}

.subtitle {
  color: var(--muted);
  font-size: 14px;
}

.header-graphic {
  width: 250px;
  opacity: 0.8;
}

/* KPI CARDS */
.cards-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 20px;
  margin-bottom: 25px;
}

.kpi-card {
  padding: 20px;
  border-radius: 20px;
  color: white;
  display: flex;
  align-items: center;
  gap: 15px;
  position: relative;
  overflow: hidden;
  box-shadow: var(--shadow-panel);
}

.kpi-card::after {
  content: '';
  position: absolute;
  right: -20px;
  bottom: -20px;
  width: 100px;
  height: 100px;
  background: rgba(255, 255, 255, 0.1);
  border-radius: 50%;
}

.c-blue {
  background: var(--card-blue);
}

.c-purple {
  background: var(--card-purple);
}

.c-green {
  background: var(--card-green);
}

.c-orange {
  background: var(--card-orange);
}

.kpi-icon {
  font-size: 24px;
  background: rgba(255, 255, 255, 0.2);
  padding: 15px;
  border-radius: 50%;
  width: 56px;
  height: 56px;
  display: flex;
  align-items: center;
  justify-content: center;
}

.kpi-content h3 {
  font-size: 13px;
  font-weight: 500;
  opacity: 0.9;
  margin-bottom: 5px;
}

.kpi-content .value {
  font-size: 26px;
  font-weight: 800;
  font-family: 'Plus Jakarta Sans';
  margin-bottom: 5px;
}

.kpi-content .trend {
  font-size: 12px;
  font-weight: 600;
  opacity: 0.9;
}

.text-green {
  color: #10b981;
}

/* MIDDLE GRID */
.middle-grid {
  display: grid;
  grid-template-columns: 2fr 1fr;
  gap: 20px;
  margin-bottom: 25px;
}

.glass-panel {
  background: var(--panel);
  border: 1px solid var(--glass-border);
  border-radius: 24px;
  padding: 24px;
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  box-shadow: var(--shadow-panel);
}

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

.panel-header h2 {
  font-size: 16px;
  display: flex;
  align-items: center;
  gap: 10px;
}

.time-select {
  background: var(--bg);
  border: 1px solid var(--glass-border);
  color: var(--text);
  padding: 6px 12px;
  border-radius: 8px;
  outline: none;
  cursor: pointer;
}

.chart-container {
  height: 250px;
  width: 100%;
  position: relative;
}

/* AI PANEL */
.ai-panel {
  display: flex;
  flex-direction: column;
}

.status-online {
  font-size: 11px;
  color: #10b981;
  background: rgba(16, 185, 129, 0.1);
  padding: 4px 10px;
  border-radius: 10px;
  margin-left: auto;
}

.chat-window {
  flex: 1;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 15px;
  padding-right: 5px;
  margin-bottom: 15px;
}

.msg {
  padding: 12px 16px;
  border-radius: 16px;
  font-size: 13px;
  line-height: 1.5;
  max-width: 90%;
}

.msg.user {
  background: var(--primary);
  color: white;
  align-self: flex-end;
  border-bottom-right-radius: 4px;
}

.msg.bot {
  background: rgba(0, 0, 0, 0.03);
  border: 1px solid var(--glass-border);
  align-self: flex-start;
  border-bottom-left-radius: 4px;
}

[data-theme="dark"] .msg.bot {
  background: rgba(255, 255, 255, 0.05);
}

.chat-input-area {
  display: flex;
  gap: 10px;
  background: var(--bg);
  border: 1px solid var(--glass-border);
  border-radius: 12px;
  padding: 5px;
}

.chat-input-area input {
  flex: 1;
  background: transparent;
  border: none;
  color: var(--text);
  padding: 10px;
  outline: none;
}

.chat-input-area button {
  background: var(--primary);
  color: white;
  border: none;
  width: 40px;
  border-radius: 10px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
}

/* BOTTOM GRID */
.bottom-grid {
  display: grid;
  grid-template-columns: 1fr 1.5fr 1fr;
  gap: 20px;
}

.dist-panel h2,
.actions-panel h2,
.voice-panel h2 {
  font-size: 16px;
  margin-bottom: 15px;
}

.dist-content {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 15px;
}

.dist-legend p {
  font-size: 13px;
  color: var(--muted);
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 5px;
}

.dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  display: inline-block;
}

.dot.green {
  background: #10b981;
}

.dot.yellow {
  background: #f59e0b;
}

.dot.red {
  background: #ef4444;
}

.actions-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}

.action-btn {
  background: rgba(0, 0, 0, 0.02);
  border: 1px solid var(--glass-border);
  color: var(--text);
  padding: 15px;
  border-radius: 16px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 10px;
  font-size: 12px;
  cursor: pointer;
  transition: 0.3s;
}

[data-theme="dark"] .action-btn {
  background: rgba(255, 255, 255, 0.03);
}

.action-btn:hover {
  background: rgba(0, 0, 0, 0.05);
  transform: translateY(-2px);
}

[data-theme="dark"] .action-btn:hover {
  background: rgba(255, 255, 255, 0.08);
}

.action-btn i {
  font-size: 20px;
  padding: 10px;
  border-radius: 12px;
}

.c-blue-bg {
  background: rgba(59, 130, 246, 0.2);
  color: #3b82f6;
}

.c-purple-bg {
  background: rgba(139, 92, 246, 0.2);
  color: #8b5cf6;
}

.c-green-bg {
  background: rgba(16, 185, 129, 0.2);
  color: #10b981;
}

.c-orange-bg {
  background: rgba(245, 158, 11, 0.2);
  color: #f59e0b;
}

.voice-panel {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
}

.waveform {
  height: 30px;
  width: 100px;
  background: repeating-linear-gradient(90deg, #8b5cf6 0, #8b5cf6 4px, transparent 4px, transparent 8px);
  opacity: 0.5;
  margin-bottom: 15px;
  mask-image: linear-gradient(to right, transparent, black, transparent);
}

.mic-large {
  width: 60px;
  height: 60px;
  border-radius: 50%;
  background: var(--primary);
  color: white;
  border: none;
  font-size: 24px;
  cursor: pointer;
  box-shadow: 0 0 20px rgba(59, 130, 246, 0.5);
  transition: 0.3s;
}

.mic-large:hover {
  transform: scale(1.1);
}

.mic-large.listening {
  background: #ef4444;
  animation: pulse 1.5s infinite;
}

/* UTILS & FORMS */
.page {
  display: none;
}

.page.active {
  display: block;
  animation: fadeIn 0.3s;
}

.btn-primary {
  background: var(--primary);
  color: white;
  border: none;
  border-radius: 8px;
  cursor: pointer;
  padding: 12px;
  font-weight: 600;
}

.form-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 20px;
}

.form-grid label {
  display: flex;
  flex-direction: column;
  font-size: 13px;
  color: var(--muted);
  gap: 8px;
}

.form-grid input,
.form-grid select {
  padding: 12px;
  border-radius: 8px;
  background: var(--bg);
  border: 1px solid var(--glass-border);
  color: var(--text);
  outline: none;
}

@keyframes fadeIn {
  from {
    opacity: 0;
  }

  to {
    opacity: 1;
  }
}

@keyframes pulse {
  0% {
    box-shadow: 0 0 0 0 rgba(239, 68, 68, 0.7);
  }

  70% {
    box-shadow: 0 0 0 12px rgba(239, 68, 68, 0);
  }

  100% {
    box-shadow: 0 0 0 0 rgba(239, 68, 68, 0);
  }
}

@media (max-width: 1200px) {
  .cards-grid {
    grid-template-columns: 1fr 1fr;
  }

  .middle-grid {
    grid-template-columns: 1fr;
  }

  .bottom-grid {
    grid-template-columns: 1fr;
  }
}

/* =========================================
   LIGHT THEME SIDEBAR OVERRIDE (BLUE)
   ========================================= */
[data-theme="light"] .sidebar {
  background: linear-gradient(180deg, #1e40af, #1e3a8a);
  border-right: 1px solid rgba(255, 255, 255, 0.1);
}

[data-theme="light"] .sidebar .brand h2,
[data-theme="light"] .sidebar .brand p,
[data-theme="light"] .sidebar nav a,
[data-theme="light"] .sidebar .user-profile p {
  color: #f8fafc;
}

[data-theme="light"] .sidebar nav a:hover {
  background: rgba(255, 255, 255, 0.1);
}

[data-theme="light"] .sidebar nav a.active {
  background: rgba(255, 255, 255, 0.2);
  box-shadow: none;
  color: #ffffff;
}

[data-theme="light"] .sidebar-btn {
  background: rgba(0, 0, 0, 0.2);
  color: #ffffff;
  border-color: rgba(255, 255, 255, 0.2);
}

[data-theme="light"] .sidebar-btn:hover {
  background: rgba(0, 0, 0, 0.3);
}

[data-theme="light"] .promo-card {
  background: linear-gradient(135deg, #1e3a8a, #312e81);
}

/* =========================================
   CLEAN CENTERED LOGIN UI (NO OVERLAPS)
   ========================================= */
#auth-overlay {
  position: fixed;
  top: 0;
  left: 0;
  width: 100vw;
  height: 100vh;
  background: #0b0f19;
  background-image: radial-gradient(circle at 50% 50%, rgba(59, 130, 246, 0.15) 0%, transparent 60%);
  z-index: 9999;
  display: flex;
  align-items: center;
  justify-content: center;
}

.auth-box {
  background: rgba(22, 28, 45, 0.85);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: 24px;
  padding: 40px;
  width: 100%;
  max-width: 420px;
  box-shadow: 0 20px 40px rgba(0, 0, 0, 0.4);
  text-align: center;
}

.login-header {
  margin-bottom: 30px;
}

.logo-circle {
  width: 70px;
  height: 70px;
  background: rgba(239, 68, 68, 0.1);
  border: 1px solid rgba(239, 68, 68, 0.3);
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  margin: 0 auto 20px;
  font-size: 32px;
  color: #ef4444;
  box-shadow: 0 0 20px rgba(239, 68, 68, 0.2);
}

.auth-box h2 {
  font-size: 28px;
  color: #ffffff;
  margin-bottom: 8px;
  font-family: 'Plus Jakarta Sans', sans-serif;
}

.login-subtitle {
  color: #94a3b8;
  font-size: 14px;
}

.auth-error {
  color: #f87171;
  font-size: 13px;
  margin-bottom: 15px;
  min-height: 18px;
}

/* Inputs */
.input-group {
  position: relative;
  margin-bottom: 18px;
  text-align: left;
}

.input-group i {
  position: absolute;
  left: 16px;
  top: 50%;
  transform: translateY(-50%);
  color: #64748b;
  font-size: 16px;
}

.input-group input {
  width: 100%;
  padding: 14px 16px 14px 45px;
  background: rgba(0, 0, 0, 0.3);
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: 12px;
  color: #ffffff;
  font-size: 14px;
  outline: none;
  transition: all 0.3s;
}

.input-group input:focus {
  border-color: #3b82f6;
  background: rgba(0, 0, 0, 0.5);
  box-shadow: 0 0 10px rgba(59, 130, 246, 0.2);
}

/* Button */
.btn-login {
  width: 100%;
  padding: 14px;
  background: linear-gradient(90deg, #00c6ff 0%, #0072ff 100%);
  border: none;
  border-radius: 12px;
  color: white;
  font-size: 16px;
  font-weight: 600;
  cursor: pointer;
  display: flex;
  justify-content: center;
  align-items: center;
  gap: 10px;
  margin-top: 10px;
  box-shadow: 0 4px 15px rgba(0, 114, 255, 0.4);
  transition: all 0.3s;
}

.btn-login:hover {
  transform: translateY(-2px);
  box-shadow: 0 6px 20px rgba(0, 114, 255, 0.6);
}

/* Divider & Toggle */
.divider {
  display: flex;
  align-items: center;
  text-align: center;
  color: #64748b;
  margin: 25px 0;
  font-size: 13px;
}

.divider::before,
.divider::after {
  content: '';
  flex: 1;
  border-bottom: 1px solid rgba(255, 255, 255, 0.1);
}

.divider span {
  padding: 0 15px;
}

.auth-toggle {
  color: #94a3b8;
  font-size: 14px;
}

.auth-toggle a {
  color: #3b82f6;
  text-decoration: none;
  font-weight: 600;
  margin-left: 5px;
  transition: 0.3s;
}

.auth-toggle a:hover {
  text-shadow: 0 0 10px rgba(59, 130, 246, 0.5);
}