/* TotalAdmin v2 Custom Styles - Studio v3.0 Integration */

:root {
    --app-theme: #1f6bff;
    --app-theme-rgb: 31, 107, 255;
    --app-theme-color: #ffffff;
}

/* ==========================================================================
   Contraste Óptimo de Texto para Botones y Componentes según Paleta de Color
   ========================================================================== */

/* Temas con fondos saturados u oscuros -> Texto blanco de alto contraste */
.theme-red,
.theme-danger,
.theme-pink,
.theme-purple,
.theme-indigo,
.theme-blue,
.theme-primary,
.theme-green,
.theme-success,
.theme-orange,
.theme-gray-600,
.theme-gray-700,
.theme-gray-800,
.theme-gray-900,
.theme-dark,
.theme-black,
body:not([class*="theme-"]) {
    --app-theme-color: #ffffff !important;
    --app-component-active-color: #ffffff !important;
}

/* Temas claros / muy luminosos -> Texto oscuro de alto contraste */
.theme-yellow,
.theme-warning,
.theme-lime,
.theme-cyan,
.theme-info,
.theme-teal,
.theme-light,
.theme-white,
.theme-gray-100,
.theme-gray-200,
.theme-gray-300 {
    --app-theme-color: #0f172a !important;
    --app-component-active-color: #0f172a !important;
}

/* Bind Bootstrap variables & Theme Palette */
body {
    --bs-primary: var(--app-theme) !important;
    --bs-primary-rgb: var(--app-theme-rgb) !important;
    --bs-link-color: var(--app-theme) !important;
    --bs-link-hover-color: rgba(var(--app-theme-rgb), 0.8) !important;
}

/* Global Bootstrap Variable Fix for Text Opacity in Dark Mode */
.dark-mode,
html.dark-mode,
body.dark-mode {
    --bs-body-color: #ebeef4 !important;
    --bs-body-color-rgb: 235, 238, 244 !important;
}

html:not(.dark-mode) {
    --bs-body-color: #212837 !important;
    --bs-body-color-rgb: 33, 40, 55 !important;
}

/* Links & Text Highlights */
a:not(.btn):not(.dropdown-item):not(.menu-link):not(.brand-logo) {
    color: var(--app-theme);
    transition: color 0.15s ease-in-out;
}

a:not(.btn):not(.dropdown-item):not(.menu-link):not(.brand-logo):hover {
    color: rgba(var(--app-theme-rgb), 0.8);
}

.text-primary {
    color: var(--app-theme) !important;
}

