/* =========================
   CASTELLÓN CALENDARIO DE EVENTOS
   Estilos con soporte táctil
   Versión 1.1.0
   ========================= */

/* Variables CSS */
:root {
    --ct-azul: #005f8f;
    --ct-naranja: #ff7f11;
    --ct-verde: #3A9F6B;
    --ct-morado: #8B5CF6;
    --ct-rosa: #EC4899;
    --ct-rojo: #EF4444;
    
    --ct-bg-light: #f8f9fa;
    --ct-text-dark: #212529;
    --ct-text-light: #6c757d;
    --ct-border: #dee2e6;
}

/* Reset básico */
.ct-calendar-wrapper * {
    box-sizing: border-box;
}

/* Container principal */
.ct-calendar-wrapper {
    max-width: 1200px;
    margin: 40px auto;
    padding: 20px;
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, Cantarell, sans-serif;
    background: transparent;
    position: relative;
    clear: both;
    width: 100%;
    overflow: visible !important;
}

.ct-calendar-wrapper::before,
.ct-calendar-wrapper::after {
    content: '';
    display: table;
    clear: both;
}

/* Header del calendario */
.ct-calendar-header {
    background:
      radial-gradient(circle at 0% 0%, rgba(59,130,246,.22), transparent 60%),
      radial-gradient(circle at 100% 0%, rgba(56,189,248,.24), transparent 55%),
      linear-gradient(135deg, #ffffff, #f0f9ff);
    color: #0f172a !important;
    padding: 30px;
    border-radius: 10px;
    margin-bottom: 30px;
    text-align: center;
    box-shadow: 0 4px 6px rgba(15,23,42,.12);
    overflow: visible !important;
}

.ct-calendar-header h2 {
    margin: 0 0 10px 0 !important;
    font-size: 2rem !important;
    font-weight: 700 !important;
    color: #0f172a !important;
    line-height: 1.2 !important;
}

.ct-calendar-header p {
    margin: 0 !important;
    opacity: 0.95;
    font-size: 1.1rem !important;
    color: #1f2933 !important;
    line-height: 1.4 !important;
}

/* Logo en cabecera */
.ct-calendar-logo {
    display: block;
    margin: 0 auto 12px auto;
    width: 170px;
    max-width: 70%;
    height: auto;
}

/* Navegación del calendario */
.ct-calendar-nav {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 20px;
    padding: 15px;
    background: white;
    border-radius: 8px;
    box-shadow: 0 2px 4px rgba(0,0,0,0.1);
}

.ct-nav-btn {
    background: var(--ct-azul);
    color: white;
    border: none;
    padding: 10px 20px;
    border-radius: 5px;
    cursor: pointer;
    font-size: 16px;
    transition: background 0.3s;
}

.ct-nav-btn:hover {
    background: var(--ct-verde);
}

.ct-current-month {
    font-size: 1.5rem;
    font-weight: 600;
    color: var(--ct-text-dark);
}

/* Filtros de eventos */
.ct-filters {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    margin-bottom: 20px;
    padding: 15px;
    background: white;
    border-radius: 8px;
    box-shadow: 0 2px 4px rgba(0,0,0,0.1);
    justify-content: center;
    align-items: center;
}

.ct-filter-btn {
    padding: 8px 16px;
    border: 2px solid var(--ct-border);
    background: white;
    color: var(--ct-text-dark);
    border-radius: 20px;
    cursor: pointer;
    transition: all 0.3s;
    font-size: 14px;
    font-weight: 500;
}

.ct-filter-btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 8px rgba(0,0,0,0.1);
}

.ct-filter-btn.active {
    background: var(--ct-azul);
    color: white;
    border-color: var(--ct-azul);
}

/* Container del grid (se actualiza vía AJAX) */
#ct-calendar-container {
    position: relative;
    transition: opacity 0.3s ease;
    width: 100%;
    overflow: visible !important;
}

#ct-calendar-container.loading {
    opacity: 0.6;
    pointer-events: none;
    position: relative;
}

