/* ── White-label Backoffice — Self-contained Dark Theme ── */

/*
 * IMPORTANT: style.css defines :root vars (LIGHT theme).
 * :root has higher specificity than body for CSS custom properties.
 * We MUST use html.wl-dark (via :root override) AND body.wl-dark for
 * direct property overrides to beat all style.css selectors.
 */

/* Override CSS vars at :root level to beat style.css :root */
html:has(body.wl-dark),
body.wl-dark {
  --bg-root: #0f0f23;
  --bg-primary: #0f0f23;
  --bg-secondary: #151530;
  --bg-tertiary: #12122a;
  --bg-card: #1a1a3e;
  --bg-elevated: #1e1e45;
  --bg-hover: rgba(99,102,241,0.08);
  --bg-subtle: #12122a;
  --border-subtle: #2a2a5a;
  --border-default: #2a2a5a;
  --border-hover: #3a3a6a;
  --text-primary: #e2e2ff;
  --text-secondary: #8888bb;
  --text-tertiary: #5555aa;
  --accent: #818CF8;
  --primary: #818CF8;
  --primary-dark: #6366F1;
  --primary-light: #818CF8;
  --primary-soft: rgba(99,102,241,0.1);
  --primary-glow: rgba(99,102,241,0.15);
  --primary-glow-md: rgba(99,102,241,0.2);
  --primary-glow-strong: rgba(99,102,241,0.3);
  --gradient-brand: linear-gradient(135deg, #312e81 0%, #6366F1 40%, #818CF8 100%);
  --gradient-btn: linear-gradient(135deg, #6366F1 0%, #818CF8 100%);
  --radius-sm: 8px;
  --radius-md: 10px;
  --radius-lg: 12px;
  --shadow-sm: 0 2px 8px rgba(0,0,0,0.3);
  --shadow-md: 0 4px 16px rgba(0,0,0,0.4);
  --duration: 0.15s;
  --ease: ease;
  --success: #10B981;
  --success-bg: rgba(16,185,129,0.1);
  --success-border: rgba(16,185,129,0.3);
  --error: #EF4444;
  --error-bg: rgba(239,68,68,0.1);
  --error-border: rgba(239,68,68,0.3);
  --warning: #F59E0B;
  --info: #818CF8;
}

body.wl-dark {
  background: #0f0f23 !important;
  color: #e2e2ff !important;
}

/* ── Global overrides for style.css hardcoded colors ── */

body.wl-dark .container {
  background: #0f0f23;
}

body.wl-dark .card {
  background: #1a1a3e;
  border-color: #2a2a5a;
}

body.wl-dark .card h2 {
  color: #e2e2ff;
}

body.wl-dark .card .subtitle {
  color: #5555aa;
}

body.wl-dark .form-group input,
body.wl-dark .form-group select,
body.wl-dark .form-group textarea {
  background: #1e1e45;
  border-color: #2a2a5a;
  color: #e2e2ff;
}

body.wl-dark .form-group input:focus,
body.wl-dark .form-group select:focus,
body.wl-dark .form-group textarea:focus {
  border-color: #818CF8;
  box-shadow: 0 0 0 3px rgba(99,102,241,0.15);
}

body.wl-dark .form-group input::placeholder,
body.wl-dark .form-group textarea::placeholder {
  color: #5555aa;
}

body.wl-dark .form-group label {
  color: #8888bb;
}

body.wl-dark .btn {
  background: linear-gradient(135deg, #6366F1 0%, #818CF8 100%);
  color: #fff;
}

body.wl-dark .btn:hover {
  box-shadow: 0 4px 12px rgba(99,102,241,0.3);
}

body.wl-dark .btn-outline {
  background: #1e1e45;
  border-color: #2a2a5a;
  color: #8888bb;
}

body.wl-dark .btn-outline:hover {
  border-color: #818CF8;
  color: #818CF8;
  background: rgba(99,102,241,0.1);
}

body.wl-dark .logo-subtitle {
  color: #5555aa;
}

/* ── Login Page ── */

#wl-page-login {
  display: none;
  max-width: 420px;
  margin: 0 auto;
  padding: 80px 20px 40px;
}

#wl-page-login.active {
  display: block;
}

body.wl-dark #wl-page-login .card {
  background: #1a1a3e;
  border: 1px solid #2a2a5a;
  border-radius: 12px;
  padding: 32px;
}

