/* Slot picker host — prevent nested padding from forcing horizontal overflow */
#slotPicker,
#agent-slot-picker,
.booking-slot-picker {
    --cal-primary: #2563eb;
    --cal-primary-light: #dbeafe;
    --cal-success: #059669;
    --cal-success-light: #d1fae5;
    --cal-muted: #94a3b8;
    --cal-border: #e2e8f0;
    --cal-radius: 1rem;
    min-width: 0;
    max-width: 100%;
    overflow: hidden;
}

/* Customer booking — Jalali calendar */
.booking-cal {
    --cal-primary: #2563eb;
    --cal-primary-light: #dbeafe;
    --cal-success: #059669;
    --cal-success-light: #d1fae5;
    --cal-muted: #94a3b8;
    --cal-border: #e2e8f0;
    --cal-radius: 1rem;
    font-family: 'Vazirmatn', sans-serif;
    width: 100%;
    max-width: 100%;
    min-width: 0;
    overflow: hidden;
    box-sizing: border-box;
}

.booking-cal *,
.booking-cal *::before,
.booking-cal *::after {
    box-sizing: border-box;
}

.booking-cal-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 0.5rem;
    padding: 0.75rem 1rem;
    background: linear-gradient(135deg, #1e40af 0%, #3b82f6 50%, #6366f1 100%);
    border-radius: var(--cal-radius) var(--cal-radius) 0 0;
    color: #fff;
    box-shadow: 0 4px 14px rgba(37, 99, 235, 0.25);
    min-width: 0;
}

.booking-cal-title {
    font-weight: 700;
    font-size: 1.05rem;
    letter-spacing: -0.01em;
    min-width: 0;
    text-align: center;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.booking-cal-nav {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 2rem;
    height: 2rem;
    border: none;
    border-radius: 0.5rem;
    background: rgba(255, 255, 255, 0.15);
    color: #fff;
    font-size: 1.1rem;
    cursor: pointer;
    transition: background 0.15s, transform 0.1s;
}

.booking-cal-nav:hover {
    background: rgba(255, 255, 255, 0.28);
}

.booking-cal-nav:active {
    transform: scale(0.94);
}

.booking-cal-body {
    background: #fff;
    border: 1px solid var(--cal-border);
    border-top: none;
    border-radius: 0 0 var(--cal-radius) var(--cal-radius);
    padding: 0.75rem;
    min-width: 0;
    overflow: hidden;
}

.booking-cal-weekdays {
    display: grid;
    grid-template-columns: repeat(7, minmax(0, 1fr));
    gap: 2px;
    margin-bottom: 0.35rem;
    width: 100%;
    min-width: 0;
}

.booking-cal-weekdays span {
    text-align: center;
    font-size: 0.7rem;
    font-weight: 600;
    color: var(--cal-muted);
    padding: 0.25rem 0;
    min-width: 0;
}

.booking-cal-grid {
    display: grid;
    grid-template-columns: repeat(7, minmax(0, 1fr));
    gap: 4px;
    width: 100%;
    min-width: 0;
}

.booking-cal-empty {
    aspect-ratio: 1;
    min-width: 0;
    width: 100%;
}

.booking-cal-day {
    position: relative;
    aspect-ratio: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    border: 2px solid transparent;
    border-radius: 0.65rem;
    background: #f8fafc;
    font-size: 0.85rem;
    font-weight: 600;
    color: #334155;
    cursor: pointer;
    transition: background 0.15s ease, border-color 0.15s ease, box-shadow 0.15s ease, color 0.15s ease;
    padding: 0;
    margin: 0;
    min-width: 0;
    width: 100%;
    max-width: 100%;
    min-height: 0;
}

.booking-cal-day:hover:not(:disabled) {
    background: var(--cal-primary-light);
    border-color: #93c5fd;
}

@media (hover: hover) and (min-width: 480px) {
    .booking-cal-day:hover:not(:disabled) {
        transform: translateY(-1px);
    }
}

.booking-cal-day.is-today {
    border-color: var(--cal-primary);
    color: var(--cal-primary);
    font-weight: 700;
}

.booking-cal-day.is-selected {
    background: var(--cal-primary);
    color: #fff;
    border-color: var(--cal-primary);
    box-shadow: 0 4px 12px rgba(37, 99, 235, 0.35);
}

.booking-cal-day.is-selected.is-today {
    color: #fff;
}

.booking-cal-day.is-available::after {
    content: '';
    position: absolute;
    bottom: 3px;
    width: 5px;
    height: 5px;
    border-radius: 50%;
    background: var(--cal-success);
}

.booking-cal-day.is-selected.is-available::after {
    background: #fff;
}

.booking-cal-day.is-closed,
.booking-cal-day.is-past,
.booking-cal-day.is-unavailable {
    background: #f1f5f9;
    color: #cbd5e1;
    cursor: not-allowed;
    opacity: 0.7;
}

.booking-cal-day.is-closed::after,
.booking-cal-day.is-unavailable::after {
    display: none;
}

.booking-cal-footer {
    display: flex;
    justify-content: center;
    margin-top: 0.5rem;
    padding-top: 0.5rem;
    border-top: 1px solid #f1f5f9;
}

.booking-cal-today-btn {
    font-size: 0.8rem;
    color: var(--cal-primary);
    background: none;
    border: none;
    cursor: pointer;
    padding: 0.25rem 0.75rem;
    border-radius: 0.5rem;
    font-weight: 600;
}

.booking-cal-today-btn:hover {
    background: var(--cal-primary-light);
}

.booking-cal-selected-label {
    text-align: center;
    font-size: 0.85rem;
    color: #64748b;
    margin: 0.75rem 0 0.5rem;
    font-weight: 500;
}

.booking-cal-selected-label strong {
    color: #1e293b;
}

.booking-slots {
    margin-top: 1rem;
    --cal-primary: #2563eb;
    --cal-primary-light: #dbeafe;
}

.booking-slots-title {
    font-size: 0.9rem;
    font-weight: 600;
    color: #475569;
    margin-bottom: 0.5rem;
}

.booking-slots-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 0.5rem;
}

