/* ===========================================================================
   AvtoBooking — оформление
   =========================================================================== */

:root {
    --ab-brand: #0A5AFF;
    --ab-brand-dark: #0642c4;
    --ab-line: #e9ecef;
    --ab-line-soft: #eef1f5;
    --ab-muted: #6c757d;
    --ab-slot: 46px;
    --ab-row: 46px;
    --ab-group: 28px;
    --ab-hours: 38px;
}

body {
    font-family: -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
    font-size: .95rem;
    color: #212529;
}

.card {
    border: 0;
    border-radius: .75rem;
}

.card-header {
    border-bottom: 1px solid var(--ab-line);
    border-top-left-radius: .75rem !important;
    border-top-right-radius: .75rem !important;
    padding: .7rem 1rem;
}

.btn-primary {
    --bs-btn-bg: var(--ab-brand);
    --bs-btn-border-color: var(--ab-brand);
    --bs-btn-hover-bg: var(--ab-brand-dark);
    --bs-btn-hover-border-color: var(--ab-brand-dark);
    --bs-btn-active-bg: var(--ab-brand-dark);
    --bs-btn-active-border-color: var(--ab-brand-dark);
}

.btn-outline-primary {
    --bs-btn-color: var(--ab-brand);
    --bs-btn-border-color: var(--ab-brand);
    --bs-btn-hover-bg: var(--ab-brand);
    --bs-btn-hover-border-color: var(--ab-brand);
}

/* ---------------------------------------------------------------------------
   Шапка
   --------------------------------------------------------------------------- */
.ab-header {
    position: sticky;
    top: 0;
    z-index: 1030;
    background: #fff;
    border-bottom: 1px solid var(--ab-line);
    box-shadow: 0 1px 2px rgba(16, 24, 40, .04);
}

.ab-brand {
    display: inline-flex;
    align-items: center;
    gap: .55rem;
    font-weight: 700;
    font-size: 1.12rem;
    letter-spacing: -.01em;
    color: #101828;
    text-decoration: none;
}

.ab-brand:hover {
    color: var(--ab-brand);
}

.ab-nav {
    display: flex;
    align-items: center;
    gap: .15rem;
    overflow-x: auto;
}

.ab-nav-link {
    padding: .35rem .7rem;
    border-radius: .5rem;
    color: #475467;
    text-decoration: none;
    font-size: .92rem;
    white-space: nowrap;
}

.ab-nav-link:hover {
    background: #f2f5fa;
    color: #101828;
}

.ab-nav-link.active {
    background: rgba(10, 90, 255, .1);
    color: var(--ab-brand);
    font-weight: 600;
}

/* ---------------------------------------------------------------------------
   Экран входа
   --------------------------------------------------------------------------- */
