/* Dark mode overrides */
body {
    background-color: #121416 !important;
    color: #e6eef6 !important;        
}
:root {
    --panel-header-start: #162d47;
    --panel-header-end: #13263d;
    --panel-header-border: #244160;
}

.card-header h6,
.card-header h5,
.card-header .text-primary,
.card-header .text-secondary,
.card-header .text-success {
    color: #ffffff !important;
}

.app-title-icon {
    border-color: rgba(107, 149, 206, 0.5) !important;
    background: linear-gradient(180deg, rgba(20, 36, 54, 0.96) 0%, rgba(18, 31, 46, 0.94) 100%) !important;
    box-shadow: 0 6px 15px rgba(2, 10, 22, 0.42) !important;
}
.navbar, .navbar-dark.bg-dark {
    background-color: #1f2933 !important;
}
.card, .table, .table-responsive, .card-body {
    background-color: #1b2226 !important;
    color: #e6eef6 !important;
    border-color: #2a3338 !important;
}
.table thead.table-dark th {
    background-color: #263238 !important;
    color: #e6eef6 !important;
}
.badge {
    opacity: 0.95;
}
.dropdown-menu {
    background-color: #182024;
    color: #e6eef6;
    border-color: #2a3338;
}
.dropdown-menu .dropdown-item {
    color: #e6eef6 !important;
}
.dropdown-menu .dropdown-item:hover, .dropdown-menu .dropdown-item:focus {
    background-color: rgba(255,255,255,0.03);
    color: #ffffff !important;
}

/* Navbar moderno en dark mode: iconos grandes y acento visual */
.navbar .nav-link {
    display: inline-flex;
    align-items: center;
    gap: 0.45rem;
    border-radius: 0.55rem;
    padding: 0.42rem 0.66rem;
}

.navbar .nav-link i {
    font-size: 1.08rem;
    line-height: 1;
    color: #82c5ff;
    transition: transform 0.18s ease, color 0.18s ease;
}

.navbar .nav-link:hover,
.navbar .nav-link:focus {
    background: rgba(59, 130, 246, 0.14);
}

.navbar .nav-link:hover i,
.navbar .nav-link:focus i {
    color: #3ea0ff;
    transform: translateY(-1px);
}

.navbar .nav-link.active {
    background: rgba(59, 130, 246, 0.2);
    color: #ffffff !important;
}

.navbar .nav-link.active i {
    color: #54adff;
}

