/* ==========================================================================
   Cart Drawer — ported from FleetCart "sidebar-cart"
   (FleetCart/modules/Storefront/Resources/assets/public/sass/layout/_sidebar-cart.scss
    + sidebar-cart/*.scss, flattened to plain CSS; $vars mapped to :root
    custom properties on the layout)
   Markup: resources/views/public/layouts/cart-drawer.blade.php
   Behavior: public/frontend/assets/js/cart-drawer.js
   ========================================================================== */

/* Lock page scroll while the drawer is open */
body.cart-drawer-open {
    overflow: hidden;
}

/* --------------------------------------------------------------------------
   Backdrop
   -------------------------------------------------------------------------- */
.sidebar-cart-backdrop {
    position: fixed;
    inset: 0;
    background: rgba(15, 23, 42, 0.5);
    z-index: 9995;
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.3s ease, visibility 0.3s ease;
}

.sidebar-cart-backdrop.active {
    opacity: 1;
    visibility: visible;
}

/* --------------------------------------------------------------------------
   Drawer shell (FleetCart: 400px slide-in from right)
   -------------------------------------------------------------------------- */
.sidebar-cart-wrap {
    position: fixed;
    top: 0;
    right: -200px;
    bottom: 0;
    width: 400px;
    max-width: 100vw;
    background: #ffffff;
    box-shadow: 2.5px 4.33px 40px 5px rgba(12, 31, 46, 0.1);
    opacity: 0;
    visibility: hidden;
    z-index: 9996;
    display: flex;
    flex-direction: column;
    transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1), opacity 0.3s ease, visibility 0.3s ease;
}

.sidebar-cart-wrap.active {
    opacity: 1;
    visibility: visible;
    transform: translateX(-200px);
}

@media screen and (max-width: 420px) {
    .sidebar-cart-wrap { width: 360px; }
}
@media screen and (max-width: 380px) {
    .sidebar-cart-wrap { width: 330px; }
}
@media screen and (max-width: 350px) {
    .sidebar-cart-wrap { width: 300px; }
}

/* --------------------------------------------------------------------------
   Top bar — "My Cart" + count badge + close
   -------------------------------------------------------------------------- */
.sidebar-cart-top {
    display: flex;
    padding: 15px 20px;
    align-items: center;
    justify-content: space-between;
    background: #ffffff;
    flex-shrink: 0;
}

.sidebar-cart-top .title {
    position: relative;
    font-size: 16px;
    font-weight: 600;
    color: #1a1a1a;
    margin: 0;
}

