/* Pour Pos — dark / light theme (EduManage primary pattern) */

html[data-theme="light"] {
  color-scheme: light;
}

html[data-theme="dark"] {
  color-scheme: dark;
  --bg: #020617;
  --surface: #0f172a;
  --surface-alt: #1e293b;
  --text: #e2e8f0;
  --text-muted: #94a3b8;
  --border: rgba(255, 255, 255, 0.1);
  --sidebar-bg: var(--surface);
  --sidebar-text: #cbd5e1;
  --sidebar-active: rgba(255, 255, 255, 0.08);
  --shadow: 0 1px 3px rgba(0, 0, 0, 0.35);
  --shadow-lg: 0 8px 24px rgba(0, 0, 0, 0.45);
  --dk-surface: #0f172a;
  --dk-border: rgba(255, 255, 255, 0.1);
  --dk-text: #e2e8f0;
  --dk-muted: #94a3b8;
}

html[data-theme="light"] {
  --dk-surface: #ffffff;
  --dk-border: #e2e8f0;
  --dk-text: #1e293b;
  --dk-muted: #64748b;
  --surface: #ffffff;
  --surface-alt: #f8fafc;
  --text: #1e293b;
  --text-muted: #64748b;
  --border: #e2e8f0;
  --shadow: 0 2px 10px rgba(0, 0, 0, 0.08);
  --radius: 4px;
}

/* Dashboard date-range filter (Elite-style) */
.dash-filter {
  background: var(--content-surface, var(--surface));
  border: 1px solid var(--content-border, var(--border));
  border-radius: 3px;
  padding: 12px 14px;
  margin-bottom: 16px;
  box-shadow: var(--shadow, 0 2px 10px rgba(0, 0, 0, 0.08));
}
.dash-filter-form {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}
.dash-presets {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}
.dash-presets .chip {
  display: inline-flex;
  align-items: center;
  padding: 6px 12px;
  font-size: 12px;
  font-weight: 600;
  color: var(--text-primary, var(--text));
  background: var(--content-surface-alt, var(--surface-alt));
  border: 1px solid var(--content-border, var(--border));
  border-radius: 4px;
  text-decoration: none;
  transition: background .15s, color .15s, border-color .15s;
}
.dash-presets .chip:hover {
  background: var(--content-border, var(--border));
  text-decoration: none;
  color: var(--text-primary, var(--text));
}
.dash-presets .chip.active {
  background: #C7BB28;
  border-color: #C7BB28;
  color: #1f2937;
}
.dash-range {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 10px;
}
.dash-range label {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 12px;
  font-weight: 600;
  color: var(--text-secondary, var(--text-muted));
}
.dash-range input[type="date"] {
  padding: 5px 8px;
  font-size: 12px;
  border: 1px solid var(--content-border, var(--border));
  border-radius: var(--radius, 4px);
  background: var(--content-surface, var(--surface));
  color: var(--text-primary, var(--text));
}
.dash-range select.form-select-sm {
  padding: 5px 8px;
  font-size: 12px;
  min-width: 140px;
  border: 1px solid var(--content-border, var(--border));
  border-radius: var(--radius, 4px);
  background: var(--content-surface, var(--surface));
  color: var(--text-primary, var(--text));
}
.dash-filter-form-stacked {
  flex-direction: column;
  align-items: stretch;
}
.dash-filter-form-stacked .dash-filter-extras {
  padding-top: 4px;
}
@media (max-width: 700px) {
  .dash-filter-form { flex-direction: column; align-items: stretch; }
  .dash-range { justify-content: flex-start; }
}

html[data-theme="dark"] .dash-filter {
  background: var(--surface);
  border-color: var(--border);
}
html[data-theme="dark"] .dash-presets .chip {
  background: #1e293b;
  border-color: rgba(255, 255, 255, 0.12);
  color: #cbd5e1;
}
html[data-theme="dark"] .dash-presets .chip.active {
  background: #C7BB28;
  border-color: #C7BB28;
  color: #1f2937;
}
html[data-theme="dark"] .dash-presets .chip:hover:not(.active) {
  background: #334155;
  color: #fff;
}
html[data-theme="dark"] .dash-range input[type="date"] {
  background: var(--surface);
  border-color: var(--border);
  color: var(--text);
}

