/* ═══════════════════════════════════════════════════════════
   WADO – Premium SaaS Design System v2.0
   Dark/Light Mode · Responsive · Animated
═══════════════════════════════════════════════════════════ */

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

/* ───────────────────────────────────────
   DESIGN TOKENS – DARK MODE (default)
─────────────────────────────────────── */
:root {
  --bg-main:          #0b1319;
  --bg-surface:       #15202b;
  --bg-surface2:      #1a2833;
  --bg-glass:         rgba(21, 32, 43, 0.65); /* Sinkronisasi Dark bg-surface dgn opacity */
  --bg-hover:         #1d2b33;

  --primary:          #0ce3e3;
  --primary-glow:     rgba(12,227,227,0.25);
  --secondary:        #0ce3e3;
  --secondary-glow:   rgba(12,227,227,0.15);
  --success:          #00d473;
  --warning:          #ffb340;
  --danger:           #ff4f64;

  --text-main:        #ffffff;
  --text-muted:       #6b8a9c;
  --text-secondary:   #a3c1d4;
  --border:           rgba(255,255,255,0.06);
  --border-hover:     rgba(255,255,255,0.12);

  --gradient-brand:   linear-gradient(135deg, #0ce3e3, #08c2c2);
  --gradient-card:    linear-gradient(145deg, #15202b, #182531);
  --gradient-bg:      none;

  --shadow-sm:        0 2px 4px rgba(0,0,0,0.15);
  --shadow-md:        0 8px 16px rgba(0,0,0,0.2);
  --shadow-lg:        0 12px 32px rgba(0,0,0,0.4);
  --shadow-glow:      0 0 20px var(--primary-glow);
  --shadow-glow-sec:  0 0 20px var(--secondary-glow);

  --sidebar-w:        260px;
  --topbar-h:         64px;
  --radius-sm:        12px;
  --radius-md:        16px;
  --radius-lg:        20px;
  --radius-xl:        24px;

  --transition-fast:  0.15s ease;
  --transition-base:  0.25s ease;
  --transition-slow:  0.4s cubic-bezier(0.4,0,0.2,1);
}

/* ───────────────────────────────────────
   LIGHT MODE OVERRIDES
─────────────────────────────────────── */
[data-theme="light"] {
  --bg-main:          #f0f4fb;
  --bg-surface:       #ffffff;
  --bg-surface2:      #f8faff;
  --bg-glass:         rgba(255,255,255,0.9);
  --bg-hover:         rgba(0,0,0,0.04);

  --text-main:        #0f172a;
  --text-muted:       #64748b;
  --text-secondary:   #475569;
  --border:           rgba(0,0,0,0.08);
  --border-hover:     rgba(0,0,0,0.15);

  --gradient-bg:      radial-gradient(ellipse 70% 60% at 60% -10%, rgba(0,200,248,0.05) 0%, transparent 60%),
                      radial-gradient(ellipse 50% 50% at -10% 80%, rgba(168,85,247,0.05) 0%, transparent 60%);
  --gradient-card:    linear-gradient(145deg,#ffffff,#f8faff);

  --shadow-sm:        0 1px 3px rgba(0,0,0,0.07), 0 1px 2px rgba(0,0,0,0.04);
  --shadow-md:        0 4px 16px rgba(0,0,0,0.08), 0 2px 4px rgba(0,0,0,0.05);
  --shadow-lg:        0 12px 40px rgba(0,0,0,0.1), 0 4px 8px rgba(0,0,0,0.05);
  --shadow-glow:      0 0 20px rgba(0,200,248,0.15), 0 4px 16px rgba(0,200,248,0.1);
}

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

html { scroll-behavior: smooth; }

body {
  font-family: 'Inter', system-ui, sans-serif;
  background: var(--bg-main);
  color: var(--text-main);
  line-height: 1.6;
  overflow-x: hidden;
  transition: background var(--transition-slow), color var(--transition-slow);
}

body::before {
  content: '';
  position: fixed;
  inset: 0;
  background: var(--gradient-bg);
  pointer-events: none;
  z-index: 0;
  transition: background var(--transition-slow);
}

a { color: var(--primary); text-decoration: none; transition: var(--transition-base); }
a:hover { opacity: 0.85; }
img { max-width: 100%; }
select option { background: var(--bg-surface); color: var(--text-main); }

/* ───────────────────────────────────────
   SCROLLBAR
─────────────────────────────────────── */
::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--border-hover); border-radius: 4px; }
::-webkit-scrollbar-thumb:hover { background: var(--primary); }

/* ───────────────────────────────────────
   APP LAYOUT
─────────────────────────────────────── */
.app-container {
  display: flex;
  min-height: 100vh;
  position: relative;
  z-index: 1;
}

/* ───────────────────────────────────────
   SIDEBAR
─────────────────────────────────────── */
/* ───────────────────────────────────────
   SIDEBAR
─────────────────────────────────────── */
.sidebar {
  width: var(--sidebar-w);
  background: var(--bg-surface);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  position: fixed;
  top: 0;
  left: 0;
  height: 100vh;
  z-index: 200;
  overflow: hidden;
  transition: transform 0.4s cubic-bezier(0.34, 1.56, 0.64, 1), /* bounce effect */
              width var(--transition-slow), 
              background var(--transition-slow);
}

/* Glassmorphism support on light/dark mode */
@supports (backdrop-filter: blur(16px)) {
  .sidebar {
    background: var(--bg-glass);
    backdrop-filter: blur(16px);
    -webkit-backdrop-filter: blur(16px);
  }
}

/* Sidebar shimmer line at top */
.sidebar::before {
  content: '';
  position: absolute;
  top: 0; left: 0; right: 0; height: 3px;
  background: var(--gradient-brand);
  opacity: 0.9;
  z-index: 10;
}

/* Brand */
.sidebar-brand {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 24px;
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
  transition: padding var(--transition-base);
}

.brand-icon {
  width: 42px;
  height: 42px;
  border-radius: 12px;
  background: var(--gradient-brand);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.3rem;
  color: white;
  box-shadow: var(--shadow-glow);
  flex-shrink: 0;
  transform-origin: center bottom;
  animation: cuteFloat 3s ease-in-out infinite;
  transition: all 0.4s cubic-bezier(0.34, 1.56, 0.64, 1);
  cursor: pointer;
}

@keyframes cuteFloat {
  0%, 100% { transform: translateY(0) rotate(0deg); box-shadow: 0 4px 12px var(--primary-glow); }
  50% { transform: translateY(-5px) rotate(-4deg); box-shadow: 0 12px 24px rgba(0,212,255,0.35); }
}

.brand-icon:hover {
  animation: jellyPop 0.6s cubic-bezier(0.34, 1.56, 0.64, 1) forwards;
}

@keyframes jellyPop {
  0%   { transform: scale(1, 1) translateY(0); }
  30%  { transform: scale(1.25, 0.75) translateY(4px); }
  50%  { transform: scale(0.85, 1.15) translateY(-8px); }
  75%  { transform: scale(1.05, 0.95) translateY(0); }
  100% { transform: scale(1, 1) translateY(0); box-shadow: 0 8px 24px rgba(0,212,255,0.4); }
}

.brand-text {
  font-family: 'Plus Jakarta Sans', sans-serif;
  font-size: 1.4rem;
  font-weight: 800;
  background: var(--gradient-brand);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
  letter-spacing: -0.5px;
}

.brand-subtitle {
  font-size: 0.65rem;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 1.5px;
  font-weight: 600;
  line-height: 1;
}

/* Nav scroll area */
.sidebar-nav {
  flex: 1;
  overflow-y: auto;
  overflow-x: hidden;
  padding: 20px 16px;
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.sidebar-nav::-webkit-scrollbar { width: 4px; }

.nav-section-title {
  font-size: 0.68rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 1.5px;
  color: var(--text-muted);
  padding: 12px 16px 6px;
  margin-top: 10px;
}

.nav-menu { list-style: none; display: contents; }

.nav-item a {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 12px 18px;
  border-radius: 14px;
  color: var(--text-secondary);
  font-size: 0.92rem;
  font-weight: 600;
  position: relative;
  transition: all 0.3s cubic-bezier(0.34, 1.56, 0.64, 1);
  white-space: nowrap;
  overflow: hidden;
  margin-bottom: 2px;
}

.nav-item a::after { content: none; }

.nav-item a:hover {
  color: var(--text-main);
  background: var(--bg-hover);
  transform: translateX(6px);
  box-shadow: 0 4px 12px rgba(0,0,0,0.05);
}

.nav-item a.active {
  color: var(--primary);
  background: var(--primary-glow);
  box-shadow: inset 0 0 0 1px rgba(0,212,255,0.2), 0 4px 15px rgba(0,212,255,0.1);
  font-weight: 700;
}

.nav-item a.active .nav-icon { 
  color: var(--primary); 
  transform: scale(1.15); 
  filter: drop-shadow(0 0 6px var(--primary-glow));
}

.nav-icon {
  width: 20px;
  text-align: center;
  flex-shrink: 0;
  font-size: 1.05rem;
  transition: transform 0.3s cubic-bezier(0.34, 1.56, 0.64, 1), 
              color var(--transition-base),
              filter 0.3s;
}

.nav-item a:hover .nav-icon { 
  transform: scale(1.2) rotate(-5deg); 
  color: var(--text-main);
}

.nav-badge {
  margin-left: auto;
  background: var(--primary);
  color: white;
  font-size: 0.65rem;
  font-weight: 700;
  padding: 2px 7px;
  border-radius: 20px;
  line-height: 1.4;
}

.nav-divider {
  height: 1px;
  background: var(--border);
  margin: 10px 12px;
}

/* Sidebar footer */
.sidebar-footer {
  padding: 16px;
  border-top: 1px solid var(--border);
  flex-shrink: 0;
}

.sidebar-user {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px;
  border-radius: 16px;
  cursor: pointer;
  background: rgba(255,255,255,0.02);
  border: 1px solid transparent;
  transition: all 0.3s cubic-bezier(0.34, 1.56, 0.64, 1);
}

.sidebar-user:hover { 
  background: var(--bg-hover);
  border-color: var(--border);
  transform: translateY(-2px);
  box-shadow: 0 4px 12px rgba(0,0,0,0.1);
}

.sidebar-user:active { transform: translateY(0); }

.user-avatar {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  background: var(--gradient-brand);
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 800;
  font-size: 1rem;
  color: white;
  flex-shrink: 0;
  /* Glowy Ring Effect */
  box-shadow: 0 0 0 3px var(--bg-surface), 0 0 0 5px var(--primary-glow);
}

.sidebar-user:hover .user-avatar {
  animation: pulseAvatar 1.5s infinite;
}

@keyframes pulseAvatar {
  0% { box-shadow: 0 0 0 3px var(--bg-surface), 0 0 0 5px var(--primary-glow); }
  50% { box-shadow: 0 0 0 3px var(--bg-surface), 0 0 0 8px rgba(0,212,255,0.25); }
  100% { box-shadow: 0 0 0 3px var(--bg-surface), 0 0 0 5px var(--primary-glow); }
}

.user-info { flex: 1; min-width: 0; }
.user-name { font-size: 0.9rem; font-weight: 700; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.user-role { font-size: 0.72rem; font-weight: 500; color: var(--text-muted); text-transform: capitalize; }

/* ───────────────────────────────────────
   TOPBAR
─────────────────────────────────────── */
.topbar {
  position: fixed;
  top: 0;
  left: var(--sidebar-w);
  right: 0;
  height: var(--topbar-h);
  background: var(--bg-main);
  border-bottom: none;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 32px;
  z-index: 100;
  transition: left var(--transition-slow), background var(--transition-slow);
}

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

.hamburger {
  display: none;
  flex-direction: column;
  gap: 5px;
  cursor: pointer;
  padding: 4px;
  background: none;
  border: none;
}

.hamburger span {
  display: block;
  width: 22px;
  height: 2px;
  background: var(--text-main);
  border-radius: 2px;
  transition: all var(--transition-base);
}

.hamburger.open span:nth-child(1) { transform: translateY(7px) rotate(45deg); }
.hamburger.open span:nth-child(2) { opacity: 0; transform: scaleX(0); }
.hamburger.open span:nth-child(3) { transform: translateY(-7px) rotate(-45deg); }

.page-breadcrumb h2 {
  font-size: 1.15rem;
  font-weight: 700;
  color: var(--text-main);
}

.page-breadcrumb p {
  font-size: 0.8rem;
  color: var(--text-muted);
  line-height: 1.2;
}

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

/* Theme toggle */
.theme-toggle {
  width: 38px;
  height: 38px;
  border-radius: var(--radius-sm);
  background: var(--bg-hover);
  border: 1px solid var(--border);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1rem;
  transition: all var(--transition-base);
  color: var(--text-main);
  position: relative;
  overflow: hidden;
}

.theme-toggle:hover {
  background: rgba(0,200,248,0.1);
  border-color: rgba(0,200,248,0.3);
  transform: rotate(15deg) scale(1.1);
}

.theme-toggle .icon-sun,
.theme-toggle .icon-moon {
  position: absolute;
  transition: all var(--transition-base);
}

[data-theme="light"] .theme-toggle .icon-moon { opacity: 0; transform: rotate(90deg) scale(0); }
[data-theme="light"] .theme-toggle .icon-sun  { opacity: 1; transform: rotate(0) scale(1); }
[data-theme="dark"]  .theme-toggle .icon-sun  { opacity: 0; transform: rotate(-90deg) scale(0); }
[data-theme="dark"]  .theme-toggle .icon-moon { opacity: 1; transform: rotate(0) scale(1); }

/* Topbar quick profile */
.topbar-profile {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 6px 12px;
  border-radius: var(--radius-sm);
  background: var(--bg-surface2);
  border: 1px solid var(--border);
  cursor: pointer;
  transition: all var(--transition-base);
}

.topbar-profile:hover {
  border-color: var(--border-hover);
  background: var(--bg-hover);
}

.topbar-avatar {
  width: 30px;
  height: 30px;
  border-radius: 8px;
  background: var(--gradient-brand);
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  font-size: 0.8rem;
  color: white;
}

/* ───────────────────────────────────────
   MAIN CONTENT
─────────────────────────────────────── */
.main-content {
  flex: 1;
  margin-left: var(--sidebar-w);
  padding-top: var(--topbar-h);
  min-height: 100vh;
  transition: margin-left var(--transition-slow);
}

.page-content {
  padding: 28px 32px;
}

/* ───────────────────────────────────────
   CARDS
─────────────────────────────────────── */
.card, .bento-card {
  background: var(--bg-surface);
  border: none;
  border-radius: var(--radius-lg);
  padding: 24px;
  box-shadow: var(--shadow-sm);
  transition: transform var(--transition-base), box-shadow var(--transition-base), background var(--transition-slow);
  position: relative;
  overflow: hidden;
}

.card::before, .bento-card::before {
  content: none;
}

.bento-card:hover {
  transform: translateY(-2px);
  box-shadow: var(--shadow-md);
}

/* Stat card with glow accent */
.stat-card {
  position: relative;
  overflow: visible;
}

.stat-card::after {
  content: '';
  position: absolute;
  bottom: -1px; left: 20px; right: 20px;
  height: 2px;
  border-radius: 2px;
  background: var(--gradient-brand);
  transform: scaleX(0);
  transition: transform var(--transition-base);
  transform-origin: center;
}

.stat-card:hover::after { transform: scaleX(1); }

/* ───────────────────────────────────────
   BENTO GRID
─────────────────────────────────────── */
.bento-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
  gap: 20px;
}

.stats-grid {
  grid-template-columns: repeat(4, 1fr);
}

.charts-grid {
  grid-template-columns: 2.2fr 1fr;
}

/* ───────────────────────────────────────
   TYPOGRAPHY / METRICS
─────────────────────────────────────── */
h1, h2, h3, h4, h5, h6 { font-weight: 600; color: var(--text-main); line-height: 1.3; }

.metric-value {
  font-size: 2.6rem;
  font-weight: 800;
  font-family: 'Plus Jakarta Sans', sans-serif;
  color: var(--text-main);
  margin: 6px 0 4px;
  line-height: 1;
}

.metric-label {
  font-size: 0.78rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 1px;
  color: var(--text-muted);
}

.metric-icon {
  width: 42px;
  height: 42px;
  border-radius: var(--radius-sm);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.1rem;
  flex-shrink: 0;
}

/* ───────────────────────────────────────
   BADGES
─────────────────────────────────────── */
.badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 3px 10px;
  border-radius: 20px;
  font-size: 0.72rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.badge-success { background: rgba(16,217,140,0.1); color: var(--success); border: 1px solid rgba(16,217,140,0.2); }
.badge-danger  { background: rgba(244,63,94,0.1);  color: var(--danger);  border: 1px solid rgba(244,63,94,0.2);  }
.badge-warning { background: rgba(245,158,11,0.1); color: var(--warning); border: 1px solid rgba(245,158,11,0.2); }
.badge-primary { background: rgba(0,200,248,0.1);  color: var(--primary); border: 1px solid rgba(0,200,248,0.2);  }
.badge-muted   { background: var(--bg-hover); color: var(--text-muted); border: 1px solid var(--border); }

/* Pulsing dot badge */
.dot-badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
}

.dot-badge::before {
  content: '';
  width: 7px;
  height: 7px;
  border-radius: 50%;
  flex-shrink: 0;
}

.dot-badge.connected::before { background: var(--success); box-shadow: 0 0 0 2px rgba(16,217,140,0.2); animation: dotPulse 2s infinite; }
.dot-badge.disconnected::before { background: var(--danger); }
.dot-badge.connecting::before { background: var(--warning); animation: dotPulse 1s infinite; }

@keyframes dotPulse {
  0%, 100% { box-shadow: 0 0 0 2px rgba(16,217,140,0.2); }
  50% { box-shadow: 0 0 0 5px rgba(16,217,140,0); }
}

/* ───────────────────────────────────────
   BUTTONS
─────────────────────────────────────── */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 10px 24px;
  border-radius: 99px;
  font-weight: 700;
  font-size: 0.82rem;
  text-transform: uppercase;
  letter-spacing: 1px;
  font-family: inherit;
  cursor: pointer;
  border: none;
  transition: all var(--transition-base);
  white-space: nowrap;
  position: relative;
  overflow: hidden;
}

