/**
 * Cart Drawer Sidebar Component
 * Modern, clean styling for shopping cart sidebar
 */

/* ============================================
   Overlays & Backdrops
   ============================================ */

#cart-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    background-color: rgba(0, 0, 0, 0.5);
    z-index: 99998 !important;
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.3s ease-in-out, visibility 0.3s ease-in-out;
    /* Performance optimizations */
    will-change: opacity;
    transform: translateZ(0);
    backface-visibility: hidden;
}

#cart-overlay.active {
    opacity: 1;
    visibility: visible;
}

/* ============================================
   Cart Drawer Container
   ============================================ */

#cart-drawer {
    position: fixed !important;
    top: 0 !important;
    right: 0 !important;
    height: 100vh !important;
    width: 500px !important;
    max-width: 90vw !important;
    background-color: var(--background, #ffffff) !important;
    box-shadow: -5px 0 25px rgba(0, 0, 0, 0.15) !important;
    z-index: 100000 !important;
    display: flex !important;
    flex-direction: column !important;
    transform: translateX(100%) !important;
    visibility: hidden;
    transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1), visibility 0.3s ease-in-out !important;
    overflow: hidden;
    padding: 0;
    /* Performance optimizations */
    will-change: transform;
    backface-visibility: hidden;
    /* Ensure footer is always at bottom and doesn't move */
    align-items: stretch;
}

#cart-drawer.drawer-open {
    transform: translateX(0) !important;
    visibility: visible !important;
}

/* ============================================
   Header Section
   ============================================ */

#cart-drawer .cart-header {
    padding: clamp(18px, 4vw, 24px);
    background: linear-gradient(135deg, var(--gray-50, #f9fafb) 0%, var(--background, #ffffff) 100%);
    border-bottom: 2px solid var(--gray-200, #e5e7eb);
    flex-shrink: 0;
}

#cart-drawer .cart-header h2 {
    font-size: clamp(1.1rem, 2.5vw, 1.3rem);
    font-weight: 700;
    color: var(--foreground, #171717);
    margin: 0;
    text-transform: uppercase;
    letter-spacing: 0.03em;
}

#cart-drawer #close-cart-drawer {
    width: 36px;
    height: 36px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: transparent;
    border: none;
    border-radius: 50%;
    cursor: pointer;
    transition: all 0.2s ease;
    color: var(--neutral, #6b7280);
}

#cart-drawer #close-cart-drawer:hover {
    background: rgba(204, 22, 22, 0.1);
    /* primary with 10% opacity */
    color: var(--primary, #cc1616);
}

#cart-drawer #close-cart-drawer .material-icons {
    font-size: 24px;
}

/* ============================================
   Content Area (Mini Cart)
   ============================================ */

#cart-drawer #mini-cart-content {
    flex: 1;
    overflow-y: auto;
    overflow-x: hidden;
    padding: clamp(12px, 2vw, 16px);
    background: var(--background, #ffffff);
    /* Ensure content doesn't push footer */
    min-height: 0;
    /* Prevent content from affecting footer position */
    position: relative;
    z-index: 1;
    max-width: 100%;
    box-sizing: border-box;
}

/* Scrollbar Styling */
#cart-drawer #mini-cart-content::-webkit-scrollbar {
    width: 8px;
}

#cart-drawer #mini-cart-content::-webkit-scrollbar-track {
    background: var(--gray-100, #f3f4f6);
    border-radius: 10px;
}

#cart-drawer #mini-cart-content::-webkit-scrollbar-thumb {
    background: var(--gray-300, #d1d5db);
    border-radius: 10px;
}

#cart-drawer #mini-cart-content::-webkit-scrollbar-thumb:hover {
    background: var(--gray-400, #9ca3af);
}

/* Empty Cart State - Modern Design (using global CSS variables) */
#cart-drawer .woocommerce-mini-cart__empty-message {
    text-align: center;
    padding: 80px 20px 40px;
    color: var(--neutral, #6b7280);
    font-size: 1rem;
    line-height: 1.6;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    min-height: 200px;
}

/* Empty Cart Icon (using global CSS variables) */
#cart-drawer .woocommerce-mini-cart__empty-message::before {
    content: '';
    display: block;
    width: 80px;
    height: 80px;
    margin: 0 auto 24px;
    background: url('data:image/svg+xml,<svg xmlns="http://www.w3.org/2000/svg" fill="none" viewBox="0 0 24 24" stroke="%236b7280"><path stroke-linecap="round" stroke-linejoin="round" stroke-width="1.5" d="M16 11V7a4 4 0 00-8 0v4M5 9h14l1 12H4L5 9z"/></svg>') no-repeat center;
    background-size: contain;
    opacity: 0.5;
}

/* Cart Items */
#cart-drawer .woocommerce-mini-cart {
    list-style: none;
    margin: 0;
    padding: 0;
}

/* Cart Item - Main Container - Two-Row Grid Layout */
/* Row 1: [Image (spans 2 rows)] [Name (full width)] [empty] [empty] [empty] */
/* Row 2: [empty] [Variants] [Qty] [Price] [X] */
#cart-drawer .woocommerce-mini-cart-item {
    display: grid;
    grid-template-columns: 70px 1fr auto auto 28px;
    grid-template-rows: auto auto;
    gap: 8px 14px;
    padding: 18px 0;
    border-bottom: 1px solid var(--gray-200, #e5e7eb);
    position: relative;
    align-items: start;
    background: transparent;
    transition: background-color 0.2s ease;
    min-height: auto;
    max-width: 100%;
    overflow: visible;
    align-content: start;
}

