/* === Variables === */
:root {
    --sidebar-width: 250px;
    --topbar-height: 56px;
    --sidebar-bg: #343a40;
    --sidebar-text: rgba(255, 255, 255, 0.65);
    --sidebar-hover-bg: rgba(255, 255, 255, 0.1);
    --sidebar-active-bg: rgba(255, 255, 255, 0.15);
    --sidebar-active-text: #ffffff;
    --content-bg: #f4f6f9;
}

body {
    background-color: var(--content-bg);
}

/* === Sidebar === */

.sidebar {
    position: fixed;
    top: 0;
    left: 0;
    bottom: 0;
    width: var(--sidebar-width);
    background-color: var(--sidebar-bg);
    display: flex;
    flex-direction: column;
    overflow-y: auto;
    z-index: 1050;
    transition: transform 0.25s ease;
}

.sidebar-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 1rem;
    height: var(--topbar-height);
    border-bottom: 1px solid rgba(255, 255, 255, 0.1);
    flex-shrink: 0;
}

.sidebar-brand {
    color: #ffffff;
    font-size: 1.15rem;
    font-weight: 700;
    text-decoration: none;
    letter-spacing: 0.3px;
}

.sidebar-brand:hover {
    color: #ffffff;
}

.sidebar-close-btn {
    background: none;
    border: none;
    color: var(--sidebar-text);
    font-size: 1.4rem;
    line-height: 1;
    padding: 2px 6px;
    cursor: pointer;
}

.sidebar-close-btn:hover {
    color: #ffffff;
}

.sidebar-nav {
    padding: 0.5rem 0;
    flex: 1;
}

.sidebar-menu {
    list-style: none;
    padding: 0;
    margin: 0;
}

.sidebar-icon {
    width: 18px;
    height: 18px;
    flex-shrink: 0;
    margin-right: 10px;
}

.sidebar-link {
    display: flex;
    align-items: center;
    padding: 0.625rem 1.25rem;
    color: var(--sidebar-text);
    text-decoration: none;
    font-size: 0.9rem;
    transition: background-color 0.15s, color 0.15s;
    white-space: nowrap;
}

.sidebar-link:hover {
    background-color: var(--sidebar-hover-bg);
    color: var(--sidebar-active-text);
}

.sidebar-link.active {
    background-color: var(--sidebar-active-bg);
    color: var(--sidebar-active-text);
    font-weight: 500;
}

.sidebar-sublink {
    padding-left: 2.75rem;
    font-size: 0.83rem;
}

.sidebar-sublink::before {
    content: '›';
    margin-right: 6px;
    opacity: 0.5;
}

.sidebar-footer {
    border-top: 1px solid rgba(255, 255, 255, 0.1);
    padding: 0.5rem 0;
    flex-shrink: 0;
}

.sidebar-username {
    padding: 0.5rem 1.25rem;
    color: var(--sidebar-text);
    font-size: 0.85rem;
    font-weight: 500;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.sidebar-username-link {
    font-size: 0.85rem;
    font-weight: 500;
    padding: 0.5rem 1.25rem;
}

.sidebar-logout {
    background: none;
    border: none;
    width: 100%;
    text-align: left;
    cursor: pointer;
}

/* === Overlay (мобильные) === */

.sidebar-overlay {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.5);
    z-index: 1040;
}

.sidebar-overlay.active {
    display: block;
}

/* === Topbar (мобильные) === */

.topbar {
    height: var(--topbar-height);
    background: #ffffff;
    border-bottom: 1px solid #e9ecef;
    box-shadow: 0 1px 4px rgba(0, 0, 0, 0.08);
    display: flex;
    align-items: center;
    padding: 0 0.75rem;
    position: sticky;
    top: 0;
    z-index: 100;
    gap: 8px;
}

.topbar-toggle {
    background: none;
    border: none;
    padding: 8px 6px;
    cursor: pointer;
    display: flex;
    flex-direction: column;
    justify-content: center;
    gap: 5px;
    flex-shrink: 0;
    border-radius: 6px;
    transition: background 0.15s;
}

.topbar-toggle:hover {
    background: #f0f2f5;
}

.topbar-toggle span {
    display: block;
    width: 22px;
    height: 2px;
    background-color: #343a40;
    border-radius: 1px;
}

.topbar-brand {
    font-weight: 700;
    font-size: 1.1rem;
    color: #343a40;
    text-decoration: none;
}

.topbar-brand:hover {
    color: #343a40;
}

/* === Main wrapper === */

#main-wrapper {
    min-height: 100vh;
    display: flex;
    flex-direction: column;
}

.page-content {
    flex: 1;
    padding: 1.5rem;
}

@media (max-width: 991.98px) {
    .page-content {
        padding: 1rem 0;
    }

    .page-content .container-fluid {
        padding-left: 0;
        padding-right: 0;
    }

    .page-content h1 {
        padding-left: 1rem;
        padding-right: 1rem;
    }

    .page-content .alert {
        margin-left: 1rem;
        margin-right: 1rem;
    }

    .card {
        border-radius: 0;
        border-left: none;
        border-right: none;
    }

    .card-body.p-0 {
        overflow-x: auto;
    }
}