/* Structural dark mode (EduManage body.dark-mode) */
body.dark-mode {
  background: var(--bg);
  color: var(--text);
}

body.dark-mode .topbar {
  background: var(--surface);
  border-color: var(--border);
}

body.dark-mode .topbar-business {
  color: var(--text);
}

body.dark-mode .content:not(.orders-bg) {
  background: var(--bg);
}

body.dark-mode .card {
  background: var(--surface);
  border-color: var(--border);
  color: var(--text);
}

body.dark-mode .card-header {
  background: rgba(255, 255, 255, 0.05);
  border-color: var(--border);
  color: var(--text);
}

body.dark-mode .sidebar .brand {
  background: var(--surface);
  border-bottom-color: var(--border);
}

html[data-theme="dark"] .sidebar,
body.dark-mode .sidebar {
  background: var(--surface);
}

body.dark-mode .sidebar .brand .name {
  color: var(--text);
}

body.dark-mode .dash-filter {
  background: var(--surface);
  border-color: var(--border);
}

body.dark-mode .app-footer {
  background: var(--surface);
  border-color: var(--border);
  color: var(--text-muted);
}

body.dark-mode .stat-card:not([class*="accent-"]) {
  background: var(--surface);
  border-color: var(--border);
}

body.dark-mode .form-section {
  background: linear-gradient(135deg, var(--surface) 0%, var(--surface-alt) 100%);
  border-color: var(--border);
}

body.dark-mode .form-section-header {
  background: linear-gradient(135deg, rgba(99, 102, 241, 0.1) 0%, rgba(99, 102, 241, 0.03) 100%);
  border-color: var(--border);
}

html[data-theme="dark"] .sidebar .brand {
  background: var(--surface);
  border-bottom-color: var(--border);
}

html[data-theme="dark"] .sidebar .brand .name {
  color: #e2e8f0;
}

html[data-theme="dark"] .topbar-actions .topbar-icon:hover {
  background: #334155;
  border-color: #334155;
}

html[data-theme="dark"] .sidebar-toggle:hover {
  color: #fff;
}

/* Theme toggle */
.theme-switch {
  position: relative;
  display: inline-flex;
  align-items: center;
  width: 44px;
  height: 24px;
  margin: 0;
  cursor: pointer;
  flex-shrink: 0;
}

.theme-switch input {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  margin: 0;
  opacity: 0;
  cursor: pointer;
  z-index: 2;
}

.theme-switch-track {
  position: relative;
  display: block;
  width: 100%;
  height: 100%;
  border-radius: 999px;
  background: #94a3b8;
  transition: background 0.2s ease;
  border: none;
  box-shadow: none;
}

.theme-switch-thumb {
  position: absolute;
  top: 2px;
  left: 2px;
  width: 20px;
  height: 20px;
  border-radius: 50%;
  background: #ffffff;
  transition: transform 0.2s ease;
  border: none;
  box-shadow: none;
}

.theme-switch input:checked + .theme-switch-track {
  background: #000000;
}

.theme-switch input:checked + .theme-switch-track .theme-switch-thumb {
  transform: translateX(20px);
}

.theme-switch:hover .theme-switch-track {
  filter: brightness(1.05);
}

html[data-theme="light"] .theme-switch-track {
  background: #cbd5e1;
}

html[data-theme="light"] .theme-switch input:checked + .theme-switch-track {
  background: #000000;
}

/* Dark mode — form & table polish */
body.dark-mode .form-control,
body.dark-mode .form-select,
body.dark-mode textarea.form-control {
  background: #1e293b;
  border-color: rgba(255, 255, 255, 0.15);
  color: #e2e8f0;
}

body.dark-mode .form-control:focus,
body.dark-mode .form-select:focus {
  background: #1e293b;
  border-color: #6366f1;
  color: #e2e8f0;
  box-shadow: 0 0 0 3px rgba(99, 102, 241, 0.2);
}

body.dark-mode .form-control::placeholder {
  color: #64748b;
}

body.dark-mode .table {
  color: #e2e8f0;
  --bs-table-bg: transparent;
  --bs-table-color: #e2e8f0;
  --bs-table-border-color: rgba(255, 255, 255, 0.08);
}