body.wl-dark #wl-page-login .card h2 {
  color: #e2e2ff;
  margin: 0 0 4px;
  font-size: 22px;
}

body.wl-dark #wl-page-login .card .subtitle {
  color: #8888bb;
  font-size: 13px;
  margin-bottom: 20px;
}

body.wl-dark #wl-page-login .form-group label {
  color: #8888bb;
}

body.wl-dark #wl-page-login .form-group input {
  background: #1e1e45;
  border: 1px solid #2a2a5a;
  color: #e2e2ff;
}

body.wl-dark #wl-page-login .form-group input:focus {
  border-color: #818CF8;
  box-shadow: 0 0 0 3px rgba(99,102,241,0.15);
}

body.wl-dark #wl-page-login .form-group input::placeholder {
  color: #5555aa;
}

body.wl-dark #wl-page-login .btn {
  width: 100%;
  padding: 10px 16px;
  font-size: 14px;
  margin-top: 4px;
  background: linear-gradient(135deg, #6366F1 0%, #818CF8 100%);
  color: #fff;
}

/* ── Message (login errors/success) ── */

body.wl-dark .message {
  padding: 10px 14px;
  border-radius: 8px;
  font-size: 13px;
  margin-bottom: 12px;
}

body.wl-dark .message.error {
  background: rgba(220,38,38,0.1);
  border: 1px solid rgba(220,38,38,0.3);
  color: #FCA5A5;
}

body.wl-dark .message.success {
  background: rgba(16,185,129,0.1);
  border: 1px solid rgba(16,185,129,0.3);
  color: #6EE7B7;
}

/* ── Shell Layout ── */

.wl-shell {
  display: flex;
  min-height: 100vh;
  background: #0f0f23;
}

.wl-sidebar {
  width: 260px;
  min-height: 100vh;
  background: #1a1a3e;
  border-right: 1px solid #2a2a5a;
  display: flex;
  flex-direction: column;
  flex-shrink: 0;
}

.wl-sidebar-brand {
  padding: 24px 20px 16px;
  border-bottom: 1px solid #2a2a5a;
}

.wl-sidebar-brand strong {
  display: block;
  font-size: 16px;
  color: #818CF8;
  letter-spacing: -0.3px;
}

