/* Tema visual adicional. O modo claro continua a usar integralmente os estilos existentes. */
:root {
    color-scheme: light;
}

.theme-toggle {
    align-items: center;
    background: transparent;
    border: 1px solid #d7dce2;
    border-radius: 999px;
    color: #4b5563;
    cursor: pointer;
    display: inline-flex;
    font: inherit;
    font-weight: 500;
    gap: 0.45rem;
    justify-content: center;
    line-height: 1;
    min-height: 40px;
    padding: 0.65rem 0.8rem;
    transition: background-color 0.2s ease, border-color 0.2s ease, color 0.2s ease;
}

.theme-toggle:hover {
    background: #f3f4f6;
    color: #111827;
}

.theme-toggle:focus-visible {
    box-shadow: 0 0 0 3px rgba(200, 159, 86, 0.3);
    outline: 2px solid #c89f56;
    outline-offset: 2px;
}

.theme-toggle--icon {
    font-size: 1.25rem;
    height: 40px;
    margin-right: 0.75rem;
    padding: 0;
    width: 40px;
}

.theme-toggle--labelled {
    font-size: 0.875rem;
    line-height: 1.25rem;
}

.theme-toggle--floating {
    position: fixed;
    right: 1rem;
    top: 1rem;
    z-index: 1050;
}

[data-theme-icon-light] {
    display: none;
}

html[data-theme="dark"] [data-theme-icon-dark] {
    display: none;
}

html[data-theme="dark"] [data-theme-icon-light] {
    display: inline;
}

html[data-theme="dark"] {
    color-scheme: dark;
    --theme-bg: #0b1120;
    --theme-surface: #111827;
    --theme-surface-raised: #182235;
    --theme-surface-hover: #1e293b;
    --theme-border: #334155;
    --theme-text: #dbe4f0;
    --theme-muted: #a7b4c6;
    --iq-title-text: #f8fafc;
    --iq-body-text: #cbd5e1;
    --iq-body-bg: #0b1120;
    --iq-secondary: #b6c1cf;
    --iq-light: #475569;
    --iq-gray: #64748b;
    --iq-light-card: #111827;
    --iq-border-light: #334155;
    --iq-light-primary: #332f28;
    --iq-light-secondary: #273244;
    --iq-light-success: #123b32;
    --iq-light-danger: #432a2a;
    --iq-light-warning: #423a22;
    --iq-light-info: #18364a;
    --iq-light-dark: #263244;
    --iq-light-hover: #1e293b;
}

html[data-theme="dark"] body,
html[data-theme="dark"] .content-page,
html[data-theme="dark"] .theme-auth-page,
html[data-theme="dark"] .theme-app-page,
html[data-theme="dark"] .theme-auth-shell,
html[data-theme="dark"] .theme-app-shell {
    background-color: var(--theme-bg) !important;
    color: var(--theme-text);
}

html[data-theme="dark"] a:not(.btn):not(.badge) {
    color: #ddbb7b;
}

html[data-theme="dark"] a:not(.btn):not(.badge):hover {
    color: #efd39e;
}

html[data-theme="dark"] h1,
html[data-theme="dark"] h2,
html[data-theme="dark"] h3,
html[data-theme="dark"] h4,
html[data-theme="dark"] h5,
html[data-theme="dark"] h6,
html[data-theme="dark"] label,
html[data-theme="dark"] legend,
html[data-theme="dark"] .text-dark,
html[data-theme="dark"] .text-black,
html[data-theme="dark"] .text-gray-900,
html[data-theme="dark"] .text-gray-800,
html[data-theme="dark"] .text-gray-700 {
    color: #f1f5f9 !important;
}

html[data-theme="dark"] .text-gray-600,
html[data-theme="dark"] .text-gray-500,
html[data-theme="dark"] .text-gray-400,
html[data-theme="dark"] .text-muted {
    color: var(--theme-muted) !important;
}

html[data-theme="dark"] .iq-sidebar,
html[data-theme="dark"] .iq-sidebar-logo,
html[data-theme="dark"] .iq-top-navbar,
html[data-theme="dark"] .iq-navbar-custom,
html[data-theme="dark"] .iq-card,
html[data-theme="dark"] .iq-footer,
html[data-theme="dark"] .iq-sub-dropdown,
html[data-theme="dark"] .dropdown-menu,
html[data-theme="dark"] .modal-content,
html[data-theme="dark"] .popover,
html[data-theme="dark"] .card,
html[data-theme="dark"] .list-group-item,
html[data-theme="dark"] .theme-auth-card,
html[data-theme="dark"] .theme-app-header,
html[data-theme="dark"] .theme-secondary-nav,
html[data-theme="dark"] .bg-white {
    background-color: var(--theme-surface) !important;
    color: var(--theme-text);
}