@media (min-width: 480px) {
    .booking-slots-grid {
        grid-template-columns: repeat(3, 1fr);
    }

    .booking-cal-day {
        min-height: 2.5rem;
    }
}

/* Narrow phones: nested page padding leaves little room for 7 day cells. */
@media (max-width: 479px) {
    .booking-cal-header {
        padding: 0.65rem 0.75rem;
    }

    .booking-cal-title {
        font-size: 0.95rem;
    }

    .booking-cal-body {
        padding: 0.5rem;
    }

    .booking-cal-grid {
        gap: 2px;
    }

    .booking-cal-day {
        font-size: 0.75rem;
        border-width: 1px;
        border-radius: 0.5rem;
    }

    .booking-cal-day.is-available::after {
        bottom: 2px;
        width: 4px;
        height: 4px;
    }

    .booking-cal-legend {
        gap: 0.5rem;
        font-size: 0.65rem;
    }
}

.booking-slot-btn {
    border: 2px solid #86efac;
    border-radius: 0.75rem;
    padding: 0.65rem 0.5rem;
    font-size: 0.9rem;
    font-weight: 600;
    background: linear-gradient(180deg, #f0fdf4 0%, #dcfce7 100%);
    color: #166534;
    cursor: pointer;
    transition: all 0.15s;
    font-family: 'Vazirmatn', sans-serif;
}

.booking-slot-btn:hover:not(:disabled) {
    background: linear-gradient(180deg, #dcfce7 0%, #bbf7d0 100%);
    border-color: #4ade80;
    transform: translateY(-1px);
    box-shadow: 0 3px 10px rgba(22, 101, 52, 0.15);
}

.booking-slot-btn.is-held,
.booking-slot-btn.is-pending {
    border-color: #2563eb;
    background: #dbeafe;
    color: #1d4ed8;
    box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.2);
}

.booking-slot-btn.is-pending {
    opacity: 0.85;
}

.booking-slot-btn:disabled {
    background: #f1f5f9;
    border-color: #e2e8f0;
    color: #cbd5e1;
    cursor: not-allowed;
}

.booking-cal-loading {
    text-align: center;
    padding: 2rem;
    color: var(--cal-muted);
    font-size: 0.9rem;
}

.booking-cal-legend {
    display: flex;
    flex-wrap: wrap;
    gap: 0.75rem;
    justify-content: center;
    margin-top: 0.65rem;
    font-size: 0.7rem;
    color: #64748b;
}

.booking-cal-legend span {
    display: inline-flex;
    align-items: center;
    gap: 0.3rem;
}

.booking-cal-legend .dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
}

.booking-cal-legend .dot.available { background: var(--cal-success); }
.booking-cal-legend .dot.closed { background: #cbd5e1; }