.sidebar-cart-top .title .count {
    position: absolute;
    top: -4px;
    right: -15px;
    height: 16px;
    width: 16px;
    font-size: 10px;
    font-weight: 400;
    line-height: 16px;
    color: #ffffff;
    background: var(--color-red, #e23e1d);
    text-align: center;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
}

.sidebar-cart-close {
    display: flex;
    cursor: pointer;
    opacity: 0.8;
    padding: 4px;
    transition: opacity 0.15s ease;
}

.sidebar-cart-close:hover { opacity: 1; }

.sidebar-cart-close > svg {
    width: 18px;
    height: 18px;
    transition: 0.15s ease;
}

.sidebar-cart-close > svg path { stroke: #191919; }

.sidebar-cart-close:hover > svg path { stroke: var(--color-red, #e23e1d); }

/* --------------------------------------------------------------------------
   Middle — scrollable item list inside a bordered box
   -------------------------------------------------------------------------- */
.sidebar-cart-middle {
    position: absolute;
    left: 0;
    right: 0;
    top: 58px;
    bottom: 102px;
    margin: 0 20px;
    padding: 10px 15px;
    border: 1px solid #e2e8f0;
    border-radius: var(--radius-default, 8px);
    background: #ffffff;
    overflow-y: auto;
}

.sidebar-cart-middle::-webkit-scrollbar { width: 4px; }
.sidebar-cart-middle::-webkit-scrollbar-track { background: transparent; }
.sidebar-cart-middle::-webkit-scrollbar-thumb {
    background: #cbd5e1;
    border-radius: 4px;
    transition: 0.2s ease-in-out;
}
.sidebar-cart-middle::-webkit-scrollbar-thumb:hover {
    background: var(--color-primary, #0758A2);
}

/* Empty state stretches the box to near the bottom */
.sidebar-cart-middle.empty {
    bottom: 20px;
    overflow: visible;
}

.sidebar-cart-items-wrap {
    padding: 8px 0;
    background: #ffffff;
}

/* --------------------------------------------------------------------------
   Cart item row
   -------------------------------------------------------------------------- */
.sidebar-cart-item {
    display: flex;
    padding: 18px 0;
    border-bottom: 1px solid #e2e8f0;
}

.sidebar-cart-item:first-child { padding-top: 0; }

.sidebar-cart-item:last-child {
    padding-bottom: 0;
    border-bottom: none;
}

.sidebar-cart-item .product-image {
    border: 1px solid #e2e8f0;
    border-radius: 6px;
    width: 60px;
    min-width: 60px;
    height: 55px;
    overflow: hidden;
    background: #f8fafc;
    display: flex;
    align-items: center;
    justify-content: center;
}

.sidebar-cart-item .product-image img {
    width: 100%;
    height: 100%;
    object-fit: contain;
    display: block;
}

.sidebar-cart-item .product-image .img-placeholder {
    width: 30px;
    height: 30px;
    border-radius: 6px;
    background: #e2e8f0;
}

.sidebar-cart-item .product-info {
    position: relative;
    margin-left: 12px;
    flex: 1;
    min-width: 0;
}

.sidebar-cart-item .remove-cart-item {
    position: absolute;
    top: -2px;
    right: 0;
}

.sidebar-cart-item .btn-remove {
    width: 22px;
    height: 22px;
    padding: 0;
    border: none;
    background: none;
    color: var(--color-gray, #6e6e6e);
    font-size: 16px;
    line-height: 1;
    cursor: pointer;
    opacity: 0.9;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: color 0.15s ease, opacity 0.15s ease;
}

.sidebar-cart-item .btn-remove:hover {
    color: var(--color-red, #e23e1d);
    opacity: 1;
}

.sidebar-cart-item .product-name {
    display: -webkit-box;
    font-size: 13px;
    font-weight: 500;
    line-height: 1.35;
    color: #1a1a1a;
    margin: 0 12px 8px 0;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
    word-break: break-word;
    transition: color 0.15s ease;
}

.sidebar-cart-item .product-name:hover {
    color: var(--color-primary, #0758A2);
}

.sidebar-cart-item .product-info-bottom {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
}

.sidebar-cart-item .product-price {
    font-size: 13px;
    font-weight: 600;
    color: #0f172a;
    line-height: 1;
    margin-top: 2px;
}

/* --------------------------------------------------------------------------
   Quantity picker (shared component — drawer + cart page)
   -------------------------------------------------------------------------- */
.number-picker { width: auto; }

.number-picker .input-group-quantity {
    display: inline-flex;
    align-items: center;
    gap: 4px;
}

.number-picker .btn-number {
    position: relative;
    background: #ffffff;
    border: 1px solid #e2e8f0;
    width: 26px;
    height: 26px;
    border-radius: 6px;
    padding: 0;
    color: #1a1a1a;
    font-size: 14px;
    line-height: 1;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    transition: border-color 0.15s ease, color 0.15s ease;
}

.number-picker .btn-number:hover:not(:disabled) {
    border-color: var(--color-primary, #0758A2);
    color: var(--color-primary, #0758A2);
}

.number-picker .btn-number:disabled {
    opacity: 0.4;
    cursor: not-allowed;
}

.number-picker .input-quantity {
    width: 40px;
    height: 26px;
    padding: 0 4px;
    margin: 0;
    font-size: 13px;
    font-weight: 600;
    text-align: center;
    color: #1a1a1a;
    border: 1px solid #e2e8f0;
    border-radius: 6px;
    background: #ffffff;
    transition: border-color 0.15s ease;
}

.number-picker .input-quantity:focus {
    outline: none;
    border-color: var(--color-primary, #0758A2);
}

/* --------------------------------------------------------------------------
   Empty state (FleetCart truck illustration)
   -------------------------------------------------------------------------- */
.sidebar-cart-middle .empty-message {
    position: absolute;
    left: 0;
    top: 0;
    height: 100%;
    width: 100%;
    padding: 40px 0;
    display: none;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    text-align: center;
}

.sidebar-cart-middle .empty-message svg {
    height: 100px;
    width: 100px;
    margin-bottom: 22px;
}

.sidebar-cart-middle .empty-message svg g {
    fill: var(--color-primary, #0758A2);
}

.sidebar-cart-middle .empty-message h4 {
    font-size: 15px;
    font-weight: 600;
    color: #1a1a1a;
    margin: 0;
}

/* --------------------------------------------------------------------------
   Bottom — subtotal + actions (Clear / View Cart / Checkout)
   -------------------------------------------------------------------------- */
.sidebar-cart-bottom {
    position: absolute;
    left: 0;
    right: 0;
    bottom: 0;
    background: #ffffff;
    z-index: 2;
}

.sidebar-cart-subtotal {
    font-size: 17px;
    font-weight: 600;
    color: #1a1a1a;
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin: 0 20px;
    padding: 16px 0 12px;
}

.sidebar-cart-subtotal > span:last-child {
    font-weight: 700;
    color: var(--color-primary, #0758A2);
}

.sidebar-cart-actions {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 0 20px 16px;
    background: #ffffff;
}

.sidebar-cart-actions .btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-size: 13px;
    font-weight: 600;
    padding: 8px 14px;
    border: 1px solid transparent;
    border-radius: 8px;
    background: none;
    cursor: pointer;
    text-decoration: none;
    white-space: nowrap;
    transition: background 0.15s ease, color 0.15s ease, border-color 0.15s ease;
}

.sidebar-cart-actions .btn-clear-cart {
    margin-right: auto;
    padding: 8px 2px;
    color: var(--color-red, #e23e1d);
}

.sidebar-cart-actions .btn-clear-cart:hover {
    color: #c22b0d;
}

.sidebar-cart-actions .btn-view-cart {
    background: #f4f5f6;
    border-color: #e2e8f0;
    color: #1a1a1a;
}

.sidebar-cart-actions .btn-view-cart:hover {
    border-color: var(--color-primary, #0758A2);
    background: var(--color-primary-soft, #f0f7ff);
    color: var(--color-primary, #0758A2);
}

.sidebar-cart-actions .btn-checkout {
    margin-left: 4px;
    background: var(--color-primary, #0758A2);
    border-color: var(--color-primary, #0758A2);
    color: #ffffff;
}

.sidebar-cart-actions .btn-checkout:hover {
    background: var(--color-primary-hover, #054178);
}

/* --------------------------------------------------------------------------
   Responsive (FleetCart breakpoints)
   -------------------------------------------------------------------------- */
@media screen and (max-width: 992px) {
    .sidebar-cart-top { padding: 12px 20px; }
    .sidebar-cart-middle { top: 52px; }
}

@media screen and (max-width: 380px) {
    .sidebar-cart-middle {
        margin: 0 15px;
        padding: 6px 13px;
    }
    .sidebar-cart-item .product-info { margin-left: 10px; }
    .sidebar-cart-actions { justify-content: flex-end; }
    .sidebar-cart-actions .btn-clear-cart { display: none; }
}
