﻿/* ── کانتینر اصلی ── */
.cal-wrapper {
    /* متغیرها به اینجا منتقل شدند تا همه باکس‌ها به آن‌ها دسترسی داشته باشند */
    --cal-accent: var(--success);
    --cal-accent-text: #ffffff;
    --cal-red: #dc2626;
    display: flex;
    flex-direction: column;
    gap: 20px;
    width: 100%;
    margin-top: 40px;
    margin-bottom: 20px;
    direction: rtl;
    max-width: 1000px;
}

/* رنگ‌های حالت شب برای کل مجموعه */
html.dark .cal-wrapper {
    --cal-accent: #9ae696;
    --cal-accent-text: #000000;
    --cal-red: #ff6b6b;
}

/* ── اختصاصی تقویم شمسی ── */
.cal-widget {
    background-color: var(--surface);
    border: 1px solid var(--border);
    border-radius: 20px;
    padding: 24px;
    position: relative;
    box-shadow: var(--shadow);
    font-family: 'iransansxv', sans-serif;
    transition: background-color 0.3s, border-color 0.3s, box-shadow 0.3s;
}

    .cal-widget * {
        box-sizing: border-box;
    }

.cal-binder-ring {
    position: absolute;
    top: -15px;
    width: 18px;
    height: 40px;
    background: linear-gradient(to right, #d1d5db, #f3f4f6, #d1d5db);
    border-radius: 10px;
    box-shadow: inset 0 2px 5px rgba(0,0,0,0.15), 0 4px 6px rgba(0,0,0,0.1);
    z-index: 10;
}

html.dark .cal-binder-ring {
    background: linear-gradient(to right, #444, #777, #444);
    box-shadow: inset 0 2px 5px rgba(0,0,0,0.8), 0 4px 6px rgba(0,0,0,0.4);
}

.cal-ring-left {
    left: 20%;
}

.cal-ring-right {
    right: 20%;
}

.cal-binder-hole {
    position: absolute;
    top: 20px;
    width: 18px;
    height: 8px;
    background: var(--surface-2);
    border-radius: 50%;
    z-index: 1;
    box-shadow: inset 0 2px 4px rgba(0,0,0,0.15);
}

html.dark .cal-binder-hole {
    background: #111;
    box-shadow: inset 0 2px 4px rgba(0,0,0,0.9);
}

.cal-hole-left {
    left: 20%;
}

.cal-hole-right {
    right: 20%;
}

.cal-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    margin-bottom: 24px;
    padding-top: 10px;
    position: relative;
    z-index: 30;
}

.cal-nav-btn {
    background: none;
    border: none;
    color: var(--text);
    font-family: inherit;
    font-size: 14px;
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 6px;
    opacity: 0.8;
    transition: opacity 0.2s, color 0.2s;
    padding: 0;
    outline: none;
}

    .cal-nav-btn:hover {
        opacity: 1;
        color: var(--cal-accent);
    }

    .cal-nav-btn svg {
        width: 18px;
        height: 18px;
        stroke: var(--cal-accent);
    }

.cal-title-container {
    text-align: center;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 6px;
    position: relative;
}

.cal-main-title {
    display: flex;
    align-items: center;
    gap: 12px;
    font-size: 20px;
    font-weight: 700;
    color: var(--cal-accent);
    user-select: none;
}

.cal-title-icon {
    width: 26px;
    height: 26px;
    border: 1px solid var(--cal-accent);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: background-color 0.2s;
    background-color: transparent;
    z-index: 50;
}

    .cal-title-icon:hover {
        background-color: var(--cal-accent);
    }

html.dark .cal-title-icon:hover {
    background-color: rgba(154, 230, 150, 0.15);
}

.cal-title-icon svg {
    width: 14px;
    height: 14px;
    stroke: var(--cal-accent);
    transition: stroke 0.2s;
    pointer-events: none;
}

.cal-title-icon:hover svg {
    stroke: var(--cal-accent-text);
}

html.dark .cal-title-icon:hover svg {
    stroke: var(--cal-accent);
}

.cal-dropdown {
    position: absolute;
    top: 40px;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 12px;
    padding: 8px;
    z-index: 100;
    box-shadow: var(--shadow-hover);
    display: none;
}

.cal-month-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 4px;
    width: 240px;
}

