/* =====================================================
   CALENDAR COMPONENTS
   ===================================================== */

/* ROOT */
.c-calendar {
    display: flex;
    flex-direction: column;
    font-family: var(--tef-calendar-font);
    color: var(--tef-calendar-text);
}

/* HEADER */
.c-calendar-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 1rem;
}

.c-calendar-header h2 {
    margin: 0;
}

/* VIEW SWITCHER */
.c-calendar-views {
    display: inline-flex;
    gap: .25rem;
}

.c-calendar-views a {
    padding: .35rem .65rem;
    font-size: .75rem;
    border-radius: 999px;
    background: transparent;
    border: 1px solid var(--tef-calendar-border);
    color: var(--tef-calendar-text-muted);
    cursor: pointer;
    text-decoration: none;
}

.c-calendar-views a.active {
    background: var(--tef-calendar-surface-soft);
    color: var(--tef-calendar-text);
    border-color: var(--tef-gold);
}

/* WEEKDAYS */
.c-calendar-weekdays {
    display: grid;
    grid-template-columns: repeat(7, 1fr);
    text-align: center;
    font-size: .7rem;
    text-transform: uppercase;
    color: var(--tef-calendar-text-muted);
    padding-bottom: .5rem;
}

/* CELLS */
.c-calendar-cells,
.c-month-cells {
    display: grid;
    grid-template-columns: repeat(7, 1fr);
}

.c-calendar-cell,
.c-month-cell {
    position: relative;
    min-height: 120px;
    padding: .5rem;
    border-top: 1px solid var(--tef-border);
    border-left: 1px solid var(--tef-border);
    background: var(--tef-surface);
    transition: background .15s ease;
}

.c-month-cell.is-today {
    background: rgba(255, 193, 7, 0.08); /* gold suave */
    position: relative;
}

.c-month-cell.is-today .c-month-date {
    background: var(--tef-gold);
    color: #000;
    width: 24px;
    height: 24px;
    border-radius: 50%;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-weight: 600;
}

.c-calendar-cell:hover,
.c-month-cell:hover {
    background: var(--tef-surface-soft);
}

.c-calendar-cell.is-today,
.c-month-cell.is-today {
    outline: 2px solid var(--tef-gold);
    outline-offset: -2px;
}

.c-calendar-cell.is-outside,
.c-month-cell.is-outside {
    background: var(--tef-surface-soft);
}

.c-calendar-date,
.c-month-date {
    font-size: .75rem;
    font-weight: 600;
    margin-bottom: .25rem;
    color: var(--tef-text-muted);
}

/* EVENTS */
.c-calendar-event,
.c-week-event,
.c-day-event,
.c-month-event {
    margin-top: .25rem;
    padding: .25rem .5rem;
    font-size: .75rem;
    border-radius: var(--tef-radius-sm);
    cursor: pointer;
    line-height: 1.3;
    overflow: hidden;
    white-space: nowrap;
    text-overflow: ellipsis;
    background: var(--tef-gold-soft);
    border-left: 3px solid var(--tef-gold);
    color: var(--tef-text);
    pointer-events: auto;
    transition: all .15s ease;
}

.c-calendar-event.is-foreign,
.c-week-event.is-foreign,
.c-day-event.is-foreign {
    border-left-color: #ff9800;
}

.c-calendar-event:hover,
.c-week-event:hover,
.c-day-event:hover {
    box-shadow: 0 0 5px rgba(0,0,0,.2);
}

/* WEEK */
.c-week-calendar {
    display: flex;
    flex-direction: column;
    border: 1px solid var(--tef-border);
    border-radius: var(--tef-radius);
    overflow: hidden;
}

.c-week-header-row,
.c-week-hour-row {
    display: grid;
    grid-template-columns: 80px repeat(7, 1fr);
}

.c-week-day-header {
    padding: .75rem;
    text-align: center;
    background: var(--tef-surface);
    border-left: 1px solid var(--tef-border);
}

.c-week-hour-col {
    background: var(--tef-surface);
}

