

:root {
  --bg: #0f1117;
  --card-bg: #171b26;
  --text: #f1f1f1;
  --muted-text: #a7a7a7;
  --border: #2a2f3a;
  --primary: #4f7cff;
  --danger: #ff4f4f;
  --success: #38d27a;
  --surface: #1e2332;
  --surface-muted: #252b3b;
}

:root[data-theme="light"],
:root[data-bs-theme="light"] {
  --bg: #f6f7fb;
  --card-bg: #ffffff;
  --text: #101318;
  --muted-text: #666;
  --border: #e1e3ea;
  --primary: #2a61ff;
  --danger: #d62828;
  --success: #1c9c55;
  --surface: #f3f4f8;
  --surface-muted: #f8f9fc;
  --bs-body-bg: #f6f7fb;
  --bs-body-color: #1b1f2a;
  --bs-border-color: #d7dbe3;
  --bs-tertiary-bg: #ffffff;
  --bs-secondary-bg: #eef1f6;
}

body {
  background: var(--bg) !important;
  color: var(--text) !important;
}

:root {
  --scrollbar-thumb: rgba(255, 255, 255, 0.22);
  --scrollbar-thumb-hover: rgba(255, 255, 255, 0.4);
}
:root[data-theme="light"],
:root[data-bs-theme="light"] {
  --scrollbar-thumb: rgba(31, 41, 55, 0.32);
  --scrollbar-thumb-hover: rgba(31, 41, 55, 0.5);
}

html,
body,
* {
  scrollbar-width: thin;
  scrollbar-color: var(--scrollbar-thumb) transparent;
}

html::-webkit-scrollbar,
body::-webkit-scrollbar,
*::-webkit-scrollbar {
  width: 8px;
  height: 8px;
}
html::-webkit-scrollbar-track,
body::-webkit-scrollbar-track,
*::-webkit-scrollbar-track {
  background: transparent;
}
html::-webkit-scrollbar-thumb,
body::-webkit-scrollbar-thumb,
*::-webkit-scrollbar-thumb {
  background: var(--scrollbar-thumb);
  border-radius: 999px;
}
html::-webkit-scrollbar-thumb:hover,
body::-webkit-scrollbar-thumb:hover,
*::-webkit-scrollbar-thumb:hover {
  background: var(--scrollbar-thumb-hover);
}
html::-webkit-scrollbar-corner,
body::-webkit-scrollbar-corner,
*::-webkit-scrollbar-corner {
  background: transparent;
}

.card,
.table,
.modal-content,
.dropdown-menu {
  background: var(--card-bg) !important;
  color: var(--text) !important;
  border-color: var(--border) !important;
}

.table th,
.table td {
  border-color: var(--border) !important;
}

.text-muted {
  color: var(--muted-text) !important;
}

.btn.btn-primary,
.btn.btn-success,
.btn.btn-danger,
.btn.btn-info,
button.btn-primary,
button.btn-success,
button.btn-danger,
button.btn-info,
a.btn-primary,
a.btn-success,
a.btn-danger,
a.btn-info {
  --bs-btn-color: #ffffff !important;
  --bs-btn-hover-color: #ffffff !important;
  --bs-btn-active-color: #ffffff !important;
  --bs-btn-disabled-color: #ffffff !important;
  color: #ffffff !important;
}

.btn.btn-primary *,
.btn.btn-success *,
.btn.btn-danger *,
.btn.btn-info *,
button.btn-primary *,
button.btn-success *,
button.btn-danger *,
button.btn-info * {
  color: inherit !important;
}

.btn-primary {
  background: var(--primary) !important;
  border-color: var(--primary) !important;
}

.btn-danger {
  background: var(--danger) !important;
  border-color: var(--danger) !important;
}

.btn-success {
  background: var(--success) !important;
  border-color: var(--success) !important;
}

.btn.btn-warning,
button.btn-warning,
a.btn-warning {
  --bs-btn-color: #1b1f2a !important;
  --bs-btn-hover-color: #1b1f2a !important;
  --bs-btn-active-color: #1b1f2a !important;
  color: #1b1f2a !important;
}

.badge.bg-primary,
.badge.bg-success,
.badge.bg-danger,
.badge.bg-info,
.badge.bg-secondary,
.badge.bg-dark,
span.badge.bg-primary,
span.badge.bg-success,
span.badge.bg-danger,
span.badge.bg-info,
span.badge.bg-secondary,
span.badge.bg-dark {
  color: #ffffff !important;
}
.badge.bg-warning,
span.badge.bg-warning {
  color: #1b1f2a !important;
}