/* Primary Buttons */
.btn-primary {
    background-color: var(--app-theme) !important;
    border-color: var(--app-theme) !important;
    color: var(--app-theme-color, #ffffff) !important;
    font-weight: 600;
    box-shadow: 0 2px 5px rgba(var(--app-theme-rgb), 0.25);
    transition: all 0.2s ease-in-out;
}

.btn-primary:hover,
.btn-primary:focus,
.btn-primary:active {
    background-color: var(--app-theme) !important;
    border-color: var(--app-theme) !important;
    color: var(--app-theme-color, #ffffff) !important;
    filter: brightness(1.12);
    box-shadow: 0 4px 10px rgba(var(--app-theme-rgb), 0.35);
}

.btn-outline-primary {
    color: var(--app-theme) !important;
    border-color: var(--app-theme) !important;
    font-weight: 500;
}

.btn-outline-primary:hover,
.btn-outline-primary:focus,
.btn-outline-primary:active {
    background-color: var(--app-theme) !important;
    border-color: var(--app-theme) !important;
    color: var(--app-theme-color, #ffffff) !important;
}

/* Floating Action Button (DataTables) */
.btnsFlotando {
    position: fixed;
    right: 32px;
    top: 75px;
    z-index: 99;
}

.btnsFlotando .btn-primary {
    border-radius: 50px;
    padding: 8px 20px;
    font-weight: 600;
}

@media (max-width: 767.98px) {
    .btnsFlotandoTxt {
        display: none;
    }
}

/* Form Controls Focus & Active Checks */
.form-control:focus,
.form-select:focus {
    border-color: var(--app-theme) !important;
    box-shadow: 0 0 0 0.25rem rgba(var(--app-theme-rgb), 0.25) !important;
}

.form-check-input:checked {
    background-color: var(--app-theme) !important;
    border-color: var(--app-theme) !important;
}

.form-switch .form-check-input:checked {
    background-color: var(--app-theme) !important;
    border-color: var(--app-theme) !important;
}

/* Active Badges & Highlights */
.bg-primary {
    background-color: var(--app-theme) !important;
    color: var(--app-theme-color, #ffffff) !important;
}

.bg-primary.bg-opacity-10 {
    background-color: rgba(var(--app-theme-rgb), 0.12) !important;
}

/* DataTables & Paginators */
.page-item.active .page-link,
.dataTables_wrapper .dataTables_paginate .paginate_button.current,
.dataTables_wrapper .dataTables_paginate .paginate_button.current:hover {
    background-color: var(--app-theme) !important;
    border-color: var(--app-theme) !important;
    color: var(--app-theme-color, #ffffff) !important;
}

.page-link {
    color: var(--app-theme);
}

/* Datepicker popup elevation */
.datepicker {
    z-index: 1060 !important;
}

/* Loader Overlay */
.overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.65);
    backdrop-filter: blur(4px);
    z-index: 9999;
    display: flex;
    justify-content: center;
    align-items: center;
}

.loaderBox {
    background: var(--bs-card-bg, #1e293b);
    padding: 24px 36px;
    border-radius: 12px;
    border: 1px solid var(--bs-border-color, rgba(255, 255, 255, 0.1));
    box-shadow: 0 10px 25px rgba(0, 0, 0, 0.3);
    text-align: center;
    color: var(--bs-body-color, #f8fafc);
}

.loader {
    width: 38px;
    height: 38px;
    border: 3px solid rgba(255, 255, 255, 0.15);
    border-top: 3px solid var(--app-theme, #0dcaf0);
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
    margin: 0 auto 12px auto;
}

.loaderText {
    font-size: 14px;
    font-weight: 500;
}

@keyframes spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

/* TotalAdmin Dashboard Card Polish & Contrast */
.ta-metric-card {
    transition: transform 0.2s ease, box-shadow 0.2s ease;
}

.ta-metric-card:hover {
    transform: translateY(-3px);
}

.dark-mode .ta-metric-card,
html.dark-mode .ta-metric-card {
    background: #1e293b !important;
    border: 1px solid rgba(255, 255, 255, 0.1) !important;
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.25);
}

.dark-mode .ta-metric-card h2,
html.dark-mode .ta-metric-card h2 {
    color: #f8fafc !important;
}

.dark-mode .ta-metric-card .text-uppercase,
html.dark-mode .ta-metric-card .text-uppercase {
    color: #94a3b8 !important;
    letter-spacing: 0.04em;
}

.dark-mode .ta-metric-card hr,
html.dark-mode .ta-metric-card hr {
    border-color: rgba(255, 255, 255, 0.1) !important;
    opacity: 1 !important;
}

.dark-mode .ta-metric-card .d-flex.align-items-center.justify-content-between span,
html.dark-mode .ta-metric-card .d-flex.align-items-center.justify-content-between span {
    color: #94a3b8 !important;
}

/* Dashboard Lists & Content in Dark Mode */
.dark-mode .card,
html.dark-mode .card {
    background: #1e293b;
    border: 1px solid rgba(255, 255, 255, 0.1);
}

.dark-mode .card-header,
html.dark-mode .card-header {
    border-bottom: 1px solid rgba(255, 255, 255, 0.08);
    color: #f8fafc;
}

.dark-mode .list-group-item,
html.dark-mode .list-group-item {
    color: #f8fafc;
    border-bottom-color: rgba(255, 255, 255, 0.08) !important;
}

.dark-mode .list-group-item .fw-600,
html.dark-mode .list-group-item .fw-600 {
    color: #f8fafc;
}

.dark-mode .list-group-item .fs-12px,
html.dark-mode .list-group-item .fs-12px {
    color: #94a3b8 !important;
}

.dark-mode .list-group-item .fa-chevron-right,
html.dark-mode .list-group-item .fa-chevron-right {
    color: #64748b !important;
}

.dark-mode .alert-secondary,
html.dark-mode .alert-secondary {
    background: rgba(255, 255, 255, 0.05) !important;
    color: #cbd5e1 !important;
}

/* ==========================================================================
   TotalAdmin Notifications & Toasts Enhancement (Dark/Light Contrast)
   ========================================================================== */

.dropdown-notification {
    background: #1e293b !important;
    border: 1px solid rgba(255, 255, 255, 0.12) !important;
    border-radius: 0.75rem !important;
    box-shadow: 0 20px 25px -5px rgba(0, 0, 0, 0.5) !important;
    color: #f8fafc !important;
}

.dropdown-notification h6 {
    color: #f8fafc !important;
}

.dropdown-notification-item {
    transition: background 0.15s ease-in-out;
    border-bottom: 1px solid rgba(255, 255, 255, 0.06);
}

.dropdown-notification-item:hover {
    background: rgba(255, 255, 255, 0.06) !important;
}

/* Colores por defecto (Dark Mode por diseño) */
.dropdown-notification .dropdown-notification-title,
.dropdown-notification .title {
    color: #f8fafc !important;
}

.dropdown-notification .dropdown-notification-desc,
.dropdown-notification .text-body {
    color: #cbd5e1 !important;
}

.dropdown-notification .time {
    color: #94a3b8 !important;
}

.dropdown-notification #noNotificationsMsg {
    color: #94a3b8 !important;
}

.dropdown-notification .notif-clear-btn {
    color: #94a3b8 !important;
    transition: color 0.15s ease-in-out;
}

.dropdown-notification .notif-clear-btn:hover {
    color: #f87171 !important;
}

.dropdown-notification .notif-delete-btn {
    color: #94a3b8 !important;
    transition: color 0.15s ease-in-out;
}

.dropdown-notification .notif-delete-btn:hover {
    color: #f87171 !important;
}

/* Reglas explícitas Dark Mode */
.dark-mode .dropdown-notification,
html.dark-mode .dropdown-notification {
    background: #1e293b !important;
    border: 1px solid rgba(255, 255, 255, 0.12) !important;
}

.dark-mode .dropdown-notification h6,
html.dark-mode .dropdown-notification h6 {
    color: #f8fafc !important;
}

.dark-mode .dropdown-notification .dropdown-notification-title,
html.dark-mode .dropdown-notification .dropdown-notification-title {
    color: #f8fafc !important;
}

.dark-mode .dropdown-notification .dropdown-notification-desc,
html.dark-mode .dropdown-notification .dropdown-notification-desc {
    color: #cbd5e1 !important;
}

/* Reglas explícitas Light Mode */
html:not(.dark-mode) .dropdown-notification {
    background: #ffffff !important;
    border: 1px solid rgba(0, 0, 0, 0.08) !important;
    box-shadow: 0 15px 30px rgba(0, 0, 0, 0.12) !important;
    color: #1e293b !important;
}

html:not(.dark-mode) .dropdown-notification h6 {
    color: #0f172a !important;
}

html:not(.dark-mode) .dropdown-notification-item {
    border-bottom: 1px solid rgba(0, 0, 0, 0.05);
}

html:not(.dark-mode) .dropdown-notification-item:hover {
    background: rgba(0, 0, 0, 0.03) !important;
}

html:not(.dark-mode) .dropdown-notification .dropdown-notification-title,
html:not(.dark-mode) .dropdown-notification .title {
    color: #0f172a !important;
}

html:not(.dark-mode) .dropdown-notification .dropdown-notification-desc,
html:not(.dark-mode) .dropdown-notification .text-body {
    color: #475569 !important;
}

html:not(.dark-mode) .dropdown-notification .time {
    color: #64748b !important;
}

html:not(.dark-mode) .dropdown-notification .notif-clear-btn {
    color: #64748b !important;
}

html:not(.dark-mode) .dropdown-notification .notif-clear-btn:hover {
    color: #dc2626 !important;
}

html:not(.dark-mode) .dropdown-notification .notif-delete-btn {
    color: #94a3b8 !important;
}

html:not(.dark-mode) .dropdown-notification .notif-delete-btn:hover {
    color: #dc2626 !important;
}

/* Toast Positioning & Styling */
#globalToastContainer {
    top: 4.5rem !important;
    right: 1.25rem !important;
    z-index: 2050 !important;
    pointer-events: none;
}

#globalToastContainer .toast {
    pointer-events: auto;
    min-width: 300px;
    max-width: 380px;
    border-radius: 0.65rem;
    box-shadow: 0 10px 25px -5px rgba(0, 0, 0, 0.4);
    border: 1px solid rgba(255, 255, 255, 0.12);
}

.dark-mode #globalToastContainer .toast,
html.dark-mode #globalToastContainer .toast {
    background: #1e293b !important;
    color: #f8fafc !important;
}

.dark-mode #globalToastContainer .toast-header,
html.dark-mode #globalToastContainer .toast-header {
    background: #0f172a !important;
    border-bottom: 1px solid rgba(255, 255, 255, 0.1) !important;
    color: #f8fafc !important;
}

