/**
 * iLoveView — canonical theme tokens + universal remaps
 * Default: DARK on :root. Light via html[data-theme="light"]
 * Include after Bootstrap, before page CSS.
 */
:root,
html[data-theme="dark"] {
  --ilv-primary: #ef1919;
  --ilv-primary-hover: #dc2626;
  --ilv-text: #FBF8F3;
  --ilv-text-secondary: rgba(251, 248, 243, 0.68);
  --ilv-border: rgba(251, 248, 243, 0.12);
  --ilv-bg-page: #181A1E;
  --ilv-bg-sidebar: #1c1f26;
  --ilv-bg-selection: #22252b;
  --ilv-bg-active-nav: #2a2d35;
  --ilv-bg-card: #22252b;
  --ilv-bg-muted: #1f2228;
  --ilv-bg-header: #181A1E;
  --ilv-shadow: 0 8px 28px rgba(0, 0, 0, 0.35);
  --ilv-shadow-sm: 0 2px 10px rgba(0, 0, 0, 0.28);
  --ilv-focus-ring: rgba(239, 25, 25, 0.35);
  --ilv-danger: #ef1919;
  --ilv-success: #22c55e;
  --ilv-warning: #f59e0b;
  --ilv-info: #3b82f6;
  color-scheme: dark;
}

html[data-theme="light"] {
  --ilv-text: #121417;
  --ilv-text-secondary: #5e6a72;
  --ilv-border: #e4e7ea;
  --ilv-bg-page: #f5f5fa;
  --ilv-bg-sidebar: #ffffff;
  --ilv-bg-selection: #f6f6f6;
  --ilv-bg-active-nav: #f0f0f1;
  --ilv-bg-card: #ffffff;
  --ilv-bg-muted: #fafafa;
  --ilv-bg-header: #ffffff;
  --ilv-shadow: 0 8px 28px rgba(16, 24, 40, 0.1);
  --ilv-shadow-sm: 0 2px 10px rgba(16, 24, 40, 0.06);
  --ilv-focus-ring: rgba(239, 25, 25, 0.2);
  color-scheme: light;
}