:root[data-theme="light"] .btn-outline-light,
:root[data-bs-theme="light"] .btn-outline-light {
  color: #1b1f2a !important;
  border-color: #c8cdd6 !important;
  background: #ffffff !important;
}
:root[data-theme="light"] .btn-outline-light:hover,
:root[data-theme="light"] .btn-outline-light:focus,
:root[data-bs-theme="light"] .btn-outline-light:hover,
:root[data-bs-theme="light"] .btn-outline-light:focus {
  background: #eef2f7 !important;
  color: #12161f !important;
}
:root[data-theme="light"] .btn-outline-secondary,
:root[data-theme="light"] .btn-outline-primary,
:root[data-theme="light"] .btn-outline-success,
:root[data-theme="light"] .btn-outline-warning,
:root[data-theme="light"] .btn-outline-info,
:root[data-theme="light"] .btn-outline-danger,
:root[data-bs-theme="light"] .btn-outline-secondary,
:root[data-bs-theme="light"] .btn-outline-primary,
:root[data-bs-theme="light"] .btn-outline-success,
:root[data-bs-theme="light"] .btn-outline-warning,
:root[data-bs-theme="light"] .btn-outline-info,
:root[data-bs-theme="light"] .btn-outline-danger {
  background: #f5f7fb !important;
}
:root[data-theme="light"] .btn-outline-primary,
:root[data-bs-theme="light"] .btn-outline-primary {
  color: #1d4ed8 !important;
  border-color: #7aa7ff !important;
  background: rgba(42, 97, 255, 0.12) !important;
}
:root[data-theme="light"] .btn-outline-success,
:root[data-bs-theme="light"] .btn-outline-success {
  color: #166534 !important;
  border-color: #7ed7a4 !important;
  background: rgba(34, 197, 94, 0.12) !important;
}
:root[data-theme="light"] .btn-outline-warning,
:root[data-bs-theme="light"] .btn-outline-warning {
  color: #92400e !important;
  border-color: #f5c26b !important;
  background: rgba(245, 158, 11, 0.16) !important;
}
:root[data-theme="light"] .btn-outline-info,
:root[data-bs-theme="light"] .btn-outline-info {
  color: #0e7490 !important;
  border-color: #7cd3ea !important;
  background: rgba(14, 116, 144, 0.12) !important;
}
:root[data-theme="light"] .btn-outline-danger,
:root[data-bs-theme="light"] .btn-outline-danger {
  color: #b91c1c !important;
  border-color: #f39aa0 !important;
  background: rgba(239, 68, 68, 0.12) !important;
}
:root[data-theme="light"] .btn-outline-secondary,
:root[data-bs-theme="light"] .btn-outline-secondary {
  color: #334155 !important;
  border-color: #cbd5e1 !important;
  background: rgba(148, 163, 184, 0.18) !important;
}
:root[data-theme="light"] .btn-outline-secondary:hover,
:root[data-theme="light"] .btn-outline-primary:hover,
:root[data-theme="light"] .btn-outline-success:hover,
:root[data-theme="light"] .btn-outline-warning:hover,
:root[data-theme="light"] .btn-outline-info:hover,
:root[data-theme="light"] .btn-outline-danger:hover,
:root[data-theme="light"] .btn-outline-secondary:focus,
:root[data-theme="light"] .btn-outline-primary:focus,
:root[data-theme="light"] .btn-outline-success:focus,
:root[data-theme="light"] .btn-outline-warning:focus,
:root[data-theme="light"] .btn-outline-info:focus,
:root[data-theme="light"] .btn-outline-danger:focus,
:root[data-bs-theme="light"] .btn-outline-secondary:hover,
:root[data-bs-theme="light"] .btn-outline-primary:hover,
:root[data-bs-theme="light"] .btn-outline-success:hover,
:root[data-bs-theme="light"] .btn-outline-warning:hover,
:root[data-bs-theme="light"] .btn-outline-info:hover,
:root[data-bs-theme="light"] .btn-outline-danger:hover,
:root[data-bs-theme="light"] .btn-outline-secondary:focus,
:root[data-bs-theme="light"] .btn-outline-primary:focus,
:root[data-bs-theme="light"] .btn-outline-success:focus,
:root[data-bs-theme="light"] .btn-outline-warning:focus,
:root[data-bs-theme="light"] .btn-outline-info:focus,
:root[data-bs-theme="light"] .btn-outline-danger:focus {
  filter: brightness(0.97);
}

input:not([type="checkbox"]):not([type="radio"]),
select,
textarea {
  background: var(--card-bg) !important;
  color: var(--text) !important;
  border-color: var(--border) !important;
}

