/* ── Навигация по датам ─────────────── */

:root {
    --date-nav-h: 60px;
    --date-group-h: 36px;
}

.date-nav {
    display: flex;
    align-items: center;
    justify-content: space-between;
    position: sticky;
    top: var(--header-h);
    z-index: 20;
    background: var(--bg);
    padding: 12px 0;
    margin-bottom: 16px;
}

.date-nav__controls {
    display: flex;
    align-items: center;
    gap: 8px;
}

.date-nav__right {
    display: flex;
    align-items: center;
    gap: 8px;
}

.date-nav__label {
    font-size: 18px;
    font-weight: 600;
    min-width: 200px;
    text-align: center;
    cursor: pointer;
}

.date-nav__picker {
    position: absolute;
    opacity: 0;
    width: 0;
    height: 0;
    pointer-events: none;
}

/* ── Переключатель вида ──────────────── */

.view-toggle {
    display: flex;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    overflow: hidden;
}

.view-toggle__btn {
    border: none;
    border-radius: 0;
    font-size: 13px;
    padding: 5px 12px;
    background: var(--surface);
    color: var(--text);
}

.view-toggle__btn + .view-toggle__btn {
    border-left: 1px solid var(--border);
}

.view-toggle__btn--active {
    background: var(--header-bg);
    color: var(--header-text);
}

/* ── Календарь ─────────────────────── */

.cal {
    --gutter-w: 56px;
    --hour-h: 60px;

    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    /* clip обрезает контент (скруглённые углы) но не создаёт scroll-контейнер,
       поэтому position:sticky на cal__head работает относительно viewport */
    overflow: clip;
    box-shadow: var(--shadow-sm);
}

.cal__empty {
    padding: 48px 24px;
    text-align: center;
    color: var(--text-muted);
    font-size: 15px;
}

/* ── Шапка с названиями залов ──────── */

.cal__head {
    display: flex;
    position: sticky;
    top: calc(var(--header-h) + var(--date-nav-h));
    z-index: 10;
    background: #fafaf9;
    border-bottom: 1px solid var(--border); /* используется только в single-day режиме */
}

.cal__head-wrap {
    position: sticky;
    top: calc(var(--header-h) + var(--date-nav-h));
    z-index: 10;
    overflow-x: hidden; /* скроллится синхронно с body через JS, полоса скрыта */
    background: #fafaf9;
    border-bottom: 1px solid var(--border);
}

.cal__head-inner {
    display: grid; /* колонки задаются через JS — оба ряда делят одну сетку */
}

.cal__body-wrap {
    overflow-x: auto;
}

/* ── Строка с датами (multi-day) ────── */

.cal__date-group {
    display: flex;
    align-items: center;
    justify-content: center;
    height: var(--date-group-h);
    border-left: 1px solid var(--border);
    font-size: 13px;
    font-weight: 600;
    color: var(--text-secondary);
    text-transform: capitalize;
    letter-spacing: 0.01em;
}

.cal__date-group--day-start {
    border-left: 2px solid #c8c5c2;
}

.cal__date-group--today {
    color: var(--accent);
}

/* Разделители между днями в шапке и теле */
.cal--multi .cal__col-head--day-start,
.cal--multi .cal__col--day-start {
    border-left: 2px solid #c8c5c2;
}

/* Индикатор текущего времени внутри колонки (multi-day) */
.cal__now--col {
    position: absolute;
    left: 0;
    right: 0;
    height: 2px;
    background: var(--accent);
    z-index: 5;
    pointer-events: none;
}

.cal__now--col::before {
    content: '';
    position: absolute;
    left: -4px;
    top: -3px;
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: var(--accent);
}

.cal__col-head {
    flex: 1;
    min-width: 120px;
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 12px 14px;
    border-left: 1px solid var(--border);
}

.cal__dot {
    width: 10px;
    height: 10px;
    border-radius: 50%;
    flex-shrink: 0;
}

.cal__name {
    font-size: 14px;
    font-weight: 600;
    line-height: 1.3;
}

.cal__price {
    font-size: 12px;
    color: var(--text-secondary);
}

/* ── Тело календаря ────────────────── */

.cal__body {
    display: flex;
    position: relative;
}

/* ── Гуттер (время) ────────────────── */

.cal__gutter {
    flex: 0 0 var(--gutter-w);
    position: sticky;
    left: 0;
    z-index: 5;
    background: var(--surface);
}

.cal__head .cal__gutter,
.cal__head-wrap .cal__gutter {
    background: #fafaf9;
}

.cal__time {
    position: absolute;
    right: 8px;
    font-size: 11px;
    font-weight: 500;
    color: var(--text-muted);
    line-height: 1;
    transform: translateY(-50%);
    user-select: none;
}

/* ── Колонка зала ──────────────────── */

.cal__col {
    flex: 1;
    min-width: 120px;
    position: relative;
    border-left: 1px solid var(--border);
    background-image: repeating-linear-gradient(
        to bottom,
        var(--border) 0,
        var(--border) 1px,
        transparent 1px,
        transparent var(--hour-h)
    );
    /* сетка начинается после верхнего отступа BODY_PAD */
    background-position: 0 var(--body-pad, 16px);
}

/* ── Блок бронирования ─────────────── */