/* Align legacy landing / header aliases */
:root,
html[data-theme="dark"] {
  --text-dark: var(--ilv-text);
  --text-light: var(--ilv-text-secondary);
  --bg-page: var(--ilv-bg-page);
  --bg-surface: var(--ilv-bg-card);
  --bg-header: var(--ilv-bg-header);
  --card-border: var(--ilv-border);
  --header-shadow: var(--ilv-shadow-sm);
  --bg-gradient: radial-gradient(circle at center, #2a2d35 0%, #181A1E 55%, #12141a 100%);
  --toggle-bg: rgba(251, 248, 243, 0.12);
  --toggle-fg: rgba(251, 248, 243, 0.92);
  --toggle-border: rgba(251, 248, 243, 0.22);
  --primary-color: var(--ilv-primary);
  --primary-hover: var(--ilv-primary-hover);
}

html[data-theme="light"] {
  --text-dark: var(--ilv-text);
  --text-light: var(--ilv-text-secondary);
  --bg-page: var(--ilv-bg-page);
  --bg-surface: var(--ilv-bg-card);
  --bg-header: var(--ilv-bg-header);
  --card-border: var(--ilv-border);
  --header-shadow: var(--ilv-shadow-sm);
  --bg-gradient: radial-gradient(circle at center, #f5f5fa 0%, #e4ebf5 40%, #f4e2f5 60%, #e2f0f9 100%);
  --toggle-bg: #eef1f5;
  --toggle-fg: #1f2937;
  --toggle-border: #c5ccd6;
}

/* ---------- Universal surface remaps (both themes via tokens) ---------- */
.ilv-theme-scope,
body.ilv-v2,
body.ilv-admin-panel,
.auth-wrapper.ilv-v2,
.ilv-auth-page {
  color: var(--ilv-text);
  background-color: var(--ilv-bg-page);
}

html:not([data-theme="light"]) body {
  background-color: var(--ilv-bg-page);
  color: var(--ilv-text);
}

html[data-theme="light"] body {
  background-color: var(--ilv-bg-page);
  color: var(--ilv-text);
}

/* Bootstrap utility remaps inside themed shells */
html:not([data-theme="light"]) .ilv-v2 .bg-white,
html:not([data-theme="light"]) .ilv-v2 .bg-light,
html:not([data-theme="light"]) .ilv-v2 .bg-body,
html:not([data-theme="light"]) .ilv-admin-panel .bg-white,
html:not([data-theme="light"]) .ilv-admin-panel .bg-light,
html:not([data-theme="light"]) .auth-wrapper .bg-white {
  background-color: var(--ilv-bg-card) !important;
  color: var(--ilv-text) !important;
}

html:not([data-theme="light"]) .ilv-v2 .text-dark,
html:not([data-theme="light"]) .ilv-v2 .text-black,
html:not([data-theme="light"]) .ilv-admin-panel .text-dark,
html:not([data-theme="light"]) .auth-wrapper .text-dark {
  color: var(--ilv-text) !important;
}

html:not([data-theme="light"]) .ilv-v2 .text-muted,
html:not([data-theme="light"]) .ilv-v2 .text-secondary,
html:not([data-theme="light"]) .ilv-admin-panel .text-muted,
html:not([data-theme="light"]) .auth-wrapper .text-muted {
  color: var(--ilv-text-secondary) !important;
}

html:not([data-theme="light"]) .ilv-v2 .card,
html:not([data-theme="light"]) .ilv-v2 .modal-content,
html:not([data-theme="light"]) .ilv-v2 .dropdown-menu,
html:not([data-theme="light"]) .ilv-v2 .list-group-item,
html:not([data-theme="light"]) .ilv-v2 .offcanvas,
html:not([data-theme="light"]) .ilv-v2 .popover,
html:not([data-theme="light"]) .ilv-admin-panel .card,
html:not([data-theme="light"]) .ilv-admin-panel .modal-content,
html:not([data-theme="light"]) .ilv-admin-panel .dropdown-menu {
  background-color: var(--ilv-bg-card) !important;
  color: var(--ilv-text) !important;
  border-color: var(--ilv-border) !important;
}

html:not([data-theme="light"]) .ilv-v2 .form-control,
html:not([data-theme="light"]) .ilv-v2 .form-select,
html:not([data-theme="light"]) .ilv-admin-panel .form-control,
html:not([data-theme="light"]) .ilv-admin-panel .form-select,
html:not([data-theme="light"]) .auth-wrapper .styled-input,
html:not([data-theme="light"]) .auth-wrapper input[type="email"],
html:not([data-theme="light"]) .auth-wrapper input[type="password"],
html:not([data-theme="light"]) .auth-wrapper input[type="text"] {
  background-color: var(--ilv-bg-selection) !important;
  color: var(--ilv-text) !important;
  border-color: var(--ilv-border) !important;
}

html:not([data-theme="light"]) .ilv-v2 .form-control::placeholder,
html:not([data-theme="light"]) .ilv-admin-panel .form-control::placeholder,
html:not([data-theme="light"]) .auth-wrapper input::placeholder {
  color: var(--ilv-text-secondary) !important;
}

html:not([data-theme="light"]) .ilv-v2 .btn-light,
html:not([data-theme="light"]) .ilv-v2 .btn-outline-secondary,
html:not([data-theme="light"]) .ilv-admin-panel .btn-light,
html:not([data-theme="light"]) .ilv-admin-panel .btn-outline-secondary {
  background-color: var(--ilv-bg-selection) !important;
  color: var(--ilv-text) !important;
  border-color: var(--ilv-border) !important;
}

html:not([data-theme="light"]) .ilv-v2 .btn-close,
html:not([data-theme="light"]) .ilv-admin-panel .btn-close {
  filter: invert(1) grayscale(100%);
}

html:not([data-theme="light"]) .ilv-v2 .border,
html:not([data-theme="light"]) .ilv-v2 hr,
html:not([data-theme="light"]) .ilv-admin-panel .border,
html:not([data-theme="light"]) .ilv-admin-panel hr {
  border-color: var(--ilv-border) !important;
}

html:not([data-theme="light"]) .ilv-v2 .table,
html:not([data-theme="light"]) .ilv-admin-panel .table {
  color: var(--ilv-text-secondary);
  --bs-table-bg: transparent;
  --bs-table-color: var(--ilv-text);
  border-color: var(--ilv-border);
}

/* Focus rings */
.ilv-v2 a:focus-visible,
.ilv-v2 button:focus-visible,
.ilv-v2 input:focus-visible,
.ilv-v2 select:focus-visible,
.ilv-v2 textarea:focus-visible,
.auth-wrapper input:focus-visible,
.auth-wrapper button:focus-visible {
  outline: 2px solid var(--ilv-primary);
  outline-offset: 2px;
}

/* Scrollbars (WebKit) */
html:not([data-theme="light"]) .ilv-v2 ::-webkit-scrollbar,
html:not([data-theme="light"]) .ilv-admin-panel ::-webkit-scrollbar {
  width: 8px;
  height: 8px;
}
html:not([data-theme="light"]) .ilv-v2 ::-webkit-scrollbar-thumb,
html:not([data-theme="light"]) .ilv-admin-panel ::-webkit-scrollbar-thumb {
  background: rgba(251, 248, 243, 0.18);
  border-radius: 8px;
}
html:not([data-theme="light"]) .ilv-v2 ::-webkit-scrollbar-track,
html:not([data-theme="light"]) .ilv-admin-panel ::-webkit-scrollbar-track {
  background: transparent;
}

/* Theme toggle (shared) */
.ilv-theme-toggle {
  width: 40px;
  height: 40px;
  border: 1px solid rgba(251, 248, 243, 0.22);
  border-radius: 50%;
  background: rgba(251, 248, 243, 0.12);
  color: rgba(251, 248, 243, 0.92);
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.2);
  transition: background 0.2s ease, border-color 0.2s ease, box-shadow 0.2s ease;
}
.ilv-theme-toggle:hover {
  background: rgba(251, 248, 243, 0.18);
  border-color: rgba(251, 248, 243, 0.35);
}
.ilv-theme-toggle::after {
  content: "☀";
  font-size: 16px;
  line-height: 1;
}
html[data-theme="light"] .ilv-theme-toggle {
  background: #eef1f5;
  border: 1px solid #c5ccd6;
  color: #1f2937;
  box-shadow: 0 1px 3px rgba(16, 24, 40, 0.1);
}
html[data-theme="light"] .ilv-theme-toggle:hover {
  background: #e4e9ef;
  border-color: #9aa5b5;
}
html[data-theme="light"] .ilv-theme-toggle::after {
  content: "☾";
  color: #1f2937;
}

/* Public landing / legal / invite floating toggle */
.ilv-theme-toggle-float {
  position: fixed;
  top: 16px;
  right: 16px;
  z-index: 50;
}

/* Toast / alert remaps */
html:not([data-theme="light"]) .toast,
html:not([data-theme="light"]) .toast-notification,
html:not([data-theme="light"]) .alert-light {
  background: var(--ilv-bg-card) !important;
  color: var(--ilv-text) !important;
  border-color: var(--ilv-border) !important;
}

html:not([data-theme="light"]) .ilv-admin-toast.alert-success {
  background: #1e2a24 !important;
  color: #86efac !important;
  border-color: rgba(34, 197, 94, 0.55) !important;
  box-shadow: 0 12px 36px rgba(0, 0, 0, 0.45) !important;
}

html:not([data-theme="light"]) .ilv-admin-toast.alert-success .text-success-600,
html:not([data-theme="light"]) .ilv-admin-toast.alert-success .remove-button {
  color: #86efac !important;
}

html:not([data-theme="light"]) .ilv-admin-toast.alert-info {
  background: #2a2224 !important;
  color: #fca5a5 !important;
  border-color: rgba(239, 68, 68, 0.55) !important;
  box-shadow: 0 12px 36px rgba(0, 0, 0, 0.45) !important;
}

html:not([data-theme="light"]) .ilv-admin-toast.alert-info .text-info-600,
html:not([data-theme="light"]) .ilv-admin-toast.alert-info .remove-button {
  color: #fca5a5 !important;
}

html:not([data-theme="light"]) .toast-notification .toast-title {
  color: var(--ilv-text) !important;
}

html:not([data-theme="light"]) .toast-notification .toast-message {
  color: var(--ilv-text-secondary, rgba(251, 248, 243, 0.68)) !important;
}

html:not([data-theme="light"]) .toast-notification .toast-close {
  color: var(--ilv-text-secondary, rgba(251, 248, 243, 0.55)) !important;
}

html:not([data-theme="light"]) .toast-notification.success {
  background: #1e2a24 !important;
  border-left-color: #22c55e !important;
}

html:not([data-theme="light"]) .toast-notification.error {
  background: #2a2224 !important;
  border-left-color: #ef4444 !important;
}

html:not([data-theme="light"]) .toast-notification.warning {
  background: #2a261c !important;
  border-left-color: #f59e0b !important;
}

html:not([data-theme="light"]) .toast-notification.info {
  background: #1c2430 !important;
  border-left-color: #3b82f6 !important;
}

/* Tooltip / popover */
html:not([data-theme="light"]) .tooltip-inner,
html:not([data-theme="light"]) .popover {
  background: var(--ilv-bg-card) !important;
  color: var(--ilv-text) !important;
  border-color: var(--ilv-border) !important;
}

/* Pagination */
html:not([data-theme="light"]) .page-link {
  background: var(--ilv-bg-card) !important;
  color: var(--ilv-text) !important;
  border-color: var(--ilv-border) !important;
}
html:not([data-theme="light"]) .page-item.active .page-link {
  background: var(--ilv-primary) !important;
  border-color: var(--ilv-primary) !important;
  color: #fff !important;
}

/* Empty states often use muted text on white cards */
html:not([data-theme="light"]) .empty-state,
html:not([data-theme="light"]) .ilv-empty,
html:not([data-theme="light"]) .no-data {
  color: var(--ilv-text-secondary) !important;
}

/* Nav tabs in dashboard */
html:not([data-theme="light"]) .ilv-v2 .nav-tabs .nav-link {
  color: var(--ilv-text-secondary) !important;
  border-color: transparent !important;
}
html:not([data-theme="light"]) .ilv-v2 .nav-tabs .nav-link.active {
  background: var(--ilv-bg-card) !important;
  color: var(--ilv-text) !important;
  border-color: var(--ilv-border) !important;
}

/* Select2 / choices if present */
html:not([data-theme="light"]) .select2-container--default .select2-selection--single,
html:not([data-theme="light"]) .select2-dropdown {
  background: var(--ilv-bg-card) !important;
  color: var(--ilv-text) !important;
  border-color: var(--ilv-border) !important;
}

/* Theme brand marks — never inherit card/white fills */
img[data-theme-logo-dark],
img[data-theme-logo-light],
.ilv-v2-sidebar-logo-icon,
.ilv-admin-brand-logo,
.footer-logo-wrap img,
.logo-container img,
.brand img {
  background: transparent !important;
  box-shadow: none !important;
}