.cal-month-item {
    padding: 8px 4px;
    text-align: center;
    border-radius: 8px;
    cursor: pointer;
    font-size: 13px;
    color: var(--text);
    transition: background 0.2s;
}

    .cal-month-item:hover {
        background: var(--cal-accent);
        color: var(--cal-accent-text);
        font-weight: 700;
    }

.cal-year-wrap {
    display: flex;
    gap: 8px;
    padding: 4px;
}

.cal-year-input {
    width: 80px;
    background: var(--surface-2);
    border: 1px solid var(--border);
    color: var(--text);
    border-radius: 8px;
    padding: 8px;
    font-family: inherit;
    text-align: center;
    outline: none;
}

    .cal-year-input:focus {
        border-color: var(--cal-accent);
    }

.cal-year-btn {
    background: var(--cal-accent);
    color: var(--cal-accent-text);
    border: none;
    border-radius: 8px;
    cursor: pointer;
    font-family: inherit;
    font-weight: 700;
    padding: 0 14px;
}

.cal-subtitle {
    font-size: 13px;
    color: var(--text);
    opacity: 0.9;
    direction: ltr;
}

.cal-subtitle-hijri {
    font-size: 13px;
    color: var(--text-3);
}

.cal-card {
    background-color: var(--surface-2);
    border-radius: 16px;
    padding: 16px;
    position: relative;
    z-index: 10;
    min-height: 250px;
}

.dark .cal-card {
    background-color: var(--bg-primary)
}

.cal-grid {
    display: grid;
    grid-template-columns: repeat(7, 1fr);
    gap: 8px;
}

.cal-weekdays-row {
    display: contents;
}

.cal-weekday-cell {
    background-color: var(--cal-accent);
    color: var(--cal-accent-text);
    text-align: center;
    padding: 10px 0;
    font-weight: 700;
    font-size: 14px;
    border-radius: 8px;
    margin-bottom: 12px;
}

.cal-day-cell {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 10px 2px;
    border-radius: 10px;
    border: 2px solid transparent;
    min-height: 70px;
    position: relative;
}

.cal-day-main {
    font-size: 22px;
    font-weight: 700;
    color: var(--text);
    line-height: 1;
    margin-bottom: 8px;
}

.cal-day-subs {
    display: flex;
    justify-content: space-between;
    width: 100%;
    padding: 0 6px;
    font-size: 10px;
    color: var(--text-3);
    direction: ltr;
}

/* ── EVENT DOT UI ── */
.cal-event-indicator {
    position: absolute;
    bottom: 4px;
    width: 6px;
    height: 6px;
    border-radius: 50%;
    background-color: var(--cal-accent);
    display: none;
}

.cal-out-of-month {
    opacity: 0.3;
}

.cal-is-friday .cal-day-main, .cal-is-holiday .cal-day-main {
    color: var(--cal-red);
}

.cal-is-friday .cal-day-subs, .cal-is-holiday .cal-day-subs {
    color: var(--cal-red);
    opacity: 0.8;
}

.cal-is-today {
    border-color: var(--cal-accent);
}

.cal-btn-today {
    width: 100%;
    background-color: var(--cal-accent);
    color: var(--cal-accent-text);
    border: none;
    border-radius: 12px;
    padding: 14px;
    font-size: 15px;
    font-weight: 700;
    font-family: inherit;
    margin-top: 16px;
    cursor: pointer;
    transition: transform 0.1s, opacity 0.2s;
}

    .cal-btn-today:active {
        transform: scale(0.98);
    }

    .cal-btn-today:hover {
        opacity: 0.9;
    }

.cal-loading {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0,0,0,0.5);
    border-radius: 16px;
    display: none;
    align-items: center;
    justify-content: center;
    color: #fff;
    font-weight: bold;
    font-size: 14px;
    z-index: 20;
    backdrop-filter: blur(2px);
}

    .cal-loading.active {
        display: flex;
    }

/* ── باکس مناسبت‌ها ── */
.cal-events-box {
    background-color: var(--surface);
    border: 1px solid var(--border);
    border-radius: 20px;
    padding: 24px;
    box-shadow: var(--shadow);
    font-family: 'iransansxv', sans-serif;
    display: flex;
    flex-direction: column;
    height: 100%;
    max-height: 400px;
}