.cal__event {
    position: absolute;
    left: 3px;
    right: 3px;
    min-height: 20px;
    border-left: 3px solid var(--booking-color, #888);
    border-radius: 0 var(--radius-sm) var(--radius-sm) 0;
    padding: 4px 8px;
    overflow: hidden;
    cursor: default;
    transition: filter 0.15s;
    z-index: 1;
}

.cal__event:hover {
    filter: brightness(0.93);
}

.cal__event--cancelled {
    opacity: 0.3;
    text-decoration: line-through;
}

.cal__event--resizing {
    opacity: 0.85;
    z-index: 10;
    user-select: none;
    filter: brightness(0.9);
}

.cal__event--dragging {
    opacity: 0.75;
    z-index: 10;
    user-select: none;
    cursor: grabbing !important;
    box-shadow: 0 4px 16px rgba(0, 0, 0, 0.18);
}

.cal__event-resize {
    position: absolute;
    left: 0;
    right: 0;
    height: 10px;
    cursor: ns-resize;
    z-index: 2;
    display: flex;
    align-items: center;
    justify-content: center;
}

.cal__event-resize--top { top: 0; }
.cal__event-resize--bottom { bottom: 0; }

.cal__event-resize::after {
    content: '';
    width: 22px;
    height: 2px;
    border-radius: 1px;
    background: currentColor;
    opacity: 0.3;
    pointer-events: none;
}

.cal__event-resize:hover::after {
    opacity: 0.65;
}

.cal__event-time {
    font-size: 12px;
    font-weight: 600;
    line-height: 1.3;
    white-space: nowrap;
}

.cal__event-details {
    font-size: 11px;
    color: var(--text-secondary);
    margin-top: 2px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.cal__event-comment {
    font-size: 11px;
    color: var(--text-secondary);
    margin-top: 1px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    font-style: italic;
}

/* ── Индикатор текущего времени ─────── */

.cal__now {
    position: absolute;
    left: var(--gutter-w);
    right: 0;
    height: 2px;
    background: var(--accent);
    z-index: 5;
    pointer-events: none;
}

.cal__now::before {
    content: '';
    position: absolute;
    left: -4px;
    top: -3px;
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: var(--accent);
}

/* ── Drag-selection оверлей ─────────── */

.cal__col {
    cursor: crosshair;
}

.cal__col--selecting {
    user-select: none;
}

.cal__selection {
    position: absolute;
    left: 3px;
    right: 3px;
    background: rgba(59, 130, 246, 0.18);
    border: 2px solid rgba(59, 130, 246, 0.6);
    border-radius: var(--radius-sm);
    pointer-events: none;
    z-index: 3;
    display: flex;
    align-items: flex-start;
    padding: 4px 6px;
    font-size: 12px;
    font-weight: 600;
    color: #1d4ed8;
    white-space: nowrap;
    overflow: hidden;
}

/* ── Модал бронирования ─────────────── */

.modal--booking {
    max-width: 520px;
}

.modal--booking .modal__actions {
    justify-content: space-between;
    align-items: center;
}

.modal--booking .modal__actions-right {
    margin-left: auto;
}

.booking-room-info {
    display: flex;
    align-items: center;
    gap: 10px;
    background: #fafaf9;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 10px 14px;
}

.booking-room-info__dot {
    width: 10px;
    height: 10px;
    border-radius: 50%;
    flex-shrink: 0;
}

.booking-room-info__name {
    font-size: 14px;
    font-weight: 600;
}

.booking-room-info__price {
    font-size: 12px;
    color: var(--text-secondary);
    margin-left: auto;
}


.guest-section {
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 12px 14px;
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.guest-section__title {
    font-size: 11px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    color: var(--text-secondary);
}

.guest-section .field {
    margin: 0;
}

.guest-info {
    margin-top: 6px;
    font-size: 13px;
    padding: 8px 12px;
    border-radius: var(--radius);
    border: 1px solid var(--border);
}

.guest-info--found {
    background: rgba(22, 163, 74, 0.06);
    border-color: rgba(22, 163, 74, 0.25);
    color: #15803d;
}

.guest-info--new {
    background: rgba(234, 179, 8, 0.06);
    border-color: rgba(234, 179, 8, 0.3);
    color: #a16207;
}

.price-breakdown {
    margin-top: 6px;
    display: flex;
    flex-direction: column;
    gap: 3px;
}

.price-breakdown__row {
    display: flex;
    justify-content: space-between;
    align-items: baseline;
    gap: 8px;
    font-size: 12px;
    color: var(--text-secondary, #6b7280);
}

.price-breakdown__row--base {
    opacity: 0.75;
    font-style: italic;
}

.price-breakdown__name {
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    min-width: 0;
}

.price-breakdown__detail {
    white-space: nowrap;
    flex-shrink: 0;
    font-variant-numeric: tabular-nums;
}

.price-tag {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    font-size: 11px;
    font-weight: 500;
    color: var(--accent);
    background: color-mix(in srgb, var(--accent) 12%, transparent);
    border: 1px solid color-mix(in srgb, var(--accent) 30%, transparent);
    border-radius: 4px;
    padding: 1px 6px;
    margin-left: 6px;
    vertical-align: middle;
    cursor: default;
    user-select: none;
}

/* ── Responsive ────────────────────── */

@media (max-width: 768px) {
    .date-nav {
        flex-wrap: wrap;
        gap: 12px;
    }

    .date-nav__label {
        font-size: 16px;
        min-width: 240px;
    }

    .cal {
        overflow-x: auto;
    }

    .cal__head,
    .cal__body {
        min-width: 500px;
    }
}