body.dark-mode .table thead th {
  background: rgba(255, 255, 255, 0.04);
  color: #94a3b8;
}

body.dark-mode .table tbody tr:hover {
  background: rgba(255, 255, 255, 0.03);
}

body.dark-mode .alert-info {
  background: rgba(6, 182, 212, 0.12);
  border-color: rgba(6, 182, 212, 0.25);
  color: #a5f3fc;
}

body.dark-mode .alert-success {
  background: rgba(16, 185, 129, 0.12);
  border-color: rgba(16, 185, 129, 0.25);
  color: #86efac;
}

body.dark-mode .alert-danger,
body.dark-mode .alert-warning {
  color: #fecaca;
}

body.dark-mode .breadcrumb-item.active {
  color: #94a3b8;
}

body.dark-mode .breadcrumb-item a {
  color: #a5b4fc;
}

body.dark-mode .page-back {
  background: #1e293b;
  border-color: rgba(255, 255, 255, 0.12);
  color: #e2e8f0;
}

body.dark-mode .dash-presets .chip {
  background: #1e293b;
  border-color: rgba(255, 255, 255, 0.12);
  color: #cbd5e1;
}

body.dark-mode .dash-presets .chip.active {
  background: #C7BB28;
  border-color: #C7BB28;
  color: #1f2937;
}

body.dark-mode .dash-presets .chip:hover:not(.active) {
  background: #334155;
  color: #fff;
}

body.dark-mode .insight-card,
body.dark-mode .change-calc-card {
  background: var(--surface);
  border-color: var(--border);
}

body.dark-mode .welcome-empty {
  background: var(--surface);
  border-color: var(--border);
}

body.dark-mode.login-page {
  background: linear-gradient(160deg, #020617 0%, #0f172a 50%, #1e293b 100%);
}

body.dark-mode .login-card {
  background: #0f172a;
  border-color: rgba(255, 255, 255, 0.1);
  box-shadow: 0 20px 50px rgba(0, 0, 0, 0.45);
}

body.dark-mode .login-card h1 {
  color: #e2e8f0;
}

body.dark-mode .login-card .tagline {
  color: #94a3b8;
}

/* User menu (EduManage-style dropdown, no Bootstrap) */
.user-menu {
  position: relative;
}

.topbar-actions .topbar-user-photo {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  object-fit: cover;
  display: block;
}

.user-menu-btn {
  cursor: pointer;
}

.user-menu-panel {
  position: absolute;
  top: calc(100% + 8px);
  right: 0;
  min-width: 220px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 4px;
  box-shadow: var(--shadow-lg);
  z-index: 1100;
  padding: 6px 0;
}

.user-menu-panel[hidden] {
  display: none !important;
}

.user-menu-head {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 14px;
}

.user-avatar-sm {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  background: linear-gradient(135deg, #041A5E, #0d6efd);
  display: flex;
  align-items: center;
  justify-content: center;
  color: #fff;
  font-weight: 600;
  font-size: 0.7rem;
  flex-shrink: 0;
}

.user-menu-name {
  font-weight: 600;
  font-size: 0.875rem;
  color: var(--text);
}

.user-menu-role {
  font-size: 0.75rem;
  color: var(--text-muted);
}

.user-menu-divider {
  height: 1px;
  background: var(--border);
  margin: 4px 0;
}

.user-menu-item {
  display: flex;
  align-items: center;
  gap: 8px;
  width: 100%;
  padding: 8px 14px;
  font-size: 0.875rem;
  color: var(--text);
  text-decoration: none;
  background: transparent;
  border: none;
  cursor: pointer;
  text-align: left;
  font-family: inherit;
}

.user-menu-item:hover {
  background: var(--surface-alt);
  text-decoration: none;
  color: var(--text);
}

.user-menu-logout {
  color: #ef4444;
}

.user-menu-logout:hover {
  color: #dc2626;
  background: rgba(239, 68, 68, 0.08);
}

body.dark-mode .user-menu-panel {
  background: var(--surface);
  border-color: var(--border);
}

body.dark-mode .user-menu-item:hover {
  background: rgba(255, 255, 255, 0.08);
}
