/* month.css — small tweaks on top of style.css for the single-month printable pages. */

.month-intro {
    text-align: center;
    font-size: 14px;
    color: #555;
    margin: 10px auto 0;
    max-width: 700px;
}

.month-page-heading-period {
    font-weight: 300;
}

body.month-print-modal-open {
    overflow: hidden;
}

.month-print-modal {
    display: none;
    position: fixed;
    inset: 0;
    z-index: 1000;
    align-items: center;
    justify-content: center;
    padding: 20px;
    background: rgba(15, 23, 42, 0.55);
}

.month-print-modal.is-open {
    display: flex;
}

.month-print-dialog {
    position: relative;
    width: min(440px, 100%);
    box-sizing: border-box;
    padding: 30px;
    text-align: center;
    background: #fff;
    border-radius: 12px;
    box-shadow: 0 20px 55px rgba(15, 23, 42, 0.25);
}

.month-print-dialog h2 {
    margin: 0 0 24px;
    font-size: 25px;
    color: #1f2937;
}

.month-print-close {
    position: absolute;
    top: 10px;
    left: 12px;
    width: 34px;
    height: 34px;
    padding: 0;
    color: #64748b;
    font-size: 28px;
    line-height: 1;
    background: transparent;
    border: 0;
    border-radius: 50%;
    cursor: pointer;
}

.month-print-close:hover {
    color: #111827;
    background: #f1f5f9;
}

.month-print-format-options {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 14px;
    margin-bottom: 22px;
}

.month-print-format-option {
    min-height: 142px;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 12px;
    color: #334155;
    font: inherit;
    font-weight: 600;
    background: #fff;
    border: 2px solid #cbd5e1;
    border-radius: 10px;
    cursor: pointer;
}

.month-print-format-option:hover {
    border-color: #94a3b8;
    background: #f8fafc;
}

.month-print-format-option.is-selected {
    color: #145ec5;
    border-color: #145ec5;
    background: #eff6ff;
    box-shadow: 0 0 0 2px rgba(20, 94, 197, 0.12);
}

.month-print-format-icon {
    fill: none;
    stroke: currentColor;
    stroke-width: 2;
}

.month-print-format-icon.is-landscape { width: 72px; height: 50px; }
.month-print-format-icon.is-portrait { width: 50px; height: 72px; }

.month-print-confirm {
    width: 100%;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 9px;
    padding: 11px 18px;
    color: #fff;
    font: inherit;
    font-size: 17px;
    font-weight: 600;
    background: #145ec5;
    border: 0;
    border-radius: 8px;
    cursor: pointer;
}

.month-print-confirm:hover {
    background: #0f4da6;
}

.month-print-confirm-icon {
    width: 20px;
    height: 20px;
    fill: none;
    stroke: currentColor;
    stroke-width: 1.8;
    stroke-linecap: round;
    stroke-linejoin: round;
}

.calendar-container {
    position: relative;
    width: 90%;
    margin-inline-end: 20px;
    zoom: 1;
}

@media (max-width: 768px) {
    .calendar-container {
        width: 100% !important;
        margin-inline-end: 0 !important;
    }

    .calendar-header,
    .calendar-grid {
        width: 100%;
        max-width: 100%;
    }

    .calendar-grid {
        height: auto;
        max-height: none;
        grid-template-rows: auto repeat(var(--calendar-week-rows, 6), minmax(52px, auto));
    }

    .calendar-grid .day-cell {
        min-height: 52px;
    }
}

.calendar-grid {
    height: 80vh;
    max-height: 80vh;
    box-sizing: border-box;
    grid-template-rows: auto repeat(var(--calendar-week-rows, 6), minmax(0, 1fr));
    transition: filter 180ms ease, opacity 180ms ease;
}

.calendar-container.is-loading .calendar-header {
    min-height: 70px;
    box-sizing: border-box;
    filter: blur(4px);
    opacity: 0.45;
}