/* === Quantity input-group in product rows === */

.table .input-group .btn-outline-secondary {
    border-color: #0d6efd;
    color: #0d6efd;
}

.table .input-group .btn-outline-secondary:hover:not(:disabled) {
    background-color: #0d6efd;
    border-color: #0d6efd;
    color: #fff;
}

.table .input-group .form-control {
    border-color: #0d6efd;
}

.table .input-group .form-control:focus {
    border-color: #0d6efd;
    box-shadow: 0 0 0 0.2rem rgba(13, 110, 253, 0.2);
}

/* === Order panel (sticky bottom) === */

#order-panel {
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    z-index: 200;
    background: #fff;
    border-top: 1px solid #dee2e6;
    box-shadow: 0 -2px 8px rgba(0, 0, 0, 0.10);
}

@media (min-width: 992px) {
    #order-panel {
        left: var(--sidebar-width);
    }
}

.order-panel-inner {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 8px 1rem;
    gap: 12px;
}

.order-panel-stats {
    flex: 1;
    min-width: 0;
    font-size: 0.875rem;
    color: #343a40;
    line-height: 1.5;
}

.order-panel-actions {
    display: flex;
    flex-direction: row;
    align-items: center;
    gap: 6px;
    flex-shrink: 0;
}

.order-panel-reset {
    background: none;
    border: 1px solid #ced4da;
    border-radius: 6px;
    width: 34px;
    height: 34px;
    display: flex;
    align-items: center;
    justify-content: center;
    color: #6c757d;
    cursor: pointer;
    padding: 0;
    transition: background 0.15s, color 0.15s, border-color 0.15s;
}

.order-panel-reset:hover {
    background: #f8d7da;
    border-color: #f5c2c7;
    color: #842029;
}

.order-panel-buy {
    background: #0d6efd;
    border: none;
    border-radius: 6px;
    height: 34px;
    display: flex;
    align-items: center;
    justify-content: center;
    color: #fff;
    cursor: pointer;
    padding: 0 16px;
    font-size: 0.875rem;
    font-weight: 500;
    white-space: nowrap;
    transition: background 0.15s;
}

.order-panel-buy svg {
    width: 18px;
    height: 18px;
}

.order-panel-buy:hover {
    background: #0b5ed7;
}

/* Add bottom padding to page so panel doesn't cover content */
.page-content {
    padding-bottom: 80px;
}

/* === Desktop: sidebar always visible === */

@media (min-width: 992px) {
    #main-wrapper {
        margin-left: var(--sidebar-width);
    }
}

/* === Mobile: sidebar hidden by default === */

@media (max-width: 991.98px) {
    .sidebar {
        transform: translateX(-100%);
    }

    .sidebar.open {
        transform: translateX(0);
    }
}

/* === Category tabs in topbar (mobile) === */

.topbar-categories-wrap {
    flex: 1;
    overflow-x: auto;
    overflow-y: hidden;
    display: flex;
    align-items: center;
    min-width: 0;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: none;
    /* fade edges to hint scrollability */
    -webkit-mask-image: linear-gradient(to right, transparent 0, #000 12px, #000 calc(100% - 12px), transparent 100%);
    mask-image: linear-gradient(to right, transparent 0, #000 12px, #000 calc(100% - 12px), transparent 100%);
}

.topbar-categories-wrap::-webkit-scrollbar {
    display: none;
}

.topbar-categories {
    display: flex;
    gap: 6px;
    flex-wrap: nowrap;
    padding: 4px 12px;
}

.topbar-category-btn {
    flex-shrink: 0;
    background: #f0f2f5;
    border: none;
    border-radius: 20px;
    padding: 6px 14px;
    font-size: 0.8rem;
    font-weight: 500;
    color: #495057;
    cursor: pointer;
    white-space: nowrap;
    line-height: 1.35;
    letter-spacing: 0.1px;
    transition: background 0.18s, color 0.18s, box-shadow 0.18s;
    -webkit-tap-highlight-color: transparent;
    outline: none;
}

.topbar-category-btn.active {
    background: #343a40;
    color: #fff;
    box-shadow: 0 2px 6px rgba(52, 58, 64, 0.35);
}

.topbar-category-btn:hover:not(.active) {
    background: #dee2e6;
    color: #212529;
}

.topbar-category-btn:active {
    transform: scale(0.97);
}

/* === Sidebar category links === */

.sidebar-cat-btn {
    -webkit-tap-highlight-color: transparent;
}

/* === Print === */

@media print {
    .no-print {
        display: none !important;
    }

    #main-wrapper {
        margin-left: 0 !important;
    }
}

/* === Admin orders: selected actions bar === */

#selection-bar {
    z-index: 210;
}

.selection-bar-select {
    width: 220px;
    max-width: 100%;
}

.selection-bar-actions .btn {
    white-space: nowrap;
}

@media (max-width: 767.98px) {
    #selection-bar {
        padding-left: 0.75rem !important;
        padding-right: 0.75rem !important;
    }

    .selection-bar-select {
        width: 100%;
    }

    .selection-bar-actions {
        width: 100%;
    }

    .selection-bar-actions .btn {
        width: 100%;
    }
}
