/* ============================
   ONIX DARK COLORFUL THEME
   ============================ */

/* Paleta base */
:root[data-bs-theme="dark"] {
    color-scheme: dark;
    --onx-bg-body:        #050712;
    --onx-bg-surface:     #111323;
    --onx-bg-surface-alt: #15182a;
    --onx-bg-elevated:    #181b31;
    --onx-bg-input:       #0f2747;
    --onx-bg-chip:        rgba(138, 180, 255, 0.12);

    --onx-border-subtle:  #26293b;
    --onx-border-strong:  #3b3f57;

    --onx-primary:        #7b5cff;   /* roxo vivo */
    --onx-primary-soft:   rgba(123, 92, 255, 0.18);
    --onx-secondary:      #29b6f6;   /* azul ciano */
    --onx-accent:         #ff6f3c;   /* laranja */
    --onx-danger:         #ff4b6a;
    --onx-success:        #4fd18b;
    --onx-warning:        #f9c74f;
    --onx-info:           #41c9e2;

    --onx-text-main:      #e9ecff;
    --onx-text-muted:     #9ba0bf;
    --onx-text-soft:      #6b6f88;

    --onx-radius-md:      10px;
    --onx-radius-lg:      18px;

    --onx-shadow-soft:    0 18px 45px rgba(0, 0, 0, 0.65);
    --onx-shadow-strong:  0 26px 80px rgba(3, 5, 20, 0.95);

    --onx-trans-fast:     0.18s ease-out;

    /* Bridge para variáveis Bootstrap 5.3+ */
    --bs-body-bg:         var(--onx-bg-body);
    --bs-body-color:      var(--onx-text-main);
    --bs-border-color:    var(--onx-border-subtle);

    --bs-primary:         var(--onx-primary);
    --bs-primary-rgb:     123, 92, 255;
    --bs-secondary:       var(--onx-secondary);
    --bs-success:         var(--onx-success);
    --bs-info:            var(--onx-info);
    --bs-warning:         var(--onx-warning);
    --bs-danger:          var(--onx-danger);

    --bs-link-color:      var(--onx-primary);
    --bs-link-hover-color: #9d7fff;
}

/* Overrides para garantir o tema dark completo */
:root[data-bs-theme="dark"] .form-control,
:root[data-bs-theme="dark"] .form-select,
:root[data-bs-theme="dark"] textarea,
:root[data-bs-theme="dark"] input[type="text"],
:root[data-bs-theme="dark"] input[type="email"],
:root[data-bs-theme="dark"] input[type="password"],
:root[data-bs-theme="dark"] input[type="number"],
:root[data-bs-theme="dark"] input[type="date"],
:root[data-bs-theme="dark"] input[type="tel"],
:root[data-bs-theme="dark"] input[type="search"],
:root[data-bs-theme="dark"] .flatpickr-input {
    background-color: var(--onx-bg-input) !important;
    color: #d1d5db !important;
    border-color: var(--onx-border-subtle) !important;
}

:root[data-bs-theme="dark"] .form-floating label {
    color: #9ba0bf !important;
}

/* Editor de contrato (contenteditable) */
:root[data-bs-theme="dark"] .editor {
    background-color: var(--onx-bg-input) !important;
    color: #d1d5db !important;
    border-color: var(--onx-border-subtle) !important;
}

