/* Shared Unit Popup Component */
.khl-unit-modal {
    position: fixed;
    inset: 0;
    z-index: 99999;
    display: none;
    align-items: center;
    justify-content: center;
    background: rgba(15, 23, 42, 0.58);
    padding: 18px;
}
.khl-unit-modal.is-open {
    display: flex;
}
.khl-unit-modal__dialog {
    width: min(920px, 100%);
    max-height: 92vh;
    overflow: hidden;
    background: #ffffff;
    border: 1px solid #d7e3f0;
    border-radius: 16px;
    position: relative;
    box-shadow: 0 24px 70px rgba(6, 43, 91, 0.24);
}
.khl-unit-modal__close {
    position: absolute;
    top: 12px;
    right: 12px;
    z-index: 5;
    width: 32px;
    height: 32px;
    border: 0;
    border-radius: 50%;
    background: transparent;
    color: #94a3b8;
    font-size: 26px;
    line-height: 1;
    cursor: pointer;
}
.khl-unit-popup {
    color: #0f172a;
}
.khl-unit-popup__head {
    min-height: 58px;
    padding: 14px 52px 12px 16px;
    border-bottom: 1px solid #d7e3f0;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
    background: linear-gradient(135deg, #ffffff, #f4f8fc);
}
.khl-unit-popup__code {
    margin: 0;
    color: #10233d;
    font-size: 24px;
    font-weight: 800;
}
.khl-unit-popup__price {
    color: #e11d48;
    font-size: 22px;
    font-weight: 900;
}
.khl-unit-popup__price span {
    color: #94a3b8;
    font-size: 11px;
    font-weight: 700;
}
.khl-unit-popup__grid {
    display: grid;
    grid-template-columns: minmax(300px, 1fr) minmax(360px, 1.15fr);
    min-height: 500px;
}
.khl-unit-popup__media {
    border-right: 1px solid #d7e3f0;
    background: #f4f8fc;
}
.khl-unit-popup__gallery {
    width: 100%;
    background: #e2e8f0;
    overflow: hidden;
}
.khl-unit-popup__gallery .swiper-button-prev,
.khl-unit-popup__gallery .swiper-button-next {
    width: 44px;
    height: 44px;
    border-radius: 50%;
    background: rgba(15, 23, 42, .72);
    color: #fff;
}
.khl-unit-popup__gallery .swiper-button-prev::after,
.khl-unit-popup__gallery .swiper-button-next::after {
    font-size: 16px;
    font-weight: 900;
}
.khl-unit-popup__gallery .swiper-pagination-bullet-active { background: #f59e0b; }
.khl-unit-popup__image {
    width: 100%;
    aspect-ratio: 390 / 460;
    max-height: min(520px, 58vh);
    object-fit: cover;
    display: block;
    background: #e2e8f0;
}
.khl-unit-popup__image--empty {
    background: #e2e8f0;
}
.khl-unit-popup__quick {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    background: #ffffff;
    border-top: 1px solid #d7e3f0;
}
.khl-unit-popup__quick div {
    padding: 9px 7px;
    text-align: center;
    border-right: 1px solid #d7e3f0;
}
.khl-unit-popup__quick span {
    display: block;
    color: #1d4ed8;
    font-size: 12px;
    font-weight: 700;
}
.khl-unit-popup__quick strong {
    display: block;
    color: #111827;
    font-size: 11px;
    font-weight: 900;
    text-transform: uppercase;
}
.khl-unit-popup__side {
    padding: 14px 16px;
    overflow-y: auto;
}
.khl-unit-popup__section {
    padding: 0 0 12px;
    border-bottom: 1px solid #d7e3f0;
    margin-bottom: 12px;
}
.khl-unit-popup__section:last-child {
    margin-bottom: 0;
}
.khl-unit-popup__section-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    margin-bottom: 12px;
}
.khl-unit-popup__section-title {
    margin: 0;
    color: #062b5b;
    font-size: 15px;
    font-weight: 800;
}
.khl-unit-popup__links {
    display: flex;
    gap: 6px;
    flex-wrap: wrap;
}
.khl-unit-popup__ext {
    display: inline-flex;
    align-items: center;
    min-height: 32px;
    padding: 6px 10px;
    border: 1px solid #e5e7eb;
    border-radius: 7px;
    background: #f8fafc;
    color: #0f3b63;
    font-size: 12px;
    font-weight: 700;
    text-decoration: none;
}
.khl-unit-popup__rows {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 8px 18px;
}
.khl-unit-popup__row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
    font-size: 13px;
}
.khl-unit-popup__label {
    color: #60758e;
    font-weight: 700;
}
.khl-unit-popup__value {
    color: #0f172a;
    font-weight: 800;
    text-align: right;
}
.khl-unit-popup__status {
    display: inline-flex;
    align-items: center;
    padding: 4px 8px;
    border-radius: 6px;
    background: #dcfce7;
    color: #16a34a;
    font-size: 12px;
    font-weight: 800;
}
.khl-unit-popup__creator {
    display: flex;
    align-items: center;
    gap: 12px;
    margin-top: 10px;
    padding: 10px 12px;
    background: #f8fafc;
    border: 1px solid #e2e8f0;
    border-radius: 8px;
}
.khl-unit-popup__creator-avatar {
    width: 42px;
    height: 42px;
    border-radius: 50%;
    overflow: hidden;
    flex-shrink: 0;
    background: #e2e8f0;
    border: 2px solid #ffffff;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
}
.khl-unit-popup__creator-avatar img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
}
.khl-unit-popup__creator-fallback {
    width: 100%;
    height: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 16px;
    font-weight: 700;
    color: #475569;
    background: #cbd5e1;
}
.khl-unit-popup__creator-body {
    display: flex;
    flex-direction: column;
    gap: 2px;
    min-width: 0;
}
.khl-unit-popup__creator-badge {
    font-size: 11px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.03em;
    color: #64748b;
}
.khl-unit-popup__creator-name {
    font-size: 13px;
    font-weight: 700;
    color: #0f172a;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
.khl-unit-popup__creator-phone {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    font-size: 12px;
    font-weight: 700;
    color: #0284c7;
    text-decoration: none;
    transition: color 0.15s ease;
    min-height: 24px;
}
.khl-unit-popup__creator-phone:hover {
    color: #0369a1;
    text-decoration: underline;
}
.khl-unit-popup__creator-phone svg {
    flex-shrink: 0;
}
.khl-unit-popup__creator-nophone {
    font-size: 12px;
    color: #94a3b8;
    font-style: italic;
}
.khl-unit-popup__actions {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 8px;
    padding: 8px 10px 10px;
    background: #ffffff;
}
.khl-unit-popup__action,
.khl-unit-popup__booking {
    min-height: 34px;
    border-radius: 6px;
    border: 1px solid #b9d9f7;
    background: #ffffff;
    color: #0756a3;
    font-weight: 800;
    cursor: pointer;
}
.khl-unit-popup__action:disabled {
    color: #94a3b8;
    border-color: #e2e8f0;
    background: #f8fafc;
    cursor: not-allowed;
}
.khl-unit-chat {
    display: flex;
    flex-direction: column;
    height: 100%;
    min-height: 0;
    margin: -14px -16px;
    background: #ffffff;
}
.khl-unit-chat[hidden] {
    display: none;
}
.khl-unit-modal.is-chat-open .khl-unit-modal__dialog {
    height: var(--khl-chat-dialog-height);
}
.khl-unit-modal.is-chat-open .khl-unit-popup {
    position: absolute;
    inset: 0;
    display: flex;
    flex-direction: column;
}
.khl-unit-modal.is-chat-open .khl-unit-popup__head,
.khl-unit-modal.is-chat-open .khl-unit-popup__booking-wrap {
    flex: 0 0 auto;
    position: relative;
    z-index: 2;
}
.khl-unit-modal.is-chat-open .khl-unit-popup__grid {
    flex: 1 1 auto;
    grid-template-rows: minmax(0, 1fr);
    height: auto;
    min-height: 0;
    overflow: hidden;
}
.khl-unit-modal.is-chat-open .khl-unit-popup__side {
    height: 100%;
    min-height: 0;
    display: flex;
    padding: 0;
    overflow: hidden;
}
.khl-unit-modal.is-chat-open .khl-unit-popup__media {
    height: 100%;
    min-height: 0;
    display: flex;
    flex-direction: column;
    overflow: hidden;
}
.khl-unit-modal.is-chat-open .khl-unit-popup__gallery {
    flex: 1 1 auto;
    min-height: 0;
}
.khl-unit-modal.is-chat-open .khl-unit-popup__image {
    flex: 1 1 auto;
    min-height: 0;
    height: auto;
    max-height: none;
    aspect-ratio: auto;
}
.khl-unit-modal.is-chat-open .khl-unit-popup__quick,
.khl-unit-modal.is-chat-open .khl-unit-popup__actions {
    flex: 0 0 auto;
}
.khl-unit-modal.is-chat-open .khl-unit-chat {
    flex: 1 1 auto;
    height: auto;
    margin: 0;
}
.khl-unit-chat__head {
    min-height: 40px;
    padding: 10px 12px;
    border-bottom: 1px solid #d7e3f0;
    background: #f4f8fc;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
}
.khl-unit-chat__title {
    margin: 0;
    font-size: 18px;
    font-weight: 800;
    color: #062b5b;
}
.khl-unit-chat__close {
    border: 1px solid #dbeafe;
    background: #ffffff;
    color: #475569;
    border-radius: 7px;
    padding: 5px 10px;
    font-weight: 700;
    cursor: pointer;
}
.khl-unit-chat__messages {
    flex: 1;
    min-height: 0;
    overflow-y: auto;
    padding: 14px;
}
.khl-unit-chat__empty {
    height: 100%;
    min-height: 260px;
    display: flex;
    align-items: center;
    justify-content: center;
    text-align: center;
    color: #94a3b8;
    font-weight: 700;
}
.khl-unit-chat__message {
    display: flex;
    flex-direction: column;
    gap: 4px;
    margin-bottom: 12px;
    max-width: 78%;
}
.khl-unit-chat__message.is-mine {
    margin-left: auto;
    align-items: flex-end;
}
.khl-unit-chat__message.is-admin {
    margin-right: auto;
    align-items: flex-start;
}
.khl-unit-chat__message.is-director,
.khl-unit-chat__message.is-sales {
    margin-right: auto;
    align-items: flex-start;
}
.khl-unit-chat__sender {
    font-size: 11px;
    color: #64748b;
    font-weight: 800;
}
.khl-unit-chat__bubble {
    padding: 10px 13px;
    border-radius: 12px;
    background: #eaf4ff;
    color: #10233d;
    font-size: 14px;
    line-height: 1.45;
}
.khl-unit-chat__message.is-mine .khl-unit-chat__bubble {
    background: #0b74d1;
    color: #ffffff;
}
.khl-unit-chat__time {
    color: #94a3b8;
    font-size: 10px;
}
.khl-unit-chat__form {
    display: flex;
    gap: 8px;
    padding: 12px;
    border-top: 1px solid #d7e3f0;
    background: #f4f8fc;
    flex: 0 0 auto;
}
.khl-unit-chat__input {
    flex: 1;
    min-width: 0;
    min-height: 44px;
    padding: 0 12px;
    border: 1px solid #b9d9f7;
    border-radius: 8px;
    outline: none;
    color: #0f172a;
}
.khl-unit-chat__input:focus {
    border-color: #2563eb;
    box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.08);
}
.khl-unit-chat__send {
    min-width: 72px;
    border: 0;
    border-radius: 8px;
    background: #0756a3;
    color: #ffffff;
    font-weight: 800;
    cursor: pointer;
}
.khl-unit-chat__send:disabled {
    background: #cbd5e1;
    cursor: not-allowed;
}
.khl-unit-popup__booking-wrap {
    padding: 14px;
    display: flex;
    justify-content: center;
    border-top: 1px solid #d7e3f0;
}
.khl-unit-popup__booking {
    min-width: 180px;
    background: #f59e0b;
    border-color: #f59e0b;
    color: #ffffff;
    min-height: 44px;
}
.khl-unit-popup__booking:disabled {
    background: #cbd5e1;
    border-color: #cbd5e1;
    cursor: not-allowed;
}

