/* ==========================================================================
   ACADEMIAQR · CALENDARIO ESCOLAR & AGENDA INTEGRADA (V2 MODERNO)
   Diseño limpio, interactivo, sincronizado 1-Tap y optimizado para Móvil/Tablet
   ========================================================================== */

/* 1. Barra Superior de Filtros 1-Tap (Categorías + Switch Móvil) */
.cal-toolbar-v2 {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 0.75rem;
    flex-wrap: wrap;
    background: #ffffff;
    border: 1px solid #e2e8f0;
    border-radius: 16px;
    padding: 0.6rem 0.8rem;
    box-shadow: 0 2px 10px rgba(15, 23, 42, 0.04);
}

.cal-category-pills {
    display: flex;
    align-items: center;
    gap: 0.4rem;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: none;
    flex: 1 1 auto;
    min-width: 0;
    padding: 2px 0;
}

.cal-category-pills::-webkit-scrollbar {
    display: none;
}

.cal-cat-pill {
    display: inline-flex;
    align-items: center;
    gap: 0.35rem;
    padding: 0.38rem 0.72rem;
    border-radius: 9999px;
    border: 1.5px solid #e2e8f0;
    background: #f8fafc;
    color: #475569;
    font-size: 0.75rem;
    font-weight: 700;
    white-space: nowrap;
    cursor: pointer;
    font-family: inherit;
    transition: all 0.16s ease;
    flex-shrink: 0;
}