/* Navegacion de modulos (apps) en dark mode */
.app-module-nav {
    border-color: rgba(86, 120, 167, 0.4) !important;
    background: linear-gradient(132deg, #111a24 0%, #152232 45%, #101b28 100%) !important;
    box-shadow: 0 18px 38px rgba(2, 8, 18, 0.56) !important;
}

.app-module-nav::before {
    background: radial-gradient(circle at 8% 6%, rgba(var(--module-accent-rgb), 0.2) 0%, rgba(var(--module-accent-rgb), 0) 44%);
}

.app-nav-link {
    color: #dbeafe !important;
    border-color: rgba(114, 149, 197, 0.38) !important;
    background: rgba(16, 27, 39, 0.82) !important;
    box-shadow: 0 8px 17px rgba(3, 10, 22, 0.38) !important;
}

.app-nav-link i {
    color: #96cbff !important;
    background: rgba(var(--module-accent-rgb), 0.24) !important;
}

.app-nav-link:hover,
.app-nav-link:focus-visible {
    color: #ffffff !important;
    background: rgba(18, 34, 49, 0.96) !important;
    border-color: rgba(var(--module-accent-rgb), 0.72) !important;
    box-shadow: 0 12px 24px rgba(0, 0, 0, 0.45) !important;
}

.app-nav-link.is-active {
    color: #ffffff !important;
    border-color: rgba(var(--module-accent-rgb), 0.96) !important;
    background: linear-gradient(135deg, rgba(var(--module-accent-rgb), 0.92) 0%, rgba(var(--module-accent-rgb), 0.72) 100%) !important;
}

.app-nav-link.is-active i {
    background: rgba(7, 17, 29, 0.86) !important;
    color: #c6e4ff !important;
}
.form-control {
    background-color: #101418;
    color: #e6eef6;
    border-color: #263238;
}

/* Inputs: focus, placeholder, selection and autofill adjustments for dark mode */
.form-control::placeholder,
.form-select::placeholder {
    color: #9fb0bf !important;
    opacity: 1 !important;
}

.form-control:focus,
.form-select:focus,
textarea:focus {
    background-color: #0f1416 !important;
    color: #e6eef6 !important;
    border-color: #3b82f6 !important; /* slightly bluish focus */
    box-shadow: 0 0 0 0.15rem rgba(59,130,246,0.15) !important;
}

/* Selection color inside inputs */
.form-control::selection, textarea::selection {
    background: rgba(59,130,246,0.25);
    color: #ffffff;
}

/* WebKit autofill: force dark background and readable text */
input:-webkit-autofill,
textarea:-webkit-autofill,
select:-webkit-autofill {
    -webkit-box-shadow: 0 0 0 30px #101418 inset !important;
    box-shadow: 0 0 0 30px #101418 inset !important;
    -webkit-text-fill-color: #e6eef6 !important;
}

/* Input groups */
.input-group .form-control,
.input-group .form-select {
    background-color: #101418 !important;
    color: #e6eef6 !important;
    border-color: #263238 !important;
}

/* Global text selection for dark mode: less saturated blue and white text for legibility */
::selection { background: rgba(59,130,246,0.35); color: #ffffff; }
::-moz-selection { background: rgba(59,130,246,0.35); color: #ffffff; }

/* Improve small/muted text legibility in dark containers */
.small, small, .text-muted {
    color: #9fb0bf !important;
}

/* Tweak timestamp/meta classes to ensure they remain readable */
.timestamp, .meta, .last-access {
    color: #e6eef6 !important;
    background: transparent !important;
}

/* Disabled / readonly inputs ensure contrast still readable */
.form-control[disabled], .form-control:disabled,
.form-control[readonly] {
    background-color: #0f1416 !important;
    color: #9fb0bf !important;
    opacity: 1 !important;
}

/* Small tweaks for inputs inside .card or dark containers */
.card .form-control,
.card .form-select {
    background-color: #0f1416 !important;
    color: #e6eef6 !important;
    border-color: #232a2d !important;
}
.form-select,
select,
select.form-control,
.form-control[type="select"],
.custom-select {
    background-color: #101418 !important;
    color: #e6eef6 !important;
    border-color: #263238 !important;
}

/* Bootstrap dropdown toggle (select-like) */
.dropdown-toggle::after {
    filter: brightness(0.95) invert(0.95);
}

/* Select2 integration (single/multiple) */
.select2-container--default .select2-selection--single {
    background-color: #101418 !important;
    border: 1px solid #263238 !important;
    color: #e6eef6 !important;
}
.select2-container--default .select2-selection--single .select2-selection__rendered {
    color: #e6eef6 !important;
}
.select2-container--default .select2-results__option {
    background-color: #101418;
    color: #e6eef6;
}
.select2-container--default .select2-results__option--highlighted {
    background-color: rgba(255,255,255,0.03);
    color: #fff;
}

/* Modal content in dark mode */
.modal-content {
    background-color: #121417 !important;
    color: #e6eef6 !important;
    border-color: #2a3338 !important;
}

/* Dropdowns inside modals */
.modal .dropdown-menu {
    background-color: #151a1c !important;
}

/* Improve contrast for option elements in plain <select> */
select option {
    background-color: #101418;
    color: #e6eef6;
}

/* Small adjustments for Bootstrap custom selects and inline form selects */
.input-group .form-select, .input-group .form-control.form-select {
    background-color: #101418 !important;
    color: #e6eef6 !important;
    border-color: #263238 !important;
}
.btn-primary {
    background-color: #0d6efd;
    border-color: #0d6efd;
}
.btn-secondary {
    background-color: #374151;
    border-color: #374151;
}
.table tbody tr td {
    border-color: #2a3338;
}
/* Charts canvas background fix */
.chart-bar, .chart-pie {
    background: transparent;
}

/* Force tables to use dark backgrounds and light text */
.table {
    color: #e6eef6;
}
.table thead th {
    background-color: #263238 !important;
    color: #e6eef6 !important;
    border-color: #2a3338 !important;
}
.table tbody td {
    background-color: rgba(255,255,255,0.02) !important;
    color: #e6eef6 !important;
}
.table.table-striped tbody tr:nth-of-type(odd) td {
    background-color: rgba(255,255,255,0.02) !important;
}
.table.table-striped tbody tr:nth-of-type(even) td {
    background-color: rgba(255,255,255,0.03) !important;
}
.table-hover tbody tr:hover td {
    background-color: rgba(255,255,255,0.04) !important;
}

/* DataTables inputs contrast */
.dataTables_wrapper .dataTables_filter input, .dataTables_wrapper .dataTables_length select {
    background: #0f1416;
    color: #e6eef6;
    border-color: #263238;
}

/* DataTables pagination in dark mode */
.dataTables_wrapper .dataTables_paginate {
    margin-top: 0.75rem;
}
.dataTables_wrapper .dataTables_paginate .paginate_button {
    color: #cfe0f0 !important;
    border: 1px solid #2a3338 !important;
    background: #1b2024 !important;
    box-shadow: none !important;
}
.dataTables_wrapper .dataTables_paginate .paginate_button:hover {
    color: #ffffff !important;
    border-color: #375a7f !important;
    background: #22303a !important;
}
.dataTables_wrapper .dataTables_paginate .paginate_button.current, 
.dataTables_wrapper .dataTables_paginate .paginate_button.current:hover {
    color: #ffffff !important;
    border-color: #3b82f6 !important;
    background: #1e3a8a !important; /* dark blue */
}
.dataTables_wrapper .dataTables_paginate .paginate_button.disabled, 
.dataTables_wrapper .dataTables_paginate .paginate_button.disabled:hover {
    color: #7f8a94 !important;
    border-color: #2a3338 !important;
    background: #151a1d !important;
}
.dataTables_wrapper .dataTables_paginate .ellipsis {
    color: #9fb0bf !important;
}
.dataTables_wrapper .dataTables_info {
    color: #9fb0bf !important;
}

/* Bootstrap 5 pagination (used by DataTables Bootstrap integration) */
.dataTables_wrapper .pagination .page-link {
    background-color: #1b2024 !important;
    color: #cfe0f0 !important;
    border-color: #2a3338 !important;
}
.dataTables_wrapper .pagination .page-link:hover {
    background-color: #22303a !important;
    color: #ffffff !important;
    border-color: #375a7f !important;
}
.dataTables_wrapper .pagination .page-item.active .page-link {
    background-color: #1e3a8a !important; /* active */
    border-color: #3b82f6 !important;
    color: #ffffff !important;
}

.dataTables_wrapper .pagination .page-item.disabled .page-link {
    background-color: #151a1d !important;
    border-color: #2a3338 !important;
    color: #7f8a94 !important;
}

/* Documentos: barra de acciones en detalle */
.doc-detail-actions .btn {
    box-shadow: none;
}

.doc-detail-actions .btn-outline-primary {
    color: #86b9ff !important;
    border-color: #4b8cff !important;
    background-color: transparent !important;
}

.doc-detail-actions .btn-outline-warning {
    color: #ffd166 !important;
    border-color: #ffbf3c !important;
    background-color: transparent !important;
}

.doc-detail-actions .btn-outline-danger {
    color: #ff8a80 !important;
    border-color: #ff6b6b !important;
    background-color: transparent !important;
}

.doc-detail-actions .btn-outline-secondary {
    color: #d6e4f3 !important;
    border-color: #6f8395 !important;
    background-color: transparent !important;
}

.doc-detail-actions .btn-outline-primary:hover,
.doc-detail-actions .btn-outline-primary:focus {
    color: #0f1416 !important;
    background-color: #4b8cff !important;
    border-color: #4b8cff !important;
}

.doc-detail-actions .btn-outline-warning:hover,
.doc-detail-actions .btn-outline-warning:focus {
    color: #111111 !important;
    background-color: #ffbf3c !important;
    border-color: #ffbf3c !important;
}

.doc-detail-actions .btn-outline-danger:hover,
.doc-detail-actions .btn-outline-danger:focus {
    color: #111111 !important;
    background-color: #ff6b6b !important;
    border-color: #ff6b6b !important;
}

.doc-detail-actions .btn-outline-secondary:hover,
.doc-detail-actions .btn-outline-secondary:focus {
    color: #111111 !important;
    background-color: #a9b8c7 !important;
    border-color: #a9b8c7 !important;
}

/* Plantilla visual unificada para paginas con tablas */
.container > .d-flex.justify-content-between.align-items-center.mb-4 h1.h3 {
    color: #f4f8ff !important;
    font-weight: 700;
    letter-spacing: 0.2px;
}

.container .card.shadow.mb-4 {
    border: 1px solid #25313a !important;
    border-radius: 10px !important;
    overflow: hidden;
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.24) !important;
}

.container .card.shadow.mb-4:hover {
    transform: none;
}

.container .card.shadow.mb-4 > .card-header {
    position: relative;
    padding: 0.72rem 1rem !important;
    background: linear-gradient(90deg, var(--panel-header-start) 0%, var(--panel-header-end) 100%) !important;
    color: #ffffff !important;
    border-bottom: 1px solid var(--panel-header-border) !important;
}

.container .card.shadow.mb-4 > .card-header::before {
    content: "";
    position: absolute;
    left: 0.8rem;
    top: 50%;
    transform: translateY(-50%);
    width: 3px;
    height: 62%;
    border-radius: 999px;
    background: linear-gradient(180deg, #9cc9ff 0%, #c2ddff 100%);
}

.container .card.shadow.mb-4 > .card-header h6 {
    margin-left: 0.5rem !important;
    letter-spacing: 0.15px;
}

.container .card.shadow.mb-4 > .card-header .text-primary,
.container .card.shadow.mb-4 > .card-header .text-secondary {
    color: #ffffff !important;
}

.container .card.shadow.mb-4 > .card-header.bg-primary.text-white,
.container .card.shadow.mb-4 > .card-header.bg-secondary.text-white,
.container .card.shadow.mb-4 > .card-header.bg-success.text-white {
    background: linear-gradient(90deg, var(--panel-header-start) 0%, var(--panel-header-end) 100%) !important;
    border-bottom: 1px solid var(--panel-header-border) !important;
}

.container .card.shadow.mb-4 > .card-header.bg-primary.text-white::before,
.container .card.shadow.mb-4 > .card-header.bg-secondary.text-white::before,
.container .card.shadow.mb-4 > .card-header.bg-success.text-white::before {
    background: rgba(235, 246, 255, 0.95);
}

.container .card.shadow.mb-4 .card-body {
    padding: 1rem 1rem 0.9rem;
}

.container .card.shadow.mb-4 .form-label {
    color: #dbe7f4 !important;
    font-weight: 600;
}

.container .card.shadow.mb-4 .form-control,
.container .card.shadow.mb-4 .form-select {
    min-height: 2.2rem;
    border-radius: 0.45rem;
}

.container .card.shadow.mb-4 .table-responsive {
    border-radius: 0.55rem;
    border: 0;
    overflow: hidden;
}

.container .card.shadow.mb-4 .table {
    margin-bottom: 0;
    box-shadow: none;
}

.container .card.shadow.mb-4 .table thead th {
    text-transform: none;
    letter-spacing: 0;
    font-weight: 700;
}

.dataTables_wrapper .row:first-child {
    align-items: center;
    margin-bottom: 0.85rem;
    border: 0 !important;
    box-shadow: none !important;
}

.dataTables_wrapper .row:last-child {
    border: 0 !important;
    box-shadow: none !important;
}

.dataTables_wrapper .dataTables_length label,
.dataTables_wrapper .dataTables_filter label {
    color: #d1deec !important;
    font-weight: 600;
}

.dataTables_wrapper .dataTables_length select,
.dataTables_wrapper .dataTables_filter input {
    min-height: 2rem;
    border-radius: 0.4rem;
    margin-left: 0.4rem;
}

.dataTables_wrapper .dataTables_info {
    padding-top: 0.9rem !important;
}

.dataTables_wrapper .pagination {
    gap: 0.2rem;
}

.dataTables_wrapper .pagination .page-link {
    border-radius: 0.4rem !important;
}

/* Nuevo layout de tablas: controles limpios + tabla encapsulada sin lineas residuales */
.dataTables_wrapper .table-responsive {
    margin-top: 0.35rem;
    border: 1px solid #2a3338;
    border-radius: 0.55rem;
    overflow: hidden;
    background-color: #1b2226;
}

.dataTables_wrapper .table-responsive > .table,
.dataTables_wrapper table.table.table-bordered {
    margin-bottom: 0 !important;
    border-top: 0 !important;
    box-shadow: none !important;
}

.dataTables_wrapper .table-responsive > .table thead th,
.dataTables_wrapper table.table.table-bordered thead th {
    border-top: 0 !important;
}

/* Modo compacto para ver mas registros por pantalla */
.dataTables_wrapper table.table thead th {
    padding: 0.52rem 0.62rem;
    font-size: 0.92rem;
}

.dataTables_wrapper table.table tbody td {
    padding: 0.42rem 0.62rem;
    line-height: 1.25;
}

.dataTables_wrapper table.table .btn.btn-sm {
    padding: 0.2rem 0.45rem;
    font-size: 0.78rem;
}

.dataTables_wrapper table.table .badge {
    font-size: 0.72rem;
    padding: 0.22em 0.45em;
}

/* Tarjetas KPI unificadas (dashboard) */
.wf-stat-card,
.card.border-left-primary.shadow.h-100.py-2,
.card.border-left-success.shadow.h-100.py-2,
.card.border-left-info.shadow.h-100.py-2,
.card.border-left-warning.shadow.h-100.py-2,
.card.border-left-danger.shadow.h-100.py-2,
.card.border-left-secondary.shadow.h-100.py-2 {
    border-radius: 10px;
    border: 1px solid #2b3a45 !important;
    background: linear-gradient(135deg, #1a2630 0%, #17212b 100%) !important;
    box-shadow: 0 8px 22px rgba(0, 0, 0, 0.28) !important;
    transition: transform 0.18s ease, box-shadow 0.18s ease;
}

.wf-stat-card:hover,
.card.border-left-primary.shadow.h-100.py-2:hover,
.card.border-left-success.shadow.h-100.py-2:hover,
.card.border-left-info.shadow.h-100.py-2:hover,
.card.border-left-warning.shadow.h-100.py-2:hover,
.card.border-left-danger.shadow.h-100.py-2:hover,
.card.border-left-secondary.shadow.h-100.py-2:hover {
    transform: translateY(-2px);
    box-shadow: 0 12px 28px rgba(0, 0, 0, 0.36) !important;
}

.wf-stat-card .card-body {
    padding: 0.95rem 1.05rem;
}

.wf-stat-card .row.no-gutters {
    display: flex;
    flex-wrap: nowrap;
    align-items: center;
    gap: 0.75rem;
}

.wf-stat-card .row.no-gutters > .col-auto {
    order: 0;
    flex: 0 0 auto;
    width: 54px;
    height: 54px;
    border-radius: 14px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    background: rgba(84, 173, 255, 0.14);
}

.wf-stat-card .row.no-gutters > .col.mr-2 {
    order: 1;
    margin-right: 0 !important;
    flex: 1 1 auto;
    min-width: 0;
    display: flex;
    flex-direction: column-reverse;
    gap: 0.2rem;
}

/* Refuerzo visual: texto siempre a la derecha del icono en variantes KPI */
.wf-stat-card .card-body > .row.no-gutters,
.card.border-left-primary.shadow.h-100.py-2 .card-body > .row.no-gutters,
.card.border-left-success.shadow.h-100.py-2 .card-body > .row.no-gutters,
.card.border-left-info.shadow.h-100.py-2 .card-body > .row.no-gutters,
.card.border-left-warning.shadow.h-100.py-2 .card-body > .row.no-gutters,
.card.border-left-danger.shadow.h-100.py-2 .card-body > .row.no-gutters,
.card.border-left-secondary.shadow.h-100.py-2 .card-body > .row.no-gutters {
    flex-wrap: nowrap;
}

.wf-stat-card .text-xs,
.wf-stat-card .text-muted {
    font-size: 0.82rem;
    text-transform: none !important;
    letter-spacing: 0.01em;
    color: #9fb3c8 !important;
    margin-bottom: 0 !important;
}

.wf-stat-card .h5,
.wf-stat-card .fw-bold.fs-5 {
    font-size: 2.05rem !important;
    line-height: 1.05;
    color: #f2f7ff !important;
    font-weight: 700 !important;
    margin-bottom: 0 !important;
}

.wf-stat-card i {
    font-size: 2rem !important;
    opacity: 0.95;
    color: #54adff !important;
    text-shadow: 0 6px 18px rgba(84, 173, 255, 0.28);
}

/* Variante para tarjetas con layout d-flex (p.ej. documental) */
.wf-stat-card .card-body.d-flex > i.bi {
    width: 54px;
    height: 54px;
    border-radius: 14px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    background: rgba(84, 173, 255, 0.14);
}

/* Colores de icono por acento de tarjeta */
.wf-stat-card.border-left-primary i,
.wf-stat-card.border-start.border-primary i {
    color: #54adff !important;
    background: rgba(84, 173, 255, 0.2) !important;
}

.wf-stat-card.border-left-success i,
.wf-stat-card.border-start.border-success i {
    color: #2ed18f !important;
    background: rgba(46, 209, 143, 0.2) !important;
}

.wf-stat-card.border-left-info i,
.wf-stat-card.border-start.border-info i {
    color: #29c7e6 !important;
    background: rgba(41, 199, 230, 0.2) !important;
}

.wf-stat-card.border-left-warning i,
.wf-stat-card.border-start.border-warning i {
    color: #ffc247 !important;
    background: rgba(255, 194, 71, 0.2) !important;
}

.wf-stat-card.border-left-danger i,
.wf-stat-card.border-start.border-danger i {
    color: #ff7285 !important;
    background: rgba(255, 114, 133, 0.2) !important;
}

.wf-stat-card.border-left-secondary i,
.wf-stat-card.border-start.border-secondary i {
    color: #afc3d6 !important;
    background: rgba(175, 195, 214, 0.2) !important;
}

/* Portal de APPS: tarjetas modernas */
.app-portal-card {
    border: 1px solid #25405a !important;
    border-radius: 14px;
    background: linear-gradient(150deg, #182632 0%, #15222d 100%) !important;
    box-shadow: 0 10px 24px rgba(0, 0, 0, 0.28) !important;
}

.app-portal-card.is-clickable:hover {
    border-color: #2f5680 !important;
    box-shadow: 0 14px 28px rgba(0, 0, 0, 0.38) !important;
}

.app-portal-icon {
    border-color: #2f5680 !important;
    background: linear-gradient(180deg, #1d3348 0%, #1b2d3f 100%) !important;
    color: #8ec7ff !important;
    box-shadow: 0 7px 16px rgba(7, 22, 40, 0.45) !important;
}

.app-portal-title {
    color: #edf5ff !important;
}

.app-portal-description {
    color: #c8d9ea !important;
}

.app-portal-hint {
    color: #69b0ff !important;
}

