/* Quick Order Page - Full viewport sticky layout */

/* Our own wrapper replaces .container so we have full control over width/padding */
.quick-order-container {
    width: 100%;
    max-width: 1320px; /* matches Bootstrap .container-xxl — adjust if theme differs */
    margin-left: auto;
    margin-right: auto;
    padding-left: 1.5rem;
    padding-right: 1.5rem;
}

/* Override Shopware's base layout to allow full-height flex.
   Height is set dynamically via JS (--quick-order-top) to fit any theme. */
.quick-order-page {
    display: flex;
    flex-direction: column;
    height: calc(100vh - var(--quick-order-top, 120px));
    padding-top: 1rem;
    overflow: hidden;
}

/* Header */
.quick-order-header {
    flex-shrink: 0;
    margin-bottom: 0.75rem;
}

.quick-order-header h1 {
    font-size: 1.75rem;
    font-weight: 600;
    margin-bottom: 0.25rem;
}

.quick-order-header p {
    margin-bottom: 0;
}

/* Category Filter Buttons — sticky, no scroll */
.quick-order-filters {
    flex-shrink: 0;
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
    margin-bottom: 0.75rem;
}

.quick-order-filter-btn {
    font-size: 0.875rem;
    padding: 0.375rem 0.75rem;
}

.quick-order-filter-btn.active {
    font-weight: 600;
}

/* Sort/Search Controls — sticky, no scroll */
.quick-order-controls {
    flex-shrink: 0;
    gap: 1rem;
    margin-bottom: 0.75rem;
}

.quick-order-search input {
    min-width: 250px;
}

/* Main body: table + sidebar side by side, fills remaining height */
.quick-order-body {
    flex: 1 1 0;
    display: flex;
    flex-direction: row;
    gap: 1.5rem;
    min-height: 0; /* critical: allows flex children to shrink below content size */
    padding-bottom: 1rem;
}

/* Scrollable product table area */
.quick-order-table-area {
    flex: 1 1 0;
    min-height: 0;
    overflow-y: auto;
    overflow-x: hidden;
}

/* Sidebar — fills height, internal scroll for cart items */
.quick-order-sidebar {
    flex-shrink: 0;
    width: 320px;
    display: flex;
    flex-direction: column;
    min-height: 0;
}

.quick-order-sidebar .card {
    display: flex;
    flex-direction: column;
    height: 100%;
    border-radius: 0.5rem;
    background: #ffffff;
    border: 1px solid #dee2e6;
    overflow: hidden;
}

.quick-order-sidebar .card-header {
    flex-shrink: 0;
    background-color: #f8f9fa;
    border-bottom: 1px solid #dee2e6;
    padding: 1rem 1.25rem;
    font-weight: 600;
    font-size: 1rem;
}

.quick-order-sidebar .card-body {
    flex: 1 1 0;
    padding: 1.25rem;
    overflow-y: auto;
    min-height: 0;
}

.quick-order-sidebar .card-footer {
    flex-shrink: 0;
    background-color: #f8f9fa;
    border-top: 1px solid #dee2e6;
    padding: 1rem 1.25rem;
}

/* Category Cards */
.quick-order-category {
    border-radius: 0.5rem;
    overflow: visible; /* must NOT be hidden — breaks sticky inside */
    margin-bottom: 1.5rem;
}

/* Bootstrap .card and .card-body set overflow:hidden — breaks sticky th */
.quick-order-table-area .card,
.quick-order-table-area .card-body {
    overflow: visible;
}

.quick-order-category-header {
    background-color: #f8f9fa;
    font-size: 1rem;
    padding: 0.75rem 1.25rem;
    border-radius: 0.5rem 0.5rem 0 0;
    border: 1px solid #dee2e6;
    border-bottom: none;
    position: sticky;
    top: 0;
    z-index: 20;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.06);
}

.quick-order-category.hidden {
    display: none;
}

/* Product Table */
.quick-order-table {
    font-size: 0.875rem;
}

.quick-order-table th {
    font-weight: 600;
    white-space: nowrap;
    border-bottom-width: 2px;
    position: sticky;
    top: 46px; /* sits just below the sticky category header (~46px tall) */
    z-index: 10;
    background-color: #fff;
    box-shadow: 0 2px 0 #dee2e6;
}

