/**
 * Estilos del Calendario - Mobile First
 * Componente reutilizable para admin y frontend
 */

/* ==========================================================================
   CONTENEDOR PRINCIPAL
   ========================================================================== */

.ipb-calendar {
    background: #fff;
    border-radius: 8px;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
    padding: 12px; /* Reducido de 18px */
    max-width: 100%;
    margin: 0 auto;
    
    /* FORZAR MODO CLARO - Ignorar preferencias del sistema */
    color-scheme: light;
    color: #333;
}

/* ==========================================================================
   HEADER / NAVEGACIÓN
   ========================================================================== */

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

.ipb-calendar-title {
    margin: 0;
    font-size: 18px;
    font-weight: 600;
    text-align: center;
    flex: 1;
    color: #333;
}

.ipb-calendar-nav {
    background: #f8f9fa;
    border: 1px solid #dee2e6;
    border-radius: 4px;
    padding: 8px 12px;
    font-size: 14px;
    cursor: pointer;
    transition: all 0.2s;
    white-space: nowrap;
    color: #333; /* Forzar texto oscuro */
}

.ipb-calendar-nav:hover {
    background: #e9ecef;
    border-color: #adb5bd;
    color: #333; /* Mantener texto oscuro */
}

.ipb-calendar-nav:active {
    transform: scale(0.98);
}

button.ipb-calendar-nav {
    padding: 0px 15px;
    text-overflow: ellipsis;
    overflow: hidden;
    font-size: 0.9em;
    font-weight: 400;
    text-transform: none;
    background: transparent;
    color: var( --e-global-color-primary );
}

.ipb-form-actions button {
    padding: 0px 15px;
    font-size: 1em;
}


/* ==========================================================================
   GRID DEL CALENDARIO
   ========================================================================== */

.ipb-calendar-grid {
    margin-bottom: 15px;
}

/* Encabezados de días de la semana */
.ipb-calendar-weekdays {
    display: grid;
    grid-template-columns: repeat(7, 1fr);
    gap: 4px;
    margin-bottom: 8px;
}

.ipb-weekday {
    text-align: center;
    font-weight: 600;
    font-size: 12px;
    color: #666;
    padding: 6px 4px;
    text-transform: uppercase;
}

/* Grid de días */
.ipb-calendar-days {
    display: grid;
    grid-template-columns: repeat(7, 1fr);
    gap: 3px; /* Gap mínimo en móvil */
}

/* ==========================================================================
   DÍA INDIVIDUAL
   ========================================================================== */

.ipb-calendar-day {
    border: 1px solid #e9ecef; /* Borde más fino */
    border-radius: 4px; /* Menos redondeado */
    /* min-height: 80px; */
    padding: 4px; /* Padding mínimo */
    background: #fff !important;
    position: relative;
    transition: all 0.2s;
}

.ipb-day-empty {
    background: transparent !important;
    border: none;
}

.ipb-day-number {
    font-weight: 600;
    font-size: 14px;
    color: #333 !important;
    margin-bottom: 4px; /* Menos espacio */
}

/* Estados del día */
.ipb-day-today .ipb-day-number {
    background: #0073aa;
    color: #fff;
    border-radius: 50%;
    width: 24px;
    height: 24px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-size: 12px;
}

.ipb-day-past {
    opacity: 0.6;
}

.ipb-day-closed {
    background: #f8f9fa !important; /* Forzar fondo claro */
    border-color: #dee2e6;
}

/* Día cerrado */
.ipb-day-closed .ipb-closed-label {
    display: block;
    text-align: center;
    font-size: 11px;
    color: #999 !important;
    margin-top: 10px;
}

/* ==========================================================================
   SLOTS
   ========================================================================== */

.ipb-day-slots {
    display: flex;
    flex-direction: column;
    gap: 3px; /* Mínimo gap en móvil */
}

.ipb-slot {
    padding: 6px 4px; /* Padding mínimo en móvil */
    border-radius: 4px;
    font-size: 11px;
    line-height: 1.3;
    transition: all 0.2s;
    min-height: 40px; /* Reducido para móvil */
    display: flex;
    flex-direction: column;
    justify-content: center;
}

/* EN MÓVIL: Solo mostrar bloque de color, sin texto */
.ipb-slot-time {
    font-weight: 700;
    margin-bottom: 2px;
    font-size: 0; /* Ocultar en móvil */
    height: 0;
    overflow: hidden;
}

.ipb-slot-status {
    display: none; /* Ocultar completamente en móvil */
}

