:root {
    --app-primary: #315b7d;
    --app-bg: #f4f6f9;
    --app-text: #343a40;
}

html,
body {
    min-height: 100%;
}

body {
    margin: 0;
    background: var(--app-bg);
    color: var(--app-text);
    font-size: 14px;
}

.login-page {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 24px;
}

.login-wrapper {
    width: 100%;
    max-width: 390px;
}

.login-brand {
    text-align: center;
    margin-bottom: 24px;
}

.login-logo {
    width: 58px;
    height: 58px;
    margin: 0 auto 12px;
    border-radius: 14px;

    display: flex;
    align-items: center;
    justify-content: center;

    background: var(--app-primary);
    color: #fff;

    font-size: 28px;
}

.login-brand h1 {
    margin: 0;
    font-size: 25px;
    font-weight: 600;
}

.login-brand p {
    margin: 4px 0 0;
    color: #6c757d;
}

.login-card {
    border: 0;
    border-radius: 12px;
}

.form-label {
    font-size: 13px;
    font-weight: 500;
}

.input-group-text {
    background: #fff;
}

.btn-primary {
    background: var(--app-primary);
    border-color: var(--app-primary);
}

.btn-primary:hover,
.btn-primary:focus {
    background: #284d6b;
    border-color: #284d6b;
}

.login-footer {
    margin-top: 20px;
    text-align: center;
    font-size: 12px;
    color: #8a939b;
}


/* ===== Panel administratora ===== */

.app-layout {
    display: flex;
    min-height: 100vh;
}

.app-sidebar {
    width: 230px;
    flex-shrink: 0;
    background: #253b50;
    color: #fff;
    min-height: 100vh;
}

.sidebar-brand {
    height: 65px;
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 0 20px;
    font-size: 19px;
    font-weight: 600;
    border-bottom: 1px solid rgba(255,255,255,.1);
}

.sidebar-brand i {
    font-size: 24px;
}

.sidebar-section {
    color: #92a6b8;
    font-size: 10px;
    font-weight: 700;
    letter-spacing: 1px;
    padding: 24px 20px 8px;
}

.sidebar-nav a {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 11px 20px;
    color: #cbd6df;
    text-decoration: none;
    font-size: 13px;
}

.sidebar-nav a i {
    font-size: 17px;
}

.sidebar-nav a:hover,
.sidebar-nav a.active {
    background: rgba(255,255,255,.09);
    color: #fff;
}

.sidebar-nav a.active {
    border-left: 3px solid #83b9df;
    padding-left: 17px;
}

.app-main {
    flex: 1;
    min-width: 0;
}

.app-header {
    height: 65px;
    padding: 0 24px;
    background: #fff;
    border-bottom: 1px solid #e5e9ed;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
}

#locationSelect {
    width: 220px;
}

.app-content {
    padding: 24px;
}

.stat-card {
    background: #fff;
    border: 1px solid #e9edf1;
    border-radius: 10px;
    padding: 20px;
    min-height: 145px;
}

.stat-icon {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 36px;
    height: 36px;
    border-radius: 9px;
    margin-bottom: 12px;
    font-size: 18px;
}

.stat-label {
    color: #6c757d;
    font-size: 12px;
}

.stat-value {
    font-size: 28px;
    font-weight: 700;
}

.dashboard-card {
    border: 1px solid #e9edf1;
    border-radius: 10px;
}

.dashboard-card .card-header {
    background: #fff;
    border-bottom: 1px solid #edf0f3;
    padding: 15px 18px;
    font-weight: 600;
    font-size: 13px;
}

.dashboard-data-row {
    display: flex;
    justify-content: space-between;
    padding: 10px 0;
    border-bottom: 1px solid #f0f2f4;
    font-size: 13px;
}

.dashboard-data-row:last-child {
    border-bottom: 0;
}

@media (max-width: 991px) {
    .app-sidebar {
        position: fixed;
        z-index: 1050;
        left: -230px;
        top: 0;
        transition: left .2s;
    }

    .app-sidebar.open {
        left: 0;
    }

    .app-header {
        padding: 0 12px;
    }

    .app-content {
        padding: 16px;
    }

    #locationSelect {
        width: 150px;
    }
}


/* ===== Stałe menu i sticky header ===== */

/* Lewy panel pozostaje w miejscu podczas przewijania */
.app-sidebar {
    position: sticky;
    top: 0;
    height: 100vh;
    min-height: 0;
    overflow-y: auto;
    overscroll-behavior: contain;
}

/* Górny pasek pozostaje widoczny */
.app-header {
    position: sticky;
    top: 0;
    z-index: 1020;
}

