/* Dark Mode Styles */
body.dark-mode {
    background-color: #121212;
    color: #e0e0e0;
    transition: background-color 0.3s ease, color 0.3s ease;
}

body.dark-mode .main-sidebar {
    background: linear-gradient(180deg, #1a1a1a, #0d0d0d);
    box-shadow: 2px 0 10px rgba(0, 0, 0, 0.5);
}

body.dark-mode .brand-link {
    background: rgba(255, 255, 255, 0.03);
    border-bottom: 1px solid rgba(255, 255, 255, 0.05);
}

body.dark-mode .user-panel {
    background: rgba(255, 255, 255, 0.02);
    border-bottom: 1px solid rgba(255, 255, 255, 0.05);
}

body.dark-mode .nav-sidebar .nav-item .nav-link {
    color: #e0e0e0;
}

body.dark-mode .nav-sidebar .nav-item .nav-link:hover {
    background-color: rgba(255, 255, 255, 0.05);
}

body.dark-mode .nav-sidebar .nav-item .nav-link.active {
    background: linear-gradient(90deg, #007bff, #0056b3);
    box-shadow: 0 2px 10px rgba(0, 123, 255, 0.2);
}

body.dark-mode .content-wrapper {
    background-color: #121212;
}

body.dark-mode .card {
    background-color: #1e1e1e;
    border-color: #333;
    box-shadow: 0 0.125rem 0.375rem rgba(0, 0, 0, 0.3);
}

body.dark-mode .card-header {
    background-color: #252525;
    border-bottom-color: #333;
    color: #e0e0e0;
}

body.dark-mode .card-footer {
    background-color: #252525;
    border-top-color: #333;
}

body.dark-mode .main-footer {
    background: linear-gradient(to right, #1a1a1a, #1e1e1e);
    border-top: 1px solid rgba(255, 255, 255, 0.05);
    color: #aaa;
    box-shadow: 0 -1px 5px rgba(0, 0, 0, 0.3);
}

body.dark-mode .main-footer strong {
    color: #e0e0e0;
}

body.dark-mode .main-footer a {
    color: #4da3ff;
}

body.dark-mode .main-footer a:hover {
    color: #77b7ff;
}

body.dark-mode .main-footer .version {
    background-color: #252525;
    color: #aaa;
}

/* Estilos mejorados para tablas */
body.dark-mode .table {
    color: #e0e0e0;
}

body.dark-mode .table td,
body.dark-mode .table th {
    border-color: #333;
    color: #e0e0e0;
}

/* Cabecera de tabla */
body.dark-mode .table thead th {
    background-color: #252525;
    color: #e0e0e0;
    border-color: #333;
}

/* Filas alternadas de la tabla */
body.dark-mode .table-striped tbody tr:nth-of-type(odd) {
    background-color: #1a1a1a;
}

body.dark-mode .table-striped tbody tr:nth-of-type(even) {
    background-color: #222;
}

/* Hover en filas de tabla */
body.dark-mode .table-hover tbody tr:hover {
    background-color: #2a2a2a;
    color: #ffffff;
}

/* Estilos para DataTables */
body.dark-mode .dataTables_wrapper .dataTables_length select,
body.dark-mode .dataTables_wrapper .dataTables_filter input {
    background-color: #252525;
    border-color: #333;
    color: #e0e0e0;
}

body.dark-mode .dataTables_wrapper .dataTables_info,
body.dark-mode .dataTables_wrapper .dataTables_paginate .paginate_button {
    color: #e0e0e0 !important;
}

body.dark-mode .dataTables_wrapper .dataTables_paginate .paginate_button:hover {
    background: #2a2a2a !important;
    color: #ffffff !important;
    border-color: #333 !important;
}

body.dark-mode .dataTables_wrapper .dataTables_paginate .paginate_button.current {
    background: linear-gradient(to bottom, #007bff, #0056b3) !important;
    color: #ffffff !important;
    border-color: #0056b3 !important;
}

body.dark-mode .dataTables_wrapper .dataTables_paginate .paginate_button.current:hover {
    background: linear-gradient(to bottom, #0069d9, #0043a0) !important;
}

/* Formularios */
body.dark-mode .form-control {
    background-color: #252525;
    border-color: #333;
    color: #e0e0e0;
}

body.dark-mode .form-control:focus {
    background-color: #2a2a2a;
    border-color: #0069d9;
    color: #e0e0e0;
    box-shadow: 0 0 0 0.2rem rgba(0, 123, 255, 0.25);
}

body.dark-mode .form-control::placeholder {
    color: #999;
}

body.dark-mode .form-select {
    background-color: #252525;
    border-color: #333;
    color: #e0e0e0;
}

body.dark-mode .input-group-text {
    background-color: #252525;
    border-color: #333;
    color: #e0e0e0;
}

body.dark-mode .form-label {
    color: #e0e0e0;
}

/* Botones */
body.dark-mode .btn-default {
    background-color: #2a2a2a;
    border-color: #333;
    color: #e0e0e0;
}

body.dark-mode .btn-default:hover {
    background-color: #3a3a3a;
    border-color: #444;
    color: #ffffff;
}

body.dark-mode .btn-outline-info {
    color: #4da3ff;
    border-color: #4da3ff;
}

body.dark-mode .btn-outline-info:hover {
    background-color: #4da3ff;
    color: #121212;
}

/* Modales */
body.dark-mode .modal-content {
    background-color: #1e1e1e;
    border-color: #333;
}

body.dark-mode .modal-header {
    border-bottom-color: #333;
    background: linear-gradient(135deg, #1a1a1a, #252525);
}

body.dark-mode .modal-footer {
    border-top-color: #333;
    background-color: #1a1a1a;
}

body.dark-mode .modal-title {
    color: #e0e0e0;
}

body.dark-mode .btn-close {
    filter: invert(1) grayscale(100%) brightness(200%);
}

/* Dropdown */
body.dark-mode .dropdown-menu {
    background-color: #1e1e1e;
    border-color: #333;
    box-shadow: 0 0.5rem 1rem rgba(0, 0, 0, 0.3);
}

body.dark-mode .dropdown-item {
    color: #e0e0e0;
}

body.dark-mode .dropdown-item:hover {
    background-color: #2a2a2a;
    color: #ffffff;
}

body.dark-mode .dropdown-divider {
    border-top-color: #333;
}

/* Dark Mode Toggle Button Styles */
.dark-mode-toggle .btn {
    transition: all 0.3s ease;
}

.dark-mode-toggle .btn i {
    margin-right: 5px;
}

body.dark-mode .dark-mode-toggle .btn {
    background-color: #2a2a2a;
    border-color: #333;
    color: #e0e0e0;
}

body.dark-mode .dark-mode-toggle .btn:hover {
    background-color: #3a3a3a;
    color: #ffffff;
}

/* Dashboard */
body.dark-mode .info-box {
    background-color: #1e1e1e;
    box-shadow: 0 5px 15px rgba(0, 0, 0, 0.2);
}

body.dark-mode .info-box-content {
    color: #e0e0e0;
}

body.dark-mode .info-box-text {
    color: #ccc;
}

body.dark-mode .info-box-number {
    color: #ffffff;
}

body.dark-mode .info-box-progress {
    background: rgba(255, 255, 255, 0.05);
}

body.dark-mode .chart-container {
    background-color: #1e1e1e;
    box-shadow: 0 5px 15px rgba(0, 0, 0, 0.2);
}

body.dark-mode .chart-title {
    color: #e0e0e0;
    border-bottom-color: #333;
}

body.dark-mode .chart-legend-item {
    color: #ccc;
}

/* Estilos para el Calendario del Turnero */
body.dark-mode .calendar {
    background-color: #1e1e1e;
    border-radius: 10px;
    padding: 15px;
    box-shadow: 0 5px 15px rgba(0, 0, 0, 0.2);
}

body.dark-mode .calendar header {
    padding: 10px 15px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    border-bottom: 1px solid #333;
}

body.dark-mode .calendar .days li {
    color: #e0e0e0;
}

body.dark-mode .calendar .days li:not(.active):not(.today):not(.other-month) {
    color: #e0e0e0;
}

body.dark-mode .calendar .days li.other-month {
    color: #666;
}

body.dark-mode .calendar .days li.today {
    color: #ffffff;
    background-color: rgba(0, 123, 255, 0.3);
    border-radius: 50%;
    box-shadow: 0 0 0 2px rgba(0, 123, 255, 0.3);
}

body.dark-mode .calendar .days li.active {
    color: #ffffff;
    background-color: #007bff;
    border-radius: 50%;
    box-shadow: 0 2px 5px rgba(0, 123, 255, 0.5);
}

body.dark-mode .calendar .days li:hover:not(.active):not(.today):not(.other-month) {
    background-color: #2a2a2a;
    color: #ffffff;
    border-radius: 50%;
}

body.dark-mode .calendar .weeks li {
    color: #aaa;
    font-weight: 500;
}

body.dark-mode .calendar .current-date {
    color: #ffffff;
    font-weight: 600;
}

body.dark-mode .calendar .icons span {
    color: #e0e0e0;
    background-color: #2a2a2a;
    border-radius: 50%;
    width: 30px;
    height: 30px;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.3s ease;
}

body.dark-mode .calendar .icons span:hover {
    background-color: #3a3a3a;
    transform: translateY(-2px);
    box-shadow: 0 2px 5px rgba(0, 0, 0, 0.3);
}

/* Alertas y notificaciones */
body.dark-mode .alert {
    border: none;
    box-shadow: 0 0.125rem 0.25rem rgba(0, 0, 0, 0.3);
}

body.dark-mode .alert-primary {
    background-color: rgba(0, 123, 255, 0.15);
    color: #7bb9ff;
}

body.dark-mode .alert-success {
    background-color: rgba(40, 167, 69, 0.15);
    color: #8eda9f;
}

body.dark-mode .alert-info {
    background-color: rgba(23, 162, 184, 0.15);
    color: #82d7e8;
}

body.dark-mode .alert-warning {
    background-color: rgba(255, 193, 7, 0.15);
    color: #ffe083;
}

body.dark-mode .alert-danger {
    background-color: rgba(220, 53, 69, 0.15);
    color: #f09da6;
}

/* Scrollbar personalizado */
body.dark-mode::-webkit-scrollbar {
    width: 10px;
}

body.dark-mode::-webkit-scrollbar-track {
    background: #1a1a1a;
}

body.dark-mode::-webkit-scrollbar-thumb {
    background: #333;
    border-radius: 5px;
}

body.dark-mode::-webkit-scrollbar-thumb:hover {
    background: #444;
}

/* =========================================================
   OVERRIDES FUERTES DE TABLAS ESPECÍFICAS (HCI / GM2 / GENERAL)
   ========================================================= */
body.dark-mode .table-responsive { background-color: transparent !important; border-color: #333 !important; }

/* Tabla principal HC/Pacientes, GM2, Turnero V2, Alta Administrativa V2 y HCI Global */
body.dark-mode #tblpacientes.table-striped tbody tr:nth-of-type(odd),
body.dark-mode #gm2_tbl.table-striped tbody tr:nth-of-type(odd),
body.dark-mode #turnero_v2_tblDia.table-striped tbody tr:nth-of-type(odd),
body.dark-mode #turnero_v2_dniTbl tbody tr:nth-of-type(odd),
body.dark-mode #aa2_tbl.table-striped tbody tr:nth-of-type(odd),
body.dark-mode #hci-modal .table-striped tbody tr:nth-of-type(odd) {
    background-color: rgba(255, 255, 255, 0.05) !important;
}
body.dark-mode #tblpacientes.table-striped tbody tr:nth-of-type(even),
body.dark-mode #gm2_tbl.table-striped tbody tr:nth-of-type(even),
body.dark-mode #turnero_v2_tblDia.table-striped tbody tr:nth-of-type(even),
body.dark-mode #turnero_v2_dniTbl tbody tr:nth-of-type(even),
body.dark-mode #aa2_tbl.table-striped tbody tr:nth-of-type(even),
body.dark-mode #hci-modal .table-striped tbody tr:nth-of-type(even) {
    background-color: transparent !important;
}
body.dark-mode #tblpacientes tbody td,
body.dark-mode #gm2_tbl tbody td,
body.dark-mode #turnero_v2_tblDia tbody td,
body.dark-mode #turnero_v2_dniTbl tbody td,
body.dark-mode #aa2_tbl tbody td,
body.dark-mode #hci-modal .table tbody td {
    color: #e0e0e0 !important;
    background-color: transparent !important;
}

/* Gestión Médico V2 y Alta Administrativa V2 específicos (filtros, tablewrap) */
body.dark-mode .gm2-filters,
body.dark-mode .gm2-tablewrap,
body.dark-mode .aa2-filters,
body.dark-mode .aa2-tablewrap {
    background: #1e1e1e !important;
    border-color: #333 !important;
}
body.dark-mode .gm2-col-actions,
body.dark-mode #gm2_tbl td.gm2-td-actions,
body.dark-mode .aa2-col-actions,
body.dark-mode #aa2_tbl td.aa2-td-actions {
    background: #1e1e1e !important;
}
body.dark-mode #gm2_tbl.table-striped tbody tr:nth-of-type(odd) td.gm2-td-actions,
body.dark-mode #aa2_tbl.table-striped tbody tr:nth-of-type(odd) td.aa2-td-actions {
    background: #242424 !important; /* Slightly lighter for odd row sticky column */
}

/* Turnero V2 específicos */
body.dark-mode #turnero_v2_root .turnero-card,
body.dark-mode #turnero_v2_root .turnero-day,
body.dark-mode #turnero_v2_root .turnero-cal,
body.dark-mode .dni-pac-card {
    background: #1e1e1e !important;
    border-color: #333 !important;
}
body.dark-mode #turnero_v2_root .card-body > .row:first-child,
body.dark-mode .turnero-morebox {
    background: #252525 !important;
    border-color: #333 !important;
}
body.dark-mode #turnero_v2_tblDia .th-actions,
body.dark-mode #turnero_v2_tblDia td.td-actions {
    background: #1e1e1e !important; 
}
body.dark-mode #turnero_v2_tblDia.table-striped tbody tr:nth-of-type(odd) td.td-actions {
    background: #242424 !important; 
}
body.dark-mode #turnero_v2_mdlTurno .modal-content,
body.dark-mode #turnero_v2_mdlDni .modal-content {
    background: #1e1e1e !important;
    border-color: #333 !important;
}
body.dark-mode #turnero_v2_mdlTurno .modal-header,
body.dark-mode #turnero_v2_mdlDni .modal-header {
    background: #1e1e1e !important;
    border-bottom-color: #333 !important;
}
body.dark-mode #turnero_v2_mdlTurno .modal-title,
body.dark-mode #turnero_v2_mdlDni .modal-title,
body.dark-mode #turnero_v2_root #turnero_v2_lblDia {
    color: #fff !important;
}
body.dark-mode #turnero_v2_dniTbl thead th,
body.dark-mode #turnero_v2_tblDia thead th,
body.dark-mode #aa2_tbl thead th,
body.dark-mode #hci-modal .table thead th {
    background: #1a1a1a !important;
    color: #e0e0e0 !important;
    border-color: #333 !important;
    border-bottom: 2px solid #555 !important;
}
body.dark-mode .dni-pac-card--active {
    background: rgba(37,99,235,.3) !important;
}
body.dark-mode .dni-pac-card__name {
    color: #fff !important;
}
body.dark-mode #turnero_v2_tblDia tr.tr-sobre td:first-child {
    box-shadow: inset 4px 0 0 rgba(168, 85, 247, .85) !important;
}

