/* Responsive appointment picker. Load AFTER schedule.css.
   Phone and tablet, and a desktop column narrower than the week table, use the day strip.
   A wide desktop column keeps table.schedule-week. */
.smc-panel { display: none; }

/* Clinic booking tab must not keep the old 500px reserve above the map. */
#Clinic .hp-content .tab-pane,
#Clinic .hp-content .tab-content {
    min-height: 0 !important;
    height: auto !important;
}

#clinic-calendar {
    max-width: 100%;
    min-width: 0;
}

.smc-enhanced {
    container-type: inline-size;
    container-name: smc;
    max-width: 100%;
    min-width: 0;
}

.smc-enhanced > .smc-panel {
    --smc-navy: #14325c;
    --smc-blue: #1d63b8;
    --smc-green: #0f7a55;
    --smc-green-soft: #e7f6ef;
    --smc-ink: #1b2533;
    --smc-muted: #5b6878;
    --smc-line: #d9e1ea;
    --smc-off: #f2f4f7;
    width: 100%;
    min-width: 0;
    direction: rtl;
    color: var(--smc-ink);
    font-family: inherit;
}

.smc-panel * { box-sizing: border-box; }

.smc-days {
    display: flex;
    gap: 8px;
    overflow-x: auto;
    overscroll-behavior-x: contain;
    scroll-snap-type: x proximity;
    scroll-padding-inline: 2px;
    padding: 2px 2px 8px;
    scrollbar-width: thin;
    -webkit-overflow-scrolling: touch;
    touch-action: pan-x;
}

.smc-day {
    flex: 0 0 calc((100% - 32px) / 4.22);
    min-width: 0;
    min-height: 156px;
    padding: 16px 4px;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 2px;
    scroll-snap-align: start;
    border: 1px solid var(--smc-line);
    -webkit-border-radius: 12px !important;
    -moz-border-radius: 12px !important;
    border-radius: 12px !important;
    background: #fff;
    color: var(--smc-ink);
    font: inherit;
    cursor: pointer;
    transition: border-color .15s, background-color .15s;
}

.smc-day-weekday {
    max-width: 100%;
    overflow: hidden;
    text-overflow: ellipsis;
    font-size: 12px;
    line-height: 1.6;
    color: var(--smc-muted);
    white-space: nowrap;
}

.smc-day-date {
    display: flex;
    flex-direction: column;
    align-items: center;
    line-height: 1.3;
}

.smc-day-date b { font-size: 28px; font-weight: 700; }
.smc-day-date small { font-size: 11px; white-space: nowrap; color: inherit; }

.smc-day-count {
    margin-top: 2px;
    font-size: 11px;
    line-height: 1.6;
    color: var(--smc-green);
    font-weight: 600;
    white-space: nowrap;
}

.smc-day-empty,
.smc-day-full { background: var(--smc-off); }

.smc-day-empty .smc-day-count,
.smc-day-full .smc-day-count { color: var(--smc-muted); font-weight: 400; }

.smc-day-empty .smc-day-date,
.smc-day-full .smc-day-date { color: var(--smc-muted); }

.smc-day[aria-pressed="true"] {
    background: var(--smc-navy);
    border-color: var(--smc-navy);
    color: #fff;
}