#ct-calendar-container.loading::after {
    content: '';
    position: absolute;
    top: 50%;
    left: 50%;
    width: 50px;
    height: 50px;
    margin: -25px 0 0 -25px;
    border: 4px solid var(--ct-border);
    border-top-color: var(--ct-azul);
    border-radius: 50%;
    animation: spin 1s linear infinite;
    z-index: 1000;
}

@keyframes spin {
    to { transform: rotate(360deg); }
}

/* Grid del calendario */
.ct-calendar-grid {
    display: grid;
    grid-template-columns: repeat(7, 1fr);
    gap: 10px;
    background: white;
    padding: 20px;
    border-radius: 8px;
    box-shadow: 0 2px 8px rgba(0,0,0,0.1);
    margin-bottom: 20px;
    width: 100%;
    clear: both;
    position: relative;
    overflow: visible !important;
}

/* Días de la semana */
.ct-calendar-day-name {
    text-align: center;
    padding: 10px 5px;
    font-weight: 600 !important;
    color: var(--ct-azul) !important;
    background: var(--ct-bg-light);
    border-radius: 5px;
    font-size: 14px !important;
    line-height: 1.2 !important;
    margin: 0 !important;
}

.ct-calendar-day-name.ct-weekend-header {
    background: #e8f4f8;
    color: #0369a1 !important;
}

/* Celdas de día */
.ct-calendar-day {
    min-height: 120px;
    padding: 10px;
    border: 1px solid var(--ct-border);
    border-radius: 5px;
    position: relative;
    background: white !important;
    transition: all 0.3s;
    display: block;
    overflow: visible !important;
}

/* Fin de semana - Sábado y Domingo */
.ct-calendar-day.ct-weekend {
    background: #f8f9fa !important;
}

/* Festivos */
.ct-calendar-day.ct-holiday {
    background: linear-gradient(135deg, rgba(239, 68, 68, 0.08) 0%, rgba(239, 68, 68, 0.05) 100%) !important;
    border-color: rgba(239, 68, 68, 0.3);
}

.ct-calendar-day.ct-holiday .ct-day-number {
    color: #dc2626 !important;
    font-weight: 700 !important;
}

.ct-calendar-day:hover {
    box-shadow: 0 4px 8px rgba(0,0,0,0.1);
    transform: translateY(-2px);
}

.ct-calendar-day.ct-other-month {
    opacity: 0.3;
    background: #f5f5f5 !important;
}

.ct-calendar-day.ct-today {
    background: linear-gradient(135deg, rgba(0,95,143,0.1) 0%, rgba(58,159,107,0.1) 100%) !important;
    border-color: var(--ct-azul);
    border-width: 2px;
}

.ct-day-number {
    font-size: 14px !important;
    font-weight: 600 !important;
    color: var(--ct-text-dark) !important;
    margin: 0 0 5px 0 !important;
    padding: 0 !important;
    line-height: 1.2 !important;
    display: flex;
    align-items: center;
    gap: 4px;
}

.ct-holiday-name {
    font-size: 12px;
    display: inline-block;
}

/* Tarjetas de eventos */
.ct-event-card {
    background: white;
    border-left: 4px solid var(--ct-azul);
    padding: 8px;
    margin-bottom: 5px;
    border-radius: 4px;
    cursor: pointer;
    transition: all 0.3s;
    position: relative;
    -webkit-tap-highlight-color: transparent;
}

.ct-event-card:hover {
    transform: translateX(3px);
    box-shadow: 0 2px 8px rgba(0,0,0,0.15);
}

/* Colores por tipo de evento */
.ct-event-card[data-event-type="EXPOSICIONES"] {
    border-left-color: var(--ct-morado);
}

.ct-event-card[data-event-type="DEPORTE"] {
    border-left-color: var(--ct-verde);
}

.ct-event-card[data-event-type="MUSICA"] {
    border-left-color: var(--ct-azul);
}

.ct-event-card[data-event-type="CULTURA"] {
    border-left-color: var(--ct-naranja);
}

.ct-event-card[data-event-type="TEATRO Y DANZA"] {
    border-left-color: var(--ct-rosa);
}

