/* Loader */
.loader-spin {
    border: 4px solid rgba(255,255,255,0.1);
    border-left-color: #3b82f6;
    border-radius: 50%;
    width: 50px;
    height: 50px;
    animation: spin 1s linear infinite;
}
@keyframes spin { 0% { transform: rotate(0deg); } 100% { transform: rotate(360deg); } }

/* AGENDA MEJORADA - 100% RESPONSIVE */
.agenda-container {
    background: white;
    border-radius: 16px;
    box-shadow: 0 10px 25px rgba(0, 0, 0, 0.05);
    overflow: hidden;
    border: 1px solid #e2e8f0;
    width: 100%;
}

.agenda-wrapper {
    overflow-x: auto;
    overflow-y: auto;
    max-height: calc(100vh - 350px);
    width: 100%;
    -webkit-overflow-scrolling: touch;
}

.agenda-grid {
    display: grid;
    grid-template-columns: 100px repeat(3, minmax(180px, 1fr));
    min-width: 800px;
    background: white;
    position: relative;
    height: 1440px; /* 24 horas * 60px */
}

/* Header de Agenda */
.agenda-header {
    position: sticky;
    top: 0;
    left: 0;
    z-index: 50;
    background: white;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.08);
    border-bottom: 2px solid #e5e7eb;
    min-width: 800px;
}

.time-header {
    background: linear-gradient(135deg, #1e293b 0%, #334155 100%);
    color: white;
    font-weight: 700;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 1.25rem;
    border-right: 1px solid #475569;
    position: sticky;
    left: 0;
    z-index: 40;
}

.court-header {
    padding: 1.25rem;
    font-weight: 700;
    font-size: 1.1rem;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    color: white;
    position: relative;
    overflow: hidden;
    border-right: 1px solid rgba(255,255,255,0.2);
    cursor: pointer;
    transition: all 0.2s ease;
}

.court-header:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 12px rgba(0, 0, 0, 0.15);
}

.court-header:last-child {
    border-right: none;
}

.court-header::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: linear-gradient(rgba(0,0,0,0.1), rgba(0,0,0,0.2));
    z-index: 1;
}

.court-header-content {
    position: relative;
    z-index: 2;
    text-align: center;
}

/* Columna de Horas - Sticky para scroll horizontal */
.time-column {
    background: #f8fafc;
    border-right: 2px solid #e5e7eb;
    position: relative;
    width: 100px;
    position: sticky;
    left: 0;
    z-index: 30;
    background: #f8fafc !important;
}

.time-slot {
    height: 60px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-bottom: 1px solid #e5e7eb;
    position: relative;
    font-weight: 600;
    color: #475569;
    font-size: 0.9rem;
    background: white;
}

.time-slot:nth-child(even) {
    background: #f8fafc;
}

.time-label {
    position: absolute;
    left: 8px;
    top: 50%;
    transform: translateY(-50%);
    background: white;
    padding: 4px 10px;
    border-radius: 6px;
    border: 1px solid #e2e8f0;
    box-shadow: 0 2px 4px rgba(0,0,0,0.05);
    min-width: 65px;
    text-align: center;
    font-size: 0.85rem;
    font-weight: 700;
    color: #1e293b;
    z-index: 35;
}

/* Columnas de Canchas */
.court-column {
    position: relative;
    border-right: 1px solid #e5e7eb;
    background: repeating-linear-gradient(
        0deg,
        transparent,
        transparent 59px,
        #f1f5f9 59px,
        #f1f5f9 60px
    );
    min-width: 180px;
}

.court-column:last-child {
    border-right: none;
}

/* ================= TARJETAS DE RESERVA MEJORADAS ================= */
/* Estilo base para todas las tarjetas */
.booking-card {
    position: absolute;
    left: 6px;
    right: 6px;
    border-radius: 8px;
    box-shadow: 0 3px 8px rgba(0, 0, 0, 0.1);
    z-index: 20;
    transition: all 0.2s ease;
    cursor: pointer;
    overflow: hidden;
    border: 2px solid white;
    display: flex;
    flex-direction: column;
    backdrop-filter: blur(4px);
    min-height: 50px; /* Altura mínima base */
    font-size: 0.8rem;
    line-height: 1.3;
}

