/*
 * Shared layer for every theme except Classic. Each theme file sets the --t-* tokens on
 * body.theme-<id>; the rules below map them onto the Silicon template. --sa-* accent
 * tokens come from the inline :root style in the base templates.
 */

.sa-themed {
  --t-surface-rgb: 255, 255, 255;
  --t-h2-font: var(--t-head-font);
  --t-h2-weight: var(--t-head-weight);
  --t-h2-color: var(--t-text);
  --t-hero-bg: transparent;
  --t-hero-shadow: none;
  --t-hero-padding: 0.5rem 0 1.5rem;
  --t-fade-display: none;
  --t-hero-text: var(--t-text);
  --t-hero-muted: var(--t-muted);
  --t-icon-bg: var(--t-surface);
  --t-icon-border: 1px solid var(--t-border);
  --t-icon-color: var(--sa-accent-text);
  --t-book-bg: var(--sa-accent);
  --t-book-color: var(--sa-on-accent);
  --t-book-shadow: none;
  --t-chip-bg: var(--sa-accent-soft);
  --t-selected-bg: var(--sa-accent);
  --t-selected-color: var(--sa-on-accent);
  --t-pill-radius: var(--t-radius);

  --si-body-bg: var(--t-bg);
  --si-body-bg-rgb: var(--t-surface-rgb);
  --si-body-color: var(--t-muted);
  --si-emphasis-color: var(--t-text);
  --si-heading-color: var(--t-text);
  --si-border-color: var(--t-border);
  --si-secondary-rgb: var(--t-surface-rgb);
  --si-light-rgb: var(--t-surface-rgb);
  --si-white-rgb: var(--t-surface-rgb);
  --si-gray-100: color-mix(in srgb, var(--t-text) 6%, var(--t-surface));
  --si-gray-300: var(--t-border);
  --si-gray-400: color-mix(in srgb, var(--t-muted) 55%, var(--t-surface));
  --si-gray-600: var(--t-muted);
  --si-gray-700: var(--t-muted);
  --si-gray-800: var(--t-text);
  --si-gray-900: var(--t-text);
  --si-body-font-family: var(--t-body-font);
  --si-font-sans-serif: var(--t-body-font);
  --si-progress-bg: color-mix(in srgb, var(--t-text) 12%, var(--t-bg));
  background-color: var(--t-bg);
  color: var(--t-muted);
  font-family: var(--t-body-font);
}

/* Text and surface utilities skip the footer: it is SmartAgenda's own dark chrome and keeps the template's
   colours. :where() keeps each selector's specificity what it was without the exclusion. */
:where(.sa-themed) :is(h1, h2, h3, h4, h5, h6):not(.footer *),
:where(.sa-themed) :is(.h1, .h2, .h3, .h4, .h5, .h6):not(.footer *) {
  font-family: var(--t-body-font);
  color: var(--t-text);
}

:where(.sa-themed) .text-muted:not(.footer *) { color: var(--t-muted) !important; }
:where(.sa-themed) .text-body:not(.footer *) { color: var(--t-text) !important; }
:where(.sa-themed) strong:not(.footer *),
:where(.sa-themed) :is(.fw-medium, .fw-semibold):not(.footer *) { color: var(--t-text); }
:where(.sa-themed) .text-primary:not(.footer *) { color: var(--sa-accent-text) !important; }
:where(.sa-themed) :is(.bg-secondary, .bg-light, .bg-white):not(.footer *) { background-color: var(--t-surface) !important; }
:where(.sa-themed) hr:not(.footer *) { border-color: var(--t-border); opacity: 1; }