/* Botões cinza no light (secondary) tornam-se azuis no dark */
:root[data-bs-theme="dark"] .btn-secondary {
    background: linear-gradient(180deg, #3b82f6 0%, #2563eb 100%) !important;
    color: #fff !important;
    border: none !important;
    box-shadow: 0 4px 0px #1d4ed8, 0 8px 15px rgba(0, 0, 0, 0.3) !important;
}

:root[data-bs-theme="dark"] .btn-secondary:hover {
    background: linear-gradient(180deg, #60a5fa 0%, #3b82f6 100%) !important;
    transform: translateY(-1px);
    box-shadow: 0 5px 0px #1d4ed8, 0 10px 20px rgba(0, 0, 0, 0.4) !important;
}

:root[data-bs-theme="dark"] .btn-secondary:active {
    transform: translateY(3px);
    box-shadow: 0 1px 0px #1d4ed8, 0 2px 5px rgba(0, 0, 0, 0.4) !important;
}

:root[data-bs-theme="dark"] .btn-outline-secondary {
    border-color: #3b82f6 !important;
    color: #60a5fa !important;
    background: rgba(59, 130, 246, 0.1) !important;
}

:root[data-bs-theme="dark"] .btn-outline-secondary:hover {
    background: #3b82f6 !important;
    color: #fff !important;
}

:root[data-bs-theme="dark"] .form-control:focus,
:root[data-bs-theme="dark"] .form-select:focus,
:root[data-bs-theme="dark"] textarea:focus,
:root[data-bs-theme="dark"] input[type="text"]:focus,
:root[data-bs-theme="dark"] input[type="email"]:focus,
:root[data-bs-theme="dark"] input[type="password"]:focus,
:root[data-bs-theme="dark"] input[type="number"]:focus,
:root[data-bs-theme="dark"] input[type="date"]:focus,
:root[data-bs-theme="dark"] input[type="tel"]:focus,
:root[data-bs-theme="dark"] input[type="search"]:focus,
:root[data-bs-theme="dark"] .flatpickr-input:focus {
    background-color: var(--onx-bg-elevated) !important;
    border-color: var(--onx-primary) !important;
    color: var(--onx-text-main) !important;
    box-shadow: 0 0 0 0.2rem var(--onx-primary-soft) !important;
}

/* Placeholders transparentes no dark-mode */
:root[data-bs-theme="dark"] .form-control::placeholder,
:root[data-bs-theme="dark"] .form-select::placeholder,
:root[data-bs-theme="dark"] textarea::placeholder,
:root[data-bs-theme="dark"] input::placeholder {
    color: transparent !important;
    opacity: 0 !important;
}

:root[data-bs-theme="dark"] .table {
    --bs-table-bg: var(--onx-bg-surface-alt) !important;
    --bs-table-color: var(--onx-text-main) !important;
    --bs-table-border-color: var(--onx-border-subtle) !important;
}

body.swal2-shown[data-bs-theme="dark"]:not(.swal2-toast-shown) .swal2-container {
    background-color: rgba(0, 0, 0, 0.8) !important;
    backdrop-filter: blur(4px) !important;
    z-index: 999999 !important;
}

body.swal2-shown[data-bs-theme="dark"] .swal2-popup,
html[data-bs-theme="dark"] .swal2-popup,
[data-bs-theme="dark"] .swal2-popup {
    background: linear-gradient(160deg, #1e213a 0%, #0a0b14 100%) !important;
    color: #e9ecff !important;
    border: 1px solid rgba(123, 92, 255, 0.4) !important;
    border-radius: 18px !important;
    box-shadow: 0 26px 80px rgba(0, 0, 0, 0.9) !important;
}

body.swal2-shown[data-bs-theme="dark"] .swal2-title,
html[data-bs-theme="dark"] .swal2-title {
    color: #e9ecff !important;
}

body.swal2-shown[data-bs-theme="dark"] .swal2-html-container,
html[data-bs-theme="dark"] .swal2-html-container {
    color: #9ba0bf !important;
}

/* Botões no SweetAlert */
body.swal2-shown[data-bs-theme="dark"] .swal2-confirm:not([style*="background-color"]):not([style*="background"]),
html[data-bs-theme="dark"] .swal2-confirm:not([style*="background-color"]):not([style*="background"]) {
    background-color: #7b5cff !important;
    color: #fff !important;
}

body.swal2-shown[data-bs-theme="dark"] .swal2-cancel:not([style*="background-color"]):not([style*="background"]),
html[data-bs-theme="dark"] .swal2-cancel:not([style*="background-color"]):not([style*="background"]) {
    background-color: #15182a !important;
    color: #e9ecff !important;
    border: 1px solid #26293b !important;
}

/* Ícones */
body.swal2-shown[data-bs-theme="dark"] .swal2-icon,
html[data-bs-theme="dark"] .swal2-icon {
    border-color: #26293b !important;
}

/* Forçar todos os textos */
[data-bs-theme="dark"] .swal2-popup *:not(button):not(i):not(.swal2-confirm):not(.swal2-cancel):not(.swal2-deny),
.dark-mode .swal2-popup *:not(button):not(i):not(.swal2-confirm):not(.swal2-cancel):not(.swal2-deny) {
    color: #e9ecff !important;
}

/* Garantir que o fundo branco original não apareça */
.swal2-popup {
    transition: background-color 0.1s !important;
}

body.swal2-toast-shown .swal2-container {
    background-color: transparent !important;
    backdrop-filter: none !important;
    position: fixed !important;
    inset: auto !important;
    top: auto !important;
    left: auto !important;
    right: 16px !important;
    bottom: 16px !important;
    width: auto !important;
    height: auto !important;
    pointer-events: none !important;
}

html.swal2-toast-shown,
body.swal2-toast-shown {
    overflow: auto !important;
    padding-right: 0 !important;
}

body.swal2-toast-shown .swal2-container .swal2-popup {
    pointer-events: auto !important;
}

html[data-bs-theme="dark"] .onx-toast-container {
    background: transparent !important;
    inset: auto !important;
    top: auto !important;
    left: auto !important;
    right: 16px !important;
    bottom: 16px !important;
    width: auto !important;
    height: auto !important;
    pointer-events: none !important;
}

html[data-bs-theme="dark"] .onx-toast-container .swal2-popup {
    pointer-events: auto !important;
}