.smc-day[aria-pressed="true"] .smc-day-weekday,
.smc-day[aria-pressed="true"] .smc-day-date { color: #fff; }

.smc-day[aria-pressed="true"] .smc-day-count { color: #9be8c6; }

.smc-heading {
    margin: 10px 0 12px;
    font-size: 15px;
    font-weight: 700;
    line-height: 1.8;
    color: var(--smc-navy);
}

.smc-times {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 8px;
}

.smc-times[hidden] { display: none; }

.smc-time {
    position: relative;
    min-width: 0;
    min-height: 60px;
    padding: 8px 6px;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    border: 1px solid #9fd4bd;
    -webkit-border-radius: 8px !important;
    -moz-border-radius: 8px !important;
    border-radius: 8px !important;
    background: var(--smc-green-soft);
    color: var(--smc-green);
    font-family: inherit;
    font-size: 15px;
    font-weight: 600;
    line-height: 1.45;
    text-align: center;
    cursor: pointer;
}

.smc-time[aria-pressed="true"] {
    background: var(--smc-green);
    border-color: var(--smc-green);
    color: #fff;
}

.smc-time:disabled {
    color: #7a8491;
    border-color: var(--smc-line);
    background: var(--smc-off);
    text-decoration: line-through;
    font-weight: 400;
    cursor: not-allowed;
}

.smc-time-tag {
    font-size: 10px;
    line-height: 1.4;
    text-decoration: none;
    display: block;
}

.smc-status {
    margin: 10px 0 0;
    color: var(--smc-muted);
    font-size: 13px;
    line-height: 1.9;
}

.smc-status-empty {
    padding: 12px;
    border: 1px dashed var(--smc-line);
    -webkit-border-radius: 8px !important;
    -moz-border-radius: 8px !important;
    border-radius: 8px !important;
    background: var(--smc-off);
    text-align: center;
}

.smc-status-undefined {
    color: #14325c !important;
    font-weight: 700 !important;
    font-size: 14px;
}

.smc-status-picked { color: var(--smc-green); font-weight: 600; }

.smc-panel button:focus-visible {
    outline: 3px solid var(--smc-blue);
    outline-offset: 2px;
}

@media (hover: hover) {
    .smc-day:hover:not([aria-pressed="true"]) { border-color: var(--smc-blue); }
    .smc-time:hover:not(:disabled):not([aria-pressed="true"]) {
        background: var(--smc-green);
        border-color: var(--smc-green);
        color: #fff;
    }
}

/* Week bar on phone, tablet, and desktop: هفته قبل | بازه | هفته بعد. */
#clinic-calendar .schedule-week-controller {
    display: flex !important;
    flex-wrap: wrap !important;
    align-items: center !important;
    gap: 8px !important;
    margin-bottom: 12px !important;
}

#clinic-calendar .schedule-week-controller-nav {
    display: flex !important;
    align-items: center !important;
    justify-content: space-between !important;
    width: 100% !important;
    flex: 1 0 100% !important;
    gap: 8px !important;
}

#clinic-calendar .schedule-week-controller-nav > #prev { order: 1 !important; }
#clinic-calendar .schedule-week-controller-nav > #next { order: 3 !important; }

#clinic-calendar .schedule-week-controller-nav > #prev,
#clinic-calendar .schedule-week-controller-nav > #next {
    position: relative !important;
    z-index: 1 !important;
    flex: 0 0 auto !important;
    width: auto !important;
    min-width: 0 !important;
    height: auto !important;
    min-height: 40px !important;
    margin: 0 !important;
    padding: 8px 10px !important;
    font-size: 13px !important;
    font-weight: 600 !important;
    line-height: 1.4 !important;
    color: #14325c !important;
    background: #fff !important;
    border: 1px solid #d9e1ea !important;
    -webkit-border-radius: 8px !important;
    -moz-border-radius: 8px !important;
    border-radius: 8px !important;
    white-space: nowrap !important;
}

#clinic-calendar .schedule-week-controller-nav > #prev svg,
#clinic-calendar .schedule-week-controller-nav > #next svg {
    display: none !important;
}

#clinic-calendar .schedule-week-controller-nav > #prev::after {
    content: "→ هفتهٔ قبل";
}

#clinic-calendar .schedule-week-controller-nav > #next::after {
    content: "هفتهٔ بعد ←";
}

#clinic-calendar .schedule-week-controller-title {
    order: 2 !important;
    flex: 1 1 0 !important;
    min-width: 0 !important;
    max-width: 100% !important;
    height: auto !important;
    margin: 0 !important;
    padding: 0 4px !important;
    overflow: hidden !important;
    font-size: 13px !important;
    font-weight: 600 !important;
    line-height: 1.35 !important;
    color: #5b6878 !important;
    text-align: center !important;
    white-space: normal !important;
    overflow-wrap: anywhere;
}

#clinic-calendar .schedule-week-controller-actions {
    display: none !important;
}