.ct-event-card[data-event-type="FIESTAS Y TRADICIONES"] {
    border-left-color: var(--ct-rojo);
}

.ct-event-title {
    font-size: 13px;
    font-weight: 600;
    color: var(--ct-text-dark);
    margin: 0 0 3px 0;
    line-height: 1.3;
}

.ct-event-time {
    font-size: 11px;
    color: var(--ct-text-light);
    margin: 0;
}

/* TOOLTIPS */
.ct-event-tooltip {
    position: fixed !important;
    z-index: 999999 !important;
    background: white;
    border: 1px solid var(--ct-border);
    border-radius: 8px;
    padding: 15px;
    min-width: 250px;
    max-width: 300px;
    box-shadow: 0 8px 24px rgba(0,0,0,0.35);
    opacity: 0;
    visibility: hidden;
    transform: translateY(-10px);
    transition: all 0.3s ease;
    pointer-events: none;
}

/* Tooltip activo */
.ct-event-tooltip.ct-tooltip-active {
    opacity: 1;
    visibility: visible;
    transform: translateY(0);
    pointer-events: auto;
}

/* Tarjeta activa (con tooltip abierto) */
.ct-event-card.ct-card-active {
    position: relative;
    z-index: 1000;
    transform: translateX(3px);
    box-shadow: 0 4px 12px rgba(0,0,0,0.2);
}

.ct-tooltip-title {
    font-size: 16px;
    font-weight: 600;
    color: var(--ct-text-dark);
    margin: 0 0 10px 0;
}

.ct-tooltip-type {
    display: inline-block;
    padding: 4px 10px;
    border-radius: 12px;
    font-size: 11px;
    font-weight: 600;
    text-transform: uppercase;
    margin-bottom: 10px;
}

.ct-tooltip-description {
    font-size: 14px;
    color: var(--ct-text-light);
    margin: 0 0 10px 0;
    line-height: 1.5;
}

.ct-tooltip-footer {
    font-size: 12px;
    color: var(--ct-text-light);
    padding-top: 10px;
    border-top: 1px solid var(--ct-border);
}

/* MEJORAS PARA DISPOSITIVOS TÁCTILES */
@media (max-width: 768px) {
    /* scroll hints */
    #ct-calendar-container { position: relative; }
    .ct-scroll-hint {
        position: absolute;
        top: 45%;
        width: 32px;
        height: 32px;
        border-radius: 999px;
        background: var(--ct-azul);
        color: #ffffff;
        display: flex;
        align-items: center;
        justify-content: center;
        font-size: 16px;
        box-shadow: 0 10px 22px rgba(15,23,42,.45);
        opacity: 0;
        pointer-events: none;
        transition: opacity .2s ease, transform .15s ease;
        z-index: 20;
        cursor: pointer;
    }
    .ct-scroll-hint-left { left: 8px; }
    .ct-scroll-hint-right { right: 8px; }
    .ct-scroll-hint.is-visible { opacity: 1; pointer-events: auto; }
    .ct-scroll-hint.is-visible:active { transform: scale(.94); }
} {
    /* Hacer las tarjetas más grandes en móvil */
    .ct-event-card {
        padding: 10px;
        min-height: 50px;
        display: flex;
        flex-direction: column;
        justify-content: center;
    }
    
    /* Tooltip más ancho en móvil */
    .ct-event-tooltip {
        min-width: 280px;
        max-width: 90vw;
    }
    
    /* Mejorar el área de tap */
    .ct-event-card {
        margin-bottom: 8px;
    }
    
    /* Deshabilitar efectos hover en dispositivos táctiles */
    .ct-event-card:hover {
        transform: none;
    }
    
    .ct-event-card.ct-card-active {
        transform: none;
        box-shadow: 0 6px 16px rgba(0,0,0,0.25);
    }
}