.quick-order-table td {
    vertical-align: middle;
}

.quick-order-product-row.hidden {
    display: none;
}

.quick-order-product-row.selected {
    background-color: rgba(5, 150, 105, 0.08);
}

/* Product Image */
.quick-order-product-image {
    width: 50px;
    height: 50px;
    object-fit: contain;
    border-radius: 4px;
    background: #f8f9fa;
}

.quick-order-no-image {
    width: 50px;
    height: 50px;
    background: #f8f9fa;
    border-radius: 4px;
    display: flex;
    align-items: center;
    justify-content: center;
    color: #ccc;
}

/* Product Link */
.quick-order-product-link {
    color: inherit;
    text-decoration: none;
}

.quick-order-product-link:hover {
    color: #059669;
    text-decoration: underline;
}

/* Points */
.quick-order-points {
    color: #059669 !important;
}

/* Price */
.quick-order-price {
    color: #1a1a1a;
    font-weight: 600;
}

/* Quantity Input Group */
.quick-order-quantity-group {
    max-width: 120px;
    margin: 0 auto;
}

.quick-order-quantity-group .btn {
    padding: 0.25rem 0.5rem;
    font-size: 1rem;
    line-height: 1;
}

.quick-order-quantity-group input {
    text-align: center;
    font-weight: 600;
    padding: 0.25rem;
}

.quick-order-quantity-group input::-webkit-outer-spin-button,
.quick-order-quantity-group input::-webkit-inner-spin-button {
    -webkit-appearance: none;
    margin: 0;
}

.quick-order-quantity-group input[type="number"] {
    appearance: textfield;
    -moz-appearance: textfield;
}

/* Stock limit flash */
.quick-order-stock-limit {
    border-color: #dc3545 !important;
    box-shadow: 0 0 0 0.2rem rgba(220, 53, 69, 0.25);
    transition: border-color 0.15s ease, box-shadow 0.15s ease;
}

/* Out of stock badge */
.quick-order-out-of-stock-badge {
    font-size: 0.7em;
    vertical-align: middle;
}

/* Row Sum */
.quick-order-row-sum {
    font-weight: 600;
    color: #059669;
}

/* Points Progress - PointBox Style */
.quick-order-points-progress {
    padding: 0.65rem 0.95rem;
    border-radius: 10px;
    background: linear-gradient(135deg, #fafafa 0%, #ffffff 100%);
    border: 1px solid #e5e7eb;
    transition: all 0.4s cubic-bezier(0.4, 0, 0.2, 1);
    margin-bottom: 1rem;
}

.point-progress-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 0.5rem;
}

.point-progress-text {
    font-weight: 600;
    font-size: 0.8125rem;
    color: #374151;
    letter-spacing: -0.01em;
}

.point-progress-bar-wrapper {
    margin-bottom: 0.5rem;
}

.point-progress-bar-track {
    width: 100%;
    height: 8px;
    background-color: #e5e7eb;
    border-radius: 100px;
    overflow: hidden;
    position: relative;
    box-shadow: inset 0 1px 2px rgba(0, 0, 0, 0.05);
}