.dark-mode #globalToastContainer .toast-body,
html.dark-mode #globalToastContainer .toast-body {
    color: #e2e8f0 !important;
    font-size: 0.9rem;
    padding: 0.85rem 1rem;
}

.dark-mode #globalToastContainer .btn-close,
html.dark-mode #globalToastContainer .btn-close {
    filter: invert(1) grayscale(100%) brightness(200%);
}

html:not(.dark-mode) #globalToastContainer .toast {
    background: #ffffff !important;
    border: 1px solid rgba(0, 0, 0, 0.08) !important;
    color: #1e293b !important;
}

html:not(.dark-mode) #globalToastContainer .toast-header {
    background: #f8fafc !important;
    border-bottom: 1px solid rgba(0, 0, 0, 0.06) !important;
}

html:not(.dark-mode) #globalToastContainer .toast-body {
    color: #334155 !important;
}

/* ==========================================================================
   Theme Panel Contrast & Styling (Dark / Light Mode)
   ========================================================================== */

.theme-panel .theme-panel-content {
    background: #1e293b !important;
    border: 1px solid rgba(255, 255, 255, 0.12) !important;
    border-radius: 8px 0 0 8px !important;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.5) !important;
}

.theme-panel .theme-collapse-btn {
    background: #1e293b !important;
    color: var(--app-theme) !important;
    border-top: 1px solid rgba(255, 255, 255, 0.12) !important;
    border-bottom: 1px solid rgba(255, 255, 255, 0.12) !important;
    border-left: 1px solid rgba(255, 255, 255, 0.12) !important;
    border-radius: 8px 0 0 8px !important;
    box-shadow: -4px 0 16px rgba(0, 0, 0, 0.25) !important;
}

