/* =========================================================
   1. CUSTOM PROPERTIES (easily override)
   ========================================================= */

:root {
    --sago-nav-bg: rgba(255, 255, 255, 0.92);
    --sago-nav-blur: 20px;
    --sago-nav-shadow: 0 -4px 20px rgba(0, 0, 0, 0.08);
    --sago-nav-inactive: #64748b;
    --sago-nav-active: #dc350b;
    --sago-nav-active-bg: #fff5f0;
    --sago-nav-radius: 40px;
    --sago-badge-bg: #dc350b;
    --sago-badge-color: #fff;
}

/* =========================================================
   2. FLOATING NAV – CONTAINER & PILL
   ========================================================= */

.sago-floating-nav-container {
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    z-index: 99999;
    pointer-events: none;
    padding-bottom: env(safe-area-inset-bottom, 0);
}

.sago-floating-nav-pill {
    display: flex;
    align-items: center;
    justify-content: space-around;
    background: var(--sago-nav-bg);
    backdrop-filter: blur(var(--sago-nav-blur));
    -webkit-backdrop-filter: blur(var(--sago-nav-blur));
    padding: 6px 4px calc(6px + env(safe-area-inset-bottom, 0px));
    border-top: 1px solid rgba(0, 0, 0, 0.06);
    box-shadow: var(--sago-nav-shadow);
    pointer-events: auto;
    transition: transform 0.3s ease, box-shadow 0.3s ease;
    width: 100%;
    border-radius: 0;
    gap: 0.5rem;
}

/* =========================================================
   3. NAV ITEMS (shared)
   ========================================================= */

.sago-nav-item {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 2px;
    text-decoration: none !important;
    color: var(--sago-nav-inactive);
    font-size: 10px;
    font-weight: 600;
    padding: 6px 12px;
    min-height: 44px;          /* improved touch target */
    min-width: 44px;
    border-radius: var(--sago-nav-radius);
    transition: all 0.3s cubic-bezier(0.34, 1.56, 0.64, 1);
    position: relative;
    outline: none;
    border: 2px solid transparent;
    background: transparent;
    cursor: pointer;
}

.sago-nav-item i {
    font-size: 20px;
    transition: inherit;
    line-height: 1;
}

.sago-nav-item span {
    font-size: 9px;
    font-weight: 600;
    letter-spacing: 0.2px;
    color: inherit;
    transition: color 0.25s ease;
    line-height: 1.2;
}

/* --- Active state with glow --- */
.sago-nav-item.active {
    background: var(--sago-nav-active-bg);
    border-color: var(--sago-nav-active);
    color: var(--sago-nav-active);
    transform: translateY(-3px) scale(1.04);
    box-shadow: 0 4px 16px rgba(220, 53, 11, 0.15), 0 0 0 3px rgba(220, 53, 11, 0.08);
}

.sago-nav-item.active i {
    color: currentColor;
    transform: scale(1.1);
}

.sago-nav-item.active span {
    color: currentColor;
}

/* --- Hover / focus --- */
.sago-nav-item:hover:not(.active) {
    background: rgba(0, 0, 0, 0.04);
    transform: translateY(-1px);
    color: var(--sago-nav-active);
}

.sago-nav-item:active {
    transform: scale(0.92);
}

.sago-nav-item:focus-visible {
    outline: 2px solid var(--sago-nav-active);
    outline-offset: 2px;
    border-radius: var(--sago-nav-radius);
}

/* =========================================================
   4. BADGES (cart & wishlist) – scoped to floating nav
   ========================================================= */

.sago-floating-nav-container .sago-cart-badge,
.sago-floating-nav-container .sago-wishlist-badge {
    position: absolute;
    top: -8px !important;
    right: -8px !important;
    background: var(--sago-badge-bg);
    color: var(--sago-badge-color);
    font-size: 10px;
    font-weight: 700;
    min-width: 18px;
    height: 18px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 0 5px;
    box-shadow: 0 2px 8px rgba(220, 53, 11, 0.3);
    border: 2px solid #fff;
    transition: transform 0.3s cubic-bezier(0.34, 1.56, 0.64, 1);
    line-height: 1;
    z-index: 5;
    will-change: transform;
}

.sago-floating-nav-container .sago-cart-badge.hidden,
.sago-floating-nav-container .sago-wishlist-badge.hidden {
    transform: scale(0);
    visibility: hidden;
}

.sago-floating-nav-container .sago-cart-badge.pulse,
.sago-floating-nav-container .sago-wishlist-badge.pulse {
    animation: sagoBadgePulse 0.4s cubic-bezier(0.34, 1.56, 0.64, 1);
}

@keyframes sagoBadgePulse {
    0%   { transform: scale(1); }
    40%  { transform: scale(1.6); }
    100% { transform: scale(1); }
}

/* =========================================================
   5. SHOP DRAWER – BACKDROP & SHEET
   ========================================================= */

.sago-drawer-backdrop {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.5);
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
    z-index: 999998;
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.3s ease, visibility 0.3s ease;
    cursor: pointer;
}
.sago-drawer-backdrop.active {
    opacity: 1;
    visibility: visible;
}

