/* Theme variables and final application rules
   This file must be included last. It defines a premium brand palette by default
   and toggles to dark mode when `body.theme-dark` is present.
*/

:root {
  --brand-primary: #efbf04;
  --brand-primary-hover: #c19902;
  --brand-primary-active: #947501;
  --brand-secondary: #6a5301;
  --brand-surface: #ffffff;
  --surface: #ffffff;
  --surface-alt: #fff4dd;
  --surface-soft: #fff8e7;
  --surface-muted: #ffebc6;
  --bg: #ffebc6;
  --bg-soft: #fff4dd;
  --text: #1f1600;
  --text-secondary: #433300;
  --text-muted: rgba(31,22,0,0.7);
  --text-inverse: #ffffff;
  --link: #1f1600;
  --link-hover: #6a5301;
  --border: rgba(31,22,0,0.12);
  --border-strong: rgba(31,22,0,0.22);
  --border-inverse: rgba(255,255,255,0.22);
  --control-bg: #ffffff;
  --control-text: #1f1600;
  --shadow: 0 24px 70px rgba(31,22,0,0.08);
  --radius: 24px;
  --radius-sm: 16px;
  --radius-pill: 999px;
  --transition: 180ms ease;
}

body.theme-dark {
  --brand-primary: #efbf04;
  --brand-primary-hover: #c19902;
  --brand-primary-active: #947501;
  --brand-secondary: #6a5301;
  --surface: #433300;
  --surface-alt: #382900;
  --surface-soft: #4f3810;
  --surface-muted: #3a2d00;
  --bg: #1f1600;
  --bg-soft: #2c2100;
  --text: #ffebc6;
  --text-secondary: #fff5d5;
  --text-muted: rgba(255,235,198,0.72);
  --text-inverse: #1f1600;
  --link: #ffebc6;
  --link-hover: #efbf04;
  --border: rgba(255,235,198,0.14);
  --border-strong: rgba(255,235,198,0.26);
  --border-inverse: rgba(31,22,0,0.24);
  --control-bg: #1a1f25;
  --control-text: #ffebc6;
  --shadow: 0 28px 80px rgba(0,0,0,0.36);
}

html {
  color-scheme: light dark;
}

/* Apply variables as high-specificity final overrides to neutralize legacy rules */
html, body, #wrap, #wrapper {
  background-color: var(--bg) !important;
  color: var(--text) !important;
}

a, a:link, a:visited {
  color: var(--link) !important;
}

a:hover, a:focus {
  color: var(--link-hover) !important;
}

/* Theme switcher button hidden - disabled */
#theme-switcher-btn {
  display: none !important;
}

/* Preserve legacy neutralization */
[class*="bg-"], [style*="#222d32"], [style*="#404040"], [style*="#333"] {
  background: transparent !important;
}

.profile-icon i, .popup-box1 .cancel, .paging_simple_numbers a {
  background-color: var(--text-secondary) !important;
  color: var(--text) !important;
}

input, textarea, select, .form-control {
  background-color: var(--control-bg) !important;
  color: var(--control-text) !important;
}

.panel, .panel-body, .card {
  background-color: var(--surface) !important;
  color: var(--text) !important;
  border-color: var(--border) !important;
}

