/* ============================================================
 * SmartLease Theme Switcher — drop-in UI styles
 * Optional. Skip if you're rendering your own switcher chrome.
 * ============================================================ */

.sl-theme-switcher {
  display: inline-flex;
  align-items: center;
  gap: 2px;
  padding: 6px;
  background: rgba(10, 10, 10, 0.92);
  -webkit-backdrop-filter: blur(8px);
  backdrop-filter: blur(8px);
  border-radius: 10px;
  font-family: var(--sl-font-sans, system-ui, sans-serif);
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.25);
}

.sl-theme-switcher--vertical {
  flex-direction: column;
  align-items: stretch;
}

.sl-theme-switcher__label {
  padding: 6px 10px 6px 12px;
  font-size: 10px;
  font-weight: 800;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: rgba(255, 255, 255, 0.5);
  align-self: center;
}

.sl-theme-switcher__btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 6px 10px;
  background: transparent;
  border: 0;
  border-radius: 7px;
  color: rgba(255, 255, 255, 0.75);
  font: 600 11px/1 var(--sl-font-sans, system-ui, sans-serif);
  cursor: pointer;
  transition: background 120ms ease, color 120ms ease;
}

.sl-theme-switcher__btn:hover:not(.is-active) {
  color: #fff;
  background: rgba(255, 255, 255, 0.06);
}

.sl-theme-switcher__btn.is-active {
  background: rgba(255, 255, 255, 0.12);
  color: #fff;
}

.sl-theme-switcher__swatch {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.25);
  flex: 0 0 auto;
}

.sl-theme-switcher__name {
  white-space: nowrap;
}

/* Floating top-right placement helper — opt in by adding `.sl-theme-switcher--floating` */
.sl-theme-switcher--floating {
  position: fixed;
  top: 16px;
  right: 16px;
  z-index: 60;
}

/* Footer context: slightly more transparent background */
#footer-theme-bar .sl-theme-switcher {
  background: rgba(255, 255, 255, 0.08);
  box-shadow: none;
}

/* Sidebar context: transparent, flush */
#sidebar-theme-bar .sl-theme-switcher,
#sidebar-admin-theme-bar .sl-theme-switcher {
  background: transparent;
  box-shadow: none;
  padding: 2px;
  gap: 1px;
  flex-wrap: wrap;
}
#sidebar-theme-bar .sl-theme-switcher__btn,
#sidebar-admin-theme-bar .sl-theme-switcher__btn {
  padding: 5px 8px;
  font-size: 10px;
}