.theme-panel .theme-panel-title {
    color: #f8fafc !important;
    font-size: 13px;
}

.theme-panel .theme-panel-desc {
    color: #94a3b8 !important;
    font-size: 12px;
}

.theme-panel hr {
    border-color: rgba(255, 255, 255, 0.15) !important;
    opacity: 1 !important;
}

/* En Light Mode explícito */
html:not(.dark-mode) .theme-panel .theme-panel-content {
    background: #ffffff !important;
    border: 1px solid rgba(0, 0, 0, 0.08) !important;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.12) !important;
}

html:not(.dark-mode) .theme-panel .theme-collapse-btn {
    background: #ffffff !important;
    color: var(--app-theme) !important;
    border-top: 1px solid rgba(0, 0, 0, 0.08) !important;
    border-bottom: 1px solid rgba(0, 0, 0, 0.08) !important;
    border-left: 1px solid rgba(0, 0, 0, 0.08) !important;
    box-shadow: -4px 0 16px rgba(0, 0, 0, 0.08) !important;
}

html:not(.dark-mode) .theme-panel .theme-panel-title {
    color: #0f172a !important;
}

html:not(.dark-mode) .theme-panel .theme-panel-desc {
    color: #64748b !important;
}

html:not(.dark-mode) .theme-panel hr {
    border-color: rgba(0, 0, 0, 0.08) !important;
}

/* ==========================================================================
   DataTables Server-Side Processing Loader
   ========================================================================== */

.dataTables_wrapper {
    position: relative;
}

.dataTables_wrapper .dataTables_processing {
    position: absolute;
    top: 50% !important;
    left: 50% !important;
    transform: translate(-50%, -50%);
    z-index: 1050;
    padding: 12px 26px !important;
    border-radius: 10px !important;
    font-size: 13px !important;
    font-weight: 500 !important;
    background: rgba(30, 41, 59, 0.92) !important;
    backdrop-filter: blur(8px);
    border: 1px solid rgba(255, 255, 255, 0.15) !important;
    color: #f8fafc !important;
    box-shadow: 0 12px 30px rgba(0, 0, 0, 0.5) !important;
    margin: 0 !important;
    width: auto !important;
}

html:not(.dark-mode) .dataTables_wrapper .dataTables_processing {
    background: rgba(255, 255, 255, 0.95) !important;
    border: 1px solid rgba(0, 0, 0, 0.1) !important;
    color: #0f172a !important;
    box-shadow: 0 12px 30px rgba(0, 0, 0, 0.12) !important;
}

.ta-dt-loader {
    display: inline-flex;
    align-items: center;
    gap: 8px;
}

/* ==========================================================================
   Audit Log Detail Modal & Diff Styles (Dark & Light Mode)
   ========================================================================== */

.audit-target-badge {
    background-color: rgba(255, 255, 255, 0.08) !important;
    color: #e2e8f0 !important;
    border: 1px solid rgba(255, 255, 255, 0.15) !important;
    font-weight: 500;
}