:root[data-theme="light"] .form-select,
:root[data-theme="light"] .form-control,
:root[data-theme="light"] .input-group-text,
:root[data-bs-theme="light"] .form-select,
:root[data-bs-theme="light"] .form-control,
:root[data-bs-theme="light"] .input-group-text {
  background: #ffffff !important;
  color: #111827 !important;
  border-color: #cfd6e0 !important;
}
:root[data-theme="light"] .form-select:hover,
:root[data-theme="light"] .form-control:hover,
:root[data-theme="light"] .input-group-text:hover,
:root[data-bs-theme="light"] .form-select:hover,
:root[data-bs-theme="light"] .form-control:hover,
:root[data-bs-theme="light"] .input-group-text:hover {
  border-color: #b6c1d1 !important;
}
:root[data-theme="light"] .form-select:focus,
:root[data-theme="light"] .form-control:focus,
:root[data-theme="light"] input:not([type="checkbox"]):not([type="radio"]):focus,
:root[data-theme="light"] select:focus,
:root[data-theme="light"] textarea:focus,
:root[data-bs-theme="light"] .form-select:focus,
:root[data-bs-theme="light"] .form-control:focus,
:root[data-bs-theme="light"] input:not([type="checkbox"]):not([type="radio"]):focus,
:root[data-bs-theme="light"] select:focus,
:root[data-bs-theme="light"] textarea:focus {
  border-color: #7aa7ff !important;
  box-shadow: 0 0 0 0.2rem rgba(42, 97, 255, 0.18) !important;
  background: #ffffff !important;
  color: #0b1020 !important;
}

:root[data-theme="light"] .input-group .form-control,
:root[data-theme="light"] .input-group .form-control:focus,
:root[data-theme="light"] input[type="search"],
:root[data-theme="light"] input[type="search"]:focus,
:root[data-bs-theme="light"] .input-group .form-control,
:root[data-bs-theme="light"] .input-group .form-control:focus,
:root[data-bs-theme="light"] input[type="search"],
:root[data-bs-theme="light"] input[type="search"]:focus {
  background: #ffffff !important;
  color: #0b1020 !important;
  -webkit-appearance: none;
  appearance: none;
}

:root[data-theme="light"] input[type="search"]::placeholder,
:root[data-bs-theme="light"] input[type="search"]::placeholder {
  color: #9aa3af;
}

:root[data-theme="light"] .table,
:root[data-bs-theme="light"] .table {
  --bs-table-bg: #ffffff;
  --bs-table-striped-bg: #f6f8fc;
  --bs-table-hover-bg: #eef2f7;
}

/* Escopado ao header legado do dashboard/base.html: sem o escopo a regra
   vazava pra qualquer <header> — botões React text-white sobre bg-primary
   (ex.: "Registrar venda" no admin de parcerias) ficavam ilegíveis (L81). */
:root[data-theme="light"] header.dash-legacy-header .text-white,
:root[data-bs-theme="light"] header.dash-legacy-header .text-white {
  color: #1f2937 !important;
}

@keyframes theme-circle-transition {
  0% {
    clip-path: circle(0% at var(--theme-switch-x, 50%) var(--theme-switch-y, 50%));
  }
  100% {
    clip-path: circle(150% at var(--theme-switch-x, 50%) var(--theme-switch-y, 50%));
  }
}

html.theme-transition {
  view-transition-name: theme;
}

html.theme-transition::view-transition-group(theme),
html.theme-transition::view-transition-image-pair(theme) {
  animation: none;
}

html.theme-transition::view-transition-new(theme) {
  z-index: 2;
  animation: theme-circle-transition 0.4s ease-out forwards;
}

html.theme-transition::view-transition-old(theme) {
  z-index: 1;
  animation: none;
  opacity: 1;
}

.theme-toggle {
  --theme-gap: 6px;
  --theme-item: 34px;
  --theme-index: 0;
  display: inline-flex;
}

.theme-toggle__track {
  position: relative;
  display: inline-flex;
  align-items: center;
  gap: var(--theme-gap);
  padding: 4px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.08);
  border: 1px solid rgba(255, 255, 255, 0.18);
}

:root[data-theme="light"] .theme-toggle__track,
:root[data-bs-theme="light"] .theme-toggle__track {
  background: rgba(0, 0, 0, 0.05);
  border-color: rgba(0, 0, 0, 0.08);
}

.theme-toggle__indicator {
  position: absolute;
  top: 50%;
  left: 4px;
  width: var(--theme-item);
  height: var(--theme-item);
  border-radius: 999px;
  transform: translateY(-50%) translateX(calc(var(--theme-index) * (var(--theme-item) + var(--theme-gap))));
  background: rgba(56, 189, 248, 0.25);
  border: 1px solid rgba(56, 189, 248, 0.45);
  transition: transform 0.3s ease;
  z-index: 0;
}

.theme-toggle__button {
  position: relative;
  z-index: 1;
  width: var(--theme-item);
  height: var(--theme-item);
  border-radius: 999px;
  border: none;
  background: transparent;
  color: #f8fafc;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 0.9rem;
  cursor: pointer;
  transition: color 0.2s ease;
}

:root[data-theme="light"] .theme-toggle__button,
:root[data-bs-theme="light"] .theme-toggle__button {
  color: #1f2937;
}

.theme-toggle__button.active {
  color: #f8fafc;
}

:root[data-theme="light"] .theme-toggle__button.active,
:root[data-bs-theme="light"] .theme-toggle__button.active {
  color: #111827;
}