body.dark-mode .btn-icon {
    background: #2a2a2a !important;
    border-color: #333 !important;
    color: #e0e0e0 !important;
}
body.dark-mode .btn-icon:hover {
    background: #3a3a3a !important;
}

/* =========================================================
   PERFIL PACIENTE / HCI GLOBAL MODAL
   ========================================================= */
body.dark-mode #hci-modal .modal-content {
    background: #1e1e1e !important;
}
body.dark-mode #hci-modal .modal-body {
    background: #121212 !important;
}
body.dark-mode #hci-modal .paciente-info {
    background: #252525 !important;
    border-color: #333 !important;
    box-shadow: 0 2px 12px rgba(0,0,0,0.5) !important;
}
body.dark-mode #hci-modal #hci-paciente-nombre {
    color: #fff !important;
}
body.dark-mode #hci-modal #hci-list {
    background: #1e1e1e !important;
    border-color: #333 !important;
}
body.dark-mode #hci-modal .list-group-item {
    background: #1e1e1e !important;
    border-bottom-color: #333 !important;
    color: #e0e0e0 !important;
}
body.dark-mode #hci-modal .list-group-item:hover {
    background: #2a2a2a !important;
    color: #fff !important;
}
body.dark-mode #hci-modal .list-group-item.active {
    background: linear-gradient(135deg, #0d47a1, #1565c0) !important;
    color: #fff !important;
}
body.dark-mode #hci-modal #hci-detail {
    background: #1e1e1e !important;
    box-shadow: 0 2px 12px rgba(0,0,0,0.5) !important;
}
body.dark-mode #hci-modal .nav-tabs .nav-link {
    color: #aaa !important;
}
body.dark-mode #hci-modal .nav-tabs .nav-link.active {
    background: #252525 !important;
    color: #fff !important;
    border-bottom-color: #1a73e8 !important;
}
body.dark-mode #hci-modal .nav-tabs .nav-link:hover:not(.active) {
    background: #2a2a2a !important;
    color: #fff !important;
}
body.dark-mode #hci-modal .evol-item {
    background: #252525 !important;
    border-color: #333 !important;
}
body.dark-mode #hci-modal .evol-header {
    color: #fff !important;
}
body.dark-mode #hci-modal .evol-text {
    color: #ccc !important;
}
body.dark-mode #hci-modal .modal-footer {
    background: #1a1a1a !important;
    border-top-color: #333 !important;
}
body.dark-mode #hci-modal .table tbody tr:hover {
    background: rgba(255, 255, 255, 0.1) !important;
}