/* Zachowanie wysuwanego menu na urządzeniach mobilnych */
@media (max-width: 991px) {
    .app-sidebar {
        position: fixed;
        top: 0;
        height: 100dvh;
        min-height: 0;
        overflow-y: auto;
    }
}


/* ===== Zwijane menu boczne ===== */

@media (min-width: 992px) {
    .app-sidebar {
        transition: width .2s ease;
    }

    .sidebar-brand span,
    .sidebar-section,
    .sidebar-nav a {
        transition: opacity .15s ease;
    }

    body.sidebar-collapsed .app-sidebar {
        width: 64px;
    }

    body.sidebar-collapsed .sidebar-brand {
        justify-content: center;
        padding: 0;
    }

    body.sidebar-collapsed .sidebar-brand span,
    body.sidebar-collapsed .sidebar-section {
        display: none;
    }

    body.sidebar-collapsed .sidebar-nav a {
        justify-content: center;
        gap: 0;
        padding: 12px 0;
        font-size: 0;
    }

    body.sidebar-collapsed .sidebar-nav a i {
        font-size: 20px;
    }

    body.sidebar-collapsed .sidebar-nav a.active {
        border-left: 3px solid #83b9df;
        padding-left: 0;
    }
}

/* ===== Mapa boksów ===== */

.box-map-legend {
    display: flex;
    flex-wrap: wrap;
    gap: 12px 20px;
}

.box-map-legend-item {
    display: inline-flex;
    align-items: center;
    gap: 7px;
    font-size: 12px;
}

.box-map-row {
    padding: 14px;
    background: #f8fafc;
    border: 1px solid #e9edf1;
    border-radius: 8px;
}

.box-map-track {
    display: flex;
    flex-wrap: wrap;
    gap: 12px 8px;
}

.box-map-item {
    width: 38px;
    min-height: 43px;
    padding: 4px 0;
    border: 1px solid transparent;
    border-radius: 6px;
    background: transparent;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 5px;
    cursor: pointer;
}

.box-map-item:hover,
.box-map-item.selected {
    background: #e5eef8;
    border-color: #9bbbdc;
}

.box-map-dot {
    display: inline-block;
    width: 19px;
    height: 19px;
    border-radius: 50%;
    flex-shrink: 0;
}

.box-map-number {
    font-size: 10px;
    line-height: 1;
    color: #475569;
}

.box-map-item:focus-visible {
    outline: 2px solid #0d6efd;
    outline-offset: 2px;
}


/* ===== Mapa boksów — panel szczegółów ===== */

@media (min-width: 992px) {
    #boxMapView .card-body {
        display: grid;
        grid-template-columns: minmax(0, 1fr) 300px;
        gap: 20px;
        align-items: start;
    }

    #boxMapContent {
        grid-column: 1;
        grid-row: 1;
        min-width: 0;
    }

    #boxMapDetails {
        grid-column: 2;
        grid-row: 1;
        position: sticky;
        top: 85px;
        width: 100%;
        max-width: none !important;
        margin-bottom: 0 !important;
        background: #fff;
    }
}

@media (max-width: 991px) {
    #boxMapDetails {
        max-width: none !important;
    }
}

/* Klienci — DataTables */
#clientsView .dt-container .dt-layout-row {
    margin-top: .5rem;
    margin-bottom: .5rem;
}

#clientsView .client-type-icon {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 1.75rem;
    font-size: 1rem;
}

#clientsView .client-type-icon:focus-visible {
    outline: 2px solid var(--app-primary);
    outline-offset: 2px;
}

#clientsView .dt-paging .pagination {
    flex-wrap: wrap;
}

/* Cennik — kontrolki zgodne z tabelą klientów */
#pricingView .dt-container .dt-layout-row { margin-top: .5rem; margin-bottom: .5rem; }
#pricingView .dt-paging .pagination { flex-wrap: wrap; }

/* Boksy — kompaktowa tabela */
#boxesView .dt-container .dt-layout-row { margin-top: .5rem; margin-bottom: .5rem; }
#boxesView .dt-paging .pagination { flex-wrap: wrap; }

/* Lokalizacje — kompaktowy widok listy */
#locationsView .dt-container .dt-layout-row { margin-top: .5rem; margin-bottom: .5rem; }
#locationsView .dt-paging .pagination { flex-wrap: wrap; }
#locationsSearch { max-width: 350px; }

/* Historia klienta przewija się wewnątrz istniejącego modala. */
#clientCreateModal .client-rental-history {
    table-layout: fixed;
    width: 100%;
    min-width: 600px;
}

#clientCreateModal .client-rental-history :is(th, td) {
    overflow-wrap: anywhere;
}
