/* ================================================================
   THORNES SANCTUARY — BASKET / CART STYLES
   Standard: Modern e-commerce drawer (inspired by premium retail)
   Updated: 2026-03-03 — z-index fix, mobile polish, UX improvements
   ================================================================ */

/* ── Floating Action Button ─────────────────────────────────── */
.basket-fab {
    position: fixed;
    bottom: 85px;
    right: 28px;
    width: 58px;
    height: 58px;
    background: var(--color-forest, #2E4033);
    color: #FFF;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 8px 24px rgba(46, 64, 51, 0.35);
    cursor: pointer;
    z-index: 8500;
    transition: transform 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275),
        background 0.2s ease;
}

.basket-fab:hover {
    transform: scale(1.1);
    background: var(--color-midnight, #152219);
}

#basket-count {
    position: absolute;
    top: -4px;
    right: -4px;
    background: var(--color-clay, #C4714A);
    color: #FFF;
    font-size: 0.72rem;
    font-weight: 700;
    min-width: 22px;
    height: 22px;
    border-radius: 11px;
    padding: 0 5px;
    display: flex;
    align-items: center;
    justify-content: center;
    border: 2px solid #FFF;
    box-shadow: 0 2px 6px rgba(0, 0, 0, 0.2);
}

/* ── Backdrop (dimmed background) ───────────────────────────── */
.basket-backdrop {
    position: fixed;
    inset: 0;
    background: rgba(15, 25, 18, 0.55);
    -webkit-backdrop-filter: blur(3px);
    backdrop-filter: blur(3px);
    /* MUST be below drawer (9000) */
    z-index: 8990;
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.35s ease, visibility 0.35s ease;
}

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

/* ── Drawer Panel ────────────────────────────────────────────── */
.basket-overlay {
    position: fixed;
    top: 0;
    right: 0;
    width: 420px;
    max-width: 100vw;
    height: 100dvh;
    /* dvh = respects mobile browser chrome */
    background: #FAFAF8;
    /* HIGHEST z-index in the stack */
    z-index: 9000;
    display: flex;
    flex-direction: column;
    box-shadow: -20px 0 60px rgba(0, 0, 0, 0.12);
    /* Slides in from right — translate only, no inset changes */
    transform: translateX(100%);
    transition: transform 0.42s cubic-bezier(0.16, 1, 0.3, 1);
    will-change: transform;
    overflow: hidden;
}

.basket-overlay.active {
    transform: translateX(0);
}

/* Mobile: full-width */
@media (max-width: 480px) {
    .basket-overlay {
        width: 100%;
        border-radius: 0;
    }
}

/* ── Drawer Header ───────────────────────────────────────────── */
.basket-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 22px 24px 18px;
    border-bottom: 1px solid #EBEBEB;
    background: #FFF;
    flex-shrink: 0;
}