.c-week-hour {
    padding: .5rem;
    font-size: .75rem;
    text-align: right;
    color: var(--tef-text-muted);
    border-top: 1px solid var(--tef-border);
}

.c-week-cell {
    min-height: 60px;
    border-top: 1px solid var(--tef-border);
    border-left: 1px solid var(--tef-border);
    padding: .25rem;
}

.c-week-cell:hover {
    background: var(--tef-surface-soft);
}

.c-week-body {
    position: relative;
}

.c-week-events-layer {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    pointer-events: none;
}

.c-week-event {
    position: absolute;
    width: calc((100% - 80px) / 7 - 8px);
    margin-left: 4px;
    padding: .5rem;
    border-radius: var(--tef-radius-sm);
    font-size: .75rem;
}

/* DAY */
.c-day-calendar {
    border: 1px solid var(--tef-border);
    border-radius: var(--tef-radius);
    overflow: hidden;
}

.c-day-body {
    position: relative;
}

.c-day-hour-row {
    display: grid;
    grid-template-columns: 80px 1fr;
    height: 60px;
}

.c-day-hour {
    padding: .5rem;
    font-size: .75rem;
    text-align: right;
    color: var(--tef-text-muted);
    border-right: 1px solid var(--tef-border);
}

.c-day-cell {
    border-top: 1px solid var(--tef-border);
}

.c-day-events {
    position: absolute;
    top: 0;
    left: 80px;
    right: 0;
    bottom: 0;
}

/* =====================================================
   MONTH VIEW — GOOGLE CALENDAR STYLE (MOBILE)
   ===================================================== */
@media (max-width: 768px) {

    /* Grid del mes */
    .c-month-cells {
        gap: 1px;
    }

    /* Celda del día */
    .c-month-cell {
        min-height: unset;
        padding: .25rem;
        aspect-ratio: 1 / 1;
        display: flex;
        flex-direction: column;
        overflow: hidden;
    }

    /* Número del día */
    .c-month-date {
        font-size: .65rem;
        margin-bottom: .15rem;
        flex-shrink: 0;
    }

    /* Contenedor implícito de eventos */
    .c-month-cell .c-calendar-event {
        font-size: .6rem;
        padding: .15rem .3rem;
        line-height: 1.2;
        border-left-width: 2px;
        pointer-events: none;
    }

    /* Mostrar solo 2 eventos */
    .c-month-cell .c-calendar-event:nth-of-type(n+3) {
        display: none;
    }

     /* Ocultar estilo tarjeta */
    .c-month-cell .c-calendar-event {
        background: transparent;
        border: none;
        padding: 0;
        margin: 2px 2px 0 0;
        width: 6px;
        height: 6px;
        border-radius: 50%;
        display: inline-block;
    }

    /* Color por defecto */
    .c-month-cell .c-calendar-event::before {
        content: '';
        display: block;
        width: 6px;
        height: 6px;
        border-radius: 50%;
        background: var(--tef-gold);
    }

    /* Eventos de otro usuario */
    .c-month-cell .c-calendar-event.is-foreign::before {
        background: #ff9800;
    }

    /* Contenedor de puntos */
    .c-month-cell {
        align-items: flex-start;
    }

    /* Limitar cantidad visible (máx 4 puntos) */
    .c-month-cell .c-calendar-event:nth-of-type(n+5) {
        display: none;
    }
}

/* =====================================================
   MONTH AGENDA — MOBILE
   ===================================================== */
@media (max-width: 768px) {

    .c-month-agenda {
        margin-top: 1rem;
        border-top: 1px solid var(--tef-border);
        padding-top: .75rem;
    }

    .c-month-agenda-header {
        font-size: .85rem;
        font-weight: 600;
        margin-bottom: .5rem;
        color: var(--tef-text);
    }

    .c-month-agenda-list {
        display: flex;
        flex-direction: column;
        gap: .5rem;
        max-height: 40vh;
        overflow-y: auto;
        padding-right: .25rem;
    }

    .c-month-agenda-list .c-calendar-event {
        font-size: .75rem;
        white-space: normal;
    }
}

