/**
 * Events Calendar — University of Sierra Leone
 */

.usl-events-calendar-page,
.evcal-modal {
    --evcal-navy: var(--usl-primary-dark, #0f172a);
    --evcal-blue: var(--usl-primary, #1e3a8a);
    --evcal-gold: var(--usl-accent, #fbbf24);
    --evcal-accent: #3b82f6;
    --evcal-surface: #f8fafc;
    --evcal-card: #ffffff;
    --evcal-muted: #64748b;
    --evcal-border: rgba(15, 23, 42, 0.08);
}

.usl-events-calendar-page {
    color: #0f172a;
}

/* View toggle (nav) */
.evcal-view-toggle {
    display: inline-flex;
    align-items: center;
    gap: 0.25rem;
    padding: 0.25rem;
    background: #fff;
    border: 1px solid #e2e8f0;
    border-radius: 0.65rem;
    flex-shrink: 0;
}

.evcal-view-toggle a {
    display: inline-flex;
    align-items: center;
    gap: 0.35rem;
    padding: 0.48rem 0.85rem;
    font-size: 0.78rem;
    font-weight: 600;
    color: #475569;
    text-decoration: none;
    border-radius: 0.5rem;
    transition: background 0.15s ease, color 0.15s ease;
    white-space: nowrap;
}

.evcal-view-toggle a:hover {
    color: var(--evcal-blue);
    background: #f8fafc;
}

.evcal-view-toggle a.is-active {
    color: #fff;
    background: var(--evcal-blue);
}

/* Month navigation bar */
.evcal-nav {
    position: sticky;
    top: 0;
    z-index: 25;
    background: rgba(248, 250, 252, 0.96);
    border-bottom: 1px solid var(--evcal-border);
    backdrop-filter: blur(10px);
    box-shadow: 0 4px 18px rgba(15, 23, 42, 0.04);
}

.evcal-nav__inner {
    max-width: 72rem;
    margin: 0 auto;
    padding: 1rem 1.5rem 1.15rem;
}

.evcal-nav__row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
    margin-bottom: 0.85rem;
}

.evcal-nav__center {
    text-align: center;
    min-width: 0;
}

.evcal-nav__btn {
    display: inline-flex;
    align-items: center;
    gap: 0.4rem;
    padding: 0.55rem 0.95rem;
    font-size: 0.82rem;
    font-weight: 600;
    color: #334155;
    background: #fff;
    border: 1px solid #e2e8f0;
    border-radius: 0.65rem;
    text-decoration: none;
    transition: border-color 0.15s ease, color 0.15s ease, background 0.15s ease;
    white-space: nowrap;
}

.evcal-nav__btn:hover {
    border-color: var(--evcal-blue);
    color: var(--evcal-blue);
    background: #f8fafc;
}

.evcal-nav__title {
    margin: 0;
    font-size: clamp(1.15rem, 2.5vw, 1.55rem);
    font-weight: 800;
    letter-spacing: -0.02em;
    color: #0f172a;
}

.evcal-nav__count {
    display: block;
    margin-top: 0.2rem;
    font-size: 0.78rem;
    font-weight: 600;
    color: var(--evcal-muted);
}

.evcal-nav__controls {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: center;
    gap: 0.55rem;
    margin-bottom: 0.75rem;
}

.evcal-select-wrap {
    position: relative;
}

.evcal-select {
    appearance: none;
    padding: 0.55rem 2rem 0.55rem 0.85rem;
    font-size: 0.82rem;
    font-weight: 600;
    color: #334155;
    background: #fff;
    border: 1px solid #e2e8f0;
    border-radius: 0.65rem;
    cursor: pointer;
}

.evcal-select:focus {
    outline: 2px solid rgba(30, 58, 138, 0.35);
    outline-offset: 1px;
}

.evcal-select-wrap::after {
    content: '\f078';
    font-family: 'Font Awesome 6 Free';
    font-weight: 900;
    position: absolute;
    right: 0.75rem;
    top: 50%;
    transform: translateY(-50%);
    font-size: 0.62rem;
    color: #94a3b8;
    pointer-events: none;
}

.evcal-month-scroll {
    display: flex;
    flex-wrap: nowrap;
    gap: 0.45rem;
    overflow-x: auto;
    padding-bottom: 0.2rem;
    scrollbar-width: none;
    -webkit-overflow-scrolling: touch;
}

.evcal-month-scroll::-webkit-scrollbar {
    display: none;
}

.evcal-month-pill {
    flex-shrink: 0;
    padding: 0.42rem 0.8rem;
    font-size: 0.78rem;
    font-weight: 600;
    color: #475569;
    background: #fff;
    border: 1px solid #e2e8f0;
    border-radius: 999px;
    text-decoration: none;
    transition: background 0.15s ease, color 0.15s ease, border-color 0.15s ease;
}

.evcal-month-pill:hover {
    border-color: var(--evcal-blue);
    color: var(--evcal-blue);
}

.evcal-month-pill.is-active {
    background: var(--evcal-blue);
    border-color: var(--evcal-blue);
    color: #fff;
}

.evcal-month-pill--today {
    border-color: #93c5fd;
    color: var(--evcal-blue);
}

/* Main layout */
.evcal-main {
    padding: 2rem 0 4rem;
    background: linear-gradient(180deg, var(--evcal-surface) 0%, #eef2f7 100%);
}

.evcal-container {
    max-width: 72rem;
    margin: 0 auto;
    padding: 0 1.5rem;
}

.evcal-layout {
    display: grid;
    grid-template-columns: minmax(0, 1fr);
    gap: 1.5rem;
    align-items: start;
}

.evcal-col {
    min-width: 0;
}

@media (min-width: 1100px) {
    .evcal-layout {
        grid-template-columns: minmax(0, 1fr) 18.5rem;
    }

    .evcal-sidebar {
        position: sticky;
        top: 7.5rem;
    }
}

/* Calendar grid */
.evcal-calendar {
    background: var(--evcal-card);
    border: 1px solid var(--evcal-border);
    border-radius: 1.15rem;
    overflow: hidden;
    box-shadow: 0 12px 32px rgba(15, 23, 42, 0.07);
}

.evcal-weekdays {
    display: grid;
    grid-template-columns: repeat(7, minmax(0, 1fr));
    background: linear-gradient(180deg, #f1f5f9, #e8eef5);
    border-bottom: 1px solid #e2e8f0;
}

.evcal-weekday {
    padding: 0.75rem 0.35rem;
    text-align: center;
    font-size: 0.72rem;
    font-weight: 700;
    letter-spacing: 0.06em;
    text-transform: uppercase;
    color: #64748b;
}

.evcal-weekday-long {
    display: inline;
}

.evcal-weekday-short {
    display: none;
}

.evcal-calendar__footer {
    padding: 0.75rem 1rem;
    background: #f8fafc;
    border-top: 1px solid #e2e8f0;
}

@media (max-width: 640px) {
    .evcal-weekday-long {
        display: none;
    }

    .evcal-weekday-short {
        display: inline;
    }
}

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

.evcal-day {
    min-height: 7.5rem;
    padding: 0.55rem;
    background: #fff;
    transition: background 0.15s ease;
}

.evcal-day--empty {
    background: #f8fafc;
    min-height: 4.5rem;
}

.evcal-day--weekend:not(.evcal-day--today) {
    background: #fafbfc;
}

.evcal-day--today {
    background: linear-gradient(180deg, #eff6ff 0%, #dbeafe 100%);
    box-shadow: inset 0 0 0 2px #3b82f6;
}

.evcal-day__head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 0.35rem;
    margin-bottom: 0.35rem;
}

.evcal-day__num {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 1.65rem;
    height: 1.65rem;
    font-size: 0.82rem;
    font-weight: 700;
    color: #475569;
    border-radius: 999px;
}

.evcal-day--today .evcal-day__num {
    background: var(--evcal-blue);
    color: #fff;
}

.evcal-day__badge {
    font-size: 0.58rem;
    font-weight: 800;
    letter-spacing: 0.05em;
    text-transform: uppercase;
    color: #1d4ed8;
    background: rgba(59, 130, 246, 0.15);
    padding: 0.15rem 0.4rem;
    border-radius: 999px;
}

.evcal-day__events {
    display: flex;
    flex-direction: column;
    gap: 0.3rem;
    max-height: 5.5rem;
    overflow-y: auto;
    scrollbar-width: thin;
}

.evcal-day__more {
    font-size: 0.65rem;
    font-weight: 600;
    color: var(--evcal-muted);
    padding-left: 0.15rem;
}

/* Event chips */
.evcal-event-chip {
    display: block;
    width: 100%;
    text-align: left;
    padding: 0.32rem 0.45rem;
    font-size: 0.68rem;
    font-weight: 600;
    line-height: 1.3;
    color: #1e40af;
    background: #dbeafe;
    border: none;
    border-left: 3px solid #3b82f6;
    border-radius: 0.4rem;
    cursor: pointer;
    transition: transform 0.15s ease, box-shadow 0.15s ease;
}

.evcal-event-chip:hover {
    transform: translateY(-1px);
    box-shadow: 0 4px 10px rgba(15, 23, 42, 0.08);
}

.evcal-event-chip__time {
    display: block;
    font-size: 0.62rem;
    font-weight: 500;
    opacity: 0.85;
    margin-top: 0.1rem;
}

/* Sidebar */
.evcal-sidebar {
    display: flex;
    flex-direction: column;
    gap: 1rem;
}

.evcal-panel {
    background: var(--evcal-card);
    border: 1px solid var(--evcal-border);
    border-radius: 1rem;
    padding: 1.1rem 1.15rem;
    box-shadow: 0 8px 22px rgba(15, 23, 42, 0.05);
}

.evcal-panel h3 {
    margin: 0 0 0.85rem;
    font-size: 0.92rem;
    font-weight: 800;
    letter-spacing: -0.01em;
    color: #0f172a;
}

.evcal-legend--inline {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: center;
    gap: 0.65rem 1.35rem;
}

.evcal-legend__item {
    display: flex;
    align-items: center;
    gap: 0.55rem;
    font-size: 0.78rem;
    color: #475569;
}

.evcal-legend__swatch {
    width: 0.85rem;
    height: 0.85rem;
    border-radius: 0.2rem;
    flex-shrink: 0;
}

.evcal-legend__swatch--event {
    background: #3b82f6;
}

.evcal-legend__swatch--today {
    background: var(--evcal-blue);
}

.evcal-legend__swatch--empty {
    background: #e2e8f0;
}

.evcal-list {
    display: flex;
    flex-direction: column;
    gap: 0.65rem;
    max-height: 22rem;
    overflow-y: auto;
}

.evcal-list-item {
    display: flex;
    gap: 0.75rem;
    padding: 0.65rem;
    border: 1px solid #e2e8f0;
    border-radius: 0.75rem;
    cursor: pointer;
    transition: border-color 0.15s ease, background 0.15s ease;
}

.evcal-list-item:hover {
    border-color: #93c5fd;
    background: #f8fafc;
}

.evcal-list-item__date {
    flex-shrink: 0;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    min-width: 2.6rem;
    padding: 0.35rem 0.45rem;
    background: #eff6ff;
    border-radius: 0.55rem;
    line-height: 1.1;
}

.evcal-list-item__date strong {
    font-size: 1rem;
    color: var(--evcal-blue);
}

.evcal-list-item__date span {
    font-size: 0.62rem;
    font-weight: 700;
    text-transform: uppercase;
    color: #64748b;
}

.evcal-list-item__body h4 {
    margin: 0 0 0.25rem;
    font-size: 0.82rem;
    font-weight: 700;
    line-height: 1.35;
    color: #0f172a;
}

.evcal-list-item__meta {
    font-size: 0.72rem;
    color: var(--evcal-muted);
    line-height: 1.45;
}

.evcal-empty {
    text-align: center;
    padding: 1.5rem 0.75rem;
    color: var(--evcal-muted);
}

.evcal-empty i {
    display: block;
    font-size: 1.75rem;
    color: #cbd5e1;
    margin-bottom: 0.5rem;
}

.evcal-empty p {
    margin: 0;
    font-size: 0.82rem;
}

/* Modal */
.evcal-modal {
    position: fixed;
    inset: 0;
    z-index: 60;
    display: none;
    align-items: center;
    justify-content: center;
    padding: 1.5rem;
    background: rgba(15, 23, 42, 0.55);
    backdrop-filter: blur(4px);
}

.evcal-modal[hidden] {
    display: none !important;
}

.evcal-modal.is-open {
    display: flex;
}

.evcal-modal__dialog {
    width: 100%;
    max-width: 32rem;
    background: #fff;
    border-radius: 1rem;
    box-shadow: 0 24px 48px rgba(15, 23, 42, 0.2);
    overflow: hidden;
    animation: evcalModalIn 0.22s ease;
}

@keyframes evcalModalIn {
    from {
        opacity: 0;
        transform: translateY(12px) scale(0.98);
    }
    to {
        opacity: 1;
        transform: translateY(0) scale(1);
    }
}

.evcal-modal__header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
    padding: 1.1rem 1.25rem;
    border-bottom: 1px solid #e2e8f0;
    background: linear-gradient(180deg, #f8fafc, #fff);
}

.evcal-modal__header h3 {
    margin: 0;
    font-size: 0.88rem;
    font-weight: 700;
    letter-spacing: 0.04em;
    text-transform: uppercase;
    color: #64748b;
}

.evcal-modal__close {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 2rem;
    height: 2rem;
    border: none;
    border-radius: 0.5rem;
    background: #f1f5f9;
    color: #64748b;
    cursor: pointer;
    transition: background 0.15s ease, color 0.15s ease;
}

.evcal-modal__close:hover {
    background: #e2e8f0;
    color: #0f172a;
}

.evcal-modal__body {
    padding: 1.25rem;
}

.evcal-modal__title {
    margin: 0 0 1rem;
    font-size: 1.25rem;
    font-weight: 800;
    line-height: 1.35;
    color: #0f172a;
}

.evcal-modal__details {
    display: flex;
    flex-direction: column;
    gap: 0.65rem;
    margin-bottom: 1.25rem;
}

.evcal-modal__details span {
    display: flex;
    align-items: flex-start;
    gap: 0.55rem;
    font-size: 0.88rem;
    color: #475569;
    line-height: 1.5;
}

.evcal-modal__details i {
    color: var(--evcal-blue, #1e3a8a);
    margin-top: 0.2rem;
    width: 1rem;
    text-align: center;
    flex-shrink: 0;
}

.evcal-modal__actions {
    display: flex;
    flex-wrap: wrap;
    gap: 0.65rem;
}

@media (max-width: 768px) {
    .evcal-nav__controls {
        flex-direction: column;
        align-items: stretch;
    }

    .evcal-view-toggle {
        justify-content: center;
        width: 100%;
    }
}

@media (max-width: 640px) {
    .evcal-day {
        min-height: 5.5rem;
    }

    .evcal-nav__label {
        display: none;
    }

    .evcal-nav__row {
        display: grid;
        grid-template-columns: auto 1fr auto;
        width: 100%;
    }

    .evcal-nav__center {
        text-align: center;
    }

    .evcal-legend--inline {
        justify-content: flex-start;
        gap: 0.55rem 1rem;
    }
}

@media print {
    .evcal-nav,
    .evcal-sidebar,
    .usl-events-calendar-page > .evt-hero {
        display: none !important;
    }

    .evcal-main {
        padding: 0;
        background: #fff;
    }

    .evcal-calendar {
        box-shadow: none;
        border: 1px solid #ccc;
    }
}