.sago-categories-drawer-sheet {
    position: fixed;
    bottom: 0;
    left: 50%;
    transform: translateX(-50%) translateY(100%);
    width: min(550px, 100vw);
    max-height: 80vh;
    background: #fff;
    border-radius: 28px 28px 0 0;
    box-shadow: 0 -10px 40px rgba(0, 0, 0, 0.15);
    z-index: 999999;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    transition: transform 0.4s cubic-bezier(0.34, 1.56, 0.64, 1);
    will-change: transform;
}
.sago-categories-drawer-sheet.open {
    transform: translateX(-50%) translateY(0);
}

/* Drag handle */
.sago-categories-drawer-sheet::before {
    content: '';
    position: absolute;
    top: 4px;
    left: 50%;
    transform: translateX(-50%);
    width: 72px;
    height: 4px;
    border-radius: 4px;
    background: #d1d5db;
    z-index: 10;
}

/* =========================================================
   6. DRAWER HEADER & BODY
   ========================================================= */

.sago-drawer-sheet-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 20px 24px 16px;
    border-bottom: 1px solid #f1f5f9;
    background: var(--sago-nav-active, #dc350b);
    flex-shrink: 0;
}

.sago-drawer-sheet-title {
    font-size: 1.3rem;
    font-weight: 700;
    margin: 0;
    display: flex;
    align-items: center;
    gap: 10px;
    color: #fff;
}
.sago-drawer-sheet-title i {
    color: #fff5f0;
}

.sago-drawer-sheet-close {
    background: #fff !important;
    border: none;
    width: 38px;
    height: 38px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    color: var(--sago-nav-active) !important;
    transition: all 0.3s ease;
}
.sago-drawer-sheet-close:hover {
    background: #fff5f0 !important;
    transform: rotate(90deg);
}
.sago-drawer-sheet-close:focus-visible {
    outline: 2px solid #fff;
    outline-offset: 2px;
}

.sago-drawer-sheet-body {
    padding: 12px 20px 30px;
    overflow-y: auto;
    flex: 1;
    -webkit-overflow-scrolling: touch;
}
.sago-drawer-sheet-body::-webkit-scrollbar {
    width: 4px;
}
.sago-drawer-sheet-body::-webkit-scrollbar-track {
    background: #f1f5f9;
}
.sago-drawer-sheet-body::-webkit-scrollbar-thumb {
    background: #cbd5e1;
    border-radius: 4px;
}

/* =========================================================
   7. DRAWER – ALL PRODUCTS LINK
   ========================================================= */

.sago-drawer-all-products-link a {
    display: flex;
    align-items: center;
    justify-content: space-between;
    background: linear-gradient(90deg, #ffe2da, #feebe6c1);
    border: 1px solid rgba(242, 81, 41, 0.75);
    padding: 14px 18px;
    border-radius: 12px;
    text-decoration: none !important;
    color: var(--sago-nav-active);
    font-weight: 700;
    font-size: 15px;
    margin-bottom: 16px;
    transition: all 0.3s ease;
}
.sago-drawer-all-products-link a:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(122, 26, 2, 0.1);
}
.sago-drawer-all-products-link a:focus-visible {
    outline: 2px solid var(--sago-nav-active);
    outline-offset: 2px;
}

/* =========================================================
   8. DRAWER – CATEGORY LIST
   ========================================================= */