@media (max-width: 820px) {
    .khl-unit-modal {
        align-items: flex-start;
        padding: 10px;
        overflow-y: auto;
    }
    .khl-unit-modal__dialog {
        max-height: none;
        overflow: visible;
    }
    .khl-unit-popup__grid {
        grid-template-columns: 1fr;
        min-height: 0;
    }
    .khl-unit-popup__media {
        border-right: 0;
        border-bottom: 1px solid #e5e7eb;
    }
    .khl-unit-popup__gallery,
    .khl-unit-popup__image {
        aspect-ratio: 16 / 10;
        max-height: 280px;
    }
    .khl-unit-popup__side {
        max-height: none;
        overflow: visible;
    }
    .khl-unit-chat {
        margin: -16px -20px;
    }
    .khl-unit-modal.is-chat-open .khl-unit-popup__grid {
        height: auto;
    }
    .khl-unit-popup__rows {
        grid-template-columns: 1fr;
    }
    .khl-unit-popup__booking-wrap {
        position: sticky;
        bottom: 0;
        background: #ffffff;
        z-index: 2;
    }
}

@media (max-width: 480px) {
    .khl-unit-popup__head {
        flex-direction: column;
        gap: 6px;
        padding-right: 44px;
    }
    .khl-unit-popup__price {
        font-size: 20px;
    }
    .khl-unit-popup__quick {
        grid-template-columns: 1fr;
    }
    .khl-unit-popup__quick div {
        border-right: 0;
        border-bottom: 1px solid #e5e7eb;
    }
}
