/* =========================
   VARIÁVEIS DE TEMA
========================= */

:root {
    --bg: #f4f6f9;
    --text: #1e293b;
    --card: #ffffff;
    --primary: #2563eb;
    --border: #e2e8f0;
    --muted: #64748b;
    --surface: #f8fafc;
    --menu-bg: #f8f9fa;
    --menu-text: #1e293b;
    --menu-muted: #64748b;
    --menu-border: #e2e8f0;
}

body.dark {
    --bg: #0f172a;
    --text: #e2e8f0;
    --card: #1e293b;
    --primary: #50ac18;
    --border: #334155;
    --muted: #94a3b8;
    --surface: #111827;
    --menu-bg: #111827;
    --menu-text: #e2e8f0;
    --menu-muted: #94a3b8;
    --menu-border: #334155;
}

body.theme-sunset {
    --bg: #2a0b16;
    --text: #fff5e9;
    --card: #3a1222;
    --primary: #f97316;
    --border: #542038;
    --muted: #f7d7b9;
    --surface: #4a1a2d;
    --menu-bg: #31101d;
    --menu-text: #fff5e9;
    --menu-muted: #f7d7b9;
    --menu-border: #542038;
}

body.theme-sunrise {
    --bg: #fff3e0;
    --text: #4a260b;
    --card: #ffffff;
    --primary: #f59e0b;
    --border: #f2c792;
    --muted: #a16207;
    --surface: #ffe3c4;
    --menu-bg: #fff7ed;
    --menu-text: #4a260b;
    --menu-muted: #a16207;
    --menu-border: #f2c792;
}

/* =========================
   APLICAÇÃO GLOBAL
========================= */

body {
    background: var(--bg);
    color: var(--text);
    transition: 0.3s;
}

.card {
    background: var(--card);
    border: 1px solid var(--border);
}

button {
    background: var(--primary);
    color: #fff;
}

/* Ajustes para classes Bootstrap em modo dark */
body.dark .bg-light {
    background-color: #1e293b !important;
}

body.dark .bg-light-subtle {
    background-color: #0f172a !important;
}

body.dark .bg-white {
    background-color: #1e293b !important;
    color: #f1f5f9 !important;
}

body.dark .bg-body-tertiary {
    background-color: #111827 !important;
}

body.dark .text-dark {
    color: #e2e8f0 !important;
}

body.dark .form-select.bg-white,
body.dark .form-control.bg-white {
    background-color: #0f172a !important;
    color: #f1f5f9 !important;
}

body.dark .bg-primary-subtle,
body.dark .bg-success-subtle,
body.dark .bg-info-subtle,
body.dark .bg-warning-subtle,
body.dark .bg-danger-subtle,
body.dark .bg-secondary-subtle {
    filter: brightness(0.55) saturate(0.9);
}

body.dark .border-bottom {
    border-color: #334155 !important;
}

body.dark .border {
    border-color: #334155 !important;
}

body.dark .text-muted {
    color: #94a3b8 !important;
}

body.dark .text-primary {
    color: #4a9c17 !important;
}

body.dark .text-secondary {
    color: #a78bfa !important;
}

body.dark .text-success {
    color: #34d399 !important;
}

body.dark .text-info {
    color: #38bdf8 !important;
}

body.dark .text-danger {
    color: #f87171 !important;
}

body.dark .text-warning {
    color: #fbbf24 !important;
}

body.dark .text-uppercase {
    color: #94a3b8 !important;
}

body.dark .table {
    color: #f1f5f9;
    border-color: #334155;
}

body.dark .table thead th {
    background-color: #111827;
    color: #e2e8f0;
}

body.dark .table-striped > tbody > tr:nth-of-type(odd) > * {
    background-color: #0b1220;
    color: #e2e8f0;
}

body.dark .table-hover > tbody > tr:hover > * {
    background-color: #1f2937;
    color: #f8fafc;
}

body.dark .table-light {
    background-color: #1e293b;
    color: #e2e8f0;
}

body.dark .table th,
body.dark .table td {
    border-color: #334155;
}

body.dark .form-control,
body.dark .form-select,
body.dark .input-group-text {
    background-color: #0f172a;
    border-color: #334155;
    color: #f1f5f9;
}