/* Phone and tablet: replace the week table. Desktop sidebar stacks below 992px. */
@media screen and (max-width: 991px) {
    #clinic-calendar table.schedule-week,
    #clinic-calendar.smc-enhanced > table.schedule-week,
    .smc-enhanced > table.schedule-week {
        display: none !important;
        position: absolute !important;
        width: 0 !important;
        height: 0 !important;
        min-height: 0 !important;
        max-height: 0 !important;
        margin: 0 !important;
        padding: 0 !important;
        border: 0 !important;
        overflow: hidden !important;
        visibility: hidden !important;
        pointer-events: none !important;
    }

    .smc-enhanced > .smc-panel { display: block; }

    /* The booking tab used to reserve 500px, which left a blank band under the calendar. */
    #Clinic .hp-content,
    #Clinic .hp-content .tab-content,
    #Clinic .hp-content .tab-pane,
    #Clinic .hp-content .tab-pane > .row,
    #Clinic #clinic-calendar {
        height: auto !important;
        min-height: 0 !important;
    }

    #Clinic .hp-content {
        padding: 8px 8px 0 !important;
        margin-bottom: 0 !important;
        height: auto !important;
        min-height: 0 !important;
    }

    #Clinic .hp-content .tab-content,
    #Clinic .hp-content .tab-pane,
    #Clinic .hp-content .tab-pane > .row {
        min-height: 0 !important;
        height: auto !important;
        margin-bottom: 0 !important;
        padding-bottom: 0 !important;
    }

    #Clinic .hp-content .tab-content > .tab-pane:not(.active) {
        display: none !important;
    }

    #Clinic .hp-content .nav-tabs {
        margin-bottom: 6px !important;
    }

    #Clinic .cal-next-slot-bar {
        margin: 0 0 6px !important;
    }

    #Clinic .clinic-main,
    #Clinic .center-main {
        flex: 0 0 auto !important;
        height: auto !important;
        min-height: 0 !important;
        margin-bottom: 0 !important;
        padding-bottom: 0 !important;
    }

    #Clinic #clinic-calendar,
    #clinic-calendar.smc-enhanced {
        position: relative !important;
        display: block !important;
        overflow: hidden !important;
        height: auto !important;
        min-height: 0 !important;
        max-height: none !important;
        width: 100% !important;
        margin-top: 0 !important;
        margin-bottom: 0 !important;
        padding: 8px 8px 4px !important;
        background: #fff !important;
        border: 1px solid rgba(30, 127, 232, 0.14) !important;
        -webkit-border-radius: 14px !important;
        -moz-border-radius: 14px !important;
        border-radius: 14px !important;
        box-shadow: none !important;
    }

    #Clinic .center-map-panel,
    #Clinic .clinic-map-panel {
        margin-top: 8px !important;
    }
}

/* Wide viewport, but the calendar column itself is too narrow for five table columns. */
@media screen and (min-width: 992px) {
    @container smc (max-width: 680px) {
        .smc-enhanced > table.schedule-week { display: none !important; }
        .smc-enhanced > .smc-panel { display: block; }
    }

    #clinic-calendar > table.schedule-week {
        width: 100% !important;
        max-width: 100%;
    }

    #clinic-calendar .schedule-week-button {
        max-width: 100%;
        box-sizing: border-box;
        height: auto !important;
        min-height: 3rem;
        white-space: normal;
    }
}

@container smc (min-width: 560px) {
    .smc-day { flex-basis: calc((100% - 40px) / 5.22); min-height: 164px; }
    .smc-times { grid-template-columns: repeat(4, minmax(0, 1fr)); }
    .smc-time { min-height: 64px; font-size: 16px; }
}

.smc-month .smc-panel {
    --smc-navy: #14325c;
    --smc-blue: #1d63b8;
    --smc-green: #0f7a55;
    --smc-green-soft: #e7f6ef;
    --smc-ink: #1b2533;
    --smc-muted: #5b6878;
    --smc-line: #d9e1ea;
    --smc-off: #f2f4f7;
    width: 100%;
    min-width: 0;
    direction: rtl;
    color: var(--smc-ink);
    font-family: inherit;
}

.smc-day:disabled {
    opacity: 0.45;
    cursor: default;
}