.cal-cat-pill i {
    color: var(--pill-color, #64748b);
    font-size: 0.76rem;
}

.cal-cat-pill .cal-pill-count {
    font-size: 0.66rem;
    font-weight: 800;
    padding: 1px 6px;
    border-radius: 9999px;
    background: rgba(15, 23, 42, 0.06);
    color: #475569;
}

.cal-cat-pill:hover {
    border-color: var(--pill-color, #7c3aed);
    background: #ffffff;
    color: #0f172a;
}

.cal-cat-pill.active {
    background: var(--pill-color, #7c3aed);
    border-color: var(--pill-color, #7c3aed);
    color: #ffffff;
    box-shadow: 0 4px 12px color-mix(in srgb, var(--pill-color, #7c3aed) 28%, transparent);
}

.cal-cat-pill.active i,
.cal-cat-pill.active .cal-pill-count {
    color: #ffffff;
}

.cal-cat-pill.active .cal-pill-count {
    background: rgba(255, 255, 255, 0.22);
}

/* Switch de Vista Móvil (Calendario | Agenda) - oculto en Desktop */
.cal-mobile-view-switch {
    display: none;
    background: #f1f5f9;
    border-radius: 12px;
    padding: 3px;
    gap: 4px;
    border: 1px solid #e2e8f0;
}

.cal-mobile-view-btn {
    flex: 1;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.4rem;
    padding: 0.48rem 0.75rem;
    border-radius: 9px;
    border: none;
    background: transparent;
    color: #475569;
    font-size: 0.78rem;
    font-weight: 800;
    cursor: pointer;
    font-family: inherit;
    transition: all 0.16s ease;
}

.cal-mobile-view-btn.active {
    background: #ffffff;
    color: #5b21b6;
    box-shadow: 0 2px 8px rgba(15, 23, 42, 0.08);
}

/* 2. Layout Principal: Calendario (62%) + Agenda Sincronizada (38%) */
.calendar-main-layout {
    display: grid;
    grid-template-columns: minmax(0, 1.55fr) minmax(320px, 1fr);
    gap: 1.15rem;
    align-items: start;
}

/* 3. Tarjeta del Calendario Mensual */
.calendar-card {
    border-radius: 18px !important;
    border: 1px solid #e2e8f0 !important;
    overflow: hidden;
    padding: 0 !important;
    box-shadow: 0 6px 24px rgba(15, 23, 42, 0.05) !important;
}

.calendar-nav-header {
    background: linear-gradient(135deg, #1e1b4b 0%, #3730a3 55%, #6d28d9 100%);
    color: #ffffff;
    padding: 0.9rem 1.15rem !important;
    margin-bottom: 0 !important;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 0.75rem;
    border-bottom: none !important;
}

.calendar-nav-controls {
    display: flex;
    align-items: center;
    gap: 0.55rem;
}

.calendar-nav-header .btn-cal-nav {
    width: 32px;
    height: 32px;
    border-radius: 10px;
    border: 1px solid rgba(255, 255, 255, 0.24);
    background: rgba(255, 255, 255, 0.12);
    color: #ffffff;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: all 0.15s ease;
}

.calendar-nav-header .btn-cal-nav:hover {
    background: rgba(255, 255, 255, 0.24);
}

.calendar-current-title {
    margin: 0 !important;
    font-size: 1.1rem !important;
    font-weight: 800 !important;
    color: #ffffff !important;
    min-width: 155px;
    text-align: center;
    letter-spacing: -0.01em;
}

.btn-cal-today {
    display: inline-flex;
    align-items: center;
    gap: 0.35rem;
    padding: 0.38rem 0.78rem;
    border-radius: 9999px;
    border: 1px solid rgba(255, 255, 255, 0.3);
    background: rgba(255, 255, 255, 0.16);
    color: #ffffff;
    font-size: 0.76rem;
    font-weight: 800;
    cursor: pointer;
    font-family: inherit;
    transition: all 0.16s ease;
}

.btn-cal-today:hover {
    background: #ffffff;
    color: #3730a3;
}

.calendar-weekdays-grid {
    display: grid;
    grid-template-columns: repeat(7, 1fr);
    background: #f8fafc;
    border-bottom: 1px solid #e2e8f0;
    padding: 0.45rem 0.35rem;
}

.weekday-name {
    text-align: center;
    font-size: 0.72rem;
    font-weight: 800;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    color: #475569;
}

.weekday-name.weekend {
    color: #7c3aed;
}

.calendar-grid-cells {
    display: grid;
    grid-template-columns: repeat(7, minmax(0, 1fr));
    background: #e2e8f0;
    gap: 1px;
}

.calendar-day-cell {
    background: #ffffff;
    min-height: 92px;
    padding: 0.38rem 0.4rem;
    display: flex;
    flex-direction: column;
    gap: 0.25rem;
    cursor: pointer;
    transition: background 0.15s ease, box-shadow 0.15s ease;
    position: relative;
}

.calendar-day-cell:hover {
    background: #f8fafc;
}

.calendar-day-cell.cell-other-month {
    background: #f8fafc;
    opacity: 0.55;
    cursor: default;
}

.calendar-day-cell.cell-today {
    background: linear-gradient(180deg, #eff6ff 0%, #ffffff 100%);
}

.calendar-day-cell.cell-selected {
    background: linear-gradient(180deg, #f5f3ff 0%, #ffffff 100%);
    box-shadow: inset 0 0 0 2px #7c3aed;
    z-index: 2;
}

.cell-top-bar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 2px;
}

.day-number {
    font-size: 0.78rem;
    font-weight: 800;
    color: #334155;
    width: 24px;
    height: 24px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border-radius: 9999px;
}

.day-number.number-today {
    background: #2563eb;
    color: #ffffff;
    box-shadow: 0 2px 8px rgba(37, 99, 235, 0.35);
}

.cell-selected .day-number:not(.number-today) {
    background: #7c3aed;
    color: #ffffff;
}

.cell-event-count {
    font-size: 0.64rem;
    font-weight: 800;
    color: #6d28d9;
    background: #ede9fe;
    padding: 1px 5px;
    border-radius: 9999px;
}

.cell-events-container {
    display: flex;
    flex-direction: column;
    gap: 3px;
    min-width: 0;
}

.event-chip {
    display: flex;
    align-items: center;
    gap: 4px;
    padding: 2px 5px;
    border-radius: 6px;
    font-size: 0.67rem;
    font-weight: 700;
    line-height: 1.25;
    overflow: hidden;
    white-space: nowrap;
    text-overflow: ellipsis;
    border-left: 3px solid var(--evt-color, #6366f1);
    background: var(--evt-soft-bg, #eef2ff);
    color: var(--evt-text-color, #3730a3);
    transition: transform 0.12s ease, filter 0.12s ease;
}

.event-chip:hover {
    transform: translateX(1px);
    filter: brightness(0.96);
}

.event-chip-icon {
    font-size: 0.62rem;
    flex-shrink: 0;
}

.event-chip-text {
    overflow: hidden;
    text-overflow: ellipsis;
}

.event-chip-more {
    font-size: 0.64rem;
    font-weight: 800;
    color: #6d28d9;
    padding: 1px 4px;
    text-align: center;
    border-radius: 4px;
    background: #f5f3ff;
}

/* Indicadores compactos de puntos en móvil */
.cell-mobile-dots {
    display: none;
    align-items: center;
    justify-content: center;
    gap: 3px;
    flex-wrap: wrap;
    margin-top: auto;
    padding-bottom: 2px;
}

.cell-mobile-dot {
    width: 6px;
    height: 6px;
    border-radius: 9999px;
    display: inline-block;
}

/* 4. Panel Lateral: Agenda de Actividades Sincronizada */
.agenda-card-v2 {
    border-radius: 18px !important;
    border: 1px solid #e2e8f0 !important;
    padding: 1rem !important;
    background: #ffffff;
    box-shadow: 0 6px 24px rgba(15, 23, 42, 0.05) !important;
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
}

.agenda-scope-bar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 0.4rem;
    background: #f1f5f9;
    padding: 3px;
    border-radius: 10px;
}

.agenda-scope-btn {
    flex: 1;
    border: none;
    background: transparent;
    color: #475569;
    font-size: 0.72rem;
    font-weight: 800;
    padding: 0.36rem 0.45rem;
    border-radius: 8px;
    cursor: pointer;
    font-family: inherit;
    transition: all 0.15s ease;
}

.agenda-scope-btn.active {
    background: #ffffff;
    color: #5b21b6;
    box-shadow: 0 2px 6px rgba(15, 23, 42, 0.08);
}

/* Banner de Día Seleccionado en Agenda */
.agenda-selected-day-banner {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 0.5rem;
    padding: 0.55rem 0.75rem;
    border-radius: 12px;
    background: linear-gradient(135deg, #f5f3ff 0%, #eff6ff 100%);
    border: 1.5px solid #c4b5fd;
    font-size: 0.76rem;
    font-weight: 800;
    color: #4c1d95;
}

/* Mini KPIs interactivos (Click-to-Filter) */
.agenda-mini-kpis-grid {
    display: grid;
    grid-template-columns: repeat(4, minmax(0, 1fr)) !important;
    gap: 0.4rem !important;
    margin-bottom: 0 !important;
}

.agenda-mini-kpi-item {
    cursor: pointer;
    padding: 0.5rem 0.4rem !important;
    border-radius: 11px !important;
    border: 1.5px solid #e2e8f0 !important;
    background: #f8fafc !important;
    display: flex;
    flex-direction: column;
    align-items: center;
    text-align: center;
    gap: 0.15rem !important;
    transition: all 0.16s ease;
}

.agenda-mini-kpi-item:hover {
    border-color: #a78bfa !important;
    background: #ffffff !important;
    transform: translateY(-1px);
}

.agenda-mini-kpi-item.active-kpi {
    border-color: #7c3aed !important;
    background: #f5f3ff !important;
    box-shadow: 0 2px 8px rgba(124, 58, 237, 0.15);
}

.agenda-mini-kpi-val {
    font-size: 1.05rem !important;
    font-weight: 900 !important;
    line-height: 1.1;
    color: #0f172a;
}

.agenda-mini-kpi-label {
    font-size: 0.64rem !important;
    font-weight: 700 !important;
    color: #64748b;
}

.upcoming-events-feed {
    display: flex;
    flex-direction: column;
    gap: 0.6rem;
    max-height: 510px;
    overflow-y: auto;
    padding-right: 3px;
}

.upcoming-event-card {
    display: flex;
    align-items: stretch;
    gap: 0.7rem;
    padding: 0.68rem 0.75rem !important;
    border-radius: 13px !important;
    border: 1px solid #e2e8f0 !important;
    border-left: 4px solid var(--accent-color, #6366f1) !important;
    background: #ffffff !important;
    cursor: pointer;
    transition: transform 0.15s ease, box-shadow 0.15s ease, border-color 0.15s ease;
}

.upcoming-event-card:hover {
    transform: translateY(-1px);
    box-shadow: 0 8px 20px rgba(15, 23, 42, 0.08);
    border-color: var(--accent-color, #6366f1) !important;
}

.event-card-date-badge {
    width: 48px !important;
    min-width: 48px !important;
    border-radius: 10px !important;
    padding: 0.25rem 0.15rem !important;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    border: 1px solid #e2e8f0;
    overflow: hidden;
}

.date-badge-weekday {
    font-size: 0.58rem !important;
    font-weight: 800;
    letter-spacing: 0.04em;
}

.date-badge-day {
    font-size: 1.1rem !important;
    font-weight: 900;
    line-height: 1.1;
}

.date-badge-month {
    font-size: 0.56rem !important;
    font-weight: 800;
    padding: 1px 6px;
    border-radius: 999px;
    margin-top: 2px;
}

.upcoming-card-content {
    min-width: 0;
    flex: 1;
}

.upcoming-card-title {
    font-size: 0.86rem !important;
    font-weight: 800 !important;
    color: #0f172a;
    margin: 0.2rem 0 0.18rem 0 !important;
    line-height: 1.25;
}

.upcoming-card-desc {
    font-size: 0.74rem !important;
    color: #64748b;
    margin: 0 0 0.35rem 0 !important;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
    line-height: 1.35;
}

.upcoming-card-footer {
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: 0.45rem;
}

.upcoming-card-meta-pill {
    font-size: 0.69rem !important;
    font-weight: 700;
    color: #475569;
    display: inline-flex;
    align-items: center;
    gap: 0.25rem;
}

/* 5. Responsivo Tablet y Móvil */
@media (max-width: 1024px) {
    .calendar-main-layout {
        grid-template-columns: 1fr !important;
        gap: 0.9rem !important;
    }

    .upcoming-events-feed {
        max-height: 440px;
    }
}

@media (max-width: 768px) {
    .cal-mobile-view-switch {
        display: flex !important;
        width: 100%;
    }

    /* En móvil, alternar vista activa para cero scroll excesivo */
    .calendar-main-layout.mobile-view-calendar .agenda-card-v2 {
        display: none !important;
    }

    .calendar-main-layout.mobile-view-agenda .calendar-card {
        display: none !important;
    }

    .calendar-day-cell {
        min-height: 54px !important;
        padding: 0.25rem 0.2rem !important;
    }

    .cell-events-container {
        display: none !important;
    }

    .cell-mobile-dots {
        display: flex !important;
    }

    .cell-event-count {
        display: none !important;
    }

    .calendar-nav-header {
        padding: 0.7rem 0.8rem !important;
    }

    .calendar-current-title {
        font-size: 0.96rem !important;
        min-width: 125px;
    }
}

/* Bandeja rápida de día seleccionado debajo del mes en móvil */
.cal-mobile-day-tray {
    display: none;
    border-top: 1px solid #e2e8f0;
    background: #f8fafc;
    padding: 0.75rem 0.85rem;
}

@media (max-width: 768px) {
    .cal-mobile-day-tray.has-selection {
        display: block;
    }
}