/* Grid Areas:
   - Column 1 (90px): Image
   - Column 2 (1fr): Name + Variants
   - Column 3 (auto): Quantity controls
   - Column 4 (auto): Price
   - Column 5 (40px): Remove button
*/

#cart-drawer .woocommerce-mini-cart-item:hover {
    background: rgba(204, 22, 22, 0.02);
    /* primary with 2% opacity */
}

#cart-drawer .woocommerce-mini-cart-item:last-child {
    border-bottom: none;
}

/* Product Image Wrapper - Grid Column 1, spans both rows */
#cart-drawer .woocommerce-mini-cart-item .product-image-wrapper {
    grid-column: 1;
    grid-row: 1 / 3;
    /* Spans rows 1 and 2 */
    display: flex;
    align-items: start;
    justify-content: start;
}

/* Product Image - inside wrapper */
#cart-drawer .woocommerce-mini-cart-item .product-image-wrapper img,
#cart-drawer .woocommerce-mini-cart-item img {
    width: 70px;
    height: 70px;
    min-width: 70px;
    max-width: 70px;
    object-fit: contain;
    border-radius: 8px;
    border: 1px solid var(--gray-200, #e5e7eb);
    background: var(--gray-50, #f9fafb);
    transition: border-color 0.2s ease;
    padding: 3px;
    display: block;
}

#cart-drawer .woocommerce-mini-cart-item:hover img {
    border-color: var(--primary, #cc1616);
    box-shadow: 0 2px 8px rgba(204, 22, 22, 0.15);
}

/* Product Image Link */
#cart-drawer .woocommerce-mini-cart-item .product-image-wrapper a {
    display: block;
    text-decoration: none;
}

/* Product Name Wrapper - Grid Column 2, Row 1 (full width, spans columns 2-5) */
#cart-drawer .woocommerce-mini-cart-item .product-name-wrapper {
    grid-column: 2 / 6;
    /* Spans from column 2 to 6 (full width except image) */
    grid-row: 1;
    display: flex;
    align-items: start;
    min-width: 0;
    /* Critical: allows shrinking */
    width: 100%;
    max-width: 100%;
    /* Ensure text flows horizontally */
    overflow-wrap: break-word;
    word-break: normal;
}

/* Product Name Link */
#cart-drawer .woocommerce-mini-cart-item .product-name-link {
    text-decoration: none;
    color: var(--foreground, #171717);
    transition: color 0.2s ease;
    display: block;
    width: 100%;
    min-width: 0;
}

#cart-drawer .woocommerce-mini-cart-item .product-name-link:hover {
    color: var(--primary, #cc1616);
}

/* Product Name - full width, fully visible, wraps naturally */
#cart-drawer .woocommerce-mini-cart-item .product-name {
    display: block;
    color: inherit;
    font-weight: 600;
    font-size: 0.95rem;
    line-height: 1.5;
    /* Normal word breaking - break only at word boundaries */
    word-wrap: break-word;
    word-break: normal;
    /* Critical: prevents letter-by-letter breaking */
    overflow-wrap: break-word;
    margin: 0;
    padding: 0;
    min-width: 0;
    /* Critical: allows shrinking */
    width: 100%;
    max-width: 100%;
    text-align: left;
    white-space: normal;
    /* Critical: allows wrapping */
    /* Allow natural height - no limits */
    max-height: none;
    height: auto;
    /* Ensure text flows horizontally */
    writing-mode: horizontal-tb;
    text-orientation: mixed;
}

/* Quantity Controls - Grid Column 3, Row 2 (moved to second row) */
#cart-drawer .woocommerce-mini-cart-item .cart-drawer-qty-wrapper {
    grid-column: 3;
    grid-row: 2;
    /* Moved to second row */
    margin: 0;
    padding: 0;
    align-self: start;
    justify-self: end;
    width: auto;
    min-width: fit-content;
    flex-shrink: 0;
}

/* Price - Grid Column 4, Row 2 (moved to second row) */
#cart-drawer .woocommerce-mini-cart-item .cart-drawer-item-price {
    grid-column: 4;
    grid-row: 2;
    /* Moved to second row */
    margin: 0;
    padding: 0;
    text-align: right;
    align-self: start;
    justify-self: end;
    font-size: 1rem;
    font-weight: 700;
    white-space: nowrap;
    width: auto;
    min-width: fit-content;
    flex-shrink: 0;
}

/* Product Variants - Grid Column 2, Row 2 (below name) */
#cart-drawer .woocommerce-mini-cart-item .variation {
    grid-column: 2;
    grid-row: 2;
    font-size: 0.8rem;
    color: var(--neutral, #6b7280);
    line-height: 1.4;
    margin: 4px 0 0 0;
    padding: 0;
    font-weight: 400;
    display: block;
    align-self: start;
    overflow: visible;
    word-wrap: break-word;
    max-width: 100%;
}

#cart-drawer .woocommerce-mini-cart-item .variation dt,
#cart-drawer .woocommerce-mini-cart-item .variation dd {
    display: inline;
    margin: 0;
}

#cart-drawer .woocommerce-mini-cart-item .variation dt {
    font-weight: 500;
    margin-right: 4px;
}

#cart-drawer .woocommerce-mini-cart-item .variation dd {
    color: var(--gray-600, #4b5563);
}

#cart-drawer .woocommerce-mini-cart-item .variation dt::after {
    content: ':';
    margin-right: 2px;
}