html:not(.dark-mode) .audit-target-badge {
    background-color: #f1f5f9 !important;
    color: #1e293b !important;
    border: 1px solid #cbd5e1 !important;
}

/* Modal Content & Borders */
.dark-mode #modalAuditDetail .modal-content {
    background-color: #1a2234 !important;
    border: 1px solid rgba(255, 255, 255, 0.12) !important;
    color: #ebeef4 !important;
    box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.75) !important;
}

.dark-mode #modalAuditDetail .modal-header,
.dark-mode #modalAuditDetail .modal-footer {
    border-color: rgba(255, 255, 255, 0.08) !important;
}

.dark-mode #modalAuditDetail .border-bottom {
    border-color: rgba(255, 255, 255, 0.08) !important;
}

/* Diff Table */
.audit-diff-table {
    border: 1px solid rgba(255, 255, 255, 0.12) !important;
    border-radius: 0.5rem;
    overflow: hidden;
}

.audit-diff-table thead th {
    background-color: rgba(255, 255, 255, 0.05) !important;
    color: #94a3b8 !important;
    font-size: 0.75rem;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.1) !important;
}

.dark-mode .audit-diff-row-changed {
    background-color: rgba(234, 179, 8, 0.16) !important;
}
.dark-mode .audit-diff-row-changed td {
    color: #fef08a !important;
    background-color: transparent !important;
}

.dark-mode .audit-diff-row-created {
    background-color: rgba(34, 197, 94, 0.16) !important;
}
.dark-mode .audit-diff-row-created td {
    color: #86efac !important;
    background-color: transparent !important;
}

.dark-mode .audit-diff-row-deleted {
    background-color: rgba(239, 68, 68, 0.16) !important;
}
.dark-mode .audit-diff-row-deleted td {
    color: #fca5a5 !important;
    background-color: transparent !important;
}

html:not(.dark-mode) .audit-diff-table {
    border-color: #e2e8f0 !important;
}
html:not(.dark-mode) .audit-diff-table thead th {
    background-color: #f8fafc !important;
    color: #475569 !important;
    border-bottom-color: #e2e8f0 !important;
}
html:not(.dark-mode) .audit-diff-row-changed {
    background-color: #fef9c3 !important;
}
html:not(.dark-mode) .audit-diff-row-changed td {
    color: #854d0e !important;
    background-color: transparent !important;
}
html:not(.dark-mode) .audit-diff-row-created {
    background-color: #dcfce7 !important;
}
html:not(.dark-mode) .audit-diff-row-created td {
    color: #166534 !important;
    background-color: transparent !important;
}
html:not(.dark-mode) .audit-diff-row-deleted {
    background-color: #fee2e2 !important;
}
html:not(.dark-mode) .audit-diff-row-deleted td {
    color: #991b1b !important;
    background-color: transparent !important;
}

/* Accordion & Raw JSON Viewer */
.dark-mode #rawJsonAccordion .accordion-item {
    background-color: rgba(255, 255, 255, 0.02) !important;
    border: 1px solid rgba(255, 255, 255, 0.1) !important;
    border-radius: 0.5rem;
    overflow: hidden;
}

.dark-mode #rawJsonAccordion .accordion-button {
    background-color: rgba(255, 255, 255, 0.04) !important;
    color: #cbd5e1 !important;
    box-shadow: none !important;
}

.dark-mode #rawJsonAccordion .accordion-button:not(.collapsed) {
    background-color: rgba(var(--app-theme-rgb), 0.12) !important;
    color: var(--app-theme) !important;
}

.dark-mode #rawJsonAccordion .accordion-button::after {
    filter: invert(1) brightness(150%);
}

.audit-raw-json-container {
    background-color: #0d131f !important;
    border-radius: 0.375rem;
    padding: 0.85rem;
    border: 1px solid rgba(255, 255, 255, 0.08);
}

.audit-raw-json-container pre {
    color: #38bdf8 !important;
    font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace !important;
    font-size: 0.825rem;
    line-height: 1.5;
    margin-bottom: 0;
}

html:not(.dark-mode) .audit-raw-json-container {
    background-color: #f8fafc !important;
    border: 1px solid #e2e8f0;
}

html:not(.dark-mode) .audit-raw-json-container pre {
    color: #0369a1 !important;
    font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace !important;
    font-size: 0.825rem;
    line-height: 1.5;
    margin-bottom: 0;
}