.btn::after {
  content: none;
}

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

/* Ripple effect */
.btn::before {
  content: '';
  position: absolute;
  width: 0;
  height: 0;
  border-radius: 50%;
  background: rgba(255,255,255,0.3);
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  transition: width 0.5s ease, height 0.5s ease, opacity 0.5s ease;
  opacity: 0;
}

.btn:active::before { width: 200px; height: 200px; opacity: 0; }

.btn-primary {
  background: var(--primary);
  color: #0b1319;
  box-shadow: 0 4px 14px var(--primary-glow);
}

.btn-primary:hover {
  box-shadow: 0 6px 20px rgba(12,227,227,0.4);
  transform: translateY(-1px);
  background: #0ceded;
}

.btn-secondary {
  background: linear-gradient(135deg,var(--secondary),#c084fc);
  color: white;
  box-shadow: 0 4px 14px rgba(168,85,247,0.25);
}

.btn-secondary:hover {
  box-shadow: var(--shadow-glow-sec);
  transform: translateY(-1px);
}

.btn-success {
  background: var(--success);
  color: #0a0d14;
  box-shadow: 0 4px 14px rgba(16,217,140,0.25);
}

.btn-danger {
  background: rgba(244,63,94,0.1);
  color: var(--danger);
  border: 1px solid rgba(244,63,94,0.25);
}

.btn-danger:hover {
  background: var(--danger);
  color: white;
  border-color: transparent;
}

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

.btn-outline:hover {
  background: var(--bg-hover);
  border-color: var(--border-hover);
}

.btn-ghost {
  background: transparent;
  color: var(--text-secondary);
  border: none;
}

.btn-ghost:hover {
  color: var(--text-main);
  background: var(--bg-hover);
}

.btn-sm  { padding: 6px 12px; font-size: 0.8rem; }
.btn-lg  { padding: 13px 28px; font-size: 1rem; }
.btn-icon { padding: 9px; aspect-ratio: 1; }
.btn-block { width: 100%; }

/* ───────────────────────────────────────
   FORMS
─────────────────────────────────────── */
.form-group { margin-bottom: 18px; }

.form-label {
  display: block;
  font-size: 0.82rem;
  font-weight: 600;
  color: var(--text-secondary);
  margin-bottom: 7px;
  letter-spacing: 0.2px;
}

.form-control {
  width: 100%;
  padding: 10px 14px;
  background: var(--bg-surface2);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text-main);
  font-family: inherit;
  font-size: 0.9rem;
  transition: border-color var(--transition-base), box-shadow var(--transition-base), background var(--transition-slow);
  -webkit-appearance: none;
  appearance: none;
}