/* Booking header: the business's photo and name, styled with the theme. */
.sa-themed .sa-business-header.navbar {
  background-color: var(--t-header-bg, var(--t-surface));
  border-bottom: var(--t-top-border, 1px solid var(--t-border));
}
.sa-themed .sa-business-header .navbar-brand { color: var(--t-text); min-width: 0; }
.sa-themed .header .container { flex-wrap: nowrap; }
.sa-themed .sa-brand-name {
  font-family: var(--t-head-font);
  font-weight: var(--t-head-weight);
  text-transform: var(--t-name-transform);
  letter-spacing: var(--t-name-spacing);
  font-size: 1.125rem;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* SmartAgenda's own chrome (the logo header on the cancel page, the footer) keeps the template's font and colours
   in every theme. The header is white, or the footer's navy in dark themes. */
.sa-themed {
  --sa-chrome-font: "Manrope", sans-serif;
  --sa-chrome-bg: #FFFFFF;
  --sa-chrome-text: #0B0F19;
  --sa-chrome-border: #E2E5F1;
}
.sa-themed[data-bs-theme="dark"] {
  --sa-chrome-bg: #0B0F19;
  --sa-chrome-text: #FFFFFF;
  --sa-chrome-border: rgba(255, 255, 255, 0.14);
}
.sa-themed .sa-chrome-header.navbar {
  --si-navbar-stuck-bg: var(--sa-chrome-bg);
  background-color: var(--sa-chrome-bg);
  border-bottom: 1px solid var(--sa-chrome-border);
  font-family: var(--sa-chrome-font);
}
.sa-themed .sa-chrome-header .navbar-brand { color: var(--sa-chrome-text); }
.sa-themed .footer {
  --si-body-font-family: var(--sa-chrome-font);
  --si-font-sans-serif: var(--sa-chrome-font);
  font-family: var(--sa-chrome-font);
}

/* Buttons */
:where(.sa-themed) .btn:not(.footer *) {
  border-radius: var(--t-btn-radius);
  text-transform: var(--t-btn-transform);
  letter-spacing: var(--t-btn-spacing);
}
.sa-themed .btn-primary:not(.btn-sm) { font-size: var(--t-btn-size); }
.sa-themed .btn-outline-secondary {
  --si-btn-color: var(--t-icon-color);
  --si-btn-bg: var(--t-icon-bg);
  --si-btn-border-color: var(--t-border);
  --si-btn-hover-color: var(--sa-on-accent);
  --si-btn-hover-bg: var(--sa-accent);
  --si-btn-hover-border-color: var(--sa-accent);
  --si-btn-active-color: var(--sa-on-accent);
  --si-btn-active-bg: var(--sa-accent);
  --si-btn-active-border-color: var(--sa-accent);
  border: var(--t-icon-border);
}
.sa-themed .btn-icon.btn-outline-secondary { border-radius: var(--t-icon-radius) !important; }
.sa-themed .btn-outline-primary {
  --si-btn-border-color: var(--sa-accent-text);
  border-radius: var(--t-btn-radius);
}

/* Cards, accordions, lists */
.sa-themed .card {
  --si-card-bg: var(--t-surface);
  --si-card-border-color: var(--t-border);
  --si-card-border-radius: var(--t-radius);
  --si-card-inner-border-radius: var(--t-radius);
  background-color: var(--t-surface);
  border: var(--t-card-border) !important;
  border-radius: var(--t-radius) !important;
  box-shadow: var(--t-card-shadow) !important;
}
.sa-themed .card .card { box-shadow: none !important; }
.sa-themed .accordion:not([data-bs-theme=light]) {
  --si-accordion-bg: var(--t-surface);
  --si-accordion-btn-bg: var(--t-surface);
  --si-accordion-active-bg: var(--t-surface);
  --si-accordion-btn-color: var(--t-text);
  --si-accordion-active-color: var(--t-text);
  --si-accordion-btn-icon-box-bg: color-mix(in srgb, var(--t-text) 6%, var(--t-surface));
  --si-accordion-btn-icon-box-border-radius: var(--t-icon-radius);
  --si-accordion-btn-icon-box-active-shadow: none;
}
.sa-themed .accordion-item {
  border: var(--t-card-border) !important;
  border-radius: var(--t-radius) !important;
  box-shadow: var(--t-card-shadow) !important;
  overflow: hidden;
}
.sa-themed .accordion-button { border-radius: var(--t-radius) !important; }
.sa-themed .accordion-button:not(.collapsed) { border-radius: var(--t-radius) var(--t-radius) 0 0 !important; }
.sa-themed .accordion-body .card { border: 1px solid var(--t-border) !important; border-radius: calc(var(--t-radius) * 0.6) !important; box-shadow: none !important; }
.sa-themed .list-group-item { border-color: var(--t-border); color: var(--t-text); }
.sa-themed .service-thumbnail { border-radius: calc(var(--t-radius) * 0.5) !important; }

/* Chips (price, duration) */
.sa-themed .sa-chip {
  background-color: var(--t-chip-bg) !important;
  color: var(--sa-accent-text) !important;
  border-radius: var(--t-chip-radius);
  font-weight: 600;
}

/* Profile hero */
.sa-themed .sa-hero {
  background: var(--t-band) !important;
  border-bottom: var(--t-band-border, none);
}
.sa-themed .sa-hero-fade {
  display: var(--t-fade-display) !important;
  background-color: var(--t-bg) !important;
}
.sa-themed .sa-hero-card {
  background: var(--t-hero-bg) !important;
  box-shadow: var(--t-hero-shadow) !important;
  border: 0 !important;
  border-radius: var(--t-radius) !important;
  padding: var(--t-hero-padding);
  color: var(--t-hero-muted);
}
.sa-themed .sa-avatar {
  width: var(--t-avatar-size) !important;
  height: var(--t-avatar-size) !important;
  border-radius: var(--t-avatar-radius) !important;
  border: var(--t-avatar-border, 0);
}
.sa-themed .sa-name {
  font-family: var(--t-head-font);
  font-weight: var(--t-head-weight) !important;
  font-size: var(--t-name-size) !important;
  text-transform: var(--t-name-transform);
  letter-spacing: var(--t-name-spacing);
  line-height: 1.15;
  color: var(--t-hero-text);
  margin: 0.25rem 0 0.75rem !important;
}
.sa-themed .sa-description p { color: var(--t-hero-muted); font-size: 0.9375rem; }
.sa-themed .sa-description a { color: var(--t-hero-link, var(--sa-accent-text)) !important; }
.sa-themed .sa-section-title {
  font-family: var(--t-h2-font);
  font-weight: var(--t-h2-weight);
  font-size: var(--t-h2-size);
  text-transform: var(--t-h2-transform);
  letter-spacing: var(--t-h2-spacing);
  color: var(--t-h2-color);
  margin-bottom: 1rem;
}
.sa-themed .sa-book .btn-primary {
  --si-btn-bg: var(--t-book-bg);
  --si-btn-border-color: var(--t-book-bg);
  --sa-btn-on: var(--t-book-color);
  --si-btn-hover-color: var(--t-book-color);
  --si-btn-active-color: var(--t-book-color);
  --si-btn-hover-bg: color-mix(in srgb, var(--t-book-bg) 88%, #000);
  --si-btn-hover-border-color: color-mix(in srgb, var(--t-book-bg) 88%, #000);
  box-shadow: var(--t-book-shadow) !important;
}

/* Booking flow */
.sa-themed .progress {
  --si-progress-bg: color-mix(in srgb, var(--t-text) 12%, var(--t-bg));
  --si-progress-bar-bg: var(--sa-accent);
  border-radius: 999px;
}
.sa-themed .service-item.selected {
  border-color: var(--sa-accent) !important;
  box-shadow: inset 4px 0 0 var(--sa-accent) !important;
}
.sa-themed .calendar-day { border-radius: var(--t-pill-radius); }
.sa-themed .calendar-day.selected {
  background-color: var(--t-selected-bg) !important;
  color: var(--t-selected-color) !important;
}
.sa-themed .calendar-day.today:not(.selected) { border-color: color-mix(in srgb, var(--sa-accent) 35%, transparent); }
.sa-themed .time-slot {
  border: var(--t-icon-border);
  border-radius: var(--t-btn-radius);
  background-color: var(--t-surface);
  color: var(--t-text);
  font-weight: 600;
}
.sa-themed .time-slot:hover { border-color: var(--sa-accent); background-color: var(--t-chip-bg); }
.sa-themed .time-slot.selected {
  background-color: var(--t-selected-bg);
  border-color: var(--t-selected-bg);
  color: var(--t-selected-color);
  box-shadow: none;
}
.sa-themed #mobile-summary-bar {
  background-color: var(--t-surface) !important;
  border-top: var(--t-top-border, 1px solid var(--t-border));
  border-radius: min(var(--t-radius), 1.5rem) min(var(--t-radius), 1.5rem) 0 0 !important;
}

/* Forms */
/* :not([data-bs-theme=light]) matches the specificity of the template's dark-mode form and accordion rules. */
.sa-themed :is(.form-control, .form-select):not([data-bs-theme=light]) {
  background-color: var(--t-surface);
  border-color: var(--t-border);
  color: var(--t-text);
  border-radius: min(var(--t-radius), 0.75rem);
}
.sa-themed .form-control:not([data-bs-theme=light])::placeholder { color: var(--t-muted); }
.sa-themed :is(.form-control, .form-select):not([data-bs-theme=light]):focus {
  border-color: var(--sa-accent);
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--sa-accent) 22%, transparent);
}
.sa-themed :is(.form-control, .form-select, .form-check-input).is-invalid:not([data-bs-theme=light]) { border-color: var(--si-form-invalid-border-color); }
.sa-themed :is(.form-control, .form-select).is-invalid:not([data-bs-theme=light]):focus { box-shadow: 0 0 0 3px rgba(var(--si-danger-rgb), 0.25); }
.sa-themed .form-label { color: var(--t-text); }
/* :not() matches the template's own dark-mode rule, (0,3,0), so Luxe gets the theme colours too. */
.sa-themed .alert-info:not([data-bs-theme=light]) {
  --si-alert-bg: var(--t-chip-bg);
  --si-alert-border-color: color-mix(in srgb, var(--sa-accent) 25%, var(--t-surface));
  --si-alert-color: var(--t-text);
}
.sa-themed .alert-info .bx { color: var(--sa-accent-text); }
.sa-themed .alert { border-radius: min(var(--t-radius), 1rem); }
/* Status alerts keep their tinted box but use the theme's text colour: the template's tinted text is under 4.5:1. */
.sa-themed :is(.alert-warning, .alert-success, .alert-danger):not([data-bs-theme=light]) { --si-alert-color: var(--t-text); }
.sa-themed .alert-warning .bx { color: color-mix(in srgb, var(--si-warning) 60%, var(--t-text)); }
.sa-themed .bx.text-warning { color: color-mix(in srgb, var(--si-warning) 50%, var(--t-text)) !important; }