/* ESTILOS POR DURACIÓN - ADAPTATIVOS */

/* Duración 1 HORA (60px) - Más compacto */
.booking-card.duration-1h {
    min-height: 50px !important;
    max-height: 60px !important;
    padding: 6px 8px !important;
    font-size: 11px !important;
    line-height: 1.2 !important;
}


.booking-card.duration-1h .booking-time {
    font-size: 10px !important;
    padding: 2px 4px !important;
    margin-bottom: 2px !important;
}

.booking-card.duration-1h .booking-client {
    font-size: 11px !important;
    font-weight: 700 !important;
    margin-bottom: 1px !important;
    white-space: nowrap !important;
    overflow: hidden !important;
    text-overflow: ellipsis !important;
}

.booking-card.duration-1h .booking-phone,
.booking-card.duration-1h .booking-user {
    font-size: 10px !important;
}

.booking-card.duration-1h .booking-user {
    margin-top: auto !important;
}

.booking-card.duration-1h .cancel-btn {
    width: 18px !important;
    height: 18px !important;
    top: 4px !important;
    right: 4px !important;
    font-size: 10px !important;
}

/* Duración 2 HORAS (120px) - Balanceado */
.booking-card.duration-2h {
    min-height: 100px !important;
    max-height: 120px !important;
    padding: 10px 12px !important;
    font-size: 12px !important;
    line-height: 1.3 !important;
}

.booking-card.duration-2h .booking-time {
    font-size: 11px !important;
    padding: 3px 6px !important;
    margin-bottom: 4px !important;
}

.booking-card.duration-2h .booking-client {
    font-size: 12px !important;
    font-weight: 700 !important;
    margin-bottom: 3px !important;
}

.booking-card.duration-2h .booking-phone,
.booking-card.duration-2h .booking-user {
    font-size: 11px !important;
    margin-top: 2px !important;
}

.booking-card.duration-2h .cancel-btn {
    width: 20px !important;
    height: 20px !important;
    top: 6px !important;
    right: 6px !important;
    font-size: 11px !important;
}

/* Duración 3 HORAS (180px) - Más espacioso */
.booking-card.duration-3h {
    min-height: 150px !important;
    max-height: 180px !important;
    padding: 14px 16px !important;
    font-size: 13px !important;
    line-height: 1.4 !important;
}

.booking-card.duration-3h .booking-time {
    font-size: 12px !important;
    padding: 4px 8px !important;
    margin-bottom: 8px !important;
}

.booking-card.duration-3h .booking-client {
    font-size: 14px !important;
    font-weight: 800 !important;
    margin-bottom: 6px !important;
}

.booking-card.duration-3h .booking-phone,
.booking-card.duration-3h .booking-user {
    font-size: 12px !important;
    margin-top: 4px !important;
}

.booking-card.duration-3h .cancel-btn {
    width: 24px !important;
    height: 24px !important;
    top: 8px !important;
    right: 8px !important;
    font-size: 12px !important;
}

/* Duración 4+ HORAS (240px+) - Muy espacioso */
.booking-card.duration-4h {
    min-height: 200px !important;
    padding: 16px 18px !important;
    font-size: 14px !important;
    line-height: 1.5 !important;
}

.booking-card.duration-4h .booking-time {
    font-size: 13px !important;
    padding: 5px 10px !important;
    margin-bottom: 10px !important;
}

.booking-card.duration-4h .booking-client {
    font-size: 15px !important;
    font-weight: 800 !important;
    margin-bottom: 8px !important;
}

.booking-card.duration-4h .booking-phone,
.booking-card.duration-4h .booking-user {
    font-size: 13px !important;
    margin-top: 6px !important;
}

.booking-card.duration-4h .cancel-btn {
    width: 26px !important;
    height: 26px !important;
    top: 10px !important;
    right: 10px !important;
    font-size: 13px !important;
}

.booking-card:hover {
    transform: translateY(-2px);
    box-shadow: 0 5px 15px rgba(0, 0, 0, 0.15);
    z-index: 25;
}

.booking-card::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 3px;
    background: rgba(255, 255, 255, 0.5);
}