.cal-events-header {
    font-size: 18px;
    font-weight: 700;
    color: var(--cal-accent);
    margin-bottom: 16px;
    border-bottom: 1px solid var(--border);
    padding-bottom: 12px;
}

.cal-events-list {
    overflow-y: auto;
    flex: 1;
    padding-left: 5px;
}

    .cal-events-list::-webkit-scrollbar {
        width: 4px;
    }

    .cal-events-list::-webkit-scrollbar-thumb {
        background: var(--border);
        border-radius: 4px;
    }

.cal-event-item {
    display: flex;
    align-items: flex-start;
    gap: 12px;
    padding: 12px 0;
    border-bottom: 1px dashed var(--border);
    font-size: 14px;
    color: var(--text);
    line-height: 1.6;
}

    .cal-event-item:last-child {
        border-bottom: none;
    }

.cal-event-date {
    font-weight: 700;
    white-space: nowrap;
    color: var(--text-2);
    min-width: 65px;
}

.cal-event-title {
    flex: 1;
}

/* 🔴 رنگ قرمز برای مناسبت‌های تعطیل در لیست (حالا کار می‌کند!) */
.cal-event-item.cal-holiday-row .cal-event-date,
.cal-event-item.cal-holiday-row .cal-event-title {
    color: var(--cal-red) !important;
}

.cal-events-empty {
    text-align: center;
    color: var(--text-3);
    padding: 20px 0;
    font-size: 14px;
}

@media (max-width: 480px) {
    .cal-widget {
        padding: 16px 12px;
    }

    .cal-card {
        padding: 10px;
    }

    .cal-day-main {
        font-size: 18px;
    }

    .cal-day-subs {
        font-size: 9px;
        padding: 0 2px;
    }

    .cal-events-box {
        padding: 16px 12px;
        max-height: 350px;
    }

    /* ── فیکس کردن هدر تقویم در موبایل ── */
    .cal-header {
        align-items: center;
        margin-bottom: 16px;
    }

    /* مخفی کردن متن دکمه‌ها و نمایش فقط آیکون فلش */
    .cal-nav-btn span {
        display: none;
    }

    /* بزرگتر کردن ناحیه لمس دکمه‌ها */
    .cal-nav-btn {
        padding: 8px;
    }

        .cal-nav-btn svg {
            margin: 0 !important; /* حذف فاصله‌های اضافی */
            width: 22px;
            height: 22px;
        }

    /* متناسب‌سازی عنوان وسط تقویم */
    .cal-main-title {
        font-size: 16px;
        gap: 6px;
    }

    /* خنثی کردن عرض ثابت 140 پیکسلی برای جلوگیری از هل دادن عناصر */
    #calTitleFa {
        min-width: 100px !important;
        font-size: 14px;
    }

    .cal-title-icon {
        width: 22px;
        height: 22px;
    }

        .cal-title-icon svg {
            width: 12px;
            height: 12px;
        }
}

@media (min-width: 1024px) {
    .cal-wrapper {
        flex-direction: row;
        align-items: stretch;
        margin-top: 40px;
    }

    .cal-widget {
        flex: 0 0 60%;
        padding: 24px;
        margin: 0;
    }

    .cal-events-box {
        flex: 0 0 calc(40% - 20px);
        max-height: 520px;
    }

    .cal-main-title {
        font-size: 22px;
    }

    .cal-subtitle {
        font-size: 14px;
    }

    .cal-subtitle-hijri {
        font-size: 14px;
    }

    .cal-weekday-cell {
        font-size: 15px;
        padding: 10px 0;
        margin-bottom: 12px;
    }

    .cal-day-main {
        font-size: 24px;
        margin-bottom: 10px;
    }

    .cal-day-subs {
        font-size: 11px;
        padding: 0 6px;
    }



    .cal-day-cell {
        min-height: 80px;
    }

    .cal-nav-btn {
        font-size: 15px;
    }

        .cal-nav-btn svg {
            width: 18px;
            height: 18px;
        }

    .cal-btn-today {
        font-size: 16px;
        padding: 14px;
    }
}

.ennum {
    font-family: 'VazirmatnEn';
}