.form-control:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(0,200,248,0.12);
  background: var(--bg-surface);
}

.form-control::placeholder { color: var(--text-muted); }
textarea.form-control { min-height: 110px; resize: vertical; }
select.form-control { cursor: pointer; }

.input-group {
  display: flex;
  gap: 0;
  border-radius: var(--radius-sm);
  overflow: hidden;
  border: 1px solid var(--border);
  background: var(--bg-surface2);
  transition: border-color var(--transition-base), box-shadow var(--transition-base);
}

.input-group:focus-within {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(0,200,248,0.12);
}

.input-group .form-control {
  border: none;
  border-radius: 0;
  box-shadow: none !important;
  background: transparent;
}

.input-addon {
  display: flex;
  align-items: center;
  padding: 0 14px;
  color: var(--text-muted);
  font-size: 0.85rem;
  white-space: nowrap;
  border-right: 1px solid var(--border);
}

/* ───────────────────────────────────────
   TABLE
─────────────────────────────────────── */
.table-responsive { overflow-x: auto; border-radius: var(--radius-sm); }

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

thead tr {
  border-bottom: 1px solid var(--border);
}

th {
  padding: 16px;
  text-align: left;
  font-size: 0.73rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 1px;
  color: var(--text-muted);
  white-space: nowrap;
  border-bottom: none;
}

