/* ==========================================================================
   PSA Terminal Closures Calendar – calendar.css
   PSA brand colours: Red #E30613 · Navy #0A1F3D · Light grey #F5F5F5
   ========================================================================== */

/* ---- Reset / Base ---- */
.psa-cal-wrap *,
.psa-cal-wrap *::before,
.psa-cal-wrap *::after {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

.psa-cal-wrap {
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Oxygen, sans-serif;
    font-size: 14px;
    color: #222;
    max-width: 900px;
    margin: 0 auto 2rem;
}

/* ---- Legend ---- */
.psa-cal-legend {
    display: flex;
    flex-wrap: wrap;
    gap: 10px 16px;
    padding: 12px 16px;
    background: #ffffff;
    border: 1px solid #ddd;
    border-top: none;
    border-bottom: none;
}

.psa-cal-legend span.psa-legend-item {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    font-size: 13px;
    font-weight: 700;
    padding: 5px 16px 5px 10px;
    border-radius: 4px;
    color: #000000;
    background: #eeeeee;
}

.psa-cal-legend span.psa-legend-item.psa-status-open     { background: #c8e6c9; color: #000000; }
.psa-cal-legend span.psa-legend-item.psa-status-closed   { background: #ffcdd2; color: #000000; }
.psa-cal-legend span.psa-legend-item.psa-status-modified { background: #fff3cd; color: #000000; }
.psa-cal-legend span.psa-legend-item.psa-status-weather  { background: #bbdefb; color: #000000; }

.psa-legend-icon {
    font-size: 16px;
    line-height: 1;
}

/* ---- Navigation ---- */
.psa-cal-nav {
    display: flex;
    align-items: center;
    justify-content: space-between;
    background: #0A1F3D;
    border: 1px solid #0A1F3D;
    border-radius: 6px 6px 0 0;
    padding: 12px 16px;
}

.psa-cal-month-title {
    font-size: 18px;
    font-weight: 700;
    color: #ffffff;
    text-align: center;
    flex: 1;
}

.psa-cal-nav-btn {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 8px 16px;
    background: #ffffff;
    color: #0A1F3D;
    text-decoration: none;
    border-radius: 4px;
    font-size: 13px;
    font-weight: 700;
    transition: background 0.2s;
    white-space: nowrap;
}

.psa-cal-nav-btn:hover,
.psa-cal-nav-btn:focus {
    background: #E30613;
    color: #fff;
    outline: none;
}

/* ---- Month/Year Picker ---- */
.psa-cal-picker-form {
    display: flex;
    align-items: center;
    gap: 8px;
    flex: 1;
    justify-content: center;
}

.psa-picker-select {
    padding: 7px 10px;
    border: 2px solid #ffffff;
    border-radius: 4px;
    font-size: 14px;
    font-weight: 600;
    color: #0A1F3D;
    background: #fff;
    cursor: pointer;
    appearance: auto;
}

.psa-picker-select:focus {
    outline: 2px solid #E30613;
    outline-offset: 1px;
}

.psa-picker-go-btn {
    padding: 7px 16px;
    background: #E30613;
    color: #fff;
    border: none;
    border-radius: 4px;
    font-size: 14px;
    font-weight: 700;
    cursor: pointer;
    transition: background 0.2s;
}

.psa-picker-go-btn:hover,
.psa-picker-go-btn:focus {
    background: #b80010;
    outline: none;
}

@media (max-width: 640px) {
    .psa-cal-picker-form { gap: 5px; }
    .psa-picker-select   { font-size: 12px; padding: 5px 6px; }
    .psa-picker-go-btn   { font-size: 12px; padding: 5px 10px; }
}

/* ---- Grid ---- */
.psa-cal-grid {
    display: grid;
    grid-template-columns: repeat(7, 1fr);
    border-left: 1px solid #ddd;
    border-top: 1px solid #ddd;
}

/* Header cells (day names) */
.psa-cal-header-cell {
    background: #0A1F3D;
    color: #fff;
    text-align: center;
    font-size: 12px;
    font-weight: 700;
    letter-spacing: .5px;
    text-transform: uppercase;
    padding: 8px 4px;
    border-right: 1px solid #143060;
    border-bottom: 1px solid #143060;
}

/* Generic cell */
.psa-cal-cell {
    position: relative;
    min-height: 90px;
    padding: 6px 8px 8px;
    border-right: 1px solid #ddd;
    border-bottom: 1px solid #ddd;
    vertical-align: top;
    transition: filter 0.15s;
    background: #F5F5F5;
}

.psa-cal-empty {
    background: #eaeaea;
}

/* Clickable cells */
.psa-cal-cell[role="button"] {
    cursor: pointer;
}

.psa-cal-cell[role="button"]:hover,
.psa-cal-cell[role="button"]:focus {
    filter: brightness(0.93);
    outline: 2px solid #0A1F3D;
    outline-offset: -2px;
    z-index: 1;
}

/* ---- Status backgrounds ---- */
.psa-status-open     { background: #e8f5e9; }
.psa-status-closed   { background: #fde8e8; }
.psa-status-modified { background: #fff8e1; }
.psa-status-weather  { background: #e3f2fd; }

/* Today highlight */
.psa-today {
    outline: 3px solid #0A1F3D;
    outline-offset: -3px;
    z-index: 1;
}

.psa-today .psa-day-number {
    background: #0A1F3D;
    color: #fff;
    border-radius: 50%;
    width: 24px;
    height: 24px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
}

/* Day number & icon */
.psa-day-number {
    font-size: 13px;
    font-weight: 700;
    color: #0A1F3D;
    line-height: 1;
}

.psa-day-icon {
    position: absolute;
    top: 6px;
    right: 8px;
    font-size: 18px;
    line-height: 1;
    opacity: 0.75;
}

/* ---- Event chips ---- */
.psa-day-events {
    margin-top: 6px;
    display: flex;
    flex-direction: column;
    gap: 3px;
}

.psa-event-chip {
    display: flex;
    align-items: flex-start;
    gap: 4px;
    font-size: 11px;
    font-weight: 600;
    line-height: 1.3;
    border-radius: 3px;
    padding: 2px 5px;
    word-break: break-word;
}

.psa-event-chip.psa-status-open     { background: #c8e6c9; color: #1b5e20; }
.psa-event-chip.psa-status-closed   { background: #ffcdd2; color: #b71c1c; }
.psa-event-chip.psa-status-modified { background: #fff3cd; color: #6d4c00; }
.psa-event-chip.psa-status-weather  { background: #bbdefb; color: #0d47a1; }

/* ---- Modal ---- */
.psa-modal-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.55);
    z-index: 99999;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 20px;
}

.psa-modal-overlay[hidden] {
    display: none;
}

.psa-modal {
    position: relative;
    background: #fff;
    border-radius: 8px;
    max-width: 480px;
    width: 100%;
    max-height: 90vh;
    overflow-y: auto;
    padding: 28px 28px 24px;
    box-shadow: 0 8px 40px rgba(0,0,0,0.28);
    animation: psaModalIn 0.18s ease;
}

@keyframes psaModalIn {
    from { transform: translateY(20px); opacity: 0; }
    to   { transform: translateY(0);    opacity: 1; }
}

.psa-modal-close {
    position: absolute;
    top: 14px;
    right: 16px;
    background: none;
    border: none;
    font-size: 24px;
    line-height: 1;
    color: #555;
    cursor: pointer;
    padding: 2px 6px;
    border-radius: 4px;
    transition: background 0.15s, color 0.15s;
}

.psa-modal-close:hover,
.psa-modal-close:focus {
    background: #E30613;
    color: #fff;
    outline: none;
}

/* Modal body content */
#psa-modal-body .psa-modal-header {
    display: flex;
    align-items: center;
    gap: 10px;
    padding-bottom: 14px;
    border-bottom: 2px solid #0A1F3D;
    margin-bottom: 16px;
}

#psa-modal-body .psa-modal-icon {
    font-size: 32px;
    line-height: 1;
}

#psa-modal-body h3 {
    font-size: 17px;
    font-weight: 700;
    color: #0A1F3D;
    margin: 0;
}

#psa-modal-body .psa-modal-date {
    font-size: 13px;
    color: #666;
    margin-top: 2px;
}

#psa-modal-body .psa-modal-badge {
    display: inline-block;
    font-size: 12px;
    font-weight: 700;
    padding: 3px 10px;
    border-radius: 20px;
    margin-bottom: 14px;
}

#psa-modal-body .badge-open     { background: #c8e6c9; color: #1b5e20; }
#psa-modal-body .badge-closed   { background: #ffcdd2; color: #b71c1c; }
#psa-modal-body .badge-modified { background: #fff3cd; color: #6d4c00; }
#psa-modal-body .badge-weather  { background: #bbdefb; color: #0d47a1; }

#psa-modal-body .psa-modal-desc {
    font-size: 14px;
    color: #333;
    line-height: 1.65;
    white-space: pre-wrap;
}

#psa-modal-body .psa-modal-no-desc {
    font-size: 13px;
    color: #888;
    font-style: italic;
}

/* Multiple events in modal */
#psa-modal-body .psa-modal-event + .psa-modal-event {
    border-top: 1px solid #e0e0e0;
    margin-top: 16px;
    padding-top: 16px;
}

/* ---- Responsive ---- */
@media (max-width: 640px) {
    .psa-cal-cell {
        min-height: 60px;
        padding: 4px 5px 5px;
    }

    .psa-day-icon {
        font-size: 14px;
        top: 4px;
        right: 4px;
    }

    .psa-day-number {
        font-size: 11px;
    }

    .psa-event-chip {
        font-size: 9px;
        padding: 1px 3px;
    }

    .psa-cal-month-title {
        font-size: 15px;
    }

    .psa-cal-nav-btn {
        padding: 6px 10px;
        font-size: 12px;
    }

    .psa-cal-header-cell {
        font-size: 10px;
        padding: 6px 2px;
    }

    .psa-modal {
        padding: 20px 16px 18px;
    }
}

@media (max-width: 400px) {
    .psa-cal-cell {
        min-height: 48px;
        padding: 3px 3px 4px;
    }

    .psa-day-events {
        display: none;
    }
}
