/* ==========================================
   Jalali Calendar Styles (Modal Version)
   ========================================== */

/* The semi-transparent background overlay */
.calendar-modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    background-color: rgba(45, 52, 54, 0.6); /* Using theme colors */
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 1050; /* High z-index to be on top of everything */
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.3s ease, visibility 0.3s ease;
    backdrop-filter: blur(5px);
}

.calendar-modal-overlay.show {
    opacity: 1;
    visibility: visible;
}

/* The main content box of the modal */
.calendar-modal-content {
    background-color: var(--white);
    border-radius: 15px;
    box-shadow: var(--shadow-lg, 0 10px 40px rgba(0, 0, 0, 0.15));
    width: 95%;
    max-width: 980px; /* A bit wider for better spacing */
    padding: 2rem 2.5rem;
    transform: scale(0.95);
    transition: transform 0.3s ease;
    position: relative;
}

.calendar-modal-overlay.show .calendar-modal-content {
    transform: scale(1);
}

/* Modal Header */
.modal-calendar-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding-bottom: 1.5rem;
    margin-bottom: 1rem;
    border-bottom: 1px solid #e0e0e0;
}

.modal-calendar-header h5 {
    font-weight: 700;
    font-size: 1.3rem;
    color: var(--text-dark);
    margin: 0;
}

.close-modal-btn {
    background: none;
    border: none;
    font-size: 2rem;
    color: var(--text-gray);
    cursor: pointer;
    line-height: 1;
    padding: 0 0.5rem;
    transition: color 0.2s ease;
}

.close-modal-btn:hover {
    color: var(--text-dark);
}


.calendars-wrapper {
    display: flex;
    gap: 20px;
}

/* --- (بقیه استایل‌های تقویم از کد قبلی بدون تغییر باقی می‌ماند) --- */

/* Individual Calendar Styles */
.calendar {
    width: 50%;
    display: flex;
    flex-direction: column;
}

.month-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 16px;
    font-weight: 600;
    font-size: 1.1rem;
    color: var(--text-dark);
}

.month-header button {
    background: none;
    border: 1px solid #e0e0e0;
    border-radius: 50%;
    width: 36px;
    height: 36px;
    cursor: pointer;
    font-size: 18px;
    color: var(--text-gray);
    display: flex;
    justify-content: center;
    align-items: center;
    transition: var(--transition);
}

.month-header button:hover {
    background-color: #f8f9fa;
    color: var(--primary-color);
}

.days-of-week, .days-grid {
    display: grid;
    grid-template-columns: repeat(7, 1fr);
    text-align: center;
    gap: 8px;
    margin-top: 10px;
    justify-items: stretch;
    align-items: stretch;
}

.days-of-week div {
    padding: 8px 0;
    font-weight: 500;
    color: var(--text-gray);
    font-size: 0.9rem;
}

.day {
    width: 100%;
    height: 100%; /* به جای height ثابت */
    min-height: 80px; /* حداقل ارتفاع برای راحتی */
    box-sizing: border-box;

    padding: 8px 6px; /* padding بیشتر برای فضای بهتر */
    border-radius: 8px;
    border: 1px solid #e2e8f0;
    background-color: #fff;
    transition: all 0.2s ease;

    display: flex;
    flex-direction: column;
}

.day.no-price {
    justify-content: center;
    align-items: center;
}

.day.has-price {
    justify-content: space-between;
    align-items: center;
    padding: 8px 6px; /* فضای بیشتر برای قیمت */
}

.day.empty {
    border: none !important;
    background: transparent !important;
    box-shadow: none !important;
    pointer-events: none;
    visibility: hidden;
}

.day.available {
    cursor: pointer;
}

.day.available:hover {
    background-color: rgba(39, 104, 106, 0.05);
    border-color: var(--primary-color);
    transform: translateY(-2px);
    box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.1);
}

.day .day-number {
    font-size: 1rem; /* اندکی کوچک‌تر برای فضای بهتر */
    font-weight: 600;
    color: var(--text-dark);
    line-height: 1.2;
    flex-shrink: 0; /* جلوگیری از فشرده شدن */
}

.day .day-price {
    font-size: 0.7rem; /* اندکی کوچک‌تر */
    color: var(--text-gray);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    width: 100%;
    text-align: center;
    flex-shrink: 0; /* جلوگیری از فشرده شدن */
    margin-top: 4px; /* فاصله از عدد */
}