/* Responsive */
@media (max-width: 768px) {
    /* scroll hints */
    #ct-calendar-container { position: relative; }
    .ct-scroll-hint {
        position: absolute;
        top: 45%;
        width: 32px;
        height: 32px;
        border-radius: 999px;
        background: var(--ct-azul);
        color: #ffffff;
        display: flex;
        align-items: center;
        justify-content: center;
        font-size: 16px;
        box-shadow: 0 10px 22px rgba(15,23,42,.45);
        opacity: 0;
        pointer-events: none;
        transition: opacity .2s ease, transform .15s ease;
        z-index: 20;
        cursor: pointer;
    }
    .ct-scroll-hint-left { left: 8px; }
    .ct-scroll-hint-right { right: 8px; }
    .ct-scroll-hint.is-visible { opacity: 1; pointer-events: auto; }
    .ct-scroll-hint.is-visible:active { transform: scale(.94); }
} {
    .ct-calendar-wrapper {
        padding: 10px;
        max-width: 100%;
        /* Evita que el grid se "apriete" (texto en vertical). El scroll queda
           contenido dentro del bloque del calendario (no desborda la página). */
        overflow-x: auto !important;
        -webkit-overflow-scrolling: touch;
    }

    #ct-calendar-container {
        width: 100%;
        max-width: 100%;
        overflow-x: auto !important;
        -webkit-overflow-scrolling: touch;
    }
    
    .ct-calendar-header {
    background:
      radial-gradient(circle at 0% 0%, rgba(59,130,246,.22), transparent 60%),
      radial-gradient(circle at 100% 0%, rgba(56,189,248,.24), transparent 55%),
      linear-gradient(135deg, #ffffff, #f0f9ff);
    color: #0f172a !important;
    padding: 30px;
    border-radius: 10px;
    margin-bottom: 30px;
    text-align: center;
    box-shadow: 0 4px 6px rgba(15,23,42,.12);
    overflow: visible !important;
}
    
    .ct-calendar-header h2 {
    margin: 0 0 10px 0 !important;
    font-size: 2rem !important;
    font-weight: 700 !important;
    color: #0f172a !important;
    line-height: 1.2 !important;
}
    
    .ct-calendar-grid {
        gap: 5px;
        padding: 10px;
        /* Mantener 7 columnas legibles: si no caben, aparece scroll horizontal */
        grid-template-columns: repeat(7, minmax(92px, 1fr));
        width: max(100%, 720px);
        max-width: none;
        overflow: visible;
    }

    .ct-calendar-day-name,
    .ct-calendar-day {
        min-width: 0;
    }
    
    .ct-calendar-day {
        min-height: 80px;
        padding: 5px;
    }
    
    .ct-day-number {
        font-size: 12px;
    }
    
    .ct-event-title {
        font-size: 11px;
        /* Evita "texto en vertical" cuando la columna es estrecha */
        word-break: normal;
        overflow-wrap: anywhere;
        hyphens: manual;
        white-space: normal;
    }
    
    .ct-event-time {
        font-size: 10px;
    }
    
    .ct-filters {
        gap: 5px;
        padding: 10px;
    }
    
    .ct-filter-btn {
        font-size: 12px;
        padding: 6px 12px;
    }

    /* En móvil eliminamos tooltips totalmente */
    .ct-event-tooltip {
        display: none !important;
        visibility: hidden !important;
        opacity: 0 !important;
    }
}

@media (max-width: 480px) {
    .ct-calendar-day-name {
        font-size: 12px;
        padding: 5px;
    }
    
    .ct-current-month {
        font-size: 1.2rem;
    }
    
    .ct-nav-btn {
        padding: 8px 12px;
        font-size: 14px;
    }
}

/* Modal (si se implementa) */
.ct-event-modal {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0,0,0,0.7);
    z-index: 10000;
    overflow-y: auto;
}

.ct-event-modal.active {
    display: flex;
    align-items: center;
    justify-content: center;
}

.ct-modal-content {
    background: white;
    max-width: 800px;
    width: 90%;
    border-radius: 10px;
    padding: 30px;
    position: relative;
}

.ct-modal-close {
    position: absolute;
    top: 15px;
    right: 15px;
    font-size: 24px;
    cursor: pointer;
    background: none;
    border: none;
    color: var(--ct-text-light);
}

body.modal-open {
    overflow: hidden;
}