/* Ensure legacy admin/widget classes pick up unified card look */
.inner, .cintainerinner, .box, .panel, .card, .widget {
  background-color: var(--surface-alt, var(--admin-surface, #fff4dd)) !important;
  color: var(--text) !important;
  border: 1px solid var(--border) !important;
  border-radius: var(--radius-md) !important;
  padding: var(--spacing-md) !important;
  transition: var(--transition) !important;
  box-shadow: 0 6px 18px rgba(31,22,0,0.06) !important;
}

/* Admin dashboard widget variants */
.dashboard-widget {
  background-color: var(--surface-alt, var(--admin-bg, #ffebc6)) !important;
}

.widget-header {
  background-color: var(--surface-alt, var(--admin-bg, #ffebc6)) !important;
}

.widget-body {
  background-color: var(--surface-alt, var(--admin-bg, #ffebc6)) !important;
  color: var(--text) !important;
}

.widget-footer {
  background-color: var(--surface-alt, var(--admin-surface, #fff4dd)) !important;
}

.widget-row, .widget-full, .widget-half {
  background-color: var(--surface-alt, var(--admin-surface, #fff4dd)) !important;
}

/* Footer container should reflect main theme surface */
#footer, #maine-footer, footer, .site-footer {
  background-color: var(--surface-alt, var(--admin-surface, #fff4dd)) !important;
  border-top: 1px solid var(--border) !important;
  color: var(--text) !important;
}

/* Card body should match the main theme background */
.card-body {
  background-color: var(--surface-alt, var(--admin-surface, #fff4dd)) !important;
  color: var(--text) !important;
}

/* Rows should use main theme background */
.row {
  background-color: var(--surface-alt, var(--admin-surface, #fff4dd)) !important;
}

/* Override all remaining white backgrounds from legacy CSS */
[style*="background: var(--admin-surface, #fff4dd)"],
[style*="background-color: var(--admin-surface, #fff4dd)"],
[style*="background: var(--admin-surface, #fff4dd)"],
[style*="background-color: var(--admin-surface, #fff4dd)"],
[style*="background: var(--admin-surface, #fff4dd)"],
[style*="background-color: var(--admin-surface, #fff4dd)"] {
  background-color: var(--surface-alt, var(--admin-surface, #fff4dd)) !important;
}

/* Button styles with white backgrounds */
.btn-default,
.btn-line,
[class*="btn-default"],
[class*="btn-line"] {
  background-color: var(--surface-alt, var(--admin-surface, #fff4dd)) !important;
}

.btn-default:disabled,
.btn-default[disabled],
fieldset[disabled] .btn-default {
  background-color: var(--surface-alt, var(--admin-surface, #fff4dd)) !important;
}

/* Legacy element backgrounds */
.well,
.panel,
.alert,
.label,
[class*="well"],
[class*="panel"],
[class*="container"] {
  background-color: var(--surface-alt, var(--admin-surface, #fff4dd)) !important;
}

/* Form elements */
.form-control,
input[type="text"],
input[type="email"],
input[type="password"],
input[type="number"],
textarea,
select {
  background-color: var(--surface-alt, var(--admin-surface, #fff4dd)) !important;
}

/* Modal and dialog backgrounds */
.modal-content,
.popover,
.dropdown-menu {
  background-color: var(--surface-alt, var(--admin-surface, #fff4dd)) !important;
}

.button-primary, .btn-primary {
  color: var(--text-on-primary) !important;
}

/* Hover and click interaction fixes */
.btn:hover,
.btn:focus,
.btn:active,
button:hover,
button:focus,
button:active,
input[type="button"]:hover,
input[type="button"]:focus,
input[type="button"]:active,
input[type="submit"]:hover,
input[type="submit"]:focus,
input[type="submit"]:active,
input[type="reset"]:hover,
input[type="reset"]:focus,
input[type="reset"]:active,
a.btn:hover,
a.btn:focus,
a.btn:active {
  transform: none !important;
  box-shadow: 0 12px 30px rgba(31,22,0,0.14) !important;
}

.panel:hover,
.card:hover,
.box:hover,
.well:hover,
.widget:hover,
.dashboard-widget:hover {
  transform: none !important;
}

.select2-container .select2-choice:hover,
.select2-container--default .select2-selection--single:hover {
  transform: none !important;
  box-shadow: none !important;
}

button:not([disabled]),
input[type="button"]:not([disabled]),
input[type="submit"]:not([disabled]),
input[type="reset"]:not([disabled]),
.btn:not(.disabled):not([disabled]),
a.btn,
select:not([disabled]),
textarea:not([disabled]),
.dropdown-toggle,
.select2-container--default .select2-selection--single {
  pointer-events: auto !important;
}

.check-combo,
.d-flex.align-center.flex-start,
.check-combo:hover,
.check-combo:focus,
.d-flex.align-center.flex-start:hover,
.d-flex.align-center.flex-start:focus {
  transform: none !important;
  transition: none !important;
  box-shadow: none !important;
  background-color: transparent !important;
  pointer-events: auto !important;
}

.check-combo label a:hover,
.check-combo label a:focus {
  opacity: 1 !important;
  text-decoration: underline !important;
}

/* Legacy click-blocking neutralization */
html.loading,
html.loading body,
.fancybox__no-click,
.fancybox__no-click button,
.ui-widget-overlay,
.modal-backdrop,
.modal-backdrop.in {
  pointer-events: none !important;
  opacity: 0 !important;
  visibility: hidden !important;
}

html.loading {
  pointer-events: auto !important;
  background: transparent !important;
}

html.loading body {
  opacity: 1 !important;
  pointer-events: auto !important;
}

button:not([disabled]),
input:not([disabled]),
select:not([disabled]),
textarea:not([disabled]),
.btn:not(.disabled):not([disabled]),
a.btn,
a:not(.disabled):not([disabled]),
[role="button"]:not(.disabled):not([aria-disabled="true"]) {
  pointer-events: auto !important;
}