td {
  padding: 16px;
  border-bottom: none;
  font-size: 0.88rem;
  color: var(--text-main);
  vertical-align: middle;
  transition: background var(--transition-fast);
}

tbody tr {
  transition: background var(--transition-fast);
  border-bottom: 1px solid var(--border);
}

tbody tr:hover { background: rgba(12, 227, 227, 0.03); }
tbody tr:last-child { border-bottom: none; }

/* ───────────────────────────────────────
   AUTH PAGES
─────────────────────────────────────── */
.auth-page {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--bg-main);
  position: relative;
  overflow: hidden;
}

/* Animated background blobs */
.auth-blob {
  position: absolute;
  border-radius: 50%;
  filter: blur(60px);
  opacity: 0.4;
  animation: blobFloat 8s ease-in-out infinite;
}

.auth-blob:nth-child(1) {
  width: 400px; height: 400px;
  background: var(--primary);
  top: -100px; right: -100px;
  opacity: 0.1;
  animation-delay: 0s;
}

.auth-blob:nth-child(2) {
  width: 300px; height: 300px;
  background: var(--secondary);
  bottom: -100px; left: -50px;
  opacity: 0.08;
  animation-delay: -4s;
}

@keyframes blobFloat {
  0%, 100% { transform: translate(0, 0) scale(1); }
  33% { transform: translate(20px, -20px) scale(1.05); }
  66% { transform: translate(-15px, 10px) scale(0.97); }
}