.point-progress-bar-fill {
    height: 100%;
    background: linear-gradient(90deg, #9ca3af 0%, #6b7280 100%);
    border-radius: 100px;
    transition:
        width 0.6s cubic-bezier(0.4, 0, 0.2, 1),
        background 0.3s ease;
    position: relative;
    box-shadow: 0 0 8px rgba(107, 114, 128, 0.3);
}

.point-progress-message {
    font-size: 0.75rem;
    color: #6b7280;
    font-weight: 500;
    line-height: 1.3;
}

/* Threshold Reached State */
.quick-order-points-progress.threshold-reached {
    background: linear-gradient(135deg, #ecfdf5 0%, #d1fae5 100%);
    border-color: #a7f3d0;
}

.quick-order-points-progress.threshold-reached .point-progress-bar-fill {
    background: linear-gradient(90deg, #34d399 0%, #10b981 100%);
    box-shadow: 0 0 12px rgba(16, 185, 129, 0.4);
}

.quick-order-points-progress.threshold-reached .point-progress-text,
.quick-order-points-progress.threshold-reached .point-progress-message {
    color: #047857;
}

/* Threshold Blocked State */
.quick-order-points-progress.threshold-blocked {
    background: linear-gradient(135deg, #fff7ed 0%, #ffedd5 100%);
    border-color: #fed7aa;
    border-left: 4px solid #fb923c;
    box-shadow: 0 2px 8px rgba(251, 146, 60, 0.12);
}

.quick-order-points-progress.threshold-blocked .point-progress-text {
    color: #c2410c;
    font-weight: 500;
}

.quick-order-points-progress.threshold-blocked .point-progress-message {
    color: #c2410c;
}

/* Threshold Badge on Products */
.quick-order-threshold-badge {
    display: inline-flex;
    align-items: center;
    gap: 0.3rem;
    font-size: 0.7rem;
    font-weight: 600;
    color: #9a3412;
    background: linear-gradient(135deg, #fff7ed 0%, #ffedd5 100%);
    border: 1px solid #fed7aa;
    border-radius: 4px;
    padding: 0.25rem 0.5rem;
    margin-top: 0.3rem;
    line-height: 1.2;
    white-space: nowrap;
    box-shadow: 0 1px 3px rgba(251, 146, 60, 0.1);
}

.quick-order-threshold-mobile {
    display: none;
}

/* MinOrderValue Sidebar */
.quick-order-min-order-value {
    margin-bottom: 1rem;
}

.quick-order-min-order-value:empty {
    display: none;
}

.mov-title {
    font-size: 0.8125rem;
    font-weight: 600;
    color: #1f2937;
    margin-bottom: 0.5rem;
}

.mov-group-item {
    background: #f9fafb;
    border-radius: 6px;
    padding: 0.65rem 0.75rem;
    margin-bottom: 0.5rem;
    border: 1px solid transparent;
    transition:
        background-color 0.3s ease,
        border-color 0.3s ease;
}

.mov-group-item:last-child {
    margin-bottom: 0;
}

.mov-group-item.reached {
    background: #d1fae5;
    border-color: #10b981;
}

.mov-group-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 0.35rem;
}

.mov-group-name {
    font-weight: 600;
    font-size: 0.8125rem;
    color: #374151;
}

.mov-group-values {
    font-size: 0.75rem;
    font-weight: 600;
    color: #1f2937;
}

.mov-progress-bar {
    background: #e5e7eb;
    border-radius: 4px;
    height: 5px;
    overflow: hidden;
    margin: 0.35rem 0;
}

.mov-progress-fill {
    height: 100%;
    border-radius: 4px;
    transition:
        width 0.3s ease,
        background-color 0.3s ease;
}

.mov-progress-fill.success {
    background: #166534;
}

.mov-progress-fill.warning {
    background: #991b1b;
}

.mov-status-badge {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    font-size: 0.6875rem;
    padding: 2px 8px;
    border-radius: 4px;
    margin-top: 0.2rem;
}

.mov-status-badge.success {
    background: #d1fae5;
    color: #166534;
}

.mov-status-badge.warning {
    background: #fee2e2;
    color: #991b1b;
}

.mov-status-icon {
    width: 12px;
    height: 12px;
}

/* Blocked Order Buttons */
#addToCartBtn.mov-blocked,
#addToCartBtn.pointbox-blocked {
    background: #e5e7eb !important;
    color: #6b7280 !important;
    border-color: #d1d5db !important;
    cursor: not-allowed !important;
    opacity: 0.7;
    pointer-events: none !important;
}

/* Cart Items List */
#cartItemsList li {
    padding: 0.5rem 0;
    border-bottom: 1px solid #eee;
    font-size: 0.875rem;
}

#cartItemsList li:last-child {
    border-bottom: none;
}

.cart-item-name {
    font-weight: 500;
}

.cart-item-details {
    color: #6c757d;
    font-size: 0.8125rem;
}

/* Summary */
.quick-order-summary {
    font-size: 0.9375rem;
}

/* Buttons */
#addToCartBtn:disabled {
    opacity: 0.5;
}

#addToCartBtn:not(:disabled) {
    background-color: #059669;
    border-color: #059669;
}

#addToCartBtn:not(:disabled):hover {
    background-color: #047857;
    border-color: #047857;
}

