/* ========================================= */
/* === ESTILOS GLOBALES PARA TABLAS ======= */
/* ========================================= */

/* Todas las tablas del sitio */
.table,
table {
    --bs-table-bg: transparent;
    --bs-table-accent-bg: transparent;
}

/* Cabeceras de tabla - Global */
.table>thead,
.table-light,
table thead,
.table thead {
    --bs-table-bg: #f8f9fa;
}

.table>thead th,
.table-light th,
table thead th,
.table thead th {
    background-color: #f8f9fa !important;
    color: #495057 !important;
    font-weight: 600;
    text-transform: uppercase;
    font-size: 0.75rem;
    letter-spacing: 0.5px;
    border-bottom: 2px solid #dee2e6;
    vertical-align: middle;
}

/* Links en cabeceras */
.table>thead th a,
table thead th a {
    color: #495057 !important;
    text-decoration: none;
}

.table>thead th a:hover,
table thead th a:hover {
    color: var(--bs-primary) !important;
}

/* Tabla striped */
.table-striped>tbody>tr:nth-of-type(odd)>* {
    --bs-table-accent-bg: rgba(15, 76, 129, 0.03);
}

/* Tabla hover */
.table-hover>tbody>tr:hover>* {
    --bs-table-accent-bg: rgba(85, 197, 185, 0.08);
}

/* Fila activa/primaria */
.table-primary,
.table>tbody>tr.table-primary>* {
    --bs-table-bg: rgba(15, 76, 129, 0.1);
    --bs-table-accent-bg: rgba(15, 76, 129, 0.1);
}

/* Celdas de tabla */
.table>tbody td,
table tbody td {
    vertical-align: middle;
    color: #495057;
}

/* ========================================= */
/* === ESTILOS VISTAS DE GESTIÓN ========== */
/* ========================================= */

/* --- Data Tables (SaaS Style / Views de Gestión) --- */

/* Contenedor de la vista (Card Style) - Aplica a todas las vistas de gestión */
.view-gestionar-clinicas,
.view-gestionar-empleados,
.view-gestionar-pacientes,
.view-gestionar-dispositivos {
    background: #ffffff;
    border-radius: 12px;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.05);
    border: 1px solid rgba(0, 0, 0, 0.02);
    overflow: hidden;
    margin-bottom: 2rem;
}

/* Header de la vista (Botones y filtros) */
.view-gestionar-clinicas .view-header,
.view-gestionar-empleados .view-header,
.view-gestionar-pacientes .view-header,
.view-gestionar-dispositivos .view-header {
    padding: 1.5rem;
    border-bottom: 1px solid #eee;
    background: #fff;
    display: flex;
    justify-content: flex-end;
    align-items: center;
}

/* --- Filtros Expuestos (Global para todas las vistas) --- */

.views-exposed-form {
    padding: 1rem 1.5rem;
    background: #f8f9fa;
    border-bottom: 1px solid #eee;
}

/* Layout de filtros con Bootstrap flex */
.views-exposed-form .d-flex {
    align-items: flex-end !important;
    gap: 1.5rem;
}

.views-exposed-form .form-item {
    margin-bottom: 0 !important;
    flex: 0 0 auto;
}

/* Ocultar texto de descripción/ayuda en filtros */
.views-exposed-form .description,
.views-exposed-form small.text-muted {
    display: none !important;
}

/* Quitar margin-bottom de Bootstrap en los form-items */
.views-exposed-form .mb-3 {
    margin-bottom: 0 !important;
}

/* Etiquetas de filtros */
.views-exposed-form .form-item label {
    font-size: 0.75rem;
    font-weight: 600;
    color: #6c757d;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    margin-bottom: 0.35rem;
    display: block;
}

/* Campos de filtro */
.views-exposed-form .form-control,
.views-exposed-form .form-select {
    min-width: 140px;
    max-width: 220px;
    font-size: 0.9rem;
    padding: 0.5rem 0.75rem;
    border-radius: 6px;
    border: 1px solid #dee2e6;
    height: 38px;
}

.views-exposed-form .form-control:focus,
.views-exposed-form .form-select:focus {
    border-color: var(--bs-secondary);
    box-shadow: 0 0 0 2px rgba(85, 197, 185, 0.15);
}

/* Campo de autocomplete más compacto */
.views-exposed-form input[type="text"],
.views-exposed-form .form-autocomplete {
    max-width: 180px;
}

/* Botón aplicar filtros - alineado */
.views-exposed-form .form-actions {
    margin: 0 !important;
    padding: 0;
}

.views-exposed-form .form-actions .button,
.views-exposed-form .form-actions .btn {
    padding: 0.5rem 1.25rem;
    font-size: 0.9rem;
    border-radius: 6px;
    background-color: var(--bs-primary);
    border-color: var(--bs-primary);
    color: #fff;
    font-weight: 500;
    white-space: nowrap;
    height: 38px;
    display: inline-flex;
    align-items: center;
}

.views-exposed-form .form-actions .button:hover,
.views-exposed-form .form-actions .btn:hover {
    background-color: var(--bs-secondary);
    border-color: var(--bs-secondary);
}

/* Responsivo: en móvil, filtros en columna */
@media (max-width: 768px) {
    .views-exposed-form .d-flex {
        flex-direction: column;
        align-items: stretch !important;
        gap: 1rem;
    }

    .views-exposed-form .form-control,
    .views-exposed-form .form-select,
    .views-exposed-form input[type="text"] {
        max-width: 100%;
        width: 100%;
    }
}