html[data-theme="dark"] .bg-gray-100 {
    background-color: var(--theme-bg) !important;
}

html[data-theme="dark"] .bg-gray-50 {
    background-color: var(--theme-surface-raised) !important;
}

html[data-theme="dark"] .iq-card,
html[data-theme="dark"] .iq-sidebar,
html[data-theme="dark"] .iq-footer,
html[data-theme="dark"] .theme-auth-card,
html[data-theme="dark"] .theme-app-header,
html[data-theme="dark"] .theme-secondary-nav {
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.28);
}

html[data-theme="dark"] .border,
html[data-theme="dark"] .border-top,
html[data-theme="dark"] .border-right,
html[data-theme="dark"] .border-bottom,
html[data-theme="dark"] .border-left,
html[data-theme="dark"] .border-gray-100,
html[data-theme="dark"] .border-gray-200,
html[data-theme="dark"] .border-gray-300,
html[data-theme="dark"] .iq-card-header,
html[data-theme="dark"] .modal-header,
html[data-theme="dark"] .modal-footer,
html[data-theme="dark"] .dropdown-divider,
html[data-theme="dark"] hr {
    border-color: var(--theme-border) !important;
}

html[data-theme="dark"] .theme-toggle {
    background: var(--theme-surface-raised);
    border-color: var(--theme-border);
    color: #f8fafc;
}

html[data-theme="dark"] .theme-toggle:hover {
    background: var(--theme-surface-hover);
    border-color: #64748b;
}

html[data-theme="dark"] .dropdown-item,
html[data-theme="dark"] .iq-sub-card,
html[data-theme="dark"] .nav-link,
html[data-theme="dark"] .list-group-item-action {
    color: var(--theme-text) !important;
}

html[data-theme="dark"] .dropdown-item:hover,
html[data-theme="dark"] .dropdown-item:focus,
html[data-theme="dark"] .iq-sub-card:hover,
html[data-theme="dark"] .list-group-item-action:hover,
html[data-theme="dark"] .list-group-item-action:focus {
    background-color: var(--theme-surface-hover) !important;
    color: #ffffff !important;
}

html[data-theme="dark"] .form-control,
html[data-theme="dark"] .custom-select,
html[data-theme="dark"] .custom-file-label,
html[data-theme="dark"] .input-group-text,
html[data-theme="dark"] input,
html[data-theme="dark"] select,
html[data-theme="dark"] textarea {
    background-color: var(--theme-surface-raised);
    border-color: var(--theme-border);
    color: var(--theme-text);
}

html[data-theme="dark"] .form-control:focus,
html[data-theme="dark"] .custom-select:focus,
html[data-theme="dark"] input:focus,
html[data-theme="dark"] select:focus,
html[data-theme="dark"] textarea:focus {
    background-color: #1c2940;
    border-color: #c89f56;
    box-shadow: 0 0 0 0.2rem rgba(200, 159, 86, 0.18);
    color: #ffffff;
}

html[data-theme="dark"] .form-control:disabled,
html[data-theme="dark"] .form-control[readonly],
html[data-theme="dark"] input:disabled,
html[data-theme="dark"] select:disabled,
html[data-theme="dark"] textarea:disabled {
    background-color: #202b3c;
    color: #94a3b8;
    opacity: 1;
}

html[data-theme="dark"] input::placeholder,
html[data-theme="dark"] textarea::placeholder,
html[data-theme="dark"] .form-control::placeholder {
    color: #94a3b8;
    opacity: 1;
}

html[data-theme="dark"] select option {
    background-color: var(--theme-surface-raised);
    color: var(--theme-text);
}

html[data-theme="dark"] .table {
    color: var(--theme-text);
}

html[data-theme="dark"] .table td,
html[data-theme="dark"] .table th,
html[data-theme="dark"] .table-bordered,
html[data-theme="dark"] .table-bordered td,
html[data-theme="dark"] .table-bordered th,
html[data-theme="dark"] .table thead th {
    border-color: var(--theme-border);
}