.auth-card {
  width: 100%;
  max-width: 430px;
  margin: 24px;
  background: var(--bg-glass);
  backdrop-filter: blur(24px);
  -webkit-backdrop-filter: blur(24px);
  border: 1px solid var(--border);
  border-radius: var(--radius-xl);
  padding: 44px;
  box-shadow: var(--shadow-lg);
  position: relative;
  z-index: 1;
  animation: authSlideUp 0.5s var(--transition-slow) both;
}

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

.auth-logo {
  text-align: center;
  margin-bottom: 32px;
}

.auth-logo-icon {
  width: 56px;
  height: 56px;
  border-radius: 16px;
  background: var(--gradient-brand);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.5rem;
  color: white;
  margin: 0 auto 14px;
  box-shadow: var(--shadow-glow);
  animation: brandPulse 3s ease-in-out infinite;
}

/* ───────────────────────────────────────
   ALERTS / NOTICES
─────────────────────────────────────── */
.alert {
  padding: 13px 16px;
  border-radius: var(--radius-sm);
  font-size: 0.875rem;
  display: flex;
  align-items: flex-start;
  gap: 10px;
  margin-bottom: 16px;
  animation: alertIn 0.3s ease both;
}

@keyframes alertIn {
  from { opacity: 0; transform: translateY(-8px); }
  to   { opacity: 1; transform: translateY(0); }
}

.alert-success { background: rgba(16,217,140,0.08); color: var(--success); border: 1px solid rgba(16,217,140,0.2); }
.alert-danger  { background: rgba(244,63,94,0.08);  color: var(--danger);  border: 1px solid rgba(244,63,94,0.2);  }
.alert-warning { background: rgba(245,158,11,0.08); color: var(--warning); border: 1px solid rgba(245,158,11,0.2); }
.alert-info    { background: rgba(0,200,248,0.08);  color: var(--primary); border: 1px solid rgba(0,200,248,0.2);  }

/* ───────────────────────────────────────
   PAGE HEADER AREA
─────────────────────────────────────── */
.page-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  flex-wrap: wrap;
  gap: 16px;
  margin-bottom: 24px;
}

.page-title { font-size: 1.5rem; font-weight: 700; }
.page-subtitle { font-size: 0.85rem; color: var(--text-muted); margin-top: 3px; }

/* ───────────────────────────────────────
   TABS
─────────────────────────────────────── */
.tabs {
  display: flex;
  gap: 4px;
  padding: 5px;
  background: var(--bg-surface2);
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
  width: fit-content;
  flex-wrap: wrap;
  margin-bottom: 24px;
}

.tab-btn {
  padding: 7px 16px;
  border-radius: 6px;
  border: none;
  background: transparent;
  color: var(--text-muted);
  font-size: 0.85rem;
  font-weight: 500;
  font-family: inherit;
  cursor: pointer;
  transition: all var(--transition-base);
  white-space: nowrap;
}

.tab-btn:hover { color: var(--text-main); }

.tab-btn.active {
  background: var(--bg-surface);
  color: var(--text-main);
  box-shadow: var(--shadow-sm);
  font-weight: 600;
}

/* ───────────────────────────────────────
   MODALS
─────────────────────────────────────── */
.modal-overlay {
  display: none;
  position: fixed;
  inset: 0;
  z-index: 500;
  background: rgba(0,0,0,0.65);
  backdrop-filter: blur(6px);
  -webkit-backdrop-filter: blur(6px);
  align-items: center;
  justify-content: center;
  padding: 20px;
  animation: modalFadeIn 0.2s ease;
}