@media screen and (max-width: 991px) {
    .smc-month { position: relative; }
    .smc-month .smc-panel { display: block; }

    .smc-month table.schedule-month-table {
        display: none !important;
        position: absolute !important;
        width: 0 !important;
        height: 0 !important;
        overflow: hidden !important;
        visibility: hidden !important;
        margin: 0 !important;
        padding: 0 !important;
    }

    .smc-month .schedule-month-block {
        flex-direction: column !important;
    }

    .smc-month .schedule-month-list {
        width: 100% !important;
        min-width: 0 !important;
        margin: 8px 0 0 !important;
        position: relative !important;
    }

    .smc-month .schedule-month-list > div,
    .smc-month .schedule-month-list > .schedule-combo {
        position: relative !important;
        top: auto !important;
        left: auto !important;
        width: 100% !important;
        height: auto !important;
        margin: 8px 0 0 !important;
        overflow: visible !important;
    }

    .smc-month .schedule-month-controller {
        display: flex !important;
        flex-wrap: wrap !important;
        align-items: center !important;
        column-gap: 8px !important;
        row-gap: 8px !important;
        width: 100% !important;
        margin: 0 0 8px !important;
        padding: 0 !important;
    }

    .smc-month .schedule-month-controller > .col-md-6,
    .smc-month .schedule-month-controller > .calendar-buttons {
        display: contents !important;
    }

    .smc-month .schedule-month-controller-button#prev { order: 1 !important; }
    .smc-month .schedule-month-controller-title { order: 2 !important; }
    .smc-month .schedule-month-controller-button#next { order: 3 !important; }
    .smc-month .schedule-month-controller-button#current {
        order: 4 !important;
        flex: 1 0 100% !important;
        width: 100% !important;
        min-width: 0 !important;
        height: auto !important;
        min-height: 36px !important;
        margin: 0 !important;
    }

    .smc-month .schedule-month-controller-title {
        flex: 1 1 0 !important;
        min-width: 0 !important;
        width: auto !important;
        max-width: 100% !important;
        height: auto !important;
        margin: 0 !important;
        padding: 0 4px !important;
        overflow: hidden !important;
        font-size: 14px !important;
        font-weight: 600 !important;
        line-height: 1.35 !important;
        text-align: center !important;
        white-space: normal !important;
        overflow-wrap: anywhere;
    }

    .smc-month .schedule-month-controller-button#prev,
    .smc-month .schedule-month-controller-button#next {
        position: relative !important;
        z-index: 1 !important;
        flex: 0 0 auto !important;
        width: auto !important;
        min-width: 0 !important;
        height: auto !important;
        min-height: 40px !important;
        margin: 0 !important;
        padding: 8px 10px !important;
        font-size: 13px !important;
        font-weight: 600 !important;
        line-height: 1.4 !important;
        color: #14325c !important;
        background: #fff !important;
        border: 1px solid #d9e1ea !important;
        -webkit-border-radius: 8px !important;
        -moz-border-radius: 8px !important;
        border-radius: 8px !important;
        white-space: nowrap !important;
    }

    .smc-month .schedule-month-controller-button#prev svg,
    .smc-month .schedule-month-controller-button#next svg { display: none !important; }

    .smc-month .schedule-month-controller-button#prev::after { content: "→ ماه قبل"; }
    .smc-month .schedule-month-controller-button#next::after { content: "ماه بعد ←"; }

    .smc-month .smc-month-slots {
        grid-template-columns: 1fr;
        margin-top: 4px;
    }

    .smc-month .smc-month-slot {
        min-height: 52px;
        align-items: flex-start;
        text-align: right;
        padding: 10px 12px;
        white-space: normal;
    }
}

#calendar.smc-week .schedule-month-controller,
#calendar.smc-week table.schedule-month-table,
#service-calendar.smc-week .schedule-month-controller,
#service-calendar.smc-week table.schedule-month-table {
    display: none !important;
}

#calendar.smc-week .schedule-month-list,
#service-calendar.smc-week .schedule-month-list {
    display: none !important;
}

#calendar.smc-week .smc-month-slots,
#service-calendar.smc-week .smc-month-slots {
    display: grid !important;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 8px;
    margin-top: 4px;
}

#calendar.smc-week .smc-panel,
#service-calendar.smc-week .smc-panel { display: block; }

#calendar.smc-week,
#service-calendar.smc-week {
    container-type: inline-size;
    container-name: smc;
    position: relative !important;
    display: block !important;
    overflow: hidden !important;
    width: 100% !important;
    max-width: none !important;
    height: auto !important;
    min-height: 0 !important;
    margin: 0 !important;
    padding: 8px 8px 4px !important;
    background: #fff !important;
    border: 1px solid rgba(30, 127, 232, 0.14) !important;
    -webkit-border-radius: 14px !important;
    -moz-border-radius: 14px !important;
    border-radius: 14px !important;
    box-shadow: none !important;
}

#calendar.smc-week .smc-time,
#service-calendar.smc-week .smc-time {
    width: auto !important;
    min-width: 0 !important;
    max-width: none !important;
    min-height: 60px;
    white-space: nowrap;
}