.wl-sidebar-brand small {
  display: block;
  font-size: 11px;
  color: #8888bb;
  margin-top: 4px;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

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

.wl-nav-tab {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 11px 20px;
  color: #8888bb;
  text-decoration: none;
  font-size: 13px;
  border-left: 3px solid transparent;
  transition: all 0.15s ease;
}

.wl-nav-tab svg {
  flex-shrink: 0;
  opacity: 0.7;
}

.wl-nav-tab:hover {
  color: #e2e2ff;
  background: rgba(99,102,241,0.08);
}

.wl-nav-tab:hover svg { opacity: 1; }

.wl-nav-tab.active {
  color: #818CF8;
  border-left-color: #818CF8;
  background: rgba(99,102,241,0.12);
}

.wl-nav-tab.active svg {
  opacity: 1;
  color: #818CF8;
}

.wl-sidebar-footer {
  padding: 14px 20px;
  border-top: 1px solid #2a2a5a;
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.wl-sidebar-footer a {
  color: #8888bb;
  text-decoration: none;
  font-size: 12px;
}

.wl-sidebar-footer a:hover { color: #818CF8; }

/* ── Main Content ── */

.wl-main {
  flex: 1;
  padding: 28px 36px;
  overflow-y: auto;
  max-height: 100vh;
}

.wl-tab-content { display: none; }
.wl-tab-content.active { display: block; }

.wl-loading {
  text-align: center;
  color: #8888bb;
  padding: 40px;
  font-size: 14px;
}

/* ── User Header Bar ── */

.wl-header-bar {
  display: flex;
  justify-content: flex-end;
  align-items: center;
  gap: 12px;
  margin-bottom: 20px;
  padding-bottom: 12px;
  border-bottom: 1px solid #2a2a5a;
}

.wl-header-user {
  font-size: 12px;
  color: #8888bb;
}

/* ── KPI Cards ── */

.wl-kpi-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 16px;
}

body.wl-dark .kpi-card,
body.wl-dark .wl-kpi-card {
  background: #1a1a3e;
  border: 1px solid #2a2a5a;
  border-radius: 10px;
  padding: 20px;
  transition: border-color 0.15s;
}

body.wl-dark .kpi-card:hover,
body.wl-dark .wl-kpi-card:hover {
  border-color: #3a3a6a;
}

body.wl-dark .kpi-label,
body.wl-dark .wl-kpi-card .kpi-label {
  font-size: 12px;
  color: #8888bb;
  margin-bottom: 6px;
  text-transform: uppercase;
  letter-spacing: 0.3px;
}

body.wl-dark .kpi-value,
body.wl-dark .wl-kpi-card .kpi-value {
  font-size: 24px;
  font-weight: 700;
  color: #e2e2ff;
  letter-spacing: -0.5px;
}

/* ── Empty / Error States ── */

body.wl-dark .empty-state-card {
  background: #1a1a3e;
  border: 1px solid #2a2a5a;
  border-radius: 10px;
  padding: 32px;
  text-align: center;
  color: #8888bb;
  font-size: 14px;
}

body.wl-dark .empty-state-card strong {
  color: #e2e2ff;
  display: block;
  margin-bottom: 8px;
  font-size: 15px;
}

/* ── Plan Cards ── */

.wl-plans-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
  gap: 20px;
  margin-top: 8px;
}

.wl-plan-card {
  background: #1a1a3e;
  border: 1px solid #2a2a5a;
  border-radius: 12px;
  padding: 24px;
  transition: border-color 0.2s;
}

.wl-plan-card:hover { border-color: #818CF8; }

.wl-plan-card h3 {
  font-size: 18px;
  margin: 0 0 16px;
  color: #e2e2ff;
}

.wl-plan-card ul {
  list-style: none;
  padding: 0;
  margin: 0;
}

.wl-plan-card li {
  padding: 6px 0;
  color: #8888bb;
  font-size: 13px;
  border-bottom: 1px solid rgba(255,255,255,0.04);
}

.wl-plan-card li:last-child { border-bottom: none; }
.wl-plan-card li::before { content: "\2713  "; color: #10B981; }

.wl-plan-basic { border-top: 3px solid #6B7280; }
.wl-plan-pro { border-top: 3px solid #818CF8; }
.wl-plan-enterprise { border-top: 3px solid #F59E0B; }

/* ── Modal ── */

.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.6);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1000;
}

body.wl-dark .modal-card {
  background: #1a1a3e;
  border: 1px solid #2a2a5a;
  border-radius: 12px;
  padding: 28px;
  min-width: 400px;
  max-width: 520px;
}

body.wl-dark .modal-card h3 {
  margin: 0 0 16px;
  color: #e2e2ff;
}

body.wl-dark .modal-card .form-group label {
  color: #8888bb;
}

body.wl-dark .modal-card .form-group input,
body.wl-dark .modal-card .form-group select {
  background: #1e1e45;
  border: 1px solid #2a2a5a;
  color: #e2e2ff;
}

/* ── Small buttons (inline) ── */

body.wl-dark .btn-sm {
  padding: 4px 10px;
  font-size: 11px;
  background: rgba(99,102,241,0.15);
  color: #818CF8;
  border: 1px solid rgba(99,102,241,0.3);
  border-radius: 4px;
  cursor: pointer;
  transition: background 0.15s;
}

body.wl-dark .btn-sm:hover { background: rgba(99,102,241,0.25); }

/* ── Data Table override for dark theme ── */

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

body.wl-dark .data-table th {
  background: #1e1e45;
  color: #8888bb;
  border-bottom: 1px solid #2a2a5a;
  padding: 10px 12px;
  text-align: left;
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.3px;
}

body.wl-dark .data-table td {
  border-bottom: 1px solid #2a2a5a;
  color: #e2e2ff;
  padding: 10px 12px;
  font-size: 13px;
}

body.wl-dark .data-table tbody tr:hover {
  background: rgba(99,102,241,0.08);
}

body.wl-dark .data-table tbody tr:nth-child(even) {
  background: rgba(255,255,255,0.02);
}

body.wl-dark code {
  background: rgba(99,102,241,0.1);
  color: #818CF8;
  padding: 2px 6px;
  border-radius: 4px;
  font-size: 12px;
}

/* ── Override pg-header for dark ── */

body.wl-dark .pg-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  margin-bottom: 20px;
}

body.wl-dark .pg-header__title {
  color: #e2e2ff;
  font-size: 20px;
  font-weight: 700;
  margin: 0 0 4px;
}

body.wl-dark .pg-header__desc {
  color: #8888bb;
  font-size: 13px;
  margin: 0;
}

/* ── btn-primary ── */

body.wl-dark .btn-primary {
  background: linear-gradient(135deg, #6366F1 0%, #818CF8 100%);
  color: #fff;
}

/* ── btn-logout override ── */

body.wl-dark .btn-logout {
  background: transparent;
  border: 1px solid #2a2a5a;
  color: #8888bb;
  padding: 6px 12px;
  border-radius: 6px;
  cursor: pointer;
  font-size: 12px;
  transition: all 0.15s;
}

body.wl-dark .btn-logout:hover {
  border-color: #EF4444;
  color: #EF4444;
  background: rgba(239,68,68,0.1);
}

/* ── Badge ── */

body.wl-dark .badge {
  font-size: 11px;
  padding: 2px 8px;
  border-radius: 4px;
  display: inline-block;
}

/* ── Scrollbar ── */

body.wl-dark ::-webkit-scrollbar {
  width: 6px;
}

body.wl-dark ::-webkit-scrollbar-track {
  background: #0f0f23;
}

body.wl-dark ::-webkit-scrollbar-thumb {
  background: #2a2a5a;
  border-radius: 3px;
}

body.wl-dark ::-webkit-scrollbar-thumb:hover {
  background: #3a3a6a;
}

/* ── Links ── */

body.wl-dark a {
  color: #818CF8;
}

body.wl-dark a:hover {
  color: #a5b4fc;
}

/* ── Responsive ── */

@media (max-width: 768px) {
  .wl-sidebar {
    width: 200px;
  }
  .wl-main {
    padding: 20px 16px;
  }
  body.wl-dark .modal-card {
    min-width: auto;
    max-width: 95vw;
    margin: 0 10px;
  }
}

@media (max-width: 600px) {
  .wl-shell {
    flex-direction: column;
  }
  .wl-sidebar {
    width: 100%;
    min-height: auto;
    border-right: none;
    border-bottom: 1px solid #2a2a5a;
  }
  .wl-sidebar-nav {
    display: flex;
    overflow-x: auto;
    padding: 8px 0;
  }
  .wl-nav-tab {
    border-left: none;
    border-bottom: 2px solid transparent;
    padding: 8px 14px;
    white-space: nowrap;
  }
  .wl-nav-tab.active {
    border-left-color: transparent;
    border-bottom-color: #818CF8;
  }
  .wl-main {
    max-height: none;
  }
}