@keyframes modalFadeIn {
  from { opacity: 0; }
  to   { opacity: 1; }
}

.modal-overlay.show { display: flex; }

.modal-card {
  background: var(--bg-surface);
  border: 1px solid var(--border-hover);
  border-radius: var(--radius-xl);
  padding: 28px;
  width: 100%;
  max-width: 460px;
  box-shadow: var(--shadow-lg), 0 0 0 1px rgba(255,255,255,0.05);
  animation: modalSlideUp 0.3s cubic-bezier(0.34,1.56,0.64,1) both;
  position: relative;
}

@keyframes modalSlideUp {
  from { opacity: 0; transform: translateY(24px) scale(0.96); }
  to   { opacity: 1; transform: translateY(0) scale(1); }
}

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

.modal-title { font-size: 1.05rem; font-weight: 700; }

.modal-close {
  width: 30px; height: 30px;
  border-radius: 8px;
  background: var(--bg-hover);
  border: none; cursor: pointer;
  color: var(--text-muted);
  display: flex; align-items: center; justify-content: center;
  font-size: 0.9rem;
  transition: all var(--transition-base);
}

.modal-close:hover { background: rgba(244,63,94,0.1); color: var(--danger); transform: rotate(90deg); }

/* ───────────────────────────────────────
   STATUS INDICATORS
─────────────────────────────────────── */
.status-dot {
  display: inline-block;
  width: 8px; height: 8px;
  border-radius: 50%;
  margin-right: 6px;
}

.status-dot.connected    { background: var(--success); box-shadow: 0 0 8px rgba(16,217,140,0.6); animation: dotPulse 2.5s infinite; }
.status-dot.disconnected { background: var(--danger); }
.status-dot.connecting   { background: var(--warning); animation: dotPulse 1s infinite; }

/* ───────────────────────────────────────
   PROGRESS BARS
─────────────────────────────────────── */
.progress {
  width: 100%;
  height: 4px;
  background: var(--border);
  border-radius: 4px;
  overflow: hidden;
}

.progress-bar {
  height: 100%;
  border-radius: 4px;
  background: var(--gradient-brand);
  transition: width 0.8s cubic-bezier(0.4,0,0.2,1);
  animation: progressShimmer 2s infinite;
  background-size: 200% 100%;
}

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

/* ───────────────────────────────────────
   TOGGLE SWITCH
─────────────────────────────────────── */
.switch {
  position: relative;
  display: inline-flex;
  align-items: center;
  width: 40px;
  height: 22px;
  cursor: pointer;
  flex-shrink: 0;
}

.switch input { opacity: 0; width: 0; height: 0; }

.switch-track {
  position: absolute;
  inset: 0;
  border-radius: 22px;
  background: var(--border);
  transition: background var(--transition-base);
}

.switch input:checked ~ .switch-track { background: var(--primary); }

.switch-thumb {
  position: absolute;
  left: 3px;
  width: 16px; height: 16px;
  border-radius: 50%;
  background: white;
  box-shadow: 0 1px 4px rgba(0,0,0,0.3);
  transition: transform var(--transition-base);
}

.switch input:checked ~ .switch-thumb { transform: translateX(18px); }

/* ───────────────────────────────────────
   LOADING / SPINNER
─────────────────────────────────────── */
.spinner {
  width: 20px; height: 20px;
  border: 2px solid var(--border);
  border-top-color: var(--primary);
  border-radius: 50%;
  animation: spin 0.7s linear infinite;
  display: inline-block;
}

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

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

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

/* ───────────────────────────────────────
   OVERLAY / BACKDROP
─────────────────────────────────────── */
.sidebar-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.5);
  backdrop-filter: blur(3px);
  z-index: 199;
}

/* ───────────────────────────────────────
   SIDEBAR LINK ACTIVE INDICATOR
─────────────────────────────────────── */
.nav-item .active-indicator {
  position: absolute;
  right: -12px;
  top: 50%; transform: translateY(-50%);
  width: 3px; height: 50%;
  background: var(--gradient-brand);
  border-radius: 3px 0 0 3px;
}

/* ───────────────────────────────────────
   DEVICE CARDS
─────────────────────────────────────── */
.device-card {
  display: flex;
  flex-direction: column;
  gap: 14px;
}

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

.device-name {
  font-size: 1rem;
  font-weight: 700;
}

.device-phone {
  font-size: 0.8rem;
  color: var(--text-muted);
  font-family: 'JetBrains Mono', monospace;
}