.smc-week .smc-panel {
    --smc-navy: #14325c;
    --smc-blue: #1d63b8;
    --smc-green: #0f7a55;
    --smc-green-soft: #e7f6ef;
    --smc-ink: #1b2533;
    --smc-muted: #5b6878;
    --smc-line: #d9e1ea;
    --smc-off: #f2f4f7;
    width: 100%;
    direction: rtl;
    color: var(--smc-ink);
    font-family: inherit;
}

.smc-weekbar {
    display: flex;
    align-items: center;
    gap: 8px;
    margin: 0 0 8px;
}

.smc-weeknav {
    flex: 0 0 auto;
    min-height: 40px;
    margin: 0;
    padding: 8px 10px;
    font: inherit;
    font-size: 13px;
    font-weight: 600;
    line-height: 1.4;
    color: #14325c;
    background: #fff;
    border: 1px solid #d9e1ea;
    -webkit-border-radius: 8px !important;
    -moz-border-radius: 8px !important;
    border-radius: 8px !important;
    white-space: nowrap;
    cursor: pointer;
}

.smc-weeknav:disabled {
    opacity: 0.45;
    cursor: default;
}

.smc-weektitle {
    flex: 1 1 0;
    min-width: 0;
    margin: 0;
    overflow: hidden;
    font-size: 13px;
    font-weight: 600;
    line-height: 1.35;
    color: #5b6878;
    text-align: center;
    white-space: normal;
}

/* Same month calendar as desktop, fitted to a phone. The day click path stays unchanged. */
@media screen and (max-width: 991px) {
    #calendar .schedule-month-block,
    #service-calendar .schedule-month-block {
        flex-direction: column !important;
        align-items: stretch !important;
    }

    #calendar .schedule-month-table-block,
    #service-calendar .schedule-month-table-block {
        width: 100% !important;
        min-width: 0 !important;
    }

    #calendar .schedule-month-table,
    #service-calendar .schedule-month-table {
        display: table !important;
        width: 100% !important;
        max-width: 100% !important;
        table-layout: fixed !important;
        overflow: hidden !important;
        border-spacing: 3px !important;
        padding: 0 !important;
        font-size: 14px !important;
    }

    #calendar .schedule-month-week,
    #service-calendar .schedule-month-week {
        width: auto !important;
        padding: 6px 0 !important;
        font-size: 10px !important;
        font-weight: 600 !important;
        line-height: 1.25 !important;
        white-space: normal !important;
        word-break: break-word !important;
    }

    #calendar .schedule-month-button,
    #service-calendar .schedule-month-button {
        min-height: 40px !important;
        height: 40px !important;
        font-size: 15px !important;
        line-height: 40px !important;
        padding: 0 !important;
    }

    #calendar .schedule-month-button.today,
    #service-calendar .schedule-month-button.today {
        height: 48px !important;
        line-height: 34px !important;
    }

    #calendar .schedule-month-button.today::after,
    #service-calendar .schedule-month-button.today::after {
        font-size: 9px !important;
        line-height: 1 !important;
        bottom: 4px !important;
    }

    #calendar .schedule-month-list,
    #service-calendar .schedule-month-list {
        width: 100% !important;
        min-width: 0 !important;
        margin: 12px 0 0 !important;
    }

    #calendar .schedule-month-controller,
    #service-calendar .schedule-month-controller {
        flex-wrap: wrap !important;
        row-gap: 8px !important;
    }

    #calendar .schedule-month-controller-title,
    #service-calendar .schedule-month-controller-title {
        font-size: 18px !important;
        white-space: normal !important;
    }

    #calendar .calendar-buttons,
    #service-calendar .calendar-buttons {
        display: flex !important;
        justify-content: center !important;
        width: 100% !important;
        gap: 6px !important;
    }
}

@container smc (min-width: 860px) {
    .smc-day { flex-basis: calc((100% - 48px) / 7); }
    .smc-heading { font-size: 16px; }
}

@supports not (container-type: inline-size) {
    @media (min-width: 560px) and (max-width: 991px) {
        .smc-day { flex-basis: calc((100% - 40px) / 5.22); min-height: 164px; }
        .smc-times { grid-template-columns: repeat(4, minmax(0, 1fr)); }
        .smc-time { min-height: 58px; font-size: 16px; }
    }
}
