/* CalendarPopup — стили для SPA (journal) */
/* Источник: app/views/project/partials/calendar-popup.php */

/* ===== OVERLAY ===== */
.calendar-popup-modal {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    height: 100dvh;
    z-index: 10004;
    display: flex;
    align-items: center;
    justify-content: center;
    pointer-events: none;
    padding: env(safe-area-inset-top) env(safe-area-inset-right) env(safe-area-inset-bottom) env(safe-area-inset-left);
}

.calendar-popup-modal.active {
    pointer-events: auto;
}

.calendar-popup-overlay {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0,0,0,0.5);
    opacity: 0;
    transition: opacity 0.25s ease;
}

.calendar-popup-modal.active .calendar-popup-overlay {
    opacity: 1;
}

.calendar-popup-content {
    position: relative;
    z-index: 1;
    background: #fff;
    border-radius: 20px;
    width: 90%;
    max-width: 380px;
    max-height: 85vh;
    max-height: 85dvh;
    overflow: hidden;
    display: flex;
    flex-direction: column;
    opacity: 0;
    transform: scale(0.92);
    transition: opacity 0.25s ease, transform 0.25s ease;
    box-shadow: 0 20px 60px rgba(0,0,0,0.3);
}

.calendar-popup-modal.active .calendar-popup-content {
    opacity: 1;
    transform: scale(1);
}

/* ===== HEADER ===== */
.calendar-popup-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 16px 20px;
    border-bottom: 1px solid #f0f0f0;
    flex-shrink: 0;
}

.calendar-popup-header h3 {
    font-size: 16px;
    font-weight: 600;
    color: #1a1a1a;
    margin: 0;
    flex: 1;
    text-align: center;
}

.calendar-nav-btn,
.calendar-popup-close {
    background: none;
    border: none;
    width: 32px;
    height: 32px;
    border-radius: 8px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    color: #666;
    flex-shrink: 0;
    transition: background 0.15s;
}

.calendar-nav-btn:hover,
.calendar-popup-close:hover {
    background: #f5f5f5;
}

.calendar-nav-btn svg,
.calendar-popup-close svg {
    width: 20px;
    height: 20px;
}

/* ===== BODY ===== */
.calendar-popup-body {
    flex: 1;
    padding: 0 20px 20px;
    overflow-y: auto;
    max-height: 450px;
    -webkit-overflow-scrolling: touch;
    scroll-behavior: smooth;
}

.calendar-weekdays {
    display: grid;
    grid-template-columns: repeat(7, 1fr);
    text-align: center;
    margin-bottom: 12px;
    position: sticky;
    top: 0;
    background: #fff;
    z-index: 10;
    padding: 20px 0 8px;
}

.calendar-weekdays span {
    font-size: 13px;
    font-weight: 500;
    color: #888;
}

.calendar-weekdays span:nth-child(6),
.calendar-weekdays span:nth-child(7) {
    color: #dd1847;
}

/* ===== ДНИ ===== */
.calendar-days {
    display: flex;
    flex-direction: column;
}

.calendar-month-header {
    font-size: 14px;
    font-weight: 600;
    color: #1a1a1a;
    padding: 16px 0 8px;
    margin: 0;
    text-align: center;
    position: sticky;
    top: 48px;
    background: #fff;
    z-index: 5;
}

.calendar-month-header:first-of-type {
    padding-top: 0;
}

.calendar-month-grid {
    display: grid;
    grid-template-columns: repeat(7, 1fr);
    gap: 4px;
    margin-bottom: 8px;
}

.calendar-day {
    aspect-ratio: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 14px;
    font-weight: 500;
    border-radius: 50%;
    cursor: pointer;
    transition: background 0.15s, color 0.15s;
    user-select: none;
}

.calendar-day:hover {
    background: #f5f5f5;
}

.calendar-day.empty {
    cursor: default;
}

.calendar-day.empty:hover {
    background: transparent;
}

.calendar-day.today {
    background: #fdf2f5;
    color: #dd1847;
    font-weight: 600;
}

.calendar-day.selected {
    background: #dd1847;
    color: #fff;
}

.calendar-day.weekend {
    color: #dd1847;
}

.calendar-day.selected.weekend {
    color: #fff;
}

.calendar-day.unavailable {
    color: #ccc;
    cursor: default;
    pointer-events: none;
}

/* ===== АДАПТИВ ===== */
@media (max-width: 400px) {
    .calendar-popup-content {
        width: 95%;
        border-radius: 16px;
    }
    
    .calendar-day {
        font-size: 13px;
    }
}

@media (prefers-reduced-motion: reduce) {
    .calendar-popup-overlay,
    .calendar-popup-content {
        transition: none;
    }
}