html[data-theme="dark"] .table-striped tbody tr:nth-of-type(odd),
html[data-theme="dark"] .table .thead-light th {
    background-color: #162033;
    color: #f8fafc;
}

html[data-theme="dark"] .table-hover tbody tr:hover {
    background-color: var(--theme-surface-hover);
    color: #ffffff;
}

html[data-theme="dark"] .page-link {
    background-color: var(--theme-surface-raised);
    border-color: var(--theme-border);
    color: #ddbb7b;
}

html[data-theme="dark"] .page-link:hover,
html[data-theme="dark"] .page-item.active .page-link {
    background-color: #c89f56;
    border-color: #c89f56;
    color: #111827;
}

html[data-theme="dark"] .page-item.disabled .page-link {
    background-color: #202b3c;
    border-color: var(--theme-border);
    color: #77859a;
}

html[data-theme="dark"] .nav-tabs {
    border-color: var(--theme-border);
}

html[data-theme="dark"] .nav-tabs .nav-link.active,
html[data-theme="dark"] .nav-tabs .nav-item.show .nav-link {
    background-color: var(--theme-surface-raised);
    border-color: var(--theme-border) var(--theme-border) #c89f56;
    color: #efd39e !important;
}

html[data-theme="dark"] .close {
    color: #ffffff;
    opacity: 0.8;
    text-shadow: none;
}

html[data-theme="dark"] .btn-light,
html[data-theme="dark"] .btn-outline-secondary {
    background-color: var(--theme-surface-raised);
    border-color: #64748b;
    color: #f1f5f9;
}

html[data-theme="dark"] .btn-light:hover,
html[data-theme="dark"] .btn-outline-secondary:hover {
    background-color: #334155;
    color: #ffffff;
}

html[data-theme="dark"] .alert {
    background-color: var(--theme-surface-raised) !important;
    border-color: var(--theme-border);
    color: var(--theme-text);
}

html[data-theme="dark"] .alert-danger {
    border-color: #b45353;
    color: #fecaca;
}

html[data-theme="dark"] .alert-success {
    border-color: #2f855a;
    color: #bbf7d0;
}

html[data-theme="dark"] .alert-warning {
    border-color: #a87c24;
    color: #fde68a;
}

html[data-theme="dark"] .alert-info,
html[data-theme="dark"] .alert-primary {
    border-color: #39759b;
    color: #bae6fd;
}

/* Select2 */
html[data-theme="dark"] .select2-container--default .select2-selection--single,
html[data-theme="dark"] .select2-container--default .select2-selection--multiple,
html[data-theme="dark"] .select2-dropdown,
html[data-theme="dark"] .select2-search__field {
    background-color: var(--theme-surface-raised) !important;
    border-color: var(--theme-border) !important;
    color: var(--theme-text) !important;
}

html[data-theme="dark"] .select2-container--default .select2-selection--single .select2-selection__rendered,
html[data-theme="dark"] .select2-container--default .select2-selection--multiple .select2-selection__choice,
html[data-theme="dark"] .select2-results__option {
    color: var(--theme-text);
}

html[data-theme="dark"] .select2-container--default .select2-selection--multiple .select2-selection__choice {
    background-color: #273449;
    border-color: #52637a;
}

html[data-theme="dark"] .select2-container--default .select2-results__option--selected {
    background-color: #334155;
}

html[data-theme="dark"] .select2-container--default .select2-results__option--highlighted[aria-selected] {
    background-color: #8d713d;
    color: #ffffff;
}

/* Tom Select */
html[data-theme="dark"] .ts-control,
html[data-theme="dark"] .ts-wrapper.single.input-active .ts-control,
html[data-theme="dark"] .ts-dropdown,
html[data-theme="dark"] .ts-dropdown .dropdown-input {
    background-color: var(--theme-surface-raised);
    border-color: var(--theme-border);
    color: var(--theme-text);
}

html[data-theme="dark"] .ts-dropdown .option,
html[data-theme="dark"] .ts-dropdown .create {
    color: var(--theme-text);
}

html[data-theme="dark"] .ts-dropdown .active {
    background-color: var(--theme-surface-hover);
    color: #ffffff;
}

html[data-theme="dark"] .ts-wrapper.multi .ts-control > div {
    background-color: #334155;
    color: #f8fafc;
}

