/* Dashboard Calendar Styles */
.dashboard-centros-calendar {
    margin: 20px 0;
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
}

.calendar-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    margin-bottom: 20px;
    flex-wrap: wrap;
    gap: 20px;
}

.calendar-title h2 {
    margin: 0 0 10px 0;
    color: #23282d;
}

.week-selector {
    display: flex;
    align-items: center;
    gap: 10px;
}

.week-selector button {
    padding: 8px 12px;
    background: #f1f1f1;
    border: 1px solid #ddd;
    border-radius: 4px;
    cursor: pointer;
}

.week-selector button:hover {
    background: #e5e5e5;
}

#current-week {
    font-weight: bold;
    padding: 8px 12px;
    background: white;
    border: 1px solid #ddd;
    border-radius: 4px;
    min-width: 200px;
    text-align: center;
}

.calendar-controls {
    display: flex;
    flex-direction: column;
    gap: 15px;
    min-width: 300px;
}

.worker-filters {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.worker-filters label {
    font-weight: bold;
    color: #23282d;
}

.filter-buttons {
    display: flex;
    flex-wrap: wrap;
    gap: 5px;
}

.filter-btn {
    padding: 6px 10px;
    border: 1px solid #ddd;
    background: white;
    border-radius: 4px;
    cursor: pointer;
    font-size: 12px;
    transition: all 0.2s;
}

.filter-btn.active {
    background: #007cba;
    color: white;
    border-color: #007cba;
}

.filter-btn:hover {
    background: #f1f1f1;
}

.filter-btn.worker-filter {
    position: relative;
    padding-left: 20px;
}

.filter-btn.worker-filter.inactive {
    opacity: 0.5;
}

/* Calendar Container */
.calendar-container {
    display: flex;
    border: 1px solid #ddd;
    border-radius: 8px;
    overflow-x: auto; /* permitir scroll horizontal */
    background: white;
    position: relative;
}

/* Time Column */
.time-column {
    width: 80px;
    background: #f8f9fa;
    border-right: 1px solid #ddd;
    position: sticky; /* mantener visible al hacer scroll horizontal */
    left: 0;
    z-index: 4;
}

.time-header {
    height: 60px;
    border-bottom: 1px solid #ddd;
}

.time-slot {
    height: 60px;
    border-bottom: 1px solid #e9ecef;
    display: flex;
    align-items: flex-start;
    justify-content: center;
    padding-top: 5px;
}

.time-label {
    font-size: 11px;
    color: #6c757d;
    font-weight: 500;
}

/* Day Columns */
.day-column {
    flex: 0 0 200px; /* ancho fijo mínimo de 200px por columna */
    border-right: 1px solid #ddd;
    min-width: 200px;
    position: relative; /* para posicionar la linea de tiempo */
}

.day-column:last-child {
    border-right: none;
}

/* Línea de tiempo actual */
.current-time-line {
    position: absolute;
    left: 0;
    right: 0;
    height: 1px;
    background: #f44336; /* roja */
    z-index: 1000; /* encima de eventos */
    pointer-events: none;
    user-select: none;
}

.day-header {
    height: 60px;
    background: #f8f9fa;
    border-bottom: 1px solid #ddd;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 5px;
}

.day-name {
    font-weight: bold;
    font-size: 14px;
    color: #495057;
}

.day-date {
    font-size: 12px;
    color: #6c757d;
    margin-top: 2px;
}

.day-content {
    position: relative;
    height: 1020px; /* 17 horas * 60px */
    overflow: visible; /* permitir que eventos se muestren sin recortes */
}

/* Hour Slots */
.hour-slot {
    height: 60px;
    border-bottom: 1px solid #f1f3f4;
}

.hour-slot:nth-child(2n) {
    background: rgba(248, 249, 250, 0.3);
}

/* Day Events Container */
.day-events {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    pointer-events: none;
    overflow: visible;
}

.calendar-event {
    position: absolute;
    /* left/right serán controlados por estilos inline (left:%; width:%;) */
    border-radius: 4px;
    border: 1px solid rgba(255, 255, 255, 0.3);
    color: white;
    font-size: 11px;
    cursor: pointer;
    pointer-events: auto;
    z-index: 10;
    overflow: hidden;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
    transition: opacity 0.2s, transform 0.1s;
    box-sizing: border-box;
    min-height: 20px;
    /* Asegurar que el texto se ajuste y haya contraste */
    color: #fff;
}

/* Ajustes para que el borde izquierdo destaque sin reducir anchura útil */
.calendar-event {
    padding-left: 8px;
}

/* Estados por defecto (pueden ser sobreescritos inline) */
.state-completado { background-color: #4CAF50; }
.state-iniciado { background-color: #2196F3; }
.state-pausado { background-color: #FFC107; color: #333; }
/* Fichajes por defecto en amarillo claro */
.state-no-realizado { background-color: #FFF9C4; color: #333; }
.state-sin_finalizar, .state-sin-finalizar { background-color: #FFF9C4; color: #333; }
.state-pendiente { background-color: #FFF9C4; color: #333; }

/* Resaltar solapamientos detectados */
.calendar-event.overlap {
    outline: 3px solid rgba(255, 0, 0, 0.9);
    z-index: 50;
    transform: none !important;
}

/* Eventos con inconsistencia: fichaje completado pero inicio en el futuro */
.calendar-event.status-inconsistent {
    border: 2px dashed #b71c1c; /* indicar inconsistencia con borde */
    box-shadow: 0 0 0 2px rgba(183,28,28,0.06);
}

/* Estados visuales */
.state-completado { background-color: #dcedc8 !important; color: #333 !important; }
.state-iniciado, .state-pausado, .state-pendiente { background-color: #ffecb3 !important; color: #333 !important; }
.state-no-realizado, .state-sin-finalizar, .state-sin_finalizar { background-color: #ffcdd2 !important; color: #333 !important; }

.calendar-event:hover {
    transform: scale(1.02);
    z-index: 20;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.15);
}

.event-content {
    padding: 4px 6px;
    height: 100%;
    display: flex;
    flex-direction: column;
    justify-content: center;
}

.event-worker {
    font-weight: bold;
    font-size: 11px;
    line-height: 1.2;
    margin-bottom: 1px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.event-center {
    font-size: 10px;
    opacity: 0.9;
    line-height: 1.1;
    margin-bottom: 1px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.event-time {
    font-size: 9px;
    opacity: 0.8;
    line-height: 1;
}

/* Hidden events */
.calendar-event.hidden {
    display: none !important;
}

/* Calendar Legend */
.calendar-legend {
    margin-top: 20px;
    padding: 15px;
    background: #f8f9fa;
    border: 1px solid #ddd;
    border-radius: 8px;
}

.calendar-legend h4 {
    margin: 0 0 10px 0;
    color: #23282d;
}

.legend-workers {
    display: flex;
    flex-wrap: wrap;
    gap: 15px;
}

.legend-item {
    display: flex;
    align-items: center;
    gap: 8px;
}

.legend-color {
    width: 16px;
    height: 16px;
    border-radius: 3px;
    border: 1px solid rgba(0, 0, 0, 0.1);
}

.legend-item span {
    font-size: 13px;
    color: #495057;
}

/* Export Buttons */
.export-buttons {
    display: flex;
    gap: 10px;
}

/* Responsive */
@media (max-width: 768px) {
    .calendar-header {
        flex-direction: column;
        align-items: stretch;
    }

    .calendar-controls {
        min-width: auto;
    }

    .filter-buttons {
        justify-content: center;
    }

    .time-column {
        width: 60px;
    }

    .calendar-events {
        left: 60px;
    }

    .day-column {
        min-width: 100px;
    }

    .calendar-event {
        font-size: 10px;
    }

    .event-worker {
        font-size: 10px;
    }

    .event-center,
    .event-time {
        font-size: 9px;
    }
}

/* Current day highlight */
.day-column.current-day .day-header {
    background: #e3f2fd;
    border-bottom-color: #2196f3;
}

.day-column.current-day .day-name {
    color: #1976d2;
}

/* Today indicator */
.day-column.today .day-header {
    background: #fff3e0;
    border-bottom-color: #ff9800;
}

/* Modal de detalle de evento */
.dashboard-modal-overlay {
    position: fixed;
    left: 0;
    top: 0;
    right: 0;
    bottom: 0;
    background: rgba(0,0,0,0.45);
    z-index: 2000;
    display: none;
    align-items: center;
    justify-content: center;
    padding: 20px;
}

.dashboard-modal {
    background: #fff;
    border-radius: 6px;
    max-width: 520px;
    width: 100%;
    box-shadow: 0 8px 30px rgba(0,0,0,0.25);
    overflow: hidden;
}

.dashboard-modal-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 12px 16px;
    border-bottom: 1px solid #eee;
}

.dashboard-modal-title {
    font-weight: 600;
    color: #222;
}

.dashboard-modal-close {
    background: transparent;
    border: 0;
    font-size: 18px;
    cursor: pointer;
    padding: 6px;
}

.dashboard-modal-body {
    padding: 14px 16px;
    color: #333;
    font-size: 14px;
}

.dashboard-modal-row {
    display: flex;
    gap: 8px;
    margin-bottom: 8px;
}
.dashboard-modal-row .label {
    min-width: 110px;
    color: #666;
    font-weight: 600;
}
.dashboard-modal-row .value {
    flex: 1;
}

.dashboard-modal .worker-color-indicator {
    width: 10px;
    height: 10px;
    display: inline-block;
    margin-right: 6px;
    vertical-align: middle;
    border-radius: 2px;
    border: 1px solid rgba(0,0,0,0.08);
}

/* Badge de ficha asociada dentro del evento: oculto en calendario (mostrado en modal) */
/* La insignia se renderiza solo en el modal, por tanto no necesita estilos aquí. */

/* Mostrar con fade */
.dashboard-modal-overlay.show {
    display: flex;
    animation: fadeIn 160ms ease-out;
}
@keyframes fadeIn { from { opacity: 0 } to { opacity: 1 } }


.day-column.today .day-name {
    color: #f57c00;
}

/* Centros List Styles */
.centros-list {
    margin-top: 30px;
    padding: 20px;
    background: #f8f9fa;
    border-radius: 8px;
    border: 1px solid #e9ecef;
}

.centros-list h3 {
    margin: 0 0 20px 0;
    color: #23282d;
    font-size: 18px;
    font-weight: 600;
}

.centros-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
    gap: 15px;
}

.centro-item {
    background: white;
    border: 1px solid #ddd;
    border-radius: 6px;
    padding: 15px;
    transition: all 0.2s ease;
    position: relative;
}

.centro-item:hover {
    box-shadow: 0 2px 8px rgba(0,0,0,0.1);
    border-color: #bbb;
}

.centro-item.active {
    border-left: 4px solid #4CAF50;
}

.centro-item.inactive {
    border-left: 4px solid #9E9E9E;
    opacity: 0.8;
}

.centro-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 10px;
}

.centro-header a {
    color: #23282d;
    text-decoration: none;
    font-weight: 600;
    font-size: 16px;
}

.centro-header a:hover {
    color: #007cba;
}

.centro-status {
    padding: 4px 8px;
    border-radius: 12px;
    font-size: 12px;
    font-weight: 500;
    text-transform: uppercase;
}

.centro-status.active {
    background: #e8f5e8;
    color: #2e7d32;
}

.centro-status.inactive {
    background: #f5f5f5;
    color: #616161;
}

.centro-info {
    font-size: 14px;
    color: #666;
}

.trabajadores-count {
    display: inline-block;
    background: #f0f0f0;
    padding: 2px 6px;
    border-radius: 4px;
    font-size: 12px;
}

/* Legend Styles */
.calendar-legend {
    margin-top: 20px;
    padding: 15px;
    background: white;
    border: 1px solid #ddd;
    border-radius: 6px;
}

.calendar-legend h4 {
    margin: 0 0 15px 0;
    color: #23282d;
    font-size: 16px;
}

.legend-workers,
.legend-centros {
    display: flex;
    flex-wrap: wrap;
    gap: 15px;
    margin-bottom: 10px;
}

.legend-item {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 14px;
}

.legend-color {
    width: 16px;
    height: 16px;
    border-radius: 2px;
    flex-shrink: 0;
}