/* ===========================================================
   Persian Calendar — modern, responsive, vanilla JS
   Matches the SI design system (Indigo #6366F1 + Slate #1E293B)
   =========================================================== */

.pc-calendar {
    position: absolute;
    z-index: 100;
    background: #fff;
    border: 1px solid #E2E8F0;
    border-radius: 14px;
    box-shadow: 0 20px 50px -12px rgba(15, 23, 42, 0.22), 0 4px 12px -2px rgba(15, 23, 42, 0.08);
    padding: 14px;
    width: 320px;
    max-width: calc(100vw - 32px);
    font-family: 'Vazirmatn', system-ui, sans-serif;
    direction: rtl;
    /* Hidden by default */
    opacity: 0;
    transform: translateY(-8px) scale(0.98);
    transform-origin: top right;
    pointer-events: none;
    transition: opacity 180ms cubic-bezier(0.2, 0.8, 0.2, 1), transform 180ms cubic-bezier(0.2, 0.8, 0.2, 1);
}
.pc-calendar.is-open {
    opacity: 1;
    transform: translateY(0) scale(1);
    pointer-events: auto;
}
.pc-calendar.is-flipped {
    transform-origin: bottom right;
    transform: translateY(8px) scale(0.98);
}
.pc-calendar.is-flipped.is-open {
    transform: translateY(0) scale(1);
}

/* === Header: prev / month-year / next === */
.pc-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 12px;
    gap: 4px;
}
.pc-nav-btn {
    width: 32px; height: 32px;
    border-radius: 8px;
    border: 1px solid #E2E8F0;
    background: #fff;
    color: #1E293B;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-size: 18px;
    font-weight: 700;
    line-height: 1;
    transition: background-color 120ms ease, color 120ms ease, border-color 120ms ease;
    padding: 0;
}
.pc-nav-btn:hover {
    background: #EEF2FF;
    color: #6366F1;
    border-color: #C7D2FE;
}
.pc-nav-btn:active { transform: scale(0.94); }
.pc-nav-btn:disabled {
    opacity: 0.35;
    cursor: not-allowed;
    background: #F8FAFC;
}
.pc-nav-btn:disabled:hover {
    background: #F8FAFC;
    color: #1E293B;
    border-color: #E2E8F0;
}
.pc-title {
    flex: 1;
    text-align: center;
    font-size: 14px;
    font-weight: 700;
    color: #1E293B;
    letter-spacing: -0.01em;
}

/* === Weekday row === */
.pc-weekdays {
    display: grid;
    grid-template-columns: repeat(7, 1fr);
    gap: 2px;
    margin-bottom: 6px;
}
.pc-weekday {
    text-align: center;
    font-size: 11px;
    font-weight: 700;
    color: #94A3B8;
    padding: 6px 0;
    line-height: 1;
}

/* === Day grid === */
.pc-days {
    display: grid;
    grid-template-columns: repeat(7, 1fr);
    gap: 2px;
}
.pc-day {
    aspect-ratio: 1 / 1;
    min-height: 36px;
    min-width: 36px;
    border: none;
    background: transparent;
    border-radius: 8px;
    font-size: 13px;
    font-weight: 600;
    color: #1E293B;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    line-height: 1;
    transition: background-color 120ms ease, color 120ms ease, transform 100ms ease;
    padding: 0;
    font-family: inherit;
}
@media (min-width: 480px) {
    .pc-day { min-height: 40px; min-width: 40px; font-size: 14px; }
}
.pc-day:hover:not(:disabled):not(.pc-day-other) {
    background: #EEF2FF;
    color: #6366F1;
}
.pc-day:active:not(:disabled) { transform: scale(0.92); }
.pc-day-other {
    color: #CBD5E1;
    cursor: default;
}
.pc-day-other:hover { background: transparent; color: #CBD5E1; }
.pc-day-today {
    background: #F1F5F9;
    color: #4F46E5;
    font-weight: 800;
    box-shadow: inset 0 0 0 1.5px #C7D2FE;
}
.pc-day-today:hover:not(.pc-day-selected) {
    background: #EEF2FF;
    color: #4F46E5;
}
.pc-day-selected {
    background: #6366F1 !important;
    color: #fff !important;
    font-weight: 800;
    box-shadow: 0 4px 10px -2px rgba(99, 102, 241, 0.5);
}
.pc-day-selected:hover {
    background: #4F46E5 !important;
    color: #fff !important;
}
.pc-day-in-range {
    background: #EEF2FF;
    color: #4F46E5;
    border-radius: 0;
}
.pc-day-range-edge {
    background: #6366F1;
    color: #fff;
    font-weight: 800;
}
.pc-day:disabled,
.pc-day-disabled {
    color: #E2E8F0;
    cursor: not-allowed;
    text-decoration: line-through;
    text-decoration-color: #F1F5F9;
}
.pc-day:disabled:hover,
.pc-day-disabled:hover {
    background: transparent;
    color: #E2E8F0;
}

/* === Footer === */
.pc-footer {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-top: 10px;
    padding-top: 10px;
    border-top: 1px solid #F1F5F9;
    gap: 6px;
}
.pc-today-btn {
    background: #F1F5F9;
    color: #4F46E5;
    border: none;
    border-radius: 8px;
    padding: 6px 12px;
    font-size: 12px;
    font-weight: 600;
    cursor: pointer;
    font-family: inherit;
    transition: background-color 120ms ease;
}
.pc-today-btn:hover { background: #E0E7FF; }
.pc-today-btn:active { transform: scale(0.96); }
.pc-clear-btn {
    background: transparent;
    color: #94A3B8;
    border: none;
    border-radius: 8px;
    padding: 6px 12px;
    font-size: 12px;
    font-weight: 600;
    cursor: pointer;
    font-family: inherit;
    transition: color 120ms ease, background-color 120ms ease;
}
.pc-clear-btn:hover { color: #EF4444; background: #FEE2E2; }

/* === Mobile adjustments === */
@media (max-width: 480px) {
    .pc-calendar {
        padding: 12px;
        width: calc(100vw - 32px);
        max-width: 360px;
    }
    .pc-day { min-height: 36px; min-width: 36px; font-size: 13px; }
    .pc-weekday { font-size: 10px; padding: 4px 0; }
    .pc-title { font-size: 13px; }
    .pc-nav-btn { width: 30px; height: 30px; font-size: 16px; }
}

/* === Reduced motion === */
@media (prefers-reduced-motion: reduce) {
    .pc-calendar,
    .pc-calendar.is-flipped,
    .pc-day,
    .pc-nav-btn,
    .pc-today-btn,
    .pc-clear-btn {
        transition: opacity 100ms ease !important;
        transform: none !important;
    }
}

/* === Overlay (closes calendar on outside tap, mobile) === */
.pc-overlay {
    position: fixed;
    inset: 0;
    z-index: 99;
    background: transparent;
    pointer-events: auto;
}