.calendar-container.is-loading .calendar-grid {
    filter: blur(4px);
    opacity: 0.48;
    background-color: #f8fafc;
    background-image:
        repeating-linear-gradient(to left, transparent 0, transparent calc(14.2857% - 1px), #dbe1e8 calc(14.2857% - 1px), #dbe1e8 14.2857%),
        repeating-linear-gradient(to bottom, transparent 0, transparent calc(16.6667% - 1px), #dbe1e8 calc(16.6667% - 1px), #dbe1e8 16.6667%);
}

.calendar-loading-status {
    display: none;
    position: absolute;
    z-index: 3;
    left: 50%;
    top: 50%;
    transform: translate(-50%, -50%);
    font-size: 0;
    line-height: 0;
    color: transparent;
    background: none;
    border: none;
    padding: 0;
    box-shadow: none;
}

.calendar-loading-status::before {
    content: '';
    display: block;
    width: 36px;
    height: 36px;
    border: 3px solid #dbe1e8;
    border-top-color: #1f3a5f;
    border-radius: 50%;
    animation: calendar-spinner-spin 0.8s linear infinite;
}

.calendar-loading-spinner {
    display: none;
}

@keyframes calendar-spinner-spin {
    to {
        transform: rotate(360deg);
    }
}

.calendar-container.is-loading .calendar-loading-status {
    display: block;
}

.calendar-grid .day-cell {
    min-height: 0;
    overflow: hidden;
}

.month-print-actions {
    text-align: center;
    margin: 16px 0;
}

.month-title-row {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 16px;
    direction: ltr;
}

.month-title-nav {
    display: flex;
    flex-direction: column;
    align-items: center;
}

.month-title-nav-line {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 16px;
}

.month-title-subline {
    display: flex;
    align-items: center;
    justify-content: center;
    flex-wrap: wrap;
    gap: 10px 14px;
    width: 100%;
    margin-top: 2px;
    direction: rtl;
}

[dir="rtl"] .month-title-subline {
    padding-right: 50px;
}

[dir="ltr"] .month-title-subline {
    padding-left: 40px;
}

.month-title-subline .hebrew-month-span,
.month-title-subline .calendar-title-subline {
    width: auto;
    margin-top: 0;
}

.month-title-actions {
    display: inline-flex;
    align-items: center;
    gap: 5px;
}

.month-nav-arrow {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 46px;
    height: 46px;
    box-sizing: border-box;
    font-family: Arial, sans-serif;
    font-size: 46px;
    font-weight: 300;
    line-height: 1;
    color: #1f3a5f;
    text-decoration: none;
    border-radius: 6px;
    padding-bottom: 10px;
}

a.month-nav-arrow:hover {
    background: #e2e8f0;
}

.month-today-button {
    direction: rtl;
    color: #1f3a5f;
    background: #fff;
    border: 1px solid #cbd5e1;
    border-radius: 6px;
    padding: 5px 12px;
    font-size: 14px;
    line-height: 1.5;
    text-decoration: none;
}

.month-today-button:hover {
    background: #e2e8f0;
}

.month-title-print {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 34px;
    height: 34px;
    box-sizing: border-box;
    color: #145ec5;
    background: #fff;
    border: 1px solid #cbd5e1;
    border-radius: 6px;
    padding: 7px;
    cursor: pointer;
}

.month-title-print:hover {
    background: #e2e8f0;
}

.month-title-print svg {
    width: 18px;
    height: 18px;
    fill: none;
    stroke: currentColor;
    stroke-width: 1.8;
    stroke-linecap: round;
    stroke-linejoin: round;
}

.hebrew-month-span,
.calendar-title-subline {
    font-size: 30px;
    font-weight: 300;
    line-height: 1.1;
    color: #666;
    text-align: center;
    margin-top: 2px;
    width: 100%;
}

.calendar-header {
    margin-top: 30px;
    padding-top: 12px;
    padding-bottom: 50px;
}

@media print {
    .month-intro {
        display: none;
    }

    .calendar-container {
        width: 100%;
    }

    @page {
        size: A4 portrait;
        margin: 8mm 8mm 20mm 8mm;
    }

    html, body {
        height: 100%;
    }

    .calendar-container {
        display: flex;
        flex-direction: column;
        min-height: 100vh;
        padding-top: 40px;
        padding-bottom: 20px;
        box-sizing: border-box;
    }

    .calendar-grid {
        flex: 1 1 auto;
        grid-auto-rows: 1fr;
    }

    .calendar-header {
        margin-top: 0;
    }

    .calendar-container.is-loading .calendar-grid,
    .calendar-container.is-loading .calendar-header {
        filter: none;
        opacity: 1;
    }

    /* Portrait: stay inside the printable width of A4, including all 7 columns. */
    html[data-print-orientation="portrait"] .container {
        width: 190mm;
        max-width: 100%;
        margin: 0 auto;
    }

    html[data-print-orientation="portrait"] .calendar-container {
        width: 190mm;
        max-width: 100%;
        margin: 0 auto;
        padding-right: 0;
        padding-left: 0;
    }

    html[data-print-orientation="portrait"] .calendar-grid {
        width: 100%;
        min-width: 0;
        grid-template-columns: repeat(7, minmax(0, 1fr));
    }

    html[data-print-orientation="portrait"] .day-cell,
    html[data-print-orientation="portrait"] .day-header {
        width: auto;
        min-width: 0;
        padding-right: 3px;
        padding-left: 3px;
    }

    /* Landscape: fit the header and all week rows inside one printable page. */
    html[data-print-orientation="landscape"] .calendar-container {
        height: 175mm;
        min-height: 0;
        max-height: 175mm;
        padding-top: 4mm;
        padding-bottom: 2mm;
        overflow: hidden;
    }

    html[data-print-orientation="landscape"] .calendar-header {
        flex: 0 0 auto;
        padding-top: 2mm;
        padding-bottom: 3mm;
    }

    html[data-print-orientation="landscape"] .calendar-grid {
        height: auto;
        max-height: none;
        min-height: 0;
        flex: 1 1 0;
    }

    html[data-print-orientation="landscape"] .day-cell {
        min-height: 0;
        padding-top: 3px;
        padding-bottom: 3px;
    }
}

@media (max-width: 768px) {
    .calendar-header {
        margin-top: 6px;
        padding: 8px 0 10px;
    }

    .month-title-subline,
    [dir="rtl"] .month-title-subline,
    [dir="ltr"] .month-title-subline {
        padding-inline: 0;
        padding-left: 0;
        padding-right: 0;
        justify-content: center;
    }

    .month-title-nav {
        width: 100%;
        align-items: center;
    }
}