/* --- jQuery UI Autocomplete Dropdown --- */
.ui-autocomplete {
    background: #ffffff !important;
    border: 1px solid #dee2e6 !important;
    border-radius: 8px !important;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.1) !important;
    max-height: 250px;
    overflow-y: auto;
    z-index: 9999 !important;
}

.ui-autocomplete .ui-menu-item {
    padding: 0;
    margin: 0;
}

.ui-autocomplete .ui-menu-item-wrapper {
    display: block;
    padding: 0.6rem 1rem;
    color: #495057;
    font-size: 0.9rem;
    cursor: pointer;
    transition: background-color 0.15s ease;
}

.ui-autocomplete .ui-menu-item-wrapper:hover,
.ui-autocomplete .ui-menu-item-wrapper.ui-state-active {
    background-color: rgba(85, 197, 185, 0.15) !important;
    color: var(--bs-primary) !important;
}

/* Nota: Los iconos de estado (Activo/Inactivo) se generan via PHP 
   en empleado_config_preprocess_views_view_field() */

/* Tabla en sí */
.view-gestionar-clinicas table,
.view-gestionar-empleados table,
.view-gestionar-pacientes table,
.view-gestionar-dispositivos table {
    width: 100%;
    margin-bottom: 0;
    border-collapse: collapse;
}

.view-gestionar-clinicas thead th,
.view-gestionar-empleados thead th,
.view-gestionar-pacientes thead th,
.view-gestionar-dispositivos thead th {
    background-color: #f8f9fa;
    color: #6c757d;
    font-weight: 600;
    text-transform: uppercase;
    font-size: 0.75rem;
    letter-spacing: 0.5px;
    padding: 1rem 1.5rem;
    border-bottom: 1px solid #e9ecef;
    border-top: none;
    vertical-align: middle;
}

/* Enlaces en headers de tabla */
.view-gestionar-clinicas thead th a,
.view-gestionar-empleados thead th a,
.view-gestionar-pacientes thead th a,
.view-gestionar-dispositivos thead th a {
    color: #6c757d;
    text-decoration: none;
}

.view-gestionar-clinicas thead th a:hover,
.view-gestionar-empleados thead th a:hover,
.view-gestionar-pacientes thead th a:hover,
.view-gestionar-dispositivos thead th a:hover {
    color: var(--bs-primary);
}

/* Header activo (columna ordenada) */
.view-gestionar-clinicas thead th.is-active,
.view-gestionar-empleados thead th.is-active,
.view-gestionar-pacientes thead th.is-active,
.view-gestionar-dispositivos thead th.is-active {
    background-color: var(--bs-primary);
    color: #ffffff;
}

.view-gestionar-clinicas thead th.is-active a,
.view-gestionar-empleados thead th.is-active a,
.view-gestionar-pacientes thead th.is-active a,
.view-gestionar-dispositivos thead th.is-active a {
    color: #ffffff;
}

.view-gestionar-clinicas thead th.is-active a:hover,
.view-gestionar-empleados thead th.is-active a:hover,
.view-gestionar-pacientes thead th.is-active a:hover,
.view-gestionar-dispositivos thead th.is-active a:hover {
    color: rgba(255, 255, 255, 0.8);
}

/* Icono de ordenación */
.view-gestionar-clinicas thead th .tablesort,
.view-gestionar-empleados thead th .tablesort,
.view-gestionar-pacientes thead th .tablesort,
.view-gestionar-dispositivos thead th .tablesort {
    margin-left: 0.3rem;
}

.view-gestionar-clinicas tbody td,
.view-gestionar-empleados tbody td,
.view-gestionar-pacientes tbody td,
.view-gestionar-dispositivos tbody td {
    padding: 1rem 1.5rem;
    vertical-align: middle;
    border-bottom: 1px solid #f1f3f5;
    color: #495057;
    font-size: 0.95rem;
}

/* Filas hover */
.view-gestionar-clinicas tbody tr,
.view-gestionar-empleados tbody tr,
.view-gestionar-pacientes tbody tr,
.view-gestionar-dispositivos tbody tr {
    transition: background-color 0.2s ease;
}

.view-gestionar-clinicas tbody tr:hover,
.view-gestionar-empleados tbody tr:hover,
.view-gestionar-pacientes tbody tr:hover,
.view-gestionar-dispositivos tbody tr:hover {
    background-color: rgba(85, 197, 185, 0.05) !important;
}

/* Imagen en tabla (Miniatura) */
.view-gestionar-clinicas .views-field-field-clinica-imagen img,
.view-gestionar-empleados .views-field img,
.view-gestionar-pacientes .views-field img,
.view-gestionar-dispositivos .views-field img {
    border-radius: 8px;
    object-fit: cover;
    width: 48px;
    height: 48px;
    border: 1px solid #eee;
}

/* Títulos de fila (Links) */
.view-gestionar-clinicas .views-field-title a,
.view-gestionar-empleados .views-field-name a,
.view-gestionar-pacientes .views-field-field-paciente-apellido a {
    font-weight: 600;
    color: var(--bs-primary);
    text-decoration: none;
}

.view-gestionar-clinicas .views-field-title a:hover,
.view-gestionar-empleados .views-field-name a:hover,
.view-gestionar-pacientes .views-field-field-paciente-apellido a:hover {
    color: var(--bs-secondary);
    text-decoration: underline;
}

/* Mensaje vacío */
.view-gestionar-clinicas .view-empty,
.view-gestionar-empleados .view-empty,
.view-gestionar-pacientes .view-empty,
.view-gestionar-dispositivos .view-empty {
    padding: 3rem;
    text-align: center;
    color: #868e96;
    font-style: italic;
}