body.dark .form-control:focus,
body.dark .form-select:focus {
    background-color: #0f172a;
    border-color: #50ac18;
    color: #f1f5f9;
}

body.dark .form-control::placeholder {
    color: #64748b;
}

body.dark .form-label {
    color: #f1f5f9;
}

body.dark label {
    color: #f1f5f9;
}

body.dark h1, body.dark h2, body.dark h3,
body.dark h4, body.dark h5, body.dark h6 {
    color: #f1f5f9;
}

body.dark .small {
    color: #94a3b8;
}

body.dark p {
    color: #e2e8f0;
}

body.dark .btn-outline-secondary {
    color: #e2e8f0;
    border-color: #334155;
}

body.dark .btn-outline-secondary:hover {
    background-color: #334155;
    border-color: #334155;
    color: #f1f5f9;
}

body.dark .btn-outline-primary {
    border-color: var(--primary);
    color: #4a9c17;
}

body.dark .btn-outline-primary:hover {
    background-color: #4a9c17;
    border-color: #4a9c17;
    color: #f1f5f9;
}

body.dark .btn-success {
    background-color: #10b981;
}

body.dark .btn-success:hover {
    background-color: #059669;
}

body.dark .dropdown-menu {
    background-color: #1e293b;
    border-color: #334155;
}

body.dark .dropdown-menu .dropdown-item {
    color: #f1f5f9;
}

body.dark .dropdown-menu .dropdown-item:hover {
    background-color: #334155;
}

body.dark .progress {
    background-color: #1e293b;
}

body.dark .progress-bar {
    background-color: #4a9c17;
}

body.dark .modal-content {
    background-color: #1e293b;
    border-color: #334155;
}

body.dark .modal-header,
body.dark .modal-footer {
    border-color: #334155;
}

body.dark .modal-title,
body.dark .modal-body {
    color: #f1f5f9;
}

body.dark .close,
body.dark .btn-close {
    color: #f1f5f9;
    filter: brightness(0.8);
}

body.dark .list-group-item {
    background-color: #1e293b;
    border-color: #334155;
    color: #f1f5f9;
}

body.dark .list-group-item:hover {
    background-color: #334155;
}

body.dark .alert {
    border-color: #334155;
}

body.dark .alert-info {
    background-color: rgba(56, 189, 248, 0.1);
    border-color: #38bdf8;
    color: #38bdf8;
}

body.dark .alert-success {
    background-color: rgba(52, 211, 153, 0.1);
    border-color: #34d399;
    color: #34d399;
}

body.dark .alert-warning {
    background-color: rgba(251, 191, 36, 0.1);
    border-color: #fbbf24;
    color: #fbbf24;
}

body.dark .alert-danger {
    background-color: rgba(248, 113, 113, 0.1);
    border-color: #f87171;
    color: #f87171;
}

/* Ajustes para temas sunrise/sunset */
body.theme-sunrise .bg-light,
body.theme-sunset .bg-light {
    background-color: var(--surface) !important;
}

body.theme-sunrise .bg-light-subtle,
body.theme-sunset .bg-light-subtle {
    background-color: var(--surface) !important;
}

body.theme-sunrise .bg-white,
body.theme-sunset .bg-white {
    background-color: var(--card) !important;
    color: var(--text) !important;
}

body.theme-sunrise .bg-body-tertiary,
body.theme-sunset .bg-body-tertiary {
    background-color: var(--menu-bg) !important;
}

body.theme-sunrise .border,
body.theme-sunrise .border-bottom,
body.theme-sunset .border,
body.theme-sunset .border-bottom {
    border-color: var(--border) !important;
}

body.theme-sunrise .text-muted,
body.theme-sunset .text-muted {
    color: var(--muted) !important;
}

body.theme-sunrise .text-primary,
body.theme-sunset .text-primary {
    color: var(--primary) !important;
}

body.theme-sunrise .form-control,
body.theme-sunrise .form-select,
body.theme-sunrise .input-group-text,
body.theme-sunset .form-control,
body.theme-sunset .form-select,
body.theme-sunset .input-group-text {
    background-color: var(--card);
    border-color: var(--border);
    color: var(--text);
}

body.theme-sunrise .form-control::placeholder,
body.theme-sunset .form-control::placeholder {
    color: var(--muted);
}

