/*
 * TARS - tema (light/dark)
 * Usa o suporte nativo de cores do Bootstrap 5.3 via [data-bs-theme].
 * Ajustes adicionais para utilities legadas (bg-white, bg-light, text-dark)
 * que nao trocam automaticamente entre temas.
 */

:root {
    --tars-body-bg: #f8f9fa;
    --tars-surface-bg: #ffffff;
    --tars-surface-shadow: rgba(0, 0, 0, 0.08);
    --tars-brand-color: #0d6efd;
}

[data-bs-theme="dark"] {
    --tars-body-bg: #15181d;
    --tars-surface-bg: #1f242c;
    --tars-surface-shadow: rgba(0, 0, 0, 0.45);
    --tars-brand-color: #4d9bff;
}

body {
    background-color: var(--tars-body-bg);
}

.brand {
    color: var(--tars-brand-color);
}

.auth-card {
    background: var(--tars-surface-bg);
    box-shadow: 0 2px 20px var(--tars-surface-shadow);
    color: var(--bs-body-color);
}

/* --- Ajustes para classes Bootstrap que nao sao theme-aware nativamente --- */

[data-bs-theme="dark"] .bg-white {
    background-color: var(--bs-body-bg) !important;
    color: var(--bs-body-color);
}

[data-bs-theme="dark"] .bg-light {
    background-color: var(--bs-tertiary-bg) !important;
    color: var(--bs-body-color);
}

[data-bs-theme="dark"] .text-dark {
    color: var(--bs-body-color) !important;
}

[data-bs-theme="dark"] .text-black {
    color: var(--bs-body-color) !important;
}

[data-bs-theme="dark"] .border-light {
    border-color: var(--bs-border-color) !important;
}

/* Tabelas: em dark, deixa o table-light ficar coerente com o tema */
[data-bs-theme="dark"] .table-light,
[data-bs-theme="dark"] .table-light > th,
[data-bs-theme="dark"] .table-light > td {
    --bs-table-bg: var(--bs-tertiary-bg);
    --bs-table-color: var(--bs-body-color);
    --bs-table-border-color: var(--bs-border-color);
    color: var(--bs-body-color);
}

/* Em dark, table-success/table-info usam tons sutis coerentes com o tema */
[data-bs-theme="dark"] .table-success,
[data-bs-theme="dark"] .table-success > th,
[data-bs-theme="dark"] .table-success > td {
    --bs-table-color: var(--bs-success-text-emphasis);
    --bs-table-bg: var(--bs-success-bg-subtle);
    --bs-table-border-color: var(--bs-success-border-subtle);
    --bs-table-striped-bg: var(--bs-success-bg-subtle);
    --bs-table-striped-color: var(--bs-success-text-emphasis);
    --bs-table-active-bg: var(--bs-success-bg-subtle);
    --bs-table-active-color: var(--bs-success-text-emphasis);
    --bs-table-hover-bg: var(--bs-success-bg-subtle);
    --bs-table-hover-color: var(--bs-success-text-emphasis);
    color: var(--bs-success-text-emphasis);
}

[data-bs-theme="dark"] .table-info,
[data-bs-theme="dark"] .table-info > th,
[data-bs-theme="dark"] .table-info > td {
    --bs-table-color: var(--bs-info-text-emphasis);
    --bs-table-bg: var(--bs-info-bg-subtle);
    --bs-table-border-color: var(--bs-info-border-subtle);
    --bs-table-striped-bg: var(--bs-info-bg-subtle);
    --bs-table-striped-color: var(--bs-info-text-emphasis);
    --bs-table-active-bg: var(--bs-info-bg-subtle);
    --bs-table-active-color: var(--bs-info-text-emphasis);
    --bs-table-hover-bg: var(--bs-info-bg-subtle);
    --bs-table-hover-color: var(--bs-info-text-emphasis);
    color: var(--bs-info-text-emphasis);
}

/* Badges com bg-warning/text-dark continuam legiveis em dark */
[data-bs-theme="dark"] .bg-warning.text-dark,
[data-bs-theme="dark"] .badge.bg-warning {
    color: #1f1300 !important;
}

/* Botao de toggle de tema */
.theme-toggle-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 0.25rem 0.5rem;
    line-height: 1;
}

.theme-toggle-btn svg {
    width: 1rem;
    height: 1rem;
}

.theme-toggle-btn .icon-dark { display: none; }
[data-bs-theme="dark"] .theme-toggle-btn .icon-light { display: none; }
[data-bs-theme="dark"] .theme-toggle-btn .icon-dark { display: inline-block; }

/* --- Quill editor em dark mode --- */
[data-bs-theme="dark"] .ql-toolbar.ql-snow,
[data-bs-theme="dark"] .ql-container.ql-snow {
    border-color: var(--bs-border-color);
}

[data-bs-theme="dark"] .ql-toolbar.ql-snow {
    background-color: var(--bs-tertiary-bg);
}

[data-bs-theme="dark"] .ql-container.ql-snow,
[data-bs-theme="dark"] .ql-editor {
    background-color: var(--bs-body-bg);
    color: var(--bs-body-color);
}

[data-bs-theme="dark"] .ql-snow .ql-stroke {
    stroke: var(--bs-body-color);
}

[data-bs-theme="dark"] .ql-snow .ql-fill,
[data-bs-theme="dark"] .ql-snow .ql-picker-label {
    fill: var(--bs-body-color);
    color: var(--bs-body-color);
}

[data-bs-theme="dark"] .ql-snow .ql-picker-options {
    background-color: var(--bs-tertiary-bg);
    color: var(--bs-body-color);
    border-color: var(--bs-border-color);
}

[data-bs-theme="dark"] .ql-editor.ql-blank::before {
    color: var(--bs-secondary-color);
}