/* Cart Item Data (variations wrapper) */
#cart-drawer .woocommerce-mini-cart-item dl.variation {
    margin-top: 6px;
    padding: 0;
}

/* Quantity */
#cart-drawer .woocommerce-mini-cart-item .quantity {
    font-size: 0.85rem;
    color: var(--neutral, #6b7280);
    margin-bottom: 8px;
}

/* Price - better visibility */
#cart-drawer .woocommerce-mini-cart-item .amount,
#cart-drawer .woocommerce-mini-cart-item .woocommerce-Price-amount,
#cart-drawer .woocommerce-mini-cart-item .cart-drawer-item-price {
    font-weight: 800;
    color: var(--primary, #cc1616);
    font-size: 1.15rem;
    line-height: 1.2;
    margin-top: 4px;
    text-align: right;
}

#cart-drawer .woocommerce-mini-cart-item .cart-drawer-item-price {
    display: block;
}

/* Actions Container - quantity, price, remove */
#cart-drawer .woocommerce-mini-cart-item .cart-item-actions {
    display: flex;
    flex-direction: column;
    align-items: flex-end;
    gap: 8px;
    flex-shrink: 0;
    min-width: 120px;
}

/* Remove Button - Grid Column 5, Row 2 (moved to second row) */
#cart-drawer .woocommerce-mini-cart-item .remove {
    grid-column: 5;
    grid-row: 2;
    /* Moved to second row */
    width: 24px;
    height: 24px;
    min-width: 24px;
    max-width: 24px;
    border-radius: 50%;
    background: var(--background, #ffffff);
    color: var(--primary, #cc1616);
    text-decoration: none;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 18px;
    font-weight: 300;
    line-height: 1;
    transition: all 0.2s ease;
    border: 1px solid var(--gray-200, #e5e7eb);
    box-shadow: 0 1px 2px rgba(0, 0, 0, 0.08);
    align-self: start;
    justify-self: end;
    position: relative;
    flex-shrink: 0;
}

#cart-drawer .woocommerce-mini-cart-item .remove:hover {
    background: var(--primary, #cc1616);
    color: var(--background, #ffffff);
    border-color: var(--primary, #cc1616);
    transform: scale(1.1);
    box-shadow: 0 2px 6px rgba(204, 22, 22, 0.3);
}

/* Subtotal - enhanced visual emphasis */
#cart-drawer .woocommerce-mini-cart__total {
    padding: 24px 0;
    border-top: 3px solid var(--gray-200, #e5e7eb);
    margin-top: 20px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    background: linear-gradient(180deg, rgba(249, 250, 251, 0.5) 0%, rgba(255, 255, 255, 0) 100%);
    /* gray-50 with opacity */
    padding-left: 4px;
    padding-right: 4px;
    border-radius: 8px 8px 0 0;
}

#cart-drawer .woocommerce-mini-cart__total strong {
    font-size: 1.2rem;
    color: var(--foreground, #171717);
    text-transform: uppercase;
    letter-spacing: 0.03em;
    font-weight: 700;
}

#cart-drawer .woocommerce-mini-cart__total .amount,
#cart-drawer .woocommerce-mini-cart__total .woocommerce-Price-amount {
    font-size: 1.6rem;
    font-weight: 900;
    color: var(--primary, #cc1616);
    letter-spacing: -0.02em;
}

/* ============================================
   Footer Actions
   ============================================ */

/* Footer container - using semantic class with high specificity (using global CSS variables) */
#cart-drawer .cart-footer {
    padding: clamp(18px, 4vw, 24px);
    background: linear-gradient(180deg, var(--background, #ffffff) 0%, var(--gray-50, #f9fafb) 100%);
    border-top: 2px solid var(--gray-200, #e5e7eb);
    flex-shrink: 0;
    box-sizing: border-box;
    margin-top: auto;
    position: relative;
    z-index: 10;
    display: flex;
    flex-direction: column;
    gap: 12px;
    min-height: 140px;
    max-height: 140px;
}

/* Empty cart footer - smaller height */
#cart-drawer .cart-footer--empty {
    min-height: auto;
    max-height: none;
    padding: clamp(18px, 4vw, 24px);
}

/* Legacy selector for backward compatibility (can be removed later) - using global CSS variables */
#cart-drawer>div:last-child:not(.cart-footer) {
    padding: clamp(18px, 4vw, 24px) !important;
    background: linear-gradient(180deg, var(--background, #ffffff) 0%, var(--gray-50, #f9fafb) 100%) !important;
    border-top: 2px solid var(--gray-200, #e5e7eb) !important;
    flex-shrink: 0 !important;
    height: auto !important;
    min-height: 140px !important;
    max-height: 140px !important;
    box-sizing: border-box !important;
    margin-top: auto !important;
    position: relative !important;
    z-index: 10 !important;
}

/* Cart Footer Buttons - Base Styles (using semantic classes) - HIGH SPECIFICITY */
#cart-drawer .cart-footer__button,
#cart-drawer .cart-footer a.cart-footer__button {
    display: block !important;
    text-align: center !important;
    padding: 14px 24px !important;
    border-radius: 50px !important;
    font-weight: 700 !important;
    font-size: 0.95rem !important;
    text-transform: uppercase !important;
    letter-spacing: 0.05em !important;
    text-decoration: none !important;
    transition: all 0.3s ease !important;
    box-sizing: border-box !important;
    width: 100% !important;
    height: 48px !important;
    min-height: 48px !important;
    max-height: 48px !important;
    line-height: 20px !important;
    white-space: nowrap !important;
    overflow: hidden !important;
    text-overflow: ellipsis !important;
    flex-shrink: 0 !important;
    flex-grow: 0 !important;
    cursor: pointer !important;
    border: 2px solid transparent !important;
}

/* View Cart Button - Modern Design with Primary Color (using global CSS variables) */
#cart-drawer .cart-footer__button--view-cart,
#cart-drawer .cart-footer a.cart-footer__button--view-cart {
    background: var(--background, #ffffff) !important;
    color: var(--primary, #cc1616) !important;
    border: 2px solid var(--primary, #cc1616) !important;
}

#cart-drawer .cart-footer__button--view-cart:hover,
#cart-drawer .cart-footer a.cart-footer__button--view-cart:hover {
    background: var(--primary, #cc1616) !important;
    color: var(--background, #ffffff) !important;
    transform: translateY(-2px) !important;
    box-shadow: 0 8px 16px rgba(204, 22, 22, 0.3) !important;
    border-color: var(--primary-hover, #b31313) !important;
}

/* Checkout Button - Modern Design with Primary Color (using global CSS variables) */
#cart-drawer .cart-footer__button--checkout,
#cart-drawer .cart-footer a.cart-footer__button--checkout {
    background: var(--primary, #cc1616) !important;
    color: var(--background, #ffffff) !important;
    border: 2px solid transparent !important;
    box-shadow: 0 8px 20px rgba(204, 22, 22, 0.35) !important;
    margin-bottom: 0 !important;
}

#cart-drawer .cart-footer__button--checkout:hover,
#cart-drawer .cart-footer a.cart-footer__button--checkout:hover {
    background: var(--primary-hover, #b31313) !important;
    transform: translateY(-3px) !important;
    box-shadow: 0 12px 28px rgba(204, 22, 22, 0.45) !important;
}

/* Continue Shopping Button (Empty Cart) - using global CSS variables - HIGHEST SPECIFICITY */
/* Must override the pink gradient from legacy styles */
#cart-drawer .cart-footer__button--continue-shopping,
#cart-drawer .cart-footer a.cart-footer__button--continue-shopping,
#cart-drawer .cart-footer--empty .cart-footer__button--continue-shopping,
#cart-drawer .cart-footer--empty a.cart-footer__button--continue-shopping,
#cart-drawer>div:last-child.cart-footer--empty a.cart-footer__button--continue-shopping,
#cart-drawer>div:last-child.cart-footer--empty a:last-child.cart-footer__button--continue-shopping,
#cart-drawer>div:last-child.cart-footer--empty a.cart-footer__button--continue-shopping.block,
#cart-drawer>div:last-child.cart-footer--empty a:last-child.cart-footer__button--continue-shopping.block {
    background: var(--primary, #cc1616) !important;
    background-image: none !important;
    /* Override any gradient */
    color: var(--background, #ffffff) !important;
    border: 2px solid transparent !important;
    box-shadow: 0 8px 20px rgba(204, 22, 22, 0.35) !important;
    /* Fixed dimensions */
    height: 48px !important;
    min-height: 48px !important;
    max-height: 48px !important;
    width: 100% !important;
    line-height: 20px !important;
    padding-top: 14px !important;
    padding-bottom: 14px !important;
    padding-left: 24px !important;
    padding-right: 24px !important;
}

#cart-drawer .cart-footer__button--continue-shopping:hover,
#cart-drawer .cart-footer a.cart-footer__button--continue-shopping:hover,
#cart-drawer .cart-footer--empty .cart-footer__button--continue-shopping:hover,
#cart-drawer .cart-footer--empty a.cart-footer__button--continue-shopping:hover,
#cart-drawer>div:last-child.cart-footer--empty a.cart-footer__button--continue-shopping:hover,
#cart-drawer>div:last-child.cart-footer--empty a:last-child.cart-footer__button--continue-shopping:hover,
#cart-drawer>div:last-child.cart-footer--empty a.cart-footer__button--continue-shopping.block:hover,
#cart-drawer>div:last-child.cart-footer--empty a:last-child.cart-footer__button--continue-shopping.block:hover {
    background: var(--primary-hover, #b31313) !important;
    background-image: none !important;
    /* Override any gradient */
    transform: translateY(-2px) !important;
    box-shadow: 0 12px 28px rgba(204, 22, 22, 0.45) !important;
    /* Maintain fixed dimensions on hover */
    height: 48px !important;
    min-height: 48px !important;
    max-height: 48px !important;
    width: 100% !important;
}

/* Empty Cart Footer - Adjust height */
#cart-drawer .cart-footer--empty {
    min-height: auto;
    max-height: none;
}

/* Legacy selectors for backward compatibility (to be removed later) */
#cart-drawer .cart-footer a:not(.cart-footer__button),
#cart-drawer>div:last-child a {
    display: block !important;
    text-align: center !important;
    padding: 14px 24px !important;
    border-radius: 50px !important;
    font-weight: 700 !important;
    font-size: 0.95rem !important;
    text-transform: uppercase !important;
    letter-spacing: 0.05em !important;
    text-decoration: none !important;
    transition: all 0.3s ease !important;
    margin-bottom: 12px !important;
    box-sizing: border-box !important;
    width: 100% !important;
    height: 48px !important;
    min-height: 48px !important;
    max-height: 48px !important;
    line-height: 20px !important;
    white-space: nowrap !important;
    overflow: hidden !important;
    text-overflow: ellipsis !important;
    flex-shrink: 0 !important;
    flex-grow: 0 !important;
}

#cart-drawer .cart-footer a:last-child,
#cart-drawer>div:last-child a:last-child {
    margin-bottom: 0 !important;
    height: 48px !important;
    min-height: 48px !important;
    max-height: 48px !important;
}

/* View Cart Button - Legacy selectors updated to primary color */
#cart-drawer .cart-footer a[href*="cart"],
#cart-drawer>div:last-child a[href*="cart"] {
    background: #ffffff !important;
    color: var(--primary, #cc1616) !important;
    border: 2px solid var(--primary, #cc1616) !important;
    height: 48px !important;
    min-height: 48px !important;
    max-height: 48px !important;
}

#cart-drawer .cart-footer a[href*="cart"]:hover,
#cart-drawer>div:last-child a[href*="cart"]:hover {
    background: var(--primary, #cc1616) !important;
    color: #ffffff !important;
    transform: translateY(-2px) !important;
    box-shadow: 0 8px 16px rgba(204, 22, 22, 0.3) !important;
    height: 48px !important;
    min-height: 48px !important;
    max-height: 48px !important;
    border-color: var(--primary-hover, #b31313) !important;
}

/* Checkout Button - Legacy selectors updated to primary color */
#cart-drawer .cart-footer a[href*="checkout"],
#cart-drawer>div:last-child a[href*="checkout"] {
    background: var(--primary, #cc1616) !important;
    color: #ffffff !important;
    border: 2px solid transparent !important;
    box-shadow: 0 8px 20px rgba(204, 22, 22, 0.35) !important;
    height: 48px !important;
    min-height: 48px !important;
    max-height: 48px !important;
}

#cart-drawer .cart-footer a[href*="checkout"]:hover,
#cart-drawer>div:last-child a[href*="checkout"]:hover {
    background: var(--primary-hover, #b31313) !important;
    transform: translateY(-3px) !important;
    box-shadow: 0 12px 28px rgba(204, 22, 22, 0.45) !important;
    height: 48px !important;
    min-height: 48px !important;
    max-height: 48px !important;
}

/* ============================================
   Responsive Design
   ============================================ */

@media (max-width: 480px) {
    #cart-drawer {
        width: 100vw;
        max-width: 100vw;
    }

    #cart-drawer .cart-header h2 {
        font-size: 1.05rem;
    }

    #cart-drawer .woocommerce-mini-cart-item img {
        width: 60px;
        height: 60px;
    }

    #cart-drawer .cart-footer a {
        font-size: 0.9rem;
        padding: 12px 20px;
    }
}

/* ============================================
   Loading State
   ============================================ */

#cart-drawer.loading {
    pointer-events: none;
    opacity: 0.7;
}

#cart-drawer.loading::after {
    content: '';
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: 40px;
    height: 40px;
    border: 4px solid var(--gray-100, #f3f4f6);
    border-top: 4px solid var(--primary, #cc1616);
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

@keyframes spin {
    0% {
        transform: translate(-50%, -50%) rotate(0deg);
    }

    100% {
        transform: translate(-50%, -50%) rotate(360deg);
    }
}

/* ============================================
   Tailwind Brand Color Fallbacks
   ============================================ */

/* Fallback for border-brand-blue if not in Tailwind config */
#cart-drawer .border-brand-blue {
    border-color: var(--primary, #cc1616) !important;
}

/* Fallback for text-brand-blue if not in Tailwind config */
#cart-drawer .text-brand-blue {
    color: var(--primary, #cc1616) !important;
}

/* Fallback for hover:bg-brand-blue if not in Tailwind config */
#cart-drawer .hover\:bg-brand-blue:hover {
    background-color: var(--primary, #cc1616) !important;
}

/* Fallback for bg-brand-pink if not in Tailwind config */
#cart-drawer .bg-brand-pink {
    background: var(--primary, #cc1616) !important;
}

/* Fallback for focus:ring-brand-blue if not in Tailwind config */
#cart-drawer .focus\:ring-brand-blue:focus {
    --tw-ring-color: var(--primary, #cc1616) !important;
}

/* Fallback for focus:ring-brand-pink if not in Tailwind config */
#cart-drawer .focus\:ring-brand-pink:focus {
    --tw-ring-color: var(--primary, #cc1616) !important;
}

/* ============================================
   Additional Footer Button Targeting
   ============================================ */

/* Target footer buttons directly by structure - ensure consistent sizing */
/* Override Tailwind classes - CRITICAL: Footer must have fixed dimensions */
#cart-drawer>div:last-child,
#cart-drawer>div:last-child.flex,
#cart-drawer>div:last-child[class*="flex"],
#cart-drawer>div:last-child[class*="flex-col"] {
    flex-shrink: 0 !important;
    /* Fixed height calculation: padding (24px*2) + button1 (48px) + gap (12px) + button2 (48px) = 156px */
    height: 156px !important;
    min-height: 156px !important;
    max-height: 156px !important;
    box-sizing: border-box !important;
    margin-top: auto !important;
    position: relative !important;
    z-index: 10 !important;
    /* Override Tailwind flex-col if present */
    flex-direction: column !important;
    /* Override Tailwind gap if present */
    gap: 12px !important;
    /* Prevent any content from affecting footer */
    overflow: hidden !important;
}

/* Override Tailwind classes for buttons */
#cart-drawer>div:last-child a.block,
#cart-drawer>div:last-child a[class*="block"],
#cart-drawer>div:last-child a {
    display: block !important;
    text-align: center !important;
    padding: 14px 24px !important;
    border-radius: 50px !important;
    font-weight: 700 !important;
    font-size: 0.95rem !important;
    text-transform: uppercase !important;
    letter-spacing: 0.05em !important;
    text-decoration: none !important;
    transition: all 0.3s ease !important;
    margin-bottom: 12px !important;
    /* Fixed dimensions - prevent any size changes */
    box-sizing: border-box !important;
    width: 100% !important;
    height: 48px !important;
    min-height: 48px !important;
    max-height: 48px !important;
    line-height: 20px !important;
    /* Prevent text wrapping - override Tailwind */
    white-space: nowrap !important;
    overflow: hidden !important;
    text-overflow: ellipsis !important;
    /* Prevent flex from changing size */
    flex-shrink: 0 !important;
    flex-grow: 0 !important;
    /* Override Tailwind w-full if present */
    width: 100% !important;
    /* Override Tailwind py-3 if present - use fixed padding */
    padding-top: 14px !important;
    padding-bottom: 14px !important;
}

/* First button in footer (Zobacz koszyk) - override all possible styles */
#cart-drawer>div:last-child a:first-child,
#cart-drawer>div:last-child a:first-child.block,
#cart-drawer>div:last-child a:first-child[class*="block"] {
    background: var(--background, #ffffff) !important;
    color: var(--primary, #cc1616) !important;
    border: 2px solid var(--primary, #cc1616) !important;
    /* Fixed dimensions - CRITICAL */
    height: 48px !important;
    min-height: 48px !important;
    max-height: 48px !important;
    width: 100% !important;
    line-height: 20px !important;
    /* Override any Tailwind padding classes */
    padding-top: 14px !important;
    padding-bottom: 14px !important;
    padding-left: 24px !important;
    padding-right: 24px !important;
}

#cart-drawer>div:last-child a:first-child:hover {
    background: var(--primary, #cc1616) !important;
    color: var(--background, #ffffff) !important;
    transform: translateY(-2px) !important;
    box-shadow: 0 8px 16px rgba(204, 22, 22, 0.3) !important;
    /* primary color */
    border-color: var(--primary-hover, #b31313) !important;
    /* Maintain fixed dimensions on hover */
    height: 48px !important;
    min-height: 48px !important;
    max-height: 48px !important;
    width: 100% !important;
}

/* Second button in footer (Przejdź do kasy) - override all possible styles - EXCLUDE continue-shopping */
#cart-drawer>div:last-child:not(.cart-footer--empty) a:last-child:not(.cart-footer__button--continue-shopping),
#cart-drawer>div:last-child:not(.cart-footer--empty) a:last-child.block:not(.cart-footer__button--continue-shopping),
#cart-drawer>div:last-child:not(.cart-footer--empty) a:last-child[class*="block"]:not(.cart-footer__button--continue-shopping) {
    background: var(--primary, #cc1616) !important;
    color: var(--background, #ffffff) !important;
    border: 2px solid transparent !important;
    box-shadow: 0 8px 20px rgba(204, 22, 22, 0.35) !important;
    margin-bottom: 0 !important;
    /* Fixed dimensions - CRITICAL */
    height: 48px !important;
    min-height: 48px !important;
    max-height: 48px !important;
    width: 100% !important;
    line-height: 20px !important;
    /* Override any Tailwind padding classes */
    padding-top: 14px !important;
    padding-bottom: 14px !important;
    padding-left: 24px !important;
    padding-right: 24px !important;
}

#cart-drawer>div:last-child:not(.cart-footer--empty) a:last-child:not(.cart-footer__button--continue-shopping):hover {
    background: var(--primary-hover, #b31313) !important;
    transform: translateY(-3px) !important;
    box-shadow: 0 12px 28px rgba(204, 22, 22, 0.45) !important;
    /* Maintain fixed dimensions on hover */
    height: 48px !important;
    min-height: 48px !important;
    max-height: 48px !important;
    width: 100% !important;
}

/* ============================================
   Toast Notification
   ============================================ */

.add-to-cart-toast {
    position: fixed;
    top: 100px;
    /* Lower position as requested */
    right: 20px;
    background: linear-gradient(135deg, var(--success, #10b981) 0%, var(--accent-hover, #047857) 100%);
    color: var(--background, #ffffff);
    padding: 16px 24px;
    border-radius: 50px;
    font-weight: 600;
    font-size: 0.95rem;
    box-shadow: 0 8px 24px rgba(16, 185, 129, 0.4);
    /* success color */
    z-index: 10005;
    opacity: 0;
    transform: translateY(-20px);
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    pointer-events: none;
    display: flex;
    align-items: center;
    gap: 8px;
}

.add-to-cart-toast.show {
    opacity: 1;
    transform: translateY(0);
}

@media (max-width: 768px) {
    .add-to-cart-toast {
        top: 80px;
        right: 10px;
        left: 10px;
        text-align: center;
        justify-content: center;
        font-size: 0.9rem;
        padding: 14px 20px;
    }
}

/* ============================================
   Cart Badge Styling
   ============================================ */

/* Ensure parent has relative positioning */
.modeokids-header__cart-btn,
#mobile-cart-trigger {
    position: relative !important;
    display: inline-flex !important;
    align-items: center;
    justify-content: center;
}

.cart-count,
.modeokids-header__cart-count {
    background: var(--primary, #cc1616);
    color: var(--background, #ffffff);
    font-size: 0.75rem;
    font-weight: 800;
    height: 22px;
    min-width: 22px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 9999px;
    position: absolute;
    top: -8px;
    right: -8px;
    padding: 0 5px;
    box-shadow: 0 3px 8px rgba(204, 22, 22, 0.4);
    /* primary color */
    border: 2px solid var(--background, #ffffff);
    transition: transform 0.2s ease;
}

/* ============================================
   Cart Badge Bounce Animation
   ============================================ */

.cart-count.bounce,
.modeokids-header__cart-count.bounce {
    animation: badge-bounce 0.6s cubic-bezier(0.68, -0.55, 0.265, 1.55);
}

@keyframes badge-bounce {

    0%,
    100% {
        transform: scale(1);
    }

    50% {
        transform: scale(1.3);
    }
}

/* ============================================
   Highlighted Product Animation
   ============================================ */

#cart-drawer .woocommerce-mini-cart-item.just-added {
    background: linear-gradient(90deg, rgba(16, 185, 129, 0.15) 0%, rgba(16, 185, 129, 0.05) 100%);
    /* success color */
    animation: highlight-pulse 1.5s ease-out;
    border-left: 3px solid var(--success, #10b981);
    padding-left: 13px;
    /* Use transform for better performance */
    will-change: background-color, transform;
    /* Ensure smooth animation */
    transform: translateZ(0);
    backface-visibility: hidden;
}

@keyframes highlight-pulse {
    0% {
        background: rgba(16, 185, 129, 0.2);
        /* success color */
        transform: translateZ(0) scale(1);
    }

    50% {
        background: rgba(16, 185, 129, 0.15);
        /* success color */
        transform: translateZ(0) scale(1.01);
    }

    100% {
        background: rgba(16, 185, 129, 0.05);
        /* success color */
        transform: translateZ(0) scale(1);
    }
}

/* ============================================
   Hide Default WooCommerce "View Cart" Link
   ============================================ */

a.added_to_cart.wc-forward {
    display: none !important;
}

.p-5 {
    padding: 1rem !important;
}

/* FORCE Cart Drawer Styles */
#cart-drawer {
    top: 0 !important;
    right: 0 !important;
    height: 100vh !important;
    width: 90vw !important;
    max-width: 500px !important;
    z-index: 10002 !important;
    position: fixed !important;
    background-color: white !important;
    box-shadow: -5px 0 15px rgba(0, 0, 0, 0.1) !important;
    padding: 0px;
    overflow-x: hidden !important;
}

/* ============================================
   Quantity Controls in Mini Cart
   ============================================ */

/* Quantity Wrapper */
#cart-drawer .cart-drawer-qty-wrapper {
    display: flex;
    align-items: center;
    gap: 5px;
    margin: 0;
    position: relative;
    justify-content: flex-end;
    width: auto;
    flex-shrink: 0;
}

/* Quantity Buttons - compact */
#cart-drawer .cart-drawer-qty-btn {
    width: 28px;
    height: 28px;
    min-width: 28px;
    border: 1px solid var(--gray-200, #e5e7eb);
    background: var(--background, #ffffff);
    border-radius: 6px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: all 0.2s ease;
    padding: 0;
    color: var(--gray-600, #4b5563);
    font-size: 0;
    box-shadow: 0 1px 2px rgba(0, 0, 0, 0.05);
}

#cart-drawer .cart-drawer-qty-btn:hover:not(:disabled) {
    background: var(--primary, #cc1616);
    border-color: var(--primary, #cc1616);
    color: var(--background, #ffffff);
    transform: translateY(-1px);
    box-shadow: 0 2px 6px rgba(204, 22, 22, 0.25);
    /* primary color */
}

#cart-drawer .cart-drawer-qty-btn:active:not(:disabled) {
    transform: translateY(0);
    box-shadow: 0 1px 3px rgba(204, 22, 22, 0.2);
    /* primary color */
}

#cart-drawer .cart-drawer-qty-btn:disabled {
    opacity: 0.4;
    cursor: not-allowed;
    pointer-events: none;
    background: var(--gray-50, #f9fafb);
}

#cart-drawer .cart-drawer-qty-btn .material-icons {
    font-size: 16px;
    line-height: 1;
}

/* Quantity Input - compact */
#cart-drawer .cart-drawer-qty-input {
    width: 40px;
    height: 28px;
    text-align: center;
    border: 1px solid var(--gray-200, #e5e7eb);
    border-radius: 6px;
    font-size: 0.9rem;
    font-weight: 600;
    color: var(--foreground, #171717);
    background: var(--background, #ffffff);
    padding: 0 4px;
    appearance: textfield;
    -moz-appearance: textfield;
    transition: all 0.2s ease;
    box-shadow: 0 1px 2px rgba(0, 0, 0, 0.05);
}

#cart-drawer .cart-drawer-qty-input::-webkit-outer-spin-button,
#cart-drawer .cart-drawer-qty-input::-webkit-inner-spin-button {
    -webkit-appearance: none;
    margin: 0;
}

#cart-drawer .cart-drawer-qty-input:focus {
    outline: none;
    border-color: var(--primary, #cc1616);
    box-shadow: 0 0 0 3px rgba(204, 22, 22, 0.15);
    background: var(--primary-50, #fef2f2);
}

#cart-drawer .cart-drawer-qty-input:disabled {
    background: var(--gray-50, #f9fafb);
    cursor: not-allowed;
    opacity: 0.7;
}

/* Item Price - better visibility */
#cart-drawer .cart-drawer-item-price {
    font-size: 1.15rem;
    font-weight: 800;
    color: var(--primary, #cc1616);
    margin-top: 4px;
    line-height: 1.2;
    text-align: right;
    display: block;
}

/* Loading State */
#cart-drawer .woocommerce-mini-cart-item.cart-item-updating {
    opacity: 0.6;
    pointer-events: none;
}

#cart-drawer .cart-drawer-qty-wrapper.is-loading {
    position: relative;
}

#cart-drawer .cart-drawer-qty-wrapper.is-loading::after {
    content: '';
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: 16px;
    height: 16px;
    border: 2px solid #e9ecef;
    border-top-color: var(--primary, #cc1616);
    border-radius: 50%;
    animation: spin 0.6s linear infinite;
    z-index: 1;
}

/* Updated State */
#cart-drawer .woocommerce-mini-cart-item.cart-item-updated {
    animation: cart-item-updated 0.5s ease-out;
}

@keyframes cart-item-updated {
    0% {
        background-color: rgba(16, 185, 129, 0.1);
        /* success color */
    }

    100% {
        background-color: transparent;
    }
}

/* Error Message */
#cart-drawer .cart-item-error {
    margin-top: 6px;
    padding: 8px 12px;
    background: rgba(245, 158, 11, 0.1);
    /* warning with 10% opacity */
    border: 1px solid var(--warning, #f59e0b);
    border-radius: 6px;
    color: var(--gray-800, #1f2937);
    font-size: 0.85rem;
    line-height: 1.4;
    display: flex;
    align-items: center;
    animation: slideInDown 0.3s ease-out;
}

@keyframes slideInDown {
    from {
        opacity: 0;
        transform: translateY(-10px);
    }

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

/* Toast Notifications */
.cart-drawer-toast {
    position: absolute;
    /* Position inside drawer - below header */
    top: 80px;
    right: 20px;
    left: 20px;
    background: var(--background, #ffffff);
    color: var(--foreground, #171717);
    padding: 14px 20px;
    border-radius: 8px;
    font-weight: 500;
    font-size: 0.9rem;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
    z-index: 10010;
    opacity: 0;
    transform: translateY(-20px);
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    pointer-events: none;
    display: flex;
    align-items: center;
    gap: 10px;
    /* Ensure it's above drawer content but below overlay */
    margin: 0;
}

.cart-drawer-toast--show {
    opacity: 1;
    transform: translateX(0);
    pointer-events: auto;
}

.cart-drawer-toast--success {
    border-left: 4px solid var(--success, #10b981);
    background: rgba(16, 185, 129, 0.05);
    /* success with 5% opacity */
}

.cart-drawer-toast--success .material-icons {
    color: var(--success, #10b981);
}

.cart-drawer-toast--error {
    border-left: 4px solid var(--warning, #f59e0b);
    background: rgba(245, 158, 11, 0.08);
    /* warning with 8% opacity - more visible but not aggressive */
}

.cart-drawer-toast--error .material-icons {
    color: var(--warning, #f59e0b);
}

.cart-drawer-toast .material-icons {
    font-size: 20px;
    flex-shrink: 0;
}

.cart-drawer-toast__message {
    flex: 1;
    line-height: 1.4;
}

@media (max-width: 480px) {
    .cart-drawer-toast {
        top: 70px;
        right: 10px;
        left: 10px;
        min-width: auto;
        max-width: calc(100vw - 20px);
    }
}

/* Responsive Adjustments */
@media (max-width: 768px) {

    /* Adjust grid for tablets */
    #cart-drawer .woocommerce-mini-cart-item {
        grid-template-columns: 65px 1fr auto auto 26px;
        gap: 9px 12px;
        padding: 16px 0;
    }

    #cart-drawer .woocommerce-mini-cart-item img,
    #cart-drawer .woocommerce-mini-cart-item>a:not(.remove) img {
        width: 65px;
        height: 65px;
        min-width: 65px;
        max-width: 65px;
    }

    #cart-drawer .woocommerce-mini-cart-item .product-name {
        font-size: 0.9rem;
    }
}

@media (max-width: 480px) {

    /* Smaller grid on mobile */
    #cart-drawer .woocommerce-mini-cart-item {
        grid-template-columns: 60px 1fr auto auto 24px;
        gap: 8px 10px;
        padding: 14px 0;
    }

    /* Smaller image on mobile */
    #cart-drawer .woocommerce-mini-cart-item img,
    #cart-drawer .woocommerce-mini-cart-item>a:not(.remove) img {
        width: 60px;
        height: 60px;
        min-width: 60px;
        max-width: 60px;
    }

    /* Smaller font on mobile */
    #cart-drawer .woocommerce-mini-cart-item>a:not(.remove) {
        gap: 10px;
    }

    #cart-drawer .woocommerce-mini-cart-item .product-name {
        font-size: 0.85rem;
        line-height: 1.4;
    }

    /* Compact quantity controls */
    #cart-drawer .cart-drawer-qty-btn {
        width: 26px;
        height: 26px;
        min-width: 26px;
    }

    #cart-drawer .cart-drawer-qty-input {
        width: 38px;
        height: 26px;
        font-size: 0.85rem;
    }

    #cart-drawer .cart-drawer-qty-btn .material-icons {
        font-size: 14px;
    }

    /* Smaller price */
    #cart-drawer .woocommerce-mini-cart-item .cart-drawer-item-price {
        font-size: 0.9rem;
    }

    /* Smaller remove button */
    #cart-drawer .woocommerce-mini-cart-item .remove {
        width: 22px;
        height: 22px;
        min-width: 22px;
        max-width: 22px;
        font-size: 16px;
    }

    /* Adjust variants */
    #cart-drawer .woocommerce-mini-cart-item .variation {
        font-size: 0.75rem;
    }
}