body.theme-sunrise .dropdown-menu,
body.theme-sunset .dropdown-menu {
    background-color: var(--card);
    border-color: var(--border);
}

body.theme-sunrise .dropdown-menu .dropdown-item,
body.theme-sunset .dropdown-menu .dropdown-item {
    color: var(--text);
}

body.theme-sunrise .dropdown-menu .dropdown-item:hover,
body.theme-sunset .dropdown-menu .dropdown-item:hover {
    background-color: var(--surface);
}

body.theme-sunrise .btn-outline-secondary,
body.theme-sunset .btn-outline-secondary {
    color: var(--text);
    border-color: var(--border);
}

body.theme-sunrise .btn-outline-secondary:hover,
body.theme-sunset .btn-outline-secondary:hover {
    background-color: var(--surface);
    border-color: var(--border);
    color: var(--text);
}

body.theme-sunrise .btn-outline-primary,
body.theme-sunset .btn-outline-primary {
    border-color: var(--primary);
    color: var(--primary);
}

body.theme-sunrise .btn-outline-primary:hover,
body.theme-sunset .btn-outline-primary:hover {
    background-color: var(--primary);
    border-color: var(--primary);
    color: #fff;
}

body.theme-sunrise .modal-content,
body.theme-sunrise .list-group-item,
body.theme-sunset .modal-content,
body.theme-sunset .list-group-item {
    background-color: var(--card);
    border-color: var(--border);
    color: var(--text);
}

body.theme-sunrise .table,
body.theme-sunset .table {
    color: var(--text);
    border-color: var(--border);
}

body.theme-sunrise .table thead th,
body.theme-sunset .table thead th {
    background-color: var(--surface);
    color: var(--text);
}

body.theme-sunrise .table-striped > tbody > tr:nth-of-type(odd) > *,
body.theme-sunset .table-striped > tbody > tr:nth-of-type(odd) > * {
    background-color: var(--surface);
    color: var(--text);
}

body.theme-sunrise .table-hover > tbody > tr:hover > *,
body.theme-sunset .table-hover > tbody > tr:hover > * {
    background-color: var(--surface);
    color: var(--text);
}

/* ============================================
   SWEETALERT2 - DARK MODE
   ============================================ */

body.dark .swal2-popup {
    background-color: #1e293b;
    color: #f1f5f9;
}

body.dark .swal2-title {
    color: #f1f5f9;
}

body.dark .swal2-html-container {
    color: #e2e8f0;
}

body.dark .swal2-confirm {
    background-color: #4a9c17;
    color: #f1f5f9;
}

body.dark .swal2-confirm:hover {
    background-color: #4a9c17;
}

body.dark .swal2-cancel {
    background-color: #334155;
    color: #f1f5f9;
}

body.dark .swal2-cancel:hover {
    background-color: #475569;
}

body.dark .swal2-label {
    color: #f1f5f9;
}

body.dark .swal2-input {
    background-color: #0f172a;
    border-color: #334155;
    color: #f1f5f9;
}

body.dark .swal2-input:focus {
    border-color: #4a9c17;
    box-shadow: 0 0 0 2px rgba(74, 156, 23, 0.2);
}

body.dark .swal2-textarea {
    background-color: #0f172a;
    border-color: #334155;
    color: #f1f5f9;
}

body.dark .swal2-textarea:focus {
    border-color: #4a9c17;
    box-shadow: 0 0 0 2px rgba(74, 156, 23, 0.2);
}

body.dark .swal2-radio label {
    color: #f1f5f9;
}

body.dark .swal2-checkbox label {
    color: #f1f5f9;
}

body.dark .swal2-progress-steps {
    color: #4a9c17;
}

body.dark .swal2-progress-steps-container {
    background-color: transparent;
}

body.dark .swal2-icon {
    border-color: #334155;
}

.toggle-theme {
    position: fixed;
    top: 20px;
    right: 20px;
    background: var(--card);
    border: 1px solid var(--border);
    padding: 8px 14px;
    border-radius: 20px;
    cursor: pointer;
    font-size: 14px;
    transition: 0.3s;
    z-index: 999;
    color: var(--text);
}

.toggle-theme:hover {
    transform: scale(1.05);
}