.device-actions {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

/* ───────────────────────────────────────
   UTILITY CLASSES
─────────────────────────────────────── */
.d-flex               { display: flex; }
.d-grid               { display: grid; }
.d-none               { display: none; }
.d-block              { display: block; }
.d-inline-flex        { display: inline-flex; }
.align-items-center   { align-items: center; }
.align-items-start    { align-items: flex-start; }
.align-items-end      { align-items: flex-end; }
.justify-content-between { justify-content: space-between; }
.justify-content-center  { justify-content: center; }
.justify-content-end     { justify-content: flex-end; }
.flex-wrap            { flex-wrap: wrap; }
.flex-col             { flex-direction: column; }
.flex-1               { flex: 1; }
.gap-1                { gap: 4px; }
.gap-2                { gap: 8px; }
.gap-3                { gap: 14px; }
.gap-4                { gap: 20px; }
.gap-5                { gap: 28px; }
.mt-1                 { margin-top: 4px; }
.mt-2                 { margin-top: 8px; }
.mt-3                 { margin-top: 14px; }
.mt-4                 { margin-top: 20px; }
.mb-1                 { margin-bottom: 4px; }
.mb-2                 { margin-bottom: 8px; }
.mb-3                 { margin-bottom: 14px; }
.mb-4                 { margin-bottom: 20px; }
.p-0                  { padding: 0; }
.text-center          { text-align: center; }
.text-right           { text-align: right; }
.text-muted           { color: var(--text-muted); }
.text-primary         { color: var(--primary); }
.text-success         { color: var(--success); }
.text-danger          { color: var(--danger); }
.text-warning         { color: var(--warning); }
.text-sm              { font-size: 0.82rem; }
.text-xs              { font-size: 0.72rem; }
.font-mono            { font-family: 'JetBrains Mono', monospace; }
.font-bold            { font-weight: 700; }
.font-semibold        { font-weight: 600; }
.w-full               { width: 100%; }
.overflow-hidden      { overflow: hidden; }
.rounded              { border-radius: var(--radius-sm); }
.rounded-lg           { border-radius: var(--radius-lg); }
.rounded-full         { border-radius: 9999px; }
.truncate             { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.border-top           { border-top: 1px solid var(--border); }
.border-bottom        { border-bottom: 1px solid var(--border); }

/* Gradient text helper */
.gradient-text {
  background: var(--gradient-brand);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
  width: fit-content;
}

/* Glow effects */
.glow-primary { box-shadow: var(--shadow-glow); }
.glow-secondary { box-shadow: var(--shadow-glow-sec); }

/* ───────────────────────────────────────
   ANIMATE IN
─────────────────────────────────────── */
.fade-in { animation: fadeIn 0.4s ease both; }
.slide-up { animation: slideUp 0.35s cubic-bezier(0.34,1.3,0.64,1) both; }
.slide-up-delay-1 { animation-delay: 0.05s; }
.slide-up-delay-2 { animation-delay: 0.1s; }
.slide-up-delay-3 { animation-delay: 0.15s; }
.slide-up-delay-4 { animation-delay: 0.2s; }

@keyframes fadeIn  { from { opacity: 0; } to { opacity: 1; } }
@keyframes slideUp { from { opacity: 0; transform: translateY(16px); } to { opacity: 1; transform: translateY(0); } }

/* Floating card animation */
@keyframes float {
  0%, 100% { transform: translateY(0); }
  50% { transform: translateY(-4px); }
}

/* ── NEW Micro-Animations ── */
@keyframes fadeInUp {
  from { opacity: 0; transform: translateY(20px); }
  to   { opacity: 1; transform: translateY(0); }
}
@keyframes bounceIn {
  0%   { opacity: 0; transform: scale(0.3); }
  50%  { transform: scale(1.05); }
  70%  { transform: scale(0.95); }
  100% { opacity: 1; transform: scale(1); }
}
@keyframes wiggle {
  0%, 100% { transform: rotate(0deg); }
  25%      { transform: rotate(-3deg); }
  75%      { transform: rotate(3deg); }
}
@keyframes shimmer {
  0%   { background-position: -200% 0; }
  100% { background-position: 200% 0; }
}
@keyframes pulseSoft {
  0%, 100% { opacity: 1; }
  50%      { opacity: 0.7; }
}
@keyframes scaleIn {
  from { opacity: 0; transform: scale(0.8); }
  to   { opacity: 1; transform: scale(1); }
}

/* Utility classes */
.animate-fadeInUp { animation: fadeInUp 0.5s ease both; }
.animate-bounceIn { animation: bounceIn 0.6s ease both; }
.animate-wiggle:hover { animation: wiggle 0.3s ease 2; }
.animate-pulse { animation: pulseSoft 2s ease-in-out infinite; }
.animate-scaleIn { animation: scaleIn 0.4s ease both; }
.animate-shimmer {
  background: linear-gradient(90deg, transparent 25%, rgba(255,255,255,0.05) 50%, transparent 75%);
  background-size: 200% 100%;
  animation: shimmer 2s infinite;
}

/* Staggered delay helpers */
.delay-1 { animation-delay: 0.05s; }
.delay-2 { animation-delay: 0.1s; }
.delay-3 { animation-delay: 0.15s; }
.delay-4 { animation-delay: 0.2s; }
.delay-5 { animation-delay: 0.25s; }
.delay-6 { animation-delay: 0.3s; }

/* Interactive hover effects */
.hover-lift { transition: transform 0.25s ease, box-shadow 0.25s ease; }
.hover-lift:hover { transform: translateY(-4px); box-shadow: var(--shadow-md); }
.hover-glow { transition: box-shadow 0.25s ease; }
.hover-glow:hover { box-shadow: var(--shadow-glow); }

/* Stat card icon bounce on card hover */
.stat-card:hover .stat-icon { animation: bounceIn 0.5s ease; }
.stat-card .stat-value { transition: transform 0.3s ease; }
.stat-card:hover .stat-value { transform: scale(1.05); }

/* Device card buttons hover */
.dev-btn { transition: all 0.2s ease; }
.dev-btn:hover { transform: translateY(-2px); box-shadow: 0 3px 8px rgba(0,0,0,0.2); }
.dev-btn:active { transform: translateY(0) scale(0.95); }

/* ───────────────────────────────────────
   EMPTY STATES
─────────────────────────────────────── */
.empty-state {
  text-align: center;
  padding: 48px 24px;
  color: var(--text-muted);
}

.empty-state-icon {
  font-size: 3rem;
  margin-bottom: 14px;
  opacity: 0.4;
  display: block;
}

.empty-state h4 { font-size: 1rem; color: var(--text-main); margin-bottom: 6px; }
.empty-state p  { font-size: 0.85rem; max-width: 280px; margin: 0 auto 20px; }

/* ═══════════════════════════════════════
   RESPONSIVE DESIGN
═══════════════════════════════════════ */

/* Tablet */
@media (max-width: 1024px) {
  :root { --sidebar-w: 240px; }
  .page-content { padding: 20px 24px; }
  .bento-grid { grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: 16px; }
  .stats-grid { grid-template-columns: repeat(2, 1fr); }
  .charts-grid { grid-template-columns: 1fr; }
  
  /* Device action buttons: wrap nicely */
  .dev-btn { padding: 5px 10px; font-size: .75rem; }
  
  /* Message type buttons: allow wrap */
  .msg-type-btn { padding: 5px 10px; font-size: .75rem; }
  
  /* WA preview: stack below form */
  .wa-phone-preview { max-height: 380px; }
}

/* Mobile */
@media (max-width: 768px) {
  :root { --sidebar-w: 260px; }

  .sidebar {
    transform: translateX(-100%);
    box-shadow: none;
  }

  .sidebar.open {
    transform: translateX(0);
    box-shadow: 4px 0 30px rgba(0,0,0,0.5);
  }

  .sidebar-overlay.show { display: block; }

  .main-content {
    margin-left: 0;
  }

  .topbar {
    left: 0;
    padding: 0 16px;
  }

  .hamburger { display: flex; }

  .page-content { padding: 12px; }

  /* ── Stats grid: compact 2×2 ── */
  .stats-grid {
    grid-template-columns: repeat(2, 1fr) !important;
    gap: 10px !important;
  }

  .stats-grid .stat-card {
    padding: 12px !important;
  }

  .stats-grid .metric-icon {
    width: 28px !important;
    height: 28px !important;
    font-size: 0.8rem !important;
  }

  .stats-grid .metric-label {
    font-size: 0.65rem !important;
    margin-top: 6px !important;
  }

  .stats-grid .metric-value {
    font-size: 1.35rem !important;
    margin-top: 0 !important;
  }

  .stats-grid .badge {
    font-size: 0.55rem !important;
    padding: 1px 6px !important;
  }

  /* ── Everything else stacks 1-col ── */
  .bento-grid:not(.stats-grid), .charts-grid,
  .d-grid[style*="grid-template-columns"],
  div[style*="grid-template-columns"]:not(.no-mobile-stack):not(.stats-grid) {
    grid-template-columns: 1fr !important;
    gap: 14px;
  }

  .card, .bento-card { padding: 16px; }

  .topbar-profile .user-info { display: none; }

  .page-header { flex-direction: column; align-items: flex-start; }

  .auth-card { padding: 28px 22px; }

  .tabs { width: 100%; overflow-x: auto; }

  table { font-size: 0.82rem; }
  th, td { padding: 10px 12px; }

  /* ── Device page: compact buttons ── */
  .dev-btn { padding: 4px 8px; font-size: .7rem; }
  .device-card { padding: 14px !important; }
  
  /* ── Send message page ── */
  .msg-type-btn { padding: 4px 8px; font-size: .72rem; }
  .wa-biz-label { font-size: .6rem; }
  .upload-area { padding: 20px 12px; }
  .contact-picker-list { max-height: 160px; }
  
  /* ── WA Preview on mobile ── */
  .wa-phone-preview { border-radius: 12px; }
  .wa-chat-body { min-height: 180px !important; padding: 10px 12px 14px; }
  
  /* ── List builder items ── */
  .list-item-row div[style*="grid-template-columns"] { grid-template-columns: 1fr !important; }
  
  /* ── Button builder rows ── */
  .btn-row { gap: 4px; }
  .btn-row-num { width: 20px; height: 20px; font-size: .65rem; }

  /* ── Chatbot Performance: stack layout ── */
  .charts-grid .bento-card.d-flex.flex-column {
    padding: 16px !important;
  }
  .charts-grid .bento-card .flex-grow-1 {
    min-height: 120px !important;
  }
  .charts-grid .bento-card .flex-grow-1 > div {
    width: 120px !important;
    height: 120px !important;
  }
}

/* Small mobile */
@media (max-width: 480px) {
  .stats-grid .metric-value { font-size: 1.2rem !important; }
  .stats-grid .metric-label { font-size: 0.6rem !important; }
  .stats-grid .stat-card { padding: 10px !important; }
  .btn { padding: 8px 14px; font-size: 0.82rem; }
  .modal-card { margin: 0; border-radius: var(--radius-lg) var(--radius-lg) 0 0; max-width: 100%; position: fixed; bottom: 0; left: 0; right: 0; animation: sheetSlideUp 0.3s ease both; }
  @keyframes sheetSlideUp { from { transform: translateY(100%); } to { transform: translateY(0); } }
}

/* ───────────────────────────────────────
   CODE / PRE
─────────────────────────────────────── */
code {
  font-family: 'JetBrains Mono', monospace;
  font-size: 0.82em;
  background: var(--bg-surface2);
  color: var(--primary);
  padding: 2px 7px;
  border-radius: 4px;
  border: 1px solid var(--border);
}

pre {
  background: rgba(0,0,0,0.3);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 16px;
  overflow-x: auto;
  font-size: 0.82rem;
  line-height: 1.6;
}

pre code { background: none; border: none; padding: 0; color: #10d98c; font-size: inherit; }