/* Flatpickr */
html[data-theme="dark"] .flatpickr-calendar,
html[data-theme="dark"] .flatpickr-months .flatpickr-month,
html[data-theme="dark"] .flatpickr-current-month .flatpickr-monthDropdown-months,
html[data-theme="dark"] .flatpickr-current-month .flatpickr-monthDropdown-months .flatpickr-monthDropdown-month,
html[data-theme="dark"] .flatpickr-time input,
html[data-theme="dark"] .flatpickr-time .flatpickr-am-pm {
    background: var(--theme-surface-raised);
    color: var(--theme-text);
}

html[data-theme="dark"] .flatpickr-calendar.arrowTop::after {
    border-bottom-color: var(--theme-surface-raised);
}

html[data-theme="dark"] .flatpickr-calendar.arrowBottom::after {
    border-top-color: var(--theme-surface-raised);
}

html[data-theme="dark"] .flatpickr-months .flatpickr-prev-month,
html[data-theme="dark"] .flatpickr-months .flatpickr-next-month,
html[data-theme="dark"] span.flatpickr-weekday,
html[data-theme="dark"] .flatpickr-day {
    color: var(--theme-text);
    fill: var(--theme-text);
}

html[data-theme="dark"] .flatpickr-day.prevMonthDay,
html[data-theme="dark"] .flatpickr-day.nextMonthDay,
html[data-theme="dark"] .flatpickr-day.flatpickr-disabled {
    color: #66758a;
}

html[data-theme="dark"] .flatpickr-day:hover,
html[data-theme="dark"] .flatpickr-day:focus {
    background: #334155;
    border-color: #475569;
}

html[data-theme="dark"] .flatpickr-day.selected,
html[data-theme="dark"] .flatpickr-day.startRange,
html[data-theme="dark"] .flatpickr-day.endRange {
    background: #c89f56;
    border-color: #c89f56;
    color: #111827;
}

/* Summernote: a moldura acompanha o tema, mas a folha do contrato permanece branca. */
html[data-theme="dark"] .note-editor.note-frame,
html[data-theme="dark"] .note-editor.note-airframe,
html[data-theme="dark"] .note-toolbar,
html[data-theme="dark"] .note-statusbar,
html[data-theme="dark"] .note-popover .popover-content {
    background-color: var(--theme-surface-raised);
    border-color: var(--theme-border);
    color: var(--theme-text);
}

html[data-theme="dark"] .note-btn {
    background-color: #273449;
    border-color: #475569;
    color: #f8fafc;
}

html[data-theme="dark"] .note-btn:hover,
html[data-theme="dark"] .note-btn:focus,
html[data-theme="dark"] .note-btn.active {
    background-color: #3a4960;
    color: #ffffff;
}

html[data-theme="dark"] .contract-editor-tools {
    background: var(--theme-surface-raised) !important;
    border-color: var(--theme-border) !important;
}

html[data-theme="dark"] .contract-editor-shell .note-editable {
    background: #ffffff !important;
    color: #111111 !important;
    color-scheme: light;
}

html[data-theme="dark"] .contract-editor-shell .note-editable * {
    color: inherit;
}

/* Componentes das páginas Tailwind de autenticação e perfil. */
html[data-theme="dark"] .theme-auth-page input,
html[data-theme="dark"] .theme-app-page input,
html[data-theme="dark"] .theme-app-page select,
html[data-theme="dark"] .theme-app-page textarea {
    --tw-ring-offset-color: var(--theme-surface);
}

html[data-theme="dark"] .theme-secondary-trigger,
html[data-theme="dark"] .theme-secondary-nav button {
    color: var(--theme-text);
}

@media (max-width: 575.98px) {
    .theme-toggle--floating {
        right: 0.75rem;
        top: 0.75rem;
    }

    .theme-toggle--floating [data-theme-label] {
        display: none;
    }
}

@media (prefers-reduced-motion: reduce) {
    .theme-toggle {
        transition: none;
    }
}

@media print {
    html[data-theme="dark"] {
        color-scheme: light;
    }

    html[data-theme="dark"] body,
    html[data-theme="dark"] .content-page,
    html[data-theme="dark"] .iq-card,
    html[data-theme="dark"] .table,
    html[data-theme="dark"] .table td,
    html[data-theme="dark"] .table th {
        background: #ffffff !important;
        border-color: #d1d5db !important;
        color: #111111 !important;
    }

    .theme-toggle {
        display: none !important;
    }
}