/* Loading State */
.quick-order-loading {
    opacity: 0.6;
    pointer-events: none;
}

/* Responsive — tablet: sidebar moves below */
@media (max-width: 991.98px) {
    .quick-order-page {
        height: auto;
        min-height: calc(100vh - var(--quick-order-top, 32px));
        overflow: visible;
        padding: 1rem 1rem 0;
    }

    .quick-order-body {
        flex-direction: column;
        overflow: visible;
    }

    .quick-order-table-area {
        overflow: visible;
    }

    .quick-order-sidebar {
        width: 100%;
        order: -1; /* show sidebar above table on tablet/mobile */
        margin-bottom: 1rem;
    }

    .quick-order-sidebar .card {
        height: auto;
    }

    .quick-order-sidebar .card-body {
        overflow: visible;
    }

    .quick-order-search input {
        min-width: 150px;
    }
}

@media (max-width: 767.98px) {
    /* White background on body covers the full viewport; overflow-x:hidden clips
       any absolutely positioned theme nav elements that bleed outside the content area */
    body.is-active-route-frontend-quick-order-page {
        background: #fff !important;
        overflow-x: hidden;
    }

    /* Force the container to span the full viewport width regardless of any
       parent padding/margin. Using 100vw + negative offset is the only CSS-only
       way to truly break out of any ancestor's constrained width. */
    .quick-order-container {
        position: relative;
        z-index: 100;
        background: #fff;
        /* Stretch to full viewport width */
        width: 100vw;
        /* Pull left edge to viewport left, compensating for any left offset */
        margin-left: calc(50% - 50vw);
        /* Inner padding for content breathing room */
        padding-left: 0.75rem;
        padding-right: 0.75rem;
        /* Clip anything that overflows (e.g. theme nav elements) */
        overflow-x: hidden;
        /* Push the footer below all content — prevents footer from appearing
           over the product list before products have loaded */
        min-height: 100vh;
        padding-bottom: 2rem;
    }

    .quick-order-page {
        /* Full page scrolls naturally — no height constraint, no overflow hidden */
        height: auto;
        min-height: unset;
        overflow: visible;
    }

    /* Page scrolls as a whole — no internal scroll regions */
    .quick-order-body {
        overflow: visible;
    }

    .quick-order-table-area {
        overflow: visible;
    }

    .quick-order-controls {
        flex-direction: column;
        align-items: stretch !important;
    }

    .quick-order-search {
        margin-top: 0.5rem;
    }

    .quick-order-search input {
        width: 100%;
        min-width: unset;
    }

    .quick-order-filter-btn {
        font-size: 0.75rem;
        padding: 0.25rem 0.5rem;
    }

    /* Disable sticky category headers and table headers on mobile */
    .quick-order-category-header {
        position: static;
        box-shadow: none;
    }

    .quick-order-table th {
        position: static;
        box-shadow: none;
    }

    /* Hide Art.-Nr. and Summe columns on mobile; keep Bild column visible */
    .quick-order-table th:nth-child(2),
    .quick-order-table td:nth-child(2),
    .quick-order-table th:nth-child(6),
    .quick-order-table td:nth-child(6) {
        display: none;
    }

    .quick-order-table {
        font-size: 0.8125rem;
    }

    /* Keep product images compact on mobile */
    .quick-order-product-image,
    .quick-order-no-image {
        width: 36px;
        height: 36px;
    }

    .quick-order-threshold-desktop {
        display: none !important;
    }

    .quick-order-threshold-mobile {
        display: block;
        margin-top: 0.25rem;
    }

    .quick-order-sidebar .card-body {
        padding: 0.75rem;
        /* Reset desktop flex-shrink so card-body shows its full content height */
        flex: 0 0 auto;
        min-height: unset;
        overflow-y: visible;
    }

    .quick-order-sidebar .card-header {
        padding: 0.6rem 0.75rem;
        font-size: 0.875rem;
    }

    .quick-order-sidebar .card-footer {
        padding: 0.6rem 0.75rem;
    }

    /* Cart items list and divider are visible on mobile — sidebar expands in height */

    .quick-order-summary {
        font-size: 0.8125rem;
    }

    .quick-order-points-progress {
        padding: 0.5rem 0.75rem;
        margin-bottom: 0.5rem;
    }
}