/* Indicador de reserva fija */
.recurring-indicator {
    position: absolute;
    top: -5px;
    left: -5px;
    width: 20px;
    height: 20px;
    background: #f59e0b;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    color: white;
    font-size: 10px;
    font-weight: bold;
    border: 2px solid white;
    z-index: 5;
}

/* Botón de cancelar siempre visible */
.cancel-btn {
    position: absolute;
    display: flex;
    align-items: center;
    justify-content: center;
    background: rgba(255, 255, 255, 0.95);
    border-radius: 50%;
    color: #dc2626;
    font-weight: bold;
    cursor: pointer;
    z-index: 30;
    transition: all 0.2s;
    box-shadow: 0 2px 5px rgba(0,0,0,0.15);
}

.cancel-btn:hover {
    background: #dc2626;
    color: white;
    transform: scale(1.1);
    box-shadow: 0 3px 6px rgba(220, 38, 38, 0.2);
}

/* Contenido de la reserva siempre visible */
.booking-content {
    flex: 1;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    width: 100%;
}

.booking-time {
    font-weight: 700;
    color: white;
    background: rgba(0, 0, 0, 0.4);
    border-radius: 4px;
    display: inline-block;
    align-self: flex-start;
    backdrop-filter: blur(2px);
}

.booking-client {
    font-weight: 600;
    overflow: hidden;
    text-overflow: ellipsis;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
}

.booking-phone {
    opacity: 0.95;
    display: flex;
    align-items: center;
    gap: 3px;
}

.booking-user {
    opacity: 0.95;
    display: flex;
    align-items: center;
    gap: 3px;
}

/* Botones de Slot Disponible */
.slot-btn {
    position: absolute;
    left: 30%;
    right: 30%;
    height: 40px;
    top: 10px;
    border-radius: 6px;
    display: flex;
    align-items: center;
    justify-content: center;
    color: #94a3b8;
    font-size: 1.5rem;
    font-weight: 300;
    cursor: pointer;
    z-index: 10;
    transition: all 0.2s ease;
    background: rgba(255, 255, 255, 0.95);
    border: 2px dashed #cbd5e1;
    opacity: 0.8;
}

.slot-btn:hover {
    background: #eff6ff;
    color: #2563eb;
    border-color: #2563eb;
    border-style: solid;
    transform: scale(1.03);
    opacity: 1;
    box-shadow: 0 3px 8px rgba(37, 99, 235, 0.2);
    z-index: 15;
}

/* Franjas horarias */
.time-morning { background-color: #fef3c7 !important; }
.time-afternoon { background-color: #fde68a !important; }
.time-evening { background-color: #fed7aa !important; }
.time-night { background-color: #e2e8f0 !important; }

/* Toast */
#toast {
    transition: all 0.5s cubic-bezier(0.68, -0.55, 0.27, 1.55);
}

/* Estilos para la sección de horarios libres */
#free-football::-webkit-scrollbar,
#free-padel1::-webkit-scrollbar,
#free-padel2::-webkit-scrollbar {
    width: 6px;
}

#free-football::-webkit-scrollbar-track,
#free-padel1::-webkit-scrollbar-track,
#free-padel2::-webkit-scrollbar-track {
    background: #f1f5f9;
    border-radius: 3px;
}

#free-football::-webkit-scrollbar-thumb,
#free-padel1::-webkit-scrollbar-thumb,
#free-padel2::-webkit-scrollbar-thumb {
    background: #cbd5e1;
    border-radius: 3px;
}

#free-football::-webkit-scrollbar-thumb:hover,
#free-padel1::-webkit-scrollbar-thumb:hover,
#free-padel2::-webkit-scrollbar-thumb:hover {
    background: #94a3b8;
}