.ipb-status-icon {
    display: none; /* Sin iconos */
}

.ipb-status-label {
    display: none; /* Sin labels en móvil */
}

/* Estados de slots */
.ipb-slot-available {
    background: #d4edda;
    border: 1px solid #c3e6cb;
    color: #155724;
}

.ipb-slot-partial,
.ipb-slot-pending {
    background: #fff3cd;
    border: 1px solid #ffc107;
    color: #856404;
}

.ipb-slot-full,
.ipb-slot-booked {
    background: #f8d7da;
    border: 1px solid #f5c6cb;
    color: #721c24;
}

/* Slot seleccionable (solo admin) */
.ipb-slot-selectable {
    cursor: pointer;
}

.ipb-slot-selectable:hover {
    transform: scale(1.02);
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
}

.ipb-slot-selectable:active {
    transform: scale(0.98);
}

/* Slots reservados también clicables en admin */
.ipb-calendar[data-mode="admin"] .ipb-slot-partial,
.ipb-calendar[data-mode="admin"] .ipb-slot-full,
.ipb-calendar[data-mode="admin"] .ipb-slot-pending,
.ipb-calendar[data-mode="admin"] .ipb-slot-booked {
    cursor: pointer;
}

.ipb-calendar[data-mode="admin"] .ipb-slot-partial:hover,
.ipb-calendar[data-mode="admin"] .ipb-slot-full:hover,
.ipb-calendar[data-mode="admin"] .ipb-slot-pending:hover,
.ipb-calendar[data-mode="admin"] .ipb-slot-booked:hover {
    transform: scale(1.02);
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.15);
    filter: brightness(0.95);
}

/* Detalles del slot (solo admin) */
.ipb-slot-details {
    margin-top: 4px;
    padding-top: 4px;
    border-top: 1px solid rgba(0, 0, 0, 0.1);
}

.ipb-slot-customer {
    font-size: 11px;
    margin-bottom: 2px;
}

.ipb-slot-notes {
    font-size: 10px;
    font-style: italic;
    opacity: 0.8;
    overflow: hidden;
    text-overflow: ellipsis;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
}

/* ==========================================================================
   LEYENDA
   ========================================================================== */

.ipb-calendar-legend {
    display: flex;
    flex-wrap: wrap;
    gap: 12px;
    padding-top: 12px;
    border-top: 1px solid #e9ecef;
    font-size: 12px;
}

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

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

.ipb-legend-available {
    background: #d4edda;
    border-color: #c3e6cb;
}

.ipb-legend-partial,
.ipb-legend-pending {
    background: #fff3cd;
    border-color: #ffc107;
}

.ipb-legend-full,
.ipb-legend-booked {
    background: #f8d7da;
    border-color: #f5c6cb;
}

.ipb-legend-closed {
    background: #f8f9fa;
    border-color: #dee2e6;
}

/* ==========================================================================
   RESPONSIVE - TABLET
   ========================================================================== */

@media (min-width: 600px) {
    .ipb-calendar {
        padding: 20px;
    }
    
    .ipb-calendar-title {
        font-size: 22px;
    }
    
    .ipb-calendar-nav {
        padding: 10px 16px;
        font-size: 15px;
    }
    
    .ipb-weekday {
        font-size: 14px;
        padding: 10px 4px;
    }
    
    .ipb-calendar-days {
        gap: 6px;
    }
    
    .ipb-calendar-day {
        /* min-height: 120px; */
        padding: 8px;
        border: 2px solid #e9ecef;
    }
    
    .ipb-day-number {
        font-size: 16px;
        margin-bottom: 6px;
    }
    
    /* TABLET: Mostrar hora y estado */
    .ipb-slot {
        font-size: 12px;
        padding: 8px;
        min-height: 50px;
        gap: 4px;
    }
    
    .ipb-slot-time {
        font-size: 12px;
        height: auto;
        overflow: visible;
        margin-bottom: 3px;
    }
    
    .ipb-slot-status {
        display: flex;
        flex-direction: column;
        align-items: flex-start;
        gap: 2px;
    }

    .ipb-status-label {
        display: inline;
        font-size: 11px;
        font-weight: 600;
    }

    .ipb-spaces-counter {
        font-size: 10px;
        opacity: 0.85;
    }

    .ipb-slot-customer {
        font-size: 12px;
    }

    .ipb-slot-notes {
        font-size: 11px;
    }
}

