/* ============================================================
   XD Calendar Month View Module
   ============================================================ */

.xd-cmv-wrap {
    box-sizing: border-box;
    width: 100%;
    max-width: 1200px;
    margin: 0 auto;
    padding: 0 24px 40px;
    font-family: inherit;
    color: var(--xd-cmv-text, #3a3348);
}

.xd-cmv-wrap *,
.xd-cmv-wrap *::before,
.xd-cmv-wrap *::after {
    box-sizing: inherit;
}

/* ---- Navigation header ---- */
.xd-cmv-nav {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-bottom: 28px;
}

.xd-cmv-nav__arrow {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: auto;
    height: auto;
    background: transparent !important;
    border: none !important;
    box-shadow: none !important;
    cursor: pointer;
    color: var(--xd-cmv-accent, #592B8A);
    font-size: 36px;
    line-height: 1;
    padding: 4px;
    transition: transform 0.3s ease;
    border-radius: 0 !important;
}

.xd-cmv-nav__arrow:hover,
.xd-cmv-nav__arrow:focus,
.xd-cmv-nav__arrow:active {
    background: transparent !important;
    border: none !important;
    box-shadow: none !important;
    color: var(--xd-cmv-accent, #592B8A) !important;
    transform: scale(1.2);
}

.xd-cmv-nav__arrow .fa-solid {
    font-size: 36px;
    color: inherit;
}

.xd-cmv-nav__this-month {
    display: inline-flex;
    align-items: center;
    height: 38px;
    padding: 0 18px;
    background: transparent !important;
    border: 1.5px solid var(--xd-cmv-text, #3a3348) !important;
    border-radius: 6px !important;
    cursor: pointer;
    font-size: 14px;
    font-weight: 600;
    color: var(--xd-cmv-text, #3a3348) !important;
    font-family: inherit;
    white-space: nowrap;
    box-shadow: none !important;
    transition: background 0.15s;
}

.xd-cmv-nav__this-month:hover {
    background: rgba(0,0,0,0.05) !important;
}

.xd-cmv-nav__month-label {
    font-size: 32px;
    font-weight: 700;
    color: var(--xd-cmv-text, #3a3348);
    line-height: 1;
}

.xd-cmv-nav__caret {
    font-size: 20px;
    color: var(--xd-cmv-accent, #592B8A);
    display: flex;
    align-items: center;
    transition: transform 0.2s ease;
}

/* ---- Month picker trigger (formerly a div, now a button) ---- */
.xd-cmv-nav__month-wrap {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    margin-left: 4px;
    background: transparent !important;
    border: none !important;
    box-shadow: none !important;
    padding: 0;
    cursor: pointer;
    font-family: inherit;
}

.xd-cmv-nav__month-wrap:hover .xd-cmv-nav__month-label,
.xd-cmv-nav__month-wrap:focus .xd-cmv-nav__month-label {
    color: var(--xd-cmv-accent, #592B8A);
}

.xd-cmv-nav__month-wrap[aria-expanded="true"] .xd-cmv-nav__caret {
    transform: rotate(180deg);
}

/* ---- Month picker popup ---- */
.xd-cmv-nav__picker-wrap {
    position: relative;
}

.xd-cmv-month-picker {
    position: absolute;
    top: calc(100% + 8px);
    left: 0;
    z-index: 300;
    background: #fff;
    border: 1px solid #ddd;
    border-radius: 8px;
    box-shadow: 0 8px 32px rgba(0,0,0,0.14);
    padding: 16px;
    min-width: 240px;
}

.xd-cmv-month-picker[hidden] {
    display: none;
}

.xd-cmv-month-picker__header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 14px;
}

.xd-cmv-month-picker__year {
    font-size: 15px;
    font-weight: 700;
    color: var(--xd-cmv-text, #3a3348);
}

.xd-cmv-month-picker__year-nav {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 30px;
    height: 30px;
    background: transparent !important;
    border: none !important;
    border-radius: 50% !important;
    cursor: pointer;
    font-size: 16px;
    color: var(--xd-cmv-text, #3a3348);
    padding: 0;
    box-shadow: none !important;
    transition: background 0.15s;
}

.xd-cmv-month-picker__year-nav:hover {
    background: rgba(0,0,0,0.07) !important;
}

.xd-cmv-month-picker__grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 4px;
}

.xd-cmv-month-picker__month {
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 8px 4px;
    background: transparent !important;
    border: none !important;
    border-radius: 6px !important;
    cursor: pointer;
    font-size: 13px;
    font-weight: 600;
    color: var(--xd-cmv-text, #3a3348);
    font-family: inherit;
    box-shadow: none !important;
    transition: background 0.15s, color 0.15s;
}

.xd-cmv-month-picker__month:hover {
    background: rgba(89,43,138,0.1) !important;
    color: var(--xd-cmv-accent, #592B8A);
}

.xd-cmv-month-picker__month.is-current {
    background: var(--xd-cmv-accent, #592B8A) !important;
    color: #fff !important;
}

/* ---- Grid ---- */
.xd-cmv-grid {
    width: 100%;
    border: 1px solid rgba(0,0,0,0.12);
    border-radius: 4px;
    overflow: hidden;
}

.xd-cmv-grid__headers {
    display: grid;
    grid-template-columns: repeat(7, 1fr);
    border-bottom: 1px solid rgba(0,0,0,0.12);
}

.xd-cmv-grid__header-cell {
    padding: 10px 0;
    text-align: center;
    font-size: 13px;
    font-weight: 700;
    color: var(--xd-cmv-text, #3a3348);
    text-transform: uppercase;
    letter-spacing: 0.05em;
    border-right: 1px solid rgba(0,0,0,0.08);
}

.xd-cmv-grid__header-cell:last-child {
    border-right: none;
}

.xd-cmv-grid__body {
    display: grid;
    grid-template-columns: repeat(7, 1fr);
}

/* ---- Day cells ---- */
.xd-cmv-grid__cell {
    min-height: 130px;
    padding: 10px 12px 8px;
    background: var(--xd-cmv-cell-bg, #eceaf4);
    border-right: 1px solid rgba(0,0,0,0.1);
    border-bottom: 1px solid rgba(0,0,0,0.1);
    vertical-align: top;
    cursor: pointer;
    transition: background 0.15s;
    position: relative;
}

.xd-cmv-grid__cell:nth-child(7n) {
    border-right: none;
}

.xd-cmv-grid__cell--other {
    background: var(--xd-cmv-other-bg, #e0dded);
    cursor: default;
}

.xd-cmv-grid__cell--today .xd-cmv-grid__day-num {
    color: var(--xd-cmv-accent, #592B8A);
    font-weight: 900;
}

.xd-cmv-grid__day-num {
    display: block;
    font-size: 18px;
    font-weight: 700;
    color: var(--xd-cmv-text, #3a3348);
    line-height: 1;
    margin-bottom: 6px;
}

.xd-cmv-grid__cell--other .xd-cmv-grid__day-num {
    opacity: 0.45;
}

/* ---- Desktop events inside cell ---- */
.xd-cmv-grid__events {
    display: flex;
    flex-direction: column;
    gap: 3px;
}

.xd-cmv-grid__event {
    display: block;
    text-decoration: none;
    color: var(--xd-cmv-text, #3a3348);
    font-size: 12px;
    line-height: 1.3;
}

.xd-cmv-grid__event:hover {
    color: var(--xd-cmv-accent, #592B8A);
}

.xd-cmv-grid__event-time {
    display: block;
    font-weight: 500;
    color: #666;
    margin-bottom: 1px;
}

.xd-cmv-grid__event-title {
    display: block;
    font-weight: 600;
}

.xd-cmv-grid__more {
    display: block;
    font-size: 11px;
    font-weight: 600;
    color: var(--xd-cmv-accent, #592B8A);
    margin-top: 2px;
}

/* Mobile dot — hidden on desktop */
.xd-cmv-grid__dot {
    display: none;
}

/* ---- Loading state ---- */
.xd-cmv-grid-wrap.is-loading {
    opacity: 0.45;
    pointer-events: none;
    transition: opacity 0.2s;
}

/* ---- Mobile panel (hidden on desktop) ---- */
.xd-cmv-mobile-panel {
    display: none;
}

/* ---- Mobile footer nav (hidden on desktop) ---- */
.xd-cmv-mobile-footer {
    display: none;
}

/* ============================================================
   Responsive — tablet
   ============================================================ */
@media (max-width: 900px) {
    .xd-cmv-grid__cell {
        min-height: 100px;
        padding: 8px;
    }

    .xd-cmv-grid__day-num {
        font-size: 15px;
    }

    .xd-cmv-nav__month-label {
        font-size: 24px;
    }
}

/* ============================================================
   Responsive — mobile
   ============================================================ */
@media (max-width: 640px) {
    .xd-cmv-wrap {
        padding: 0 0 0;
    }

    /* Compact nav */
    .xd-cmv-nav {
        padding: 12px 16px;
        margin-bottom: 0;
        gap: 6px;
    }

    .xd-cmv-nav__arrow {
        font-size: 22px;
    }

    .xd-cmv-nav__arrow .fa-solid {
        font-size: 22px;
    }

    .xd-cmv-nav__this-month {
        display: none; /* replaced by mobile footer "Today" */
    }

    .xd-cmv-nav__month-label {
        font-size: 20px;
        font-weight: 700;
    }

    .xd-cmv-nav__caret {
        font-size: 14px;
    }

    /* Compact grid cells */
    .xd-cmv-grid__cell {
        min-height: 52px;
        padding: 6px 2px 4px;
        display: flex;
        flex-direction: column;
        align-items: center;
        cursor: pointer;
    }

    .xd-cmv-grid__day-num {
        display: flex;
        align-items: center;
        justify-content: center;
        width: 32px;
        height: 32px;
        border-radius: 50%;
        font-size: 14px;
        font-weight: 600;
        margin-bottom: 2px;
        transition: background 0.15s, color 0.15s;
    }

    /* Hide desktop event listings on mobile */
    .xd-cmv-grid__events {
        display: none;
    }

    /* Show dot on mobile for days with events */
    .xd-cmv-grid__dot {
        display: block;
        width: 6px;
        height: 6px;
        border-radius: 50%;
        background: var(--xd-cmv-accent, #592B8A);
        flex-shrink: 0;
    }

    /* Selected day */
    .xd-cmv-grid__cell.is-selected .xd-cmv-grid__day-num {
        background: var(--xd-cmv-accent, #592B8A);
        color: #fff !important;
    }

    /* Today (not selected) */
    .xd-cmv-grid__cell--today:not(.is-selected) .xd-cmv-grid__day-num {
        color: var(--xd-cmv-accent, #592B8A);
    }

    /* Mobile event panel */
    .xd-cmv-mobile-panel {
        display: block;
        padding: 16px;
        border-top: 1px solid rgba(0,0,0,0.1);
    }

    .xd-cmv-mobile-panel[hidden] {
        display: none;
    }

    .xd-cmv-mobile-panel__events {
        font-size: 14px;
        color: var(--xd-cmv-text, #3a3348);
    }

    /* Individual event row in mobile panel */
    .xd-cmv-mobile-event {
        display: flex;
        flex-direction: column;
        padding: 10px 0;
        border-bottom: 1px solid rgba(0,0,0,0.08);
        text-decoration: none;
        color: var(--xd-cmv-text, #3a3348);
    }

    .xd-cmv-mobile-event:last-child {
        border-bottom: none;
    }

    .xd-cmv-mobile-event__time {
        font-size: 13px;
        font-weight: 500;
        color: #666;
        margin-bottom: 2px;
    }

    .xd-cmv-mobile-event__title {
        font-size: 14px;
        font-weight: 600;
    }

    .xd-cmv-mobile-panel__no-events {
        display: flex;
        align-items: center;
        gap: 10px;
        color: #666;
        font-size: 14px;
        padding: 8px 0;
    }

    .xd-cmv-mobile-panel__no-events-icon {
        width: 36px;
        height: 36px;
        border: 2px solid #999;
        border-radius: 6px;
        display: flex;
        align-items: center;
        justify-content: center;
        flex-shrink: 0;
        color: #999;
        font-size: 14px;
    }

    /* Mobile footer nav */
    .xd-cmv-mobile-footer {
        display: flex;
        align-items: center;
        justify-content: space-between;
        padding: 14px 16px;
        border-top: 1px solid rgba(0,0,0,0.12);
        margin-top: 4px;
    }

    .xd-cmv-mobile-footer__btn {
        display: inline-flex;
        align-items: center;
        gap: 6px;
        background: transparent !important;
        border: none !important;
        box-shadow: none !important;
        cursor: pointer;
        font-size: 15px;
        font-weight: 600;
        color: var(--xd-cmv-text, #3a3348) !important;
        font-family: inherit;
        padding: 4px 0;
    }

    .xd-cmv-mobile-footer__btn--today {
        font-weight: 800;
    }

    .xd-cmv-mobile-footer__btn:hover {
        color: var(--xd-cmv-accent, #592B8A) !important;
    }

    .xd-cmv-mobile-footer__btn .fa-solid {
        font-size: 16px;
        color: var(--xd-cmv-accent, #592B8A);
    }

    .xd-cmv-grid__header-cell {
        padding: 6px 0;
        font-size: 11px;
    }
}