/* =========================================================
   MODALES DE ALTA ADMINISTRATIVA V2 (AA2)
   ========================================================= */
body.dark-mode #aa2_mdlHC .modal-content,
body.dark-mode #aa2_mdlPaciente .modal-content,
body.dark-mode #aa2_mdlAlta .modal-content,
body.dark-mode #aa2_mdlCobro .modal-content {
    background: #1e1e1e !important;
    border-color: #333 !important;
    color: #e0e0e0 !important;
}
body.dark-mode #aa2_mdlHC .modal-header,
body.dark-mode #aa2_mdlPaciente .modal-header,
body.dark-mode #aa2_mdlAlta .modal-header,
body.dark-mode #aa2_mdlCobro .modal-header {
    background: #1a1a1a !important;
    border-bottom-color: #333 !important;
}
body.dark-mode #aa2_h_tbl.table-striped tbody tr:nth-of-type(odd),
body.dark-mode #aa2_h_tbl_files.table-striped tbody tr:nth-of-type(odd),
body.dark-mode #aa2_a_tbl_items.table-striped tbody tr:nth-of-type(odd),
body.dark-mode #aa2_c_tbl.table-striped tbody tr:nth-of-type(odd) {
    background-color: rgba(255, 255, 255, 0.05) !important;
}
body.dark-mode #aa2_h_tbl.table-striped tbody tr:nth-of-type(even),
body.dark-mode #aa2_h_tbl_files.table-striped tbody tr:nth-of-type(even),
body.dark-mode #aa2_a_tbl_items.table-striped tbody tr:nth-of-type(even),
body.dark-mode #aa2_c_tbl.table-striped tbody tr:nth-of-type(even) {
    background-color: transparent !important;
}
body.dark-mode #aa2_h_tbl tbody td,
body.dark-mode #aa2_h_tbl_files tbody td,
body.dark-mode #aa2_a_tbl_items tbody td,
body.dark-mode #aa2_c_tbl tbody td {
    color: #e0e0e0 !important;
    background-color: transparent !important;
}
body.dark-mode #aa2_h_tbl thead th,
body.dark-mode #aa2_h_tbl_files thead th,
body.dark-mode #aa2_a_tbl_items thead th,
body.dark-mode #aa2_c_tbl thead th {
    background: #1a1a1a !important;
    color: #e0e0e0 !important;
    border-color: #333 !important;
}
body.dark-mode #aa2_mdlHC textarea,
body.dark-mode #aa2_mdlPaciente input,
body.dark-mode #aa2_mdlPaciente select,
body.dark-mode #aa2_mdlAlta input,
body.dark-mode #aa2_mdlAlta select,
body.dark-mode #aa2_mdlCobro input,
body.dark-mode #aa2_mdlCobro select {
    background-color: #252525 !important;
    color: #e0e0e0 !important;
    border-color: #333 !important;
}
body.dark-mode #aa2_mdlHC .nav-tabs .nav-link {
    color: #aaa !important;
}
body.dark-mode #aa2_mdlHC .nav-tabs .nav-link.active {
    background-color: #252525 !important;
    color: #ffffff !important;
    border-color: #333 #333 #252525 !important;
}
body.dark-mode #aa2_mdlHC .modal-body {
    background-color: #1e1e1e !important;
}