/* ================= RESPONSIVE ================= */
@media (max-width: 1024px) {
    .agenda-grid {
        min-width: 700px;
        grid-template-columns: 80px repeat(3, minmax(150px, 1fr));
    }
    
    .time-column {
        width: 80px;
    }
    
    .time-label {
        left: 5px;
        min-width: 55px;
        font-size: 0.8rem;
        padding: 3px 8px;
    }
    
    .court-header {
        padding: 0.8rem;
        font-size: 1rem;
    }
    
    .time-header {
        padding: 0.8rem;
        font-size: 0.9rem;
    }
    
    /* Tarjetas más compactas en tablets */
    .booking-card.duration-1h {
        min-height: 45px !important;
        padding: 4px 6px !important;
        font-size: 10px !important;
    }
    
    .booking-card.duration-2h {
        min-height: 90px !important;
        padding: 8px 10px !important;
        font-size: 11px !important;
    }
    
    .booking-card.duration-3h {
        min-height: 130px !important;
        padding: 12px 14px !important;
        font-size: 12px !important;
    }
    
    .booking-card.duration-4h {
        min-height: 170px !important;
        padding: 14px 16px !important;
        font-size: 13px !important;
    }
    
    /* Ajustar botón de cancelar en tablets */
    .cancel-btn {
        width: 20px !important;
        height: 20px !important;
        font-size: 10px !important;
    }
}

@media (max-width: 768px) {
    .agenda-wrapper {
        max-height: calc(100vh - 400px);
    }
    
    .big-button {
        padding: 10px 16px;
        font-size: 0.9rem;
        min-height: 50px;
    }
    
    .agenda-container {
        border-radius: 12px;
    }
}

@media (max-width: 640px) {
    .agenda-grid {
        min-width: 600px;
        grid-template-columns: 70px repeat(3, minmax(130px, 1fr));
    }
    
    .time-slot {
        height: 50px;
        font-size: 0.8rem;
    }
    
    .time-label {
        min-width: 50px;
        font-size: 0.75rem;
        padding: 2px 6px;
    }
    
    /* Aún más compacto en pantallas pequeñas */
    .booking-card.duration-1h {
        min-height: 40px !important;
        padding: 3px 5px !important;
        font-size: 9px !important;
    }
    
    .booking-card.duration-2h {
        min-height: 80px !important;
        padding: 6px 8px !important;
        font-size: 10px !important;
    }
    
    .booking-card.duration-3h {
        min-height: 110px !important;
        padding: 10px 12px !important;
        font-size: 11px !important;
    }
    
    /* Ocultar algunos elementos en móviles para ahorrar espacio */
    .booking-card.duration-1h .booking-phone,
    .booking-card.duration-1h .booking-user {
        display: none !important;
    }
    
    .slot-btn {
        height: 35px;
        font-size: 1.3rem;
        left: 25%;
        right: 25%;
    }
    
    .agenda-wrapper {
        max-height: calc(100vh - 450px);
    }
}

/* Botones grandes responsive */
.big-button {
    padding: 12px 20px;
    font-size: 0.95rem;
    font-weight: 600;
    border-radius: 10px;
    transition: all 0.2s ease;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    min-height: 50px;
    box-shadow: 0 3px 8px rgba(0, 0, 0, 0.1);
    white-space: nowrap;
}

.big-button:hover {
    transform: translateY(-1px);
    box-shadow: 0 5px 12px rgba(0, 0, 0, 0.15);
}

/* Toast mejorado */
.toast-large {
    padding: 14px 20px;
    font-size: 0.95rem;
    border-radius: 10px;
    min-width: 280px;
    box-shadow: 0 8px 20px rgba(0, 0, 0, 0.15);
    backdrop-filter: blur(10px);
}

/* Etiqueta de franja horaria */
.time-period {
    position: absolute;
    right: 5px;
    top: 50%;
    transform: translateY(-50%);
    font-size: 0.7rem;
    color: #64748b;
    font-weight: 500;
    background: rgba(255, 255, 255, 0.9);
    padding: 2px 5px;
    border-radius: 3px;
}

/* Información de reserva seleccionada */
.selected-slot-info {
    background: linear-gradient(to right, #dbeafe, #e0f2fe);
    border-left: 4px solid #3b82f6;
    padding: 10px 15px;
    margin: 10px 0;
    border-radius: 8px;
    font-weight: 600;
}

/* Modal de opciones para reservas fijas */
.smart-modal-option {
    padding: 16px;
    border-radius: 10px;
    border: 2px solid #e5e7eb;
    cursor: pointer;
    transition: all 0.2s;
    margin-bottom: 10px;
}

.smart-modal-option:hover {
    border-color: #3b82f6;
    background-color: #eff6ff;
    transform: translateY(-2px);
}

.smart-modal-option.selected {
    border-color: #3b82f6;
    background-color: #dbeafe;
}