/* ==========================================================================
   Visual Catalog Builder (Studio v3)
   ========================================================================== */
.builder-tabs .nav-link {
    font-weight: 600;
    font-size: 0.95rem;
    padding: 0.75rem 1.25rem;
    color: #64748b;
    border: none;
    border-bottom: 2px solid transparent;
    transition: all 0.2s ease-in-out;
}

.builder-tabs .nav-link:hover {
    color: var(--app-theme, #3b82f6);
    border-color: rgba(var(--app-theme-rgb, 59, 130, 246), 0.3);
}

.builder-tabs .nav-link.active {
    color: var(--app-theme, #3b82f6) !important;
    background-color: transparent !important;
    border-bottom: 2px solid var(--app-theme, #3b82f6) !important;
}

.dark-mode .builder-tabs .nav-link {
    color: #94a3b8;
}

.dark-mode .builder-tabs .nav-link.active {
    color: #60a5fa !important;
    border-bottom-color: #60a5fa !important;
}

/* Builder Row & Field Items */
.builder-row-item {
    transition: background-color 0.15s ease-in-out;
}

.dark-mode .builder-row-item {
    background-color: rgba(255, 255, 255, 0.03);
    border-color: rgba(255, 255, 255, 0.08) !important;
}

.dark-mode .builder-field-card {
    background-color: rgba(255, 255, 255, 0.02) !important;
    border-color: rgba(255, 255, 255, 0.1) !important;
}

.builder-field-card {
    border-radius: 0.5rem;
}

/* JSON Code Preview */
.builder-json-preview {
    background-color: #0b1120 !important;
    color: #38bdf8 !important;
    border: 1px solid rgba(255, 255, 255, 0.1) !important;
    border-radius: 0.5rem;
    font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace !important;
    font-size: 0.85rem;
    line-height: 1.5;
    max-height: 520px;
    overflow-y: auto;
}

html:not(.dark-mode) .builder-json-preview {
    background-color: #f8fafc !important;
    color: #0369a1 !important;
    border-color: #cbd5e1 !important;
}

/* Builder Column Cards & Reordering */
.builder-column-card {
    transition: transform 0.15s ease, box-shadow 0.15s ease, border-color 0.15s ease;
}

.builder-column-card:hover {
    border-color: rgba(59, 130, 246, 0.4) !important;
}

.dark-mode .builder-column-card {
    background-color: rgba(30, 41, 59, 0.5) !important;
    border-color: rgba(255, 255, 255, 0.08) !important;
}

.col-drag-handle {
    cursor: grab;
    user-select: none;
    padding: 0 4px;
}

.col-drag-handle:active {
    cursor: grabbing;
}

/* ==========================================================================
   Logo Dinámico para Modo Claro y Modo Oscuro
   ========================================================================== */
.app-logo-dark {
    display: none !important;
}

.app-logo-light {
    display: inline-block !important;
}

html.dark-mode .app-logo-dark,
body.dark-mode .app-logo-dark {
    display: inline-block !important;
}

html.dark-mode .app-logo-light,
body.dark-mode .app-logo-light {
    display: none !important;
}

/* ==========================================================================
   Resaltado de Menú Lateral Activo con Color Dinámico de Tema (Studio v3)
   ========================================================================== */

/* Enlace activo directo (sin submenú) */
.app-sidebar .menu .menu-item.active:not(.has-sub) > .menu-link {
    background: var(--app-theme) !important;
    color: var(--app-theme-color, #ffffff) !important;
    font-weight: 600 !important;
    border-radius: 6px;
    box-shadow: 0 3px 12px rgba(var(--app-theme-rgb), 0.35);
    transition: all 0.2s cubic-bezier(0.16, 1, 0.3, 1);
}

.app-sidebar .menu .menu-item.active:not(.has-sub) > .menu-link .menu-icon,
.app-sidebar .menu .menu-item.active:not(.has-sub) > .menu-link .menu-text {
    color: var(--app-theme-color, #ffffff) !important;
}

/* Enlace activo dentro de un submenú */
.app-sidebar .menu .menu-submenu .menu-item.active > .menu-link {
    background: var(--app-theme) !important;
    color: var(--app-theme-color, #ffffff) !important;
    font-weight: 600 !important;
    border-radius: 6px;
    box-shadow: 0 2px 8px rgba(var(--app-theme-rgb), 0.3);
    transition: all 0.2s cubic-bezier(0.16, 1, 0.3, 1);
}

.app-sidebar .menu .menu-submenu .menu-item.active > .menu-link .menu-text,
.app-sidebar .menu .menu-submenu .menu-item.active > .menu-link .menu-icon {
    color: var(--app-theme-color, #ffffff) !important;
}

/* Contenedor padre con submenú activo (abierto) */
.app-sidebar .menu .menu-item.has-sub.active > .menu-link,
.app-sidebar .menu .menu-item.has-sub.expand > .menu-link {
    color: var(--app-theme) !important;
    font-weight: 600;
}

.app-sidebar .menu .menu-item.has-sub.active > .menu-link .menu-icon,
.app-sidebar .menu .menu-item.has-sub.expand > .menu-link .menu-icon {
    color: var(--app-theme) !important;
}

.app-sidebar .menu .menu-item.has-sub.active > .menu-link .menu-caret .caret,
.app-sidebar .menu .menu-item.has-sub.expand > .menu-link .menu-caret .caret {
    border-top-color: var(--app-theme) !important;
}

/* Indicador de acento en el submenú activo */
.app-sidebar .menu .menu-submenu {
    border-left: 2px solid rgba(var(--app-theme-rgb), 0.25);
    margin-left: 1.25rem;
    padding-left: 0.25rem;
}

/* Hover suave en ítems inactivos */
.app-sidebar .menu .menu-item:not(.active) > .menu-link:hover {
    background: rgba(var(--app-theme-rgb), 0.1) !important;
    color: var(--app-theme) !important;
    border-radius: 6px;
    transition: background 0.15s ease, color 0.15s ease;
}

.app-sidebar .menu .menu-item:not(.active) > .menu-link:hover .menu-icon,
.app-sidebar .menu .menu-item:not(.active) > .menu-link:hover .menu-text {
    color: var(--app-theme) !important;
}

/* ==========================================================================
   Table Headers & DataTables Dark/Light Mode Theming
   ========================================================================== */

/* Estilos de encabezados en modo claro */
html:not(.dark-mode) table thead th,
html:not(.dark-mode) table.dataTable thead th {
    color: #1e293b !important;
    background-color: #f8fafc;
    border-bottom: 2px solid #e2e8f0 !important;
    font-weight: 600;
}

html:not(.dark-mode) .table-light,
html:not(.dark-mode) table thead.table-light th,
html:not(.dark-mode) .table-light > * > * {
    --bs-table-bg: #f8fafc !important;
    --bs-table-color: #1e293b !important;
    color: #1e293b !important;
    border-color: #e2e8f0 !important;
}

/* Estilos de encabezados en modo oscuro */
html.dark-mode table thead th,
html.dark-mode table.dataTable thead th,
.dark-mode table thead th,
.dark-mode table.dataTable thead th {
    color: #f8fafc !important;
    background-color: rgba(255, 255, 255, 0.05) !important;
    border-bottom: 1px solid rgba(255, 255, 255, 0.15) !important;
    font-weight: 600;
}

/* Sobrescribir .table-light en modo oscuro para evitar texto negro */
html.dark-mode .table-light,
html.dark-mode table thead.table-light th,
html.dark-mode .table-light > * > *,
.dark-mode .table-light,
.dark-mode table thead.table-light th,
.dark-mode .table-light > * > * {
    --bs-table-bg: rgba(255, 255, 255, 0.05) !important;
    --bs-table-color: #f8fafc !important;
    background-color: rgba(255, 255, 255, 0.05) !important;
    color: #f8fafc !important;
    border-color: rgba(255, 255, 255, 0.12) !important;
}

/* Soporte para iconos de ordenamiento en DataTables en modo oscuro */
html.dark-mode table.dataTable thead tr th.sorting:after,
html.dark-mode table.dataTable thead tr th.sorting_asc:after,
html.dark-mode table.dataTable thead tr th.sorting_desc:after,
.dark-mode table.dataTable thead tr th.sorting:after,
.dark-mode table.dataTable thead tr th.sorting_asc:after,
.dark-mode table.dataTable thead tr th.sorting_desc:after {
    color: rgba(255, 255, 255, 0.5) !important;
}

html.dark-mode table.dataTable thead tr th.sorting_asc:after,
html.dark-mode table.dataTable thead tr th.sorting_desc:after,
.dark-mode table.dataTable thead tr th.sorting_asc:after,
.dark-mode table.dataTable thead tr th.sorting_desc:after {
    color: var(--app-theme) !important;
}

/* ==========================================================================
   Bootstrap Background Utilities & Body Dark Mode Support
   ========================================================================== */

/* Variables RGB para Bootstrap en modo oscuro */
html.dark-mode,
.dark-mode {
    --bs-body-bg-rgb: 33, 40, 55 !important;
    --bs-body-color-rgb: 235, 238, 244 !important;
}

html.dark-mode .bg-body,
.dark-mode .bg-body {
    background-color: var(--bs-body-bg) !important;
    color: var(--bs-body-color) !important;
}

html.dark-mode .bg-body-secondary,
.dark-mode .bg-body-secondary,
html.dark-mode .bg-body-tertiary,
.dark-mode .bg-body-tertiary {
    background-color: rgba(255, 255, 255, 0.05) !important;
    color: var(--bs-body-color) !important;
}

/* En modo oscuro, las cabeceras de tarjeta y fondos bg-light deben integrarse armónicamente */
html.dark-mode .card-header.bg-light,
.dark-mode .card-header.bg-light {
    background-color: rgba(255, 255, 255, 0.04) !important;
    border-bottom: 1px solid rgba(255, 255, 255, 0.1) !important;
}

/* Tablas con fondo blanco forzado deben resetearse en dark mode */
html.dark-mode table.bg-white,
.dark-mode table.bg-white {
    background-color: transparent !important;
}

/* Asegurar fondo opaco del componente en tarjetas sticky-top */
.sticky-top.card {
    background-color: var(--app-component-bg) !important;
}

/* Controles de formulario en modo oscuro */
html.dark-mode .form-control,
html.dark-mode .form-select,
.dark-mode .form-control,
.dark-mode .form-select {
    border-color: var(--app-component-border-color);
}

/* ==========================================================================
   Wizard Tabs & Pestañas de Formulario / EHS / Inspecciones
   ========================================================================== */

#wizardTabs {
    scrollbar-width: thin;
    scrollbar-color: rgba(255, 255, 255, 0.15) transparent;
    padding-bottom: 4px;
}

#wizardTabs::-webkit-scrollbar {
    height: 4px;
}

#wizardTabs::-webkit-scrollbar-track {
    background: transparent;
}

#wizardTabs::-webkit-scrollbar-thumb {
    background: rgba(255, 255, 255, 0.15);
    border-radius: 4px;
}

/* Pestañas inactivas en Modo Claro */
html:not(.dark-mode) #wizardTabs .nav-link {
    color: #475569;
    background-color: #f1f5f9;
    border: 1px solid #e2e8f0;
    border-radius: 6px;
    font-weight: 500;
    transition: all 0.15s ease-in-out;
}

html:not(.dark-mode) #wizardTabs .nav-link:hover {
    color: #0f172a;
    background-color: #e2e8f0;
    border-color: #cbd5e1;
}

html:not(.dark-mode) #wizardTabs .nav-link.active {
    background-color: var(--app-theme) !important;
    color: var(--app-theme-color) !important;
    border-color: var(--app-theme) !important;
    font-weight: 600;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.08);
}