/* Agenda del mes SOLO mobile */
@media (min-width: 769px) {
    .c-month-agenda {
        display: none;
    }
}

/* =====================================================
   WEEK & DAY VIEW — MOBILE (Google Calendar Style)
   ===================================================== */
/* ===== WEEK VIEW RESPONSIVE CORREGIDO ===== */
@media (max-width: 768px) {
    .c-week-calendar {
        border: none;
        border-radius: 0;
        overflow-x: auto;
        width: 100%;
        display: block;
    }

    /* contenedor de grid */
    .c-week-header-row,
    .c-week-hour-row {
        display: grid;
        grid-template-columns: 60px repeat(7, 80px); /* columna de horas + 7 días */
        min-width: calc(60px + 7*80px);
        position: relative;
    }

    .c-week-header-row {
        position: sticky;
        top: 0;
        background: var(--tef-surface);
        z-index: 2;
        border-bottom: 1px solid var(--tef-border);
    }

    .c-week-hour-col {
        background: var(--tef-surface);
        border-right: 1px solid var(--tef-border);
    }

    .c-week-hour {
        font-size: .65rem;
        text-align: right;
        padding: .25rem;
        border-top: 1px solid var(--tef-border);
    }

    .c-week-day-header {
        text-align: center;
        font-size: .7rem;
        padding: .5rem;
        border-left: 1px solid var(--tef-border);
        white-space: nowrap;
    }

    .c-week-cell {
        min-height: 50px;
        padding: 2px;
        border-top: 1px solid var(--tef-border);
        border-left: 1px solid var(--tef-border);
        background: var(--tef-surface);
        position: relative;
    }

    /* eventos */
    .c-week-events-layer {
        position: absolute;
        top: 0;
        left: 0;
        right: 0;
        bottom: 0;
        pointer-events: none;
    }

    .c-week-event {
        position: absolute;
        font-size: .6rem;
        padding: 2px 4px;
        border-radius: 4px;
        background: var(--tef-gold-soft);
        border-left: 2px solid var(--tef-gold);
        overflow: hidden;
        white-space: nowrap;
        text-overflow: ellipsis;
        pointer-events: auto;
    }

    .c-week-event.is-foreign {
        border-left-color: #ff9800;
    }

    /* ===== DAY VIEW RESPONSIVE ===== */
    .c-day-calendar {
        border: none;
        border-radius: 0;
        overflow-y: auto;
        max-height: 70vh;
        position: relative;
    }

    .c-day-body {
        position: relative;
        min-width: 100%;
    }

    .c-day-hour-row {
        display: flex;
        min-height: 40px;
        border-bottom: 1px solid var(--tef-border);
    }

    .c-day-hour {
        width: 60px;
        font-size: .65rem;
        text-align: right;
        padding: .25rem;
        flex-shrink: 0;
        border-right: 1px solid var(--tef-border);
    }

    .c-day-cell {
        flex: 1;
        min-height: 40px;
        border-top: 1px solid var(--tef-border);
        position: relative;
        background: var(--tef-surface);
    }

    .c-day-events {
        position: absolute;
        top: 0;
        left: 60px;
        right: 0;
        bottom: 0;
        pointer-events: none;
    }

    .c-day-event {
        font-size: .65rem;
        padding: 2px 4px;
        border-radius: 4px;
        background: var(--tef-gold-soft);
        border-left: 2px solid var(--tef-gold);
        pointer-events: auto;
        overflow: hidden;
        white-space: nowrap;
        text-overflow: ellipsis;
    }

    .c-day-event.is-foreign {
        border-left-color: #ff9800;
    }

    /* ===== SCROLL & TOUCH ===== */
    .c-week-calendar::-webkit-scrollbar,
    .c-day-calendar::-webkit-scrollbar {
        height: 6px;
        width: 6px;
    }

    .c-week-calendar::-webkit-scrollbar-thumb,
    .c-day-calendar::-webkit-scrollbar-thumb {
        background: rgba(0,0,0,.2);
        border-radius: 3px;
    }
}