.ab-auth {
    background: linear-gradient(160deg, #eef3ff 0%, #f7f9fc 45%, #eef3ff 100%);
    padding: 1.5rem;
}

.ab-auth-card {
    width: 100%;
    max-width: 420px;
    border-radius: 1rem;
}

/* ---------------------------------------------------------------------------
   Шахматка
   --------------------------------------------------------------------------- */
.bb-scroll {
    overflow: auto;
    max-height: calc(100vh - 245px);
    min-height: 320px;
    overscroll-behavior: contain;
}

.bb-inner {
    display: flex;
    min-width: max-content;
    align-items: flex-start;
}

.bb-labels {
    position: sticky;
    left: 0;
    z-index: 5;
    flex: 0 0 206px;
    width: 206px;
    background: #fff;
    border-right: 1px solid var(--ab-line);
}

.bb-corner {
    position: sticky;
    top: 0;
    z-index: 6;
    display: flex;
    align-items: center;
    height: var(--ab-hours);
    padding: 0 .85rem;
    background: #f8f9fb;
    border-bottom: 1px solid var(--ab-line);
    font-size: .72rem;
    letter-spacing: .04em;
    text-transform: uppercase;
    color: var(--ab-muted);
}

.bb-group {
    display: flex;
    align-items: center;
    height: var(--ab-group);
    padding: 0 .85rem;
    background: #f1f4f9;
    border-bottom: 1px solid var(--ab-line);
    font-size: .76rem;
    font-weight: 600;
    color: #475467;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.bb-row-label {
    display: flex;
    flex-direction: column;
    justify-content: center;
    height: var(--ab-row);
    padding: 0 .85rem;
    border-bottom: 1px solid var(--ab-line-soft);
    font-size: .84rem;
    line-height: 1.15;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.bb-row-label .bb-mech {
    font-size: .72rem;
    color: var(--ab-muted);
    overflow: hidden;
    text-overflow: ellipsis;
}

.bb-row-label.is-closed {
    color: #98a2b3;
}

.bb-lanes {
    position: relative;
    flex: 1 0 auto;
}

.bb-hours {
    position: sticky;
    top: 0;
    z-index: 4;
    display: flex;
    height: var(--ab-hours);
    background: #fff;
    border-bottom: 1px solid var(--ab-line);
}

.bb-hour {
    flex: 0 0 calc(var(--ab-slot) * 2);
    width: calc(var(--ab-slot) * 2);
    padding-left: .35rem;
    border-left: 1px solid var(--ab-line);
    font-size: .72rem;
    color: var(--ab-muted);
    line-height: var(--ab-hours);
}

.bb-group-lane {
    height: var(--ab-group);
    background: #f1f4f9;
    border-bottom: 1px solid var(--ab-line);
}

.bb-lane {
    position: relative;
    height: var(--ab-row);
    border-bottom: 1px solid var(--ab-line-soft);
    background-image: repeating-linear-gradient(
        to right,
        transparent 0,
        transparent calc(var(--ab-slot) - 1px),
        var(--ab-line-soft) calc(var(--ab-slot) - 1px),
        var(--ab-line-soft) var(--ab-slot)
    );
}

.bb-lane::after {
    content: "";
    position: absolute;
    inset: 0;
    background-image: repeating-linear-gradient(
        to right,
        transparent 0,
        transparent calc(var(--ab-slot) * 2 - 1px),
        #e2e6ea calc(var(--ab-slot) * 2 - 1px),
        #e2e6ea calc(var(--ab-slot) * 2)
    );
    pointer-events: none;
}

.bb-lane.is-closed {
    background-color: #fafbfc;
    background-image: repeating-linear-gradient(
        45deg,
        rgba(0, 0, 0, .035) 0 6px,
        transparent 6px 12px
    );
}

.bb-lane.is-closed::after {
    display: none;
}

.bb-booking {
    position: absolute;
    top: 4px;
    bottom: 4px;
    display: flex;
    flex-direction: column;
    justify-content: center;
    gap: 1px;
    padding: 2px 8px 2px 7px;
    border-radius: .4rem;
    border-left: 3px solid rgba(0, 0, 0, .18);
    font-size: .72rem;
    line-height: 1.1;
    overflow: hidden;
    cursor: grab;
    user-select: none;
    box-shadow: 0 1px 2px rgba(16, 24, 40, .12);
    transition: box-shadow .12s ease, transform .12s ease;
}

.bb-booking:hover {
    box-shadow: 0 3px 10px rgba(16, 24, 40, .18);
    z-index: 3;
}

.bb-booking .bb-b-time {
    font-weight: 700;
    font-size: .7rem;
    opacity: .95;
}

.bb-booking .bb-b-client {
    font-weight: 600;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.bb-booking .bb-b-meta {
    font-size: .68rem;
    opacity: .9;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.bb-booking.is-cancelled {
    opacity: .55;
    text-decoration: line-through;
}

.bb-booking.is-dragging {
    opacity: .8;
    cursor: grabbing;
    z-index: 4;
}

.bb-booking .bb-resize {
    position: absolute;
    top: 0;
    right: 0;
    width: 9px;
    height: 100%;
    cursor: ew-resize;
}

.bb-selection {
    position: absolute;
    top: 4px;
    bottom: 4px;
    border-radius: .4rem;
    border: 2px dashed var(--ab-brand);
    background: rgba(10, 90, 255, .1);
    pointer-events: none;
    z-index: 2;
}

.bb-now {
    position: absolute;
    top: 0;
    bottom: 0;
    width: 2px;
    background: #e5484d;
    z-index: 2;
    pointer-events: none;
}

.bb-now::before {
    content: "";
    position: absolute;
    top: -3px;
    left: -3px;
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: #e5484d;
}

.bb-legend {
    gap: .15rem;
    align-items: center;
}

.bb-legend-item {
    display: inline-flex;
    align-items: center;
    gap: .35rem;
    border: 1px solid transparent;
    background: none;
    border-radius: .45rem;
    padding: .18rem .45rem;
    font-size: .78rem;
    color: #475467;
}

.bb-legend-item:hover {
    background: #f2f5fa;
}

.bb-legend-item.is-off {
    opacity: .4;
    text-decoration: line-through;
}

.bb-legend-dot {
    width: 10px;
    height: 10px;
    border-radius: 3px;
    display: inline-block;
    border: 1px solid rgba(0, 0, 0, .1);
}

.bb-empty {
    padding: 3rem 1rem;
    text-align: center;
    color: var(--ab-muted);
}

/* ---------------------------------------------------------------------------
   Карточка брони в модальном окне
   --------------------------------------------------------------------------- */
.bb-info-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(190px, 1fr));
    gap: .75rem 1rem;
}

.bb-info-label {
    font-size: .72rem;
    text-transform: uppercase;
    letter-spacing: .03em;
    color: var(--ab-muted);
}

.bb-info-value {
    font-size: .93rem;
}

.bb-status-buttons .btn {
    flex: 1 1 auto;
}

.bb-client-results {
    border: 1px solid var(--ab-line);
    border-radius: .5rem;
    max-height: 220px;
    overflow-y: auto;
}

.bb-client-item {
    display: block;
    width: 100%;
    text-align: left;
    border: 0;
    border-bottom: 1px solid var(--ab-line-soft);
    background: #fff;
    padding: .5rem .7rem;
    font-size: .88rem;
}

.bb-client-item:hover {
    background: #f5f8ff;
}

/* ---------------------------------------------------------------------------
   Таблицы
   --------------------------------------------------------------------------- */
.table-ab thead th {
    background: #f8f9fb;
    font-size: .76rem;
    text-transform: uppercase;
    letter-spacing: .03em;
    color: var(--ab-muted);
    font-weight: 600;
    border-bottom: 1px solid var(--ab-line);
}

.table-ab tbody td {
    vertical-align: middle;
}

.ab-side-link {
    display: block;
    padding: .35rem .6rem;
    border-radius: .45rem;
    color: #475467;
    text-decoration: none;
    font-size: .9rem;
}

.ab-side-link:hover {
    background: #f2f5fa;
    color: #101828;
}

.ab-side-link.active {
    background: rgba(10, 90, 255, .1);
    color: var(--ab-brand);
    font-weight: 600;
}

.ab-toast {
    position: fixed;
    right: 1rem;
    bottom: 1rem;
    z-index: 2000;
    display: flex;
    flex-direction: column;
    gap: .5rem;
}

@media (max-width: 767.98px) {
    .bb-scroll {
        max-height: calc(100vh - 300px);
    }

    .bb-labels {
        flex: 0 0 150px;
        width: 150px;
    }

    .bb-row-label,
    .bb-group {
        padding: 0 .55rem;
    }
}