/* Phone country picker (intl-tel-input). On mobile its popup is appended to <body>, outside .iti. */
.sa-themed {
  --iti-dropdown-bg: var(--t-surface);
  --iti-border-color: var(--t-border);
  --iti-hover-color: color-mix(in srgb, var(--t-text) 8%, var(--t-surface));
  --iti-dialcode-color: var(--t-muted);
  --iti-arrow-color: var(--t-muted);
}
.sa-themed .iti__country-name { color: var(--t-text); }
.sa-themed .iti__search-input { background-color: var(--t-surface); color: var(--t-text); }
.sa-themed .iti__search-input::placeholder { color: var(--t-muted); }

/* Page loader. body.sa-themed outranks the base templates' inline [data-bs-theme="dark"] .page-loading rule. */
body.sa-themed .page-loading { background-color: var(--t-bg); }
body.sa-themed .page-spinner { border-color: var(--sa-accent); border-right-color: transparent; }
body.sa-themed .page-loading-inner > span { color: var(--t-muted); opacity: 1; }

/* Dark themes. The template's dark mode hardcodes its own navy (#0b0f19) in a few places. */
body.sa-themed[data-bs-theme="dark"] .bg-light:not(.badge),
body.sa-themed[data-bs-theme="dark"] .bg-secondary:not(.badge):not(.sa-hero-card) { background-color: var(--t-surface) !important; }
body.sa-themed[data-bs-theme="dark"] .sa-hero-fade,
body.sa-themed[data-bs-theme="dark"] main > section > .position-absolute.bg-light { background-color: var(--t-bg) !important; }
body.sa-themed[data-bs-theme="dark"] .d-dark-mode-block { display: none !important; }
body.sa-themed[data-bs-theme="dark"] .sa-business-header { --si-navbar-stuck-bg: var(--t-header-bg, var(--t-surface)); --si-navbar-brand-color: var(--t-text); }
body.sa-themed[data-bs-theme="dark"] .modal { --si-modal-bg: var(--t-surface); }