/* Nav dropdown context (inside a white dropdown) */
#nav-theme-bar .sl-theme-switcher {
  background: transparent;
  box-shadow: none;
  padding: 2px;
  gap: 1px;
}
#nav-theme-bar .sl-theme-switcher__btn {
  color: var(--sl-fg-2, #344054);
  font-size: 11px;
  padding: 6px 10px;
}
#nav-theme-bar .sl-theme-switcher__btn:hover:not(.is-active) {
  color: var(--sl-fg-1, #0f172a);
  background: var(--sl-paper, #f8fafc);
}
#nav-theme-bar .sl-theme-switcher__btn.is-active {
  background: var(--sl-brand-soft, #e8f5ee);
  color: var(--sl-brand, #0a9959);
}

/* ============================================================
 * FLOATING APPEARANCE FAB (public site, citizen portal)
 * Mobile-first. Bottom-right by default with iOS safe-area inset.
 * ============================================================ */

.sl-fab-root {
  position: fixed;
  z-index: 1080;
  font-family: var(--sl-font-sans, system-ui, sans-serif);
}
.sl-fab-bottom-right {
  bottom: calc(20px + env(safe-area-inset-bottom, 0px));
  right: calc(20px + env(safe-area-inset-right, 0px));
}
.sl-fab-bottom-left {
  bottom: calc(20px + env(safe-area-inset-bottom, 0px));
  left: calc(20px + env(safe-area-inset-left, 0px));
}

/* ---- The FAB button itself ---- */
.sl-fab-btn {
  width: 52px;
  height: 52px;
  border-radius: 50%;
  background: var(--sl-brand, #0A2540);
  color: #fff;
  border: 0;
  box-shadow: var(--sl-shadow-lg, 0 10px 24px rgba(33, 28, 18, 0.16));
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  transition: transform 200ms cubic-bezier(0.16, 1, 0.3, 1),
              box-shadow 200ms ease,
              background 200ms ease;
  -webkit-tap-highlight-color: transparent;
}
.sl-fab-btn:hover { transform: scale(1.06); background: var(--sl-brand-hover, #143655); }
.sl-fab-btn:active { transform: scale(0.96); }
.sl-fab-btn:focus-visible {
  outline: 3px solid var(--sl-accent, #00875A);
  outline-offset: 3px;
}
.sl-fab-root.is-open .sl-fab-btn {
  transform: rotate(45deg) scale(1.04);
}

/* ---- Backdrop (mobile only — desktop uses outside click on the fixed panel) ---- */
.sl-fab-backdrop {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(11, 15, 22, 0.34);
  -webkit-backdrop-filter: blur(2px);
  backdrop-filter: blur(2px);
  z-index: -1;
  opacity: 0;
  transition: opacity 200ms ease;
}
.sl-fab-root.is-open .sl-fab-backdrop {
  display: block;
  opacity: 1;
}

/* ---- Panel ---- */
.sl-fab-panel {
  position: absolute;
  bottom: calc(100% + 12px);
  right: 0;
  width: min(320px, calc(100vw - 32px));
  max-height: calc(100vh - 100px);
  background: var(--sl-paper, #fff);
  color: var(--sl-fg-1, #0B0F16);
  border: 1px solid var(--sl-border, #E6E1D5);
  border-radius: 14px;
  box-shadow: var(--sl-shadow-xl, 0 20px 40px rgba(33, 28, 18, 0.14));
  overflow: hidden;
  opacity: 0;
  transform: translateY(8px) scale(0.98);
  pointer-events: none;
  transition: opacity 180ms cubic-bezier(0.16, 1, 0.3, 1),
              transform 180ms cubic-bezier(0.16, 1, 0.3, 1);
}
.sl-fab-bottom-left .sl-fab-panel { right: auto; left: 0; }

.sl-fab-root.is-open .sl-fab-panel {
  opacity: 1;
  transform: translateY(0) scale(1);
  pointer-events: auto;
}

.sl-fab-panel__header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 16px 12px;
  border-bottom: 1px solid var(--sl-border, #E6E1D5);
}
.sl-fab-panel__title {
  font-size: 13px;
  font-weight: 600;
  letter-spacing: 0.02em;
  color: var(--sl-fg-1, #0B0F16);
}
.sl-fab-panel__close {
  width: 32px;
  height: 32px;
  border-radius: 8px;
  border: 1px solid var(--sl-border, #E6E1D5);
  background: transparent;
  color: var(--sl-fg-3, #5C6478);
  cursor: pointer;
  font-size: 18px;
  line-height: 1;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  transition: background 120ms ease, color 120ms ease;
}
.sl-fab-panel__close:hover {
  background: var(--sl-warm-bg, #F4F1E8);
  color: var(--sl-fg-1, #0B0F16);
}

.sl-fab-panel__body {
  padding: 14px 16px 16px;
  max-height: calc(100vh - 220px);
  overflow-y: auto;
}

.sl-fab-section + .sl-fab-section { margin-top: 16px; }
.sl-fab-section__label {
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--sl-fg-3, #5C6478);
  margin-bottom: 8px;
}

.sl-fab-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 6px;
}

.sl-fab-theme {
  display: flex;
  align-items: center;
  gap: 8px;
  min-height: 44px; /* tap target */
  padding: 8px 10px;
  border: 1.5px solid var(--sl-border, #E6E1D5);
  border-radius: 10px;
  background: transparent;
  color: var(--sl-fg-2, #2D3748);
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
  text-align: left;
  transition: border-color 120ms ease, background 120ms ease, color 120ms ease;
  -webkit-tap-highlight-color: transparent;
}
.sl-fab-theme:hover {
  border-color: var(--sl-fg-3, #5C6478);
  background: var(--sl-warm-bg, #F4F1E8);
}
.sl-fab-theme.is-active {
  border-color: var(--sl-brand, #0A2540);
  background: var(--sl-brand-soft, #E5F4EE);
  color: var(--sl-brand, #0A2540);
}
.sl-fab-theme__swatch {
  width: 14px;
  height: 14px;
  border-radius: 50%;
  flex: 0 0 auto;
  box-shadow: inset 0 0 0 1px rgba(0, 0, 0, 0.08);
}
.sl-fab-theme__name {
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.sl-fab-modes {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 6px;
}
.sl-fab-mode {
  min-height: 44px;
  padding: 8px 10px;
  border: 1.5px solid var(--sl-border, #E6E1D5);
  border-radius: 10px;
  background: transparent;
  color: var(--sl-fg-2, #2D3748);
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
  transition: border-color 120ms ease, background 120ms ease, color 120ms ease;
  -webkit-tap-highlight-color: transparent;
}
.sl-fab-mode:hover {
  border-color: var(--sl-fg-3, #5C6478);
  background: var(--sl-warm-bg, #F4F1E8);
}
.sl-fab-mode.is-active {
  border-color: var(--sl-brand, #0A2540);
  background: var(--sl-brand-soft, #E5F4EE);
  color: var(--sl-brand, #0A2540);
}

/* ---- Mobile (< 480px): full-bleed panel ---- */
@media (max-width: 479px) {
  .sl-fab-bottom-right { bottom: calc(16px + env(safe-area-inset-bottom, 0px)); right: 16px; }
  .sl-fab-bottom-left  { bottom: calc(16px + env(safe-area-inset-bottom, 0px)); left: 16px; }
  .sl-fab-btn { width: 48px; height: 48px; }
  .sl-fab-panel {
    width: calc(100vw - 24px);
    right: -4px;
    bottom: calc(100% + 10px);
  }
  .sl-fab-bottom-left .sl-fab-panel { right: auto; left: -4px; }
}

/* ---- Daylight + dark-mode contrast tweaks ---- */
[data-mode="dark"] .sl-fab-panel {
  background: var(--sl-paper);
  color: var(--sl-fg-1);
  border-color: var(--sl-border);
}

/* Daylight: sidebar switcher needs dark text since sidebar is white */
[data-theme="daylight"] #sidebar-admin-theme-bar .sl-theme-switcher__btn,
[data-theme="daylight"] #sidebar-theme-bar .sl-theme-switcher__btn {
  color: var(--sl-fg-2);
}
[data-theme="daylight"] #sidebar-admin-theme-bar .sl-theme-switcher__btn:hover:not(.is-active),
[data-theme="daylight"] #sidebar-theme-bar .sl-theme-switcher__btn:hover:not(.is-active) {
  color: var(--sl-brand);
  background: var(--sl-brand-soft);
}
[data-theme="daylight"] #sidebar-admin-theme-bar .sl-theme-switcher__btn.is-active,
[data-theme="daylight"] #sidebar-theme-bar .sl-theme-switcher__btn.is-active {
  background: var(--sl-brand-soft);
  color: var(--sl-brand);
}