.day.unavailable {
    color: #b0b0b0;
    text-decoration: line-through;
    pointer-events: none;
    background-color: #f8f9fa;
    background-image: repeating-linear-gradient(
            45deg,
            #e9ecef,
            #e9ecef 5px,
            #f8f9fa 5px,
            #f8f9fa 10px
    );
}

.day.unavailable .day-number {
    color: #a0a0a0;
}

.day.unavailable .day-number {
    color: #a0a0a0;
}

/* Selection Styles */
.day.selected {
    background-color: var(--primary-color);
    color: var(--white) !important;
}

.day.selected .day-number, .day.selected .day-price {
    color: var(--white);
}

.day.in-range {
    background-color: rgba(39, 104, 106, 0.1);
    border-radius: 0;
}

.day.start-date {
    background-color: var(--primary-color);
    color: var(--white);
    border-radius: 0 8px 8px 0;
}

.day.start-date .day-number, .day.start-date .day-price {
    color: var(--white);
}

.day.end-date {
    background-color: var(--primary-color);
    color: var(--white);
    border-radius: 8px 0 0 8px;
}

.day.end-date .day-number, .day.end-date .day-price {
    color: var(--white);
}


/* Holiday Styling */
.day.is-holiday .day-number {
    color: #dc3545; /* Red color specifically for holidays */
    font-weight: 700;
}

/* Optional: Make the 'Jomeh' header red as well */
.days-of-week div.is-holiday {
    color: #dc3545;
}

/* Ensure selected state overrides holiday color (so user knows they selected it) */
.day.selected.is-holiday .day-number {
    color: var(--white) !important;
}


/* ==========================================
   Responsive Styles for Jalali Calendar
   ========================================== */

/* این استایل‌ها فقط برای صفحاتی با عرض کمتر از 800 پیکسل اعمال می‌شود */
@media (max-width: 800px) {

    /* 1. تغییر چیدمان اصلی تقویم‌ها از افقی به عمودی */
    .calendars-wrapper {
        flex-direction: column; /* تقویم‌ها زیر هم قرار می‌گیرند */
        gap: 30px; /* فاصله عمودی بین دو تقویم */
    }

    /* 2. هر تقویم باید عرض کامل را اشغال کند */
    .calendar {
        width: 100%; /* به جای 50%، عرض کامل می‌گیرد */
    }

    /* 3. کاهش پدینگ داخلی مودال برای استفاده بهینه از فضا */
    .calendar-modal-content {
        padding: 1.5rem 1rem; /* پدینگ افقی کمتر می‌شود */
        max-height: 90vh; /* حداکثر ارتفاع برای جلوگیری از خروج از صفحه */
        overflow-y: auto; /* اگر محتوا زیاد بود، اسکرول داخلی فعال شود */
    }

    /* 4. تنظیم اندازه روزها برای نمایش بهتر در موبایل */
    .day {
        min-height: 50px; /* کاهش حداقل ارتفاع روزها */
        padding: 6px 4px; /* پدینگ داخلی روزها کمی کمتر شود */
    }

    /* یک راه حل مدرن‌تر و بهتر برای مربع نگه داشتن روزها استفاده از aspect-ratio است */
    /* اگر می‌خواهید روزها همیشه مربع باشند، به جای min-height بالا، از کد زیر استفاده کنید */
    /*
    .day {
        aspect-ratio: 1 / 1;
        height: auto;
        padding: 6px 4px;
    }
    */

    /* 5. کاهش اندازه فونت‌ها برای خوانایی بهتر */
    .day .day-number {
        font-size: 0.9rem;
    }

    .day .day-price {
        font-size: 0.65rem;
    }

    .modal-calendar-header h5 {
        font-size: 1.1rem; /* کوچک کردن عنوان مودال */
    }
}

/* استایل‌های اضافی برای صفحات خیلی کوچک (کمتر از 400 پیکسل) */
@media (max-width: 400px) {
    .days-of-week, .days-grid {
        gap: 4px; /* کاهش فاصله بین خانه‌های روزها */
    }
    .day {
        padding: 4px 2px;
    }
    .day .day-number {
        font-size: 0.8rem;
    }
    .day .day-price {
        font-size: 0.6rem;
    }
}