/* =========================================================
   MODAL HISTORIA CLÍNICA Y NUEVA HISTORIA (GM2/HCI)
   ========================================================= */
body.dark-mode #gm2_mdlHC #gm2_h_tbl tbody tr,
body.dark-mode #gm2_mdlHC #gm2_files_tbl tbody tr,
body.dark-mode #gm2_mdlNuevaHC .gm2-editor-card {
    background-color: #2a2a2a !important;
    box-shadow: 0 5px 15px rgba(0,0,0,0.3) !important;
}
body.dark-mode #gm2_mdlHC #gm2_h_tbl tbody td,
body.dark-mode #gm2_mdlHC #gm2_files_tbl tbody td,
body.dark-mode #gm2_mdlNuevaHC .gm2-editor {
    color: #e0e0e0 !important;
    border-color: #333 !important;
}
body.dark-mode #gm2_mdlNuevaHC .gm2-editor-head {
    background: #1e1e1e !important;
    border-color: #333 !important;
}
body.dark-mode #gm2_mdlNuevaHC .gm2-editor-title {
    color: #e0e0e0 !important;
}
body.dark-mode #gm2_mdlHC textarea,
body.dark-mode #gm2_mdlHC input,
body.dark-mode #gm2_mdlHC select {
    background-color: #1e1e1e !important;
    color: #e0e0e0 !important;
    border-color: #333 !important;
}
body.dark-mode #gm2_mdlHC .gm2-hc-topbar {
    background: transparent !important;
}
body.dark-mode #gm2_mdlHC .gm2-hc-chip {
    background: #1e1e1e !important;
    border-color: #333 !important;
    color: #e0e0e0 !important;
}
body.dark-mode #gm2_mdlHC .gm2-hc-chip span {
    color: #b0b0b0 !important;
}
body.dark-mode #gm2_mdlHC .nav-tabs .nav-link {
    color: #aaa !important;
}
body.dark-mode #gm2_mdlHC .nav-tabs .nav-link.active {
    background-color: #2a2a2a !important;
    color: #ffffff !important;
    border-color: #333 #333 #2a2a2a !important;
}
body.dark-mode #gm2_h_tbl tbody td {
    background-color: transparent !important;
}