html:not(.dark-mode) #wizardTabs {
    scrollbar-color: #cbd5e1 transparent;
}

html:not(.dark-mode) #wizardTabs::-webkit-scrollbar-thumb {
    background: #cbd5e1;
}

/* Pestañas en Modo Oscuro */
html.dark-mode #wizardTabs .nav-link,
.dark-mode #wizardTabs .nav-link {
    color: #cbd5e1;
    background-color: rgba(255, 255, 255, 0.06);
    border: 1px solid rgba(255, 255, 255, 0.12);
    border-radius: 6px;
    font-weight: 500;
    transition: all 0.15s ease-in-out;
}

html.dark-mode #wizardTabs .nav-link:hover,
.dark-mode #wizardTabs .nav-link:hover {
    color: #ffffff;
    background-color: rgba(255, 255, 255, 0.12);
    border-color: rgba(255, 255, 255, 0.22);
}

html.dark-mode #wizardTabs .nav-link.active,
.dark-mode #wizardTabs .nav-link.active {
    background-color: var(--app-theme) !important;
    color: var(--app-theme-color) !important;
    border-color: var(--app-theme) !important;
    font-weight: 600;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.35);
}

/* Badge de estado de sincronización y badges bg-light en modo oscuro */
html.dark-mode #saveStatus.bg-light,
.dark-mode #saveStatus.bg-light,
html.dark-mode .badge.bg-light,
.dark-mode .badge.bg-light {
    background-color: rgba(255, 255, 255, 0.08) !important;
    color: #cbd5e1 !important;
    border-color: rgba(255, 255, 255, 0.15) !important;
}