.sago-drawer-category-list {
    list-style: none;
    padding: 0;
    margin: 0;
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.sago-drawer-category-item {
    list-style: none;
    margin: 0;
    padding: 0;
}

.sago-drawer-category-link {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 9px 17px;
    background: var(--sago-nav-active-bg, #fff5f0);
    border: 1px solid transparent;
    border-radius: 12px;
    text-decoration: none !important;
    color: var(--sago-text, #1f2937);
    transition: all 0.25s ease;
    font-weight: 500;
}
.sago-drawer-category-link:hover {
    background: var(--sago-nav-active);
    color: #fff;
    transform: translateX(4px);
}
.sago-drawer-category-link:focus-visible {
    outline: 2px solid var(--sago-nav-active);
    outline-offset: -2px;
}

.sago-drawer-cat-left {
    display: flex;
    align-items: center;
    gap: 14px;
}
.sago-drawer-cat-icon-frame {
    width: 40px;
    color: var(--sago-nav-active);
    font-size: 19px;
    text-align: center;
    transition: color 0.25s ease;
}
.sago-drawer-category-link:hover .sago-drawer-cat-icon-frame {
    color: #fff;
}

.sago-drawer-cat-right {
    display: flex;
    align-items: center;
    gap: 12px;
}
.sago-drawer-cat-badge {
    font-size: 11px;
    background: rgba(0, 0, 0, 0.06);
    padding: 2px 12px;
    border-radius: 30px;
    font-weight: 600;
    color: #6b7280;
    transition: all 0.25s ease;
}
.sago-drawer-category-link:hover .sago-drawer-cat-badge {
    background: rgba(255, 255, 255, 0.2);
    color: #fff;
}

.arrow-indicator {
    font-size: 12px;
    color: #cbd5e1;
    transition: all 0.25s ease;
}
.sago-drawer-category-link:hover .arrow-indicator {
    color: #fff;
    transform: translateX(2px);
}

/* =========================================================
   9. CATEGORY ANIMATION (stagger)
   ========================================================= */

.sago-categories-drawer-sheet.open .sago-drawer-category-item {
    animation: sagoSlideUp 0.4s ease forwards;
}
.sago-categories-drawer-sheet.open .sago-drawer-category-item:nth-child(1) { animation-delay: 0.05s; }
.sago-categories-drawer-sheet.open .sago-drawer-category-item:nth-child(2) { animation-delay: 0.10s; }
.sago-categories-drawer-sheet.open .sago-drawer-category-item:nth-child(3) { animation-delay: 0.15s; }
.sago-categories-drawer-sheet.open .sago-drawer-category-item:nth-child(4) { animation-delay: 0.20s; }
.sago-categories-drawer-sheet.open .sago-drawer-category-item:nth-child(5) { animation-delay: 0.25s; }
.sago-categories-drawer-sheet.open .sago-drawer-category-item:nth-child(6) { animation-delay: 0.30s; }

@keyframes sagoSlideUp {
    from { transform: translateY(20px); opacity: 0; }
    to   { transform: translateY(0);   opacity: 1; }
}

/* =========================================================
   10. RESPONSIVE – CONSOLIDATED BREAKPOINTS
   ========================================================= */

@media (min-width: 481px) {
    .sago-floating-nav-container {
        left: 50%;
        right: auto;
        transform: translateX(-50%);
        width: auto;
        min-width: 600px;
        bottom: 16px;
        padding-bottom: 0;
    }
    .sago-floating-nav-pill {
        border-radius: 40px;
        padding: 6px 11px;
        border: 1px solid rgba(0, 0, 0, 0.06);
        box-shadow: 0 10px 40px rgba(0, 0, 0, 0.12);
        width: auto;
    }
    .sago-nav-item {
        padding: 6px 19px !important;
        min-height: 30px;
        font-size: 9px;
    }
    .sago-nav-item i {
        font-size: 15px;
    }
    .sago-nav-item span {
        font-size: 9px;
    }
    .sago-floating-nav-container .sago-cart-badge,
    .sago-floating-nav-container .sago-wishlist-badge {
        top: -6px !important;
        right: -6px !important;
        min-width: 18px;
        height: 18px;
        font-size: 9px;
    }
}

@media (min-width: 769px) {
    .sago-floating-nav-container {
        max-width: 630px;
        bottom: 24px;
    }
    .sago-floating-nav-pill {
        border-radius: 50px;
        padding: 4px 12px;
    }
    .sago-nav-item {
        flex-direction: row;
        gap: 4px;
        padding: 8px 17px;
        min-height: 33px;
        font-size: 10px;
        min-width: fit-content;
    }
    .sago-nav-item i {
        font-size: 18px;
    }
    .sago-nav-item span {
        font-size: 11px;
    }
    .sago-floating-nav-container .sago-cart-badge,
    .sago-floating-nav-container .sago-wishlist-badge {
        top: -6px !important;
        right: 12px !important;
        min-width: 18px;
        height: 18px;
        font-size: 9px;
    }
}

@media (min-width: 1200px) {
    .sago-floating-nav-container {
        max-width: 700px;
    }
    .sago-nav-item {
        padding: 8px 19px;
    }
}

@media (max-width: 480px) {
    .sago-nav-item {
        padding: 4px 10px;
        min-height: 40px;
        min-width: 40px;
        gap: 1px;
    }
    .sago-nav-item i {
        font-size: 17px;
    }
    .sago-nav-item span {
        font-size: 8px;
    }
    .sago-floating-nav-container .sago-cart-badge,
    .sago-floating-nav-container .sago-wishlist-badge {
        top: -6px !important;
        right: -6px !important;
        min-width: 16px;
        height: 16px;
        font-size: 8px;
        border-width: 1.5px;
        padding: 0 3px;
    }
    .sago-categories-drawer-sheet {
        border-radius: 20px 20px 0 0;
        max-height: 80vh;
    }
    .sago-drawer-sheet-header {
        padding: 16px 18px 12px;
    }
    .sago-drawer-sheet-title {
        font-size: 1rem;
    }
    .sago-drawer-sheet-body {
        padding: 4px 12px 20px;
    }
    .sago-drawer-category-link {
        padding: 10px 12px;
        font-size: 0.9rem;
    }
    .sago-drawer-cat-icon-frame {
        width: 28px;
        font-size: 15px;
    }
}

/* =========================================================
   11. ACCESSIBILITY – REDUCED MOTION
   ========================================================= */

@media (prefers-reduced-motion: reduce) {
    .sago-nav-item,
    .sago-cart-badge,
    .sago-wishlist-badge,
    .sago-categories-drawer-sheet,
    .sago-drawer-category-item,
    .sago-drawer-sheet-close {
        transition: none !important;
        animation: none !important;
    }
    .sago-nav-item:active {
        transform: none !important;
    }
}