.basket-header h3 {
    margin: 0;
    font-size: 1.4rem;
    font-family: var(--font-heading, serif);
    color: var(--color-midnight, #152219);
    font-weight: 500;
    letter-spacing: -0.01em;
}

.basket-header h3 span {
    font-size: 1rem;
    color: #888;
    font-family: var(--font-body, sans-serif);
    font-weight: 400;
}

/* Close button — top right, accessible */
.basket-close-btn {
    width: 36px;
    height: 36px;
    border: 1px solid #E5E5E5;
    border-radius: 50%;
    background: #FFF;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.1rem;
    color: #555;
    transition: all 0.2s ease;
    padding: 0;
    flex-shrink: 0;
}

.basket-close-btn:hover {
    background: #111;
    color: #FFF;
    border-color: #111;
    transform: rotate(90deg);
}

/* Legacy close button style (bi-remove used in header) */
.basket-header .bi-remove {
    width: 36px;
    height: 36px;
    border: 1px solid #E5E5E5;
    border-radius: 50%;
    background: #FFF;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.2rem;
    color: #555;
    transition: all 0.2s ease;
    position: static !important;
    text-decoration: none !important;
    padding: 0;
}

.basket-header .bi-remove:hover {
    background: #111;
    color: #FFF;
    border-color: #111;
}

/* ── Free Delivery Progress ──────────────────────────────────── */
.free-delivery-zone {
    padding: 14px 24px 16px;
    border-bottom: 1px solid #EBEBEB;
    background: #FFF;
    flex-shrink: 0;
}

.fd-text {
    font-size: 0.82rem;
    text-align: center;
    margin-bottom: 10px;
    color: #555;
}

.fd-text strong {
    color: var(--color-forest, #2E4033);
}

.progress-container {
    width: 100%;
    height: 5px;
    background: #EBEBEB;
    border-radius: 10px;
    position: relative;
    overflow: visible;
}

.progress-bar {
    height: 100%;
    background: linear-gradient(90deg, var(--color-forest, #2E4033), #5a8a65);
    width: 0%;
    transition: width 0.8s cubic-bezier(0.16, 1, 0.3, 1);
    border-radius: 10px;
}

.fd-icon {
    position: absolute;
    right: -1px;
    top: 50%;
    transform: translateY(-50%);
    width: 20px;
    height: 20px;
    background: #FFF;
    border: 2px solid #DEDEDE;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 9px;
    color: transparent;
    transition: all 0.3s ease;
}

.progress-container.qualified .fd-icon {
    background: var(--color-forest, #2E4033);
    border-color: var(--color-forest, #2E4033);
    color: #FFF;
}

/* ── Item List (scrollable) ──────────────────────────────────── */
.basket-items {
    flex: 1;
    overflow-y: auto;
    padding: 16px 24px;
    scrollbar-width: thin;
    scrollbar-color: #DDD transparent;
    background: #FAFAF8;
}

.basket-items::-webkit-scrollbar {
    width: 4px;
}

.basket-items::-webkit-scrollbar-track {
    background: transparent;
}

.basket-items::-webkit-scrollbar-thumb {
    background: #DDD;
    border-radius: 4px;
}

/* ── Empty State ─────────────────────────────────────────────── */
.basket-empty {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    height: 100%;
    min-height: 220px;
    text-align: center;
    color: #999;
    gap: 8px;
    padding: 40px 20px;
}

.basket-empty-icon {
    font-size: 3rem;
    margin-bottom: 8px;
    opacity: 0.5;
}

.basket-empty h4 {
    font-size: 1.1rem;
    font-weight: 500;
    color: #555;
    margin: 0;
}

.basket-empty p {
    font-size: 0.85rem;
    color: #AAA;
    margin: 0;
}

/* ── Individual Item ─────────────────────────────────────────── */
.basket-item {
    display: grid;
    grid-template-columns: 82px 1fr;
    gap: 14px;
    padding: 16px 0;
    border-bottom: 1px solid #F0F0F0;
    position: relative;
    animation: slideInItem 0.25s ease;
}

@keyframes slideInItem {
    from {
        opacity: 0;
        transform: translateY(8px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.basket-item:last-child {
    border-bottom: none;
}

.bi-img {
    width: 82px;
    height: 82px;
    background-size: cover;
    background-position: center;
    border-radius: 6px;
    background-color: #F0EFE9;
    flex-shrink: 0;
}

.bi-info {
    display: flex;
    flex-direction: column;
    gap: 4px;
    min-width: 0;
}

.bi-info h4 {
    margin: 0;
    font-size: 0.95rem;
    font-weight: 600;
    color: #111;
    line-height: 1.3;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.bi-desc {
    font-size: 0.78rem;
    color: #999;
}

.bi-price-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-top: auto;
    padding-top: 8px;
}

.bi-price {
    font-weight: 700;
    color: #111;
    font-size: 1rem;
}

/* Remove button — subtle top-right */
.bi-remove {
    display: inline-block;
    position: static !important;
    background: none;
    border: none;
    color: #BBB;
    font-size: 0.75rem;
    text-decoration: underline;
    cursor: pointer;
    padding: 0;
    transition: color 0.2s;
    text-align: right;
    align-self: flex-end;
}

.bi-remove:hover {
    color: #C0392B;
}

/* ── Qty Stepper ─────────────────────────────────────────────── */
.bi-controls {
    display: flex;
    align-items: center;
    border: 1px solid #E0E0E0;
    border-radius: 6px;
    overflow: hidden;
    height: 32px;
}

.bi-controls button {
    width: 32px;
    height: 32px;
    border: none;
    background: #F8F8F8;
    cursor: pointer;
    font-size: 1.1rem;
    color: #333;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background 0.15s;
    padding: 0;
    flex-shrink: 0;
}

.bi-controls button:hover {
    background: #EBEBEB;
}

.bi-controls span {
    min-width: 32px;
    text-align: center;
    font-size: 0.9rem;
    font-weight: 600;
    color: #111;
    border-left: 1px solid #E0E0E0;
    border-right: 1px solid #E0E0E0;
    height: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
}

/* ── Recommendations ─────────────────────────────────────────── */
.basket-recommendations {
    padding: 14px 24px;
    background: #F4F3EF;
    border-top: 1px solid #EBEBEB;
    flex-shrink: 0;
}

.br-title {
    font-size: 0.7rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 2px;
    margin-bottom: 12px;
    color: #999;
}

.rec-card {
    display: flex;
    gap: 12px;
    align-items: center;
    background: #FFF;
    padding: 10px 12px;
    border-radius: 8px;
    border: 1px solid #EBEBEB;
}

.rec-img {
    width: 50px;
    height: 50px;
    border-radius: 4px;
    object-fit: cover;
    flex-shrink: 0;
}

.rec-info {
    flex: 1;
    min-width: 0;
}

.rec-info h5 {
    margin: 0 0 2px 0;
    font-size: 0.85rem;
    font-weight: 600;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.rec-price {
    font-size: 0.8rem;
    font-weight: 700;
    color: var(--color-forest, #2E4033);
}

.rec-add {
    margin-left: auto;
    background: var(--color-forest, #2E4033);
    color: #FFF;
    border: none;
    border-radius: 5px;
    padding: 6px 14px;
    font-size: 0.78rem;
    font-weight: 700;
    cursor: pointer;
    white-space: nowrap;
    transition: background 0.2s;
    flex-shrink: 0;
}

.rec-add:hover {
    background: var(--color-midnight, #152219);
}

/* ── Footer ──────────────────────────────────────────────────── */
.basket-footer {
    padding: 20px 24px 24px;
    border-top: 1px solid #EBEBEB;
    background: #FFF;
    flex-shrink: 0;
}

.basket-total {
    display: flex;
    justify-content: space-between;
    align-items: baseline;
    margin-bottom: 6px;
    color: #333;
    font-size: 0.9rem;
}

.basket-total-amount {
    font-size: 1.5rem;
    font-weight: 700;
    color: var(--color-midnight, #152219);
}

.basket-total-label {
    font-size: 0.85rem;
    color: #777;
}

.basket-vat-note {
    font-size: 0.75rem;
    color: #AAA;
    text-align: center;
    margin-bottom: 14px;
}

#btn-view-bag {
    background: var(--color-midnight, #152219);
    color: #FFF;
    border: none;
    width: 100%;
    padding: 17px 20px;
    font-size: 0.95rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 2px;
    cursor: pointer;
    border-radius: 8px;
    margin-bottom: 10px;
    transition: background 0.25s, transform 0.15s;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
}

#btn-view-bag:hover:not(:disabled) {
    background: #0a1210;
    transform: translateY(-1px);
}

#btn-view-bag:disabled {
    opacity: 0.6;
    cursor: not-allowed;
    transform: none;
}

#btn-view-bag::before {
    content: '🔒';
    font-size: 0.85rem;
}

.continue-shopping {
    background: none;
    border: none;
    color: #888;
    text-decoration: underline;
    font-size: 0.83rem;
    cursor: pointer;
    width: 100%;
    margin-top: 4px;
    padding: 6px;
    transition: color 0.2s;
}

.continue-shopping:hover {
    color: #333;
}

/* ── Toast Notifications ─────────────────────────────────────── */
.toast {
    position: fixed;
    bottom: 100px;
    right: 28px;
    background: rgba(21, 34, 25, 0.95);
    -webkit-backdrop-filter: blur(12px);
    backdrop-filter: blur(12px);
    color: #FFF;
    padding: 14px 22px;
    border-radius: 10px;
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.25);
    z-index: 9500;
    /* Toast must be above everything including basket overlay */
    font-weight: 500;
    font-size: 0.9rem;
    border-left: 4px solid var(--color-clay, #C4714A);
    display: flex;
    align-items: center;
    gap: 10px;
    animation: toastIn 0.3s cubic-bezier(0.16, 1, 0.3, 1);
    max-width: 320px;
}

@keyframes toastIn {
    from {
        opacity: 0;
        transform: translateY(16px) scale(0.95);
    }

    to {
        opacity: 1;
        transform: translateY(0) scale(1);
    }
}