/* ==========================================================================
   RESPONSIVE - DESKTOP
   ========================================================================== */

@media (min-width: 1024px) {
    .ipb-calendar {
        padding: 25px;
    }
    
    .ipb-calendar-title {
        font-size: 24px;
    }
    
    .ipb-calendar-days {
        gap: 8px;
    }
    
    .ipb-calendar-day {
        /*min-height: 140px;*/
        padding: 10px;
        border: 2px solid #e9ecef;
    }
    
    .ipb-day-number {
        font-size: 18px;
        margin-bottom: 8px;
    }
    
    /* DESKTOP: Mostrar todo el contenido */
    .ipb-slot {
        font-size: 13px;
        padding: 10px;
        gap: 6px;
        min-height: auto;
    }
    
    .ipb-slot-time {
        font-size: 12px;
        height: auto;
        overflow: visible;
        margin-bottom: 4px;
    }
    
    .ipb-slot-status {
        display: flex;
        flex-direction: column;
        align-items: flex-start;
        gap: 2px;
    }

    .ipb-status-label {
        display: inline;
        font-size: 12px;
        font-weight: 600;
    }

    .ipb-spaces-counter {
        font-size: 11px;
        opacity: 0.85;
    }

    .ipb-slot-customer {
        font-size: 13px;
        margin-bottom: 4px;
    }
    
    .ipb-slot-notes {
        font-size: 12px;
        -webkit-line-clamp: 3;
    }
    
    .ipb-calendar-legend {
        font-size: 13px;
    }
}

/* ==========================================================================
   MODO PÚBLICO (Frontend)
   ========================================================================== */

.ipb-calendar[data-mode="public"] .ipb-slot-details {
    display: none; /* Ocultar detalles en frontend */
}

/* Los slots seleccionables en público SÍ deben tener cursor pointer */
.ipb-calendar[data-mode="public"] .ipb-slot-selectable {
    cursor: pointer !important;
}

.ipb-calendar[data-mode="public"] .ipb-slot-selectable:hover {
    transform: scale(1.02);
    box-shadow: 0 2px 4px rgba(0, 115, 170, 0.2);
}

.ipb-calendar[data-mode="public"] .ipb-slot-selectable:active {
    transform: scale(0.98);
}

/* ==========================================================================
   TOUCH / MOBILE OPTIMIZATIONS
   ========================================================================== */

/* Pantallas muy pequeñas (< 480px) - Diseño minimalista */
@media (max-width: 480px) {
    .ipb-booking-step .ipb-public-booking-calendar {
        margin-left: -20px;
        margin-right: -20px;
    }
    .ipb-calendar {
        padding: 10px;
    }
    
    .ipb-calendar-title {
        font-size: 16px;
    }
    
    .ipb-calendar-nav {
        font-size: 13px;
        padding: 8px 10px;
    }
    
    .ipb-weekday {
        font-size: 11px;
        padding: 6px 2px;
    }
    
    .ipb-calendar-days {
        gap: 2px;
    }
    
    .ipb-calendar-day {
        /*min-height: 70px;*/
        padding: 3px;
    }
    
    .ipb-day-number {
        font-size: 13px;
        margin-bottom: 3px;
    }
    
    .ipb-slot {
        padding: 4px 3px;
        min-height: 35px;
    }
    .ipb-day-closed-label{
        display: none;
    }
}

@media (hover: none) and (pointer: coarse) {
    /* Touch devices */
    .ipb-calendar-nav {
        padding: 10px 14px;
        font-size: 15px;
    }
    
    /* En móvil touch, los slots son bloques de color clicables */
    .ipb-slot-selectable {
        min-height: 40px;
    }
    
    .ipb-slot {
        touch-action: manipulation;
    }
}

/* ==========================================================================
   PRINT STYLES
   ========================================================================== */

@media print {
    .ipb-calendar-nav {
        display: none;
    }
    
    .ipb-calendar {
        box-shadow: none;
        border: 1px solid #000;
    }
    
    .ipb-slot-selectable {
        cursor: default;
    }
}

/* ==========================================================================
   SLOTS CLICABLES EN MODO PÚBLICO
   ========================================================================== */

.ipb-slot-clickable {
    cursor: pointer !important;
    transition: all 0.2s ease;
}

.ipb-slot-clickable:hover {
    transform: scale(1.02);
    box-shadow: 0 2px 8px rgba(0, 115, 170, 0.2);
}

.ipb-slot-clickable:active {
    transform: scale(0.98);
}
