/*
==========================================================================
                              sidecart.css
==========================================================================
*/

/*
 * FoodiePress Side Cart Styles v4.4.1 (MODIFIED)
 * Cart button is now always visible. Animations are triggered by JS.
 */

/* === Keyframe Animations for Icons === */
@keyframes fp-remove-btn-appear {
  from {
    opacity: 0;
    transform: scale(0.4) rotate(-90deg);
  }
  to {
    opacity: 1;
    transform: scale(1) rotate(0deg);
  }
}

@keyframes fp-trash-icon-appear {
    from {
        opacity: 0;
        transform: scale(0.5);
    }
    to {
        opacity: 1;
        transform: scale(1);
    }
}


/* === Floating Cart Button & Animation === */
.fp-cart-button {
    position: fixed;
    bottom: 25px;
    right: 25px;
    width: 60px;
    height: 60px;
    background-color: #e4002b;
    border-radius: 50%;
    display: flex; /* MODIFIED: Makes the button always visible */
    justify-content: center;
    align-items: center;
    cursor: pointer;
    z-index: 9999;
    box-shadow: 0 5px 15px rgba(0, 0, 0, 0.2);
    border: none;
    transition: transform 0.2s ease, opacity 0.3s ease;
    opacity: 1; /* NEW */
}

.fp-cart-button:hover { transform: scale(1.1); }

.fp-cart-button svg { width: 28px; height: 28px; stroke: #ffffff; }

.fp-cart-count {
    position: absolute;
    top: -5px;
    right: -5px;
    background-color: #000;
    color: #fff;
    border-radius: 50%;
    width: 24px;
    height: 24px;
    display: flex;
    justify-content: center;
    align-items: center;
    font-size: 13px;
    font-weight: 700;
    border: 2px solid #fff;
    /* NEW: Hide count bubble when cart is empty */
    opacity: 0;
    transform: scale(0.5);
    transition: opacity 0.2s ease-in-out, transform 0.2s ease-in-out;
}

/* NEW: Show the count bubble only when the .has-items class is present */
.fp-cart-button.has-items .fp-cart-count {
    opacity: 1;
    transform: scale(1);
}

.fp-cart-button.shake { animation: fp-shake 0.5s cubic-bezier(.36, .07, .19, .97) both; }
@keyframes fp-shake { 10%, 90% { transform: translate3d(-1px, 0, 0) scale(1.1); } 20%, 80% { transform: translate3d(2px, 0, 0) scale(1.1); } 30%, 50%, 70% { transform: translate3d(-3px, 0, 0) scale(1.1); } 40%, 60% { transform: translate3d(3px, 0, 0) scale(1.1); } }


/* === Cart Overlay === */
#fp-cart-backdrop {
    position: fixed;
    inset: 0;
    background-color: rgba(0,0,0,0.5);
    z-index: 10000;
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.4s ease, visibility 0s 0.4s;
}
#fp-cart-backdrop.is-visible {
    opacity: 1;
    visibility: visible;
    transition: opacity 0.4s ease;
}

/* === Side Cart Panel === */
body.fp-body-noscroll { overflow: hidden; }
#fp-side-cart {
    position: fixed;
    top: 0;
    right: 0;
    height: 100vh; /* Fallback for older browsers */
    height: 100dvh; /* FIX: Use dynamic viewport height to adapt to browser UI */
    width: 45%;
    max-width: 500px;
    background-color: #fff;
    color: #222;
    z-index: 100091;
    /* 
     * === ANIMATION FIX: Animate the height property ===
     * When Safari's UI appears/disappears, the `height: 100dvh` causes an instant resize.
     * By adding `height` to the transition, this resize becomes a smooth animation.
     * The footer, being part of the flex layout, moves smoothly with the container's bottom edge.
    */
    transition: transform 0.4s cubic-bezier(0.77, 0, 0.175, 1), height 0.3s ease-out;
    transform: translateX(100%);
    display: flex;
    flex-direction: column;
    box-shadow: -10px 0 30px rgba(0, 0, 0, 0.15);
}
#fp-side-cart.is-open { transform: translateX(0); }
@media (max-width: 768px) { #fp-side-cart { width: 100vw; max-width: 100vw; } }

/* Loading Spinner */
#fp-side-cart.loading::before { content: ''; position: absolute; inset: 0; background-color: rgba(255, 255, 255, 0.7); z-index: 5; }
#fp-side-cart.loading::after { content: ''; position: absolute; top: 50%; left: 50%; width: 30px; height: 30px; border: 3px solid #e4002b; border-top-color: transparent; border-radius: 50%; animation: fp-cart-spinner 0.8s linear infinite; z-index: 6; transform: translate(-50%, -50%); }
@keyframes fp-cart-spinner { to { transform: translate(-50%,-50%) rotate(360deg); } }

/* === Side Cart Internals === */
#fp-side-cart .fp-cart-header { display: flex; justify-content: space-between; align-items: center; padding: 20px 25px; border-bottom: 1px solid #EAEAEA; flex-shrink: 0; }
#fp-side-cart .fp-cart-title { margin: 0; font-size: 1.5rem; font-weight: 700; color: #222; }
#fp-side-cart .fp-close-cart-btn { background: none; border: none; color: #888; font-size: 2.2rem; line-height: 1; cursor: pointer; padding: 0; transition: transform 0.3s ease, color 0.3s ease; }
#fp-side-cart .fp-close-cart-btn:hover { transform: rotate(90deg); color: #222; }
#fp-side-cart .fp-cart-body { flex-grow: 1; overflow-y: auto; }
#fp-side-cart .fp-cart-empty { text-align: center; margin-top: 50px; padding: 0 25px; }
#fp-side-cart .fp-cart-items { list-style: none; padding: 0; margin: 0; }
#fp-side-cart .fp-cart-item { display: grid; grid-template-columns: 70px 1fr auto; gap: 15px; align-items: center; padding: 20px 25px; border-bottom: 1px solid #EAEAEA; }
#fp-side-cart .fp-item-thumbnail img { width: 70px; height: 70px; object-fit: cover; border-radius: 8px; }
#fp-side-cart .fp-item-details { display: flex; flex-direction: column; gap: 4px; }
#fp-side-cart .fp-item-name { display: block; font-weight: 700; color: #111; line-height: 1.3; font-size: 1rem; text-decoration: none; }
#fp-side-cart .fp-item-price { display: block; font-weight: 500; color: #555; font-size: 0.9rem; }

/* Item actions are stacked vertically and centered */
#fp-side-cart .fp-item-actions {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 6px;
}

/* === Quantity Selector & Remove Button === */
#fp-side-cart .fp-quantity-selector { display: flex; align-items: center; justify-content: space-between; background-color: #f0f0f0; border: 1px solid #e0e0e0; border-radius: 999px; padding: 2px; height: 36px; min-width: 95px; }
#fp-side-cart .fp-qty-btn { background-color: #fff; border: 1px solid #dcdcdc; width: 32px; height: 32px; font-size: 1.3rem; line-height: 1; display: flex; align-items: center; justify-content: center; color: #444; cursor: pointer; border-radius: 50%; transition: background-color 0.2s; padding: 0; }
#fp-side-cart .fp-qty-btn:hover { background-color: #f8f9fa; }
#fp-side-cart .fp-item-quantity { font-weight: 700; font-size: 1rem; color: #212529; padding: 0 4px; }

/* Styles for the X button */
#fp-side-cart .fp-remove-item {
    background-color: #f1f1f1;
    border: 1px solid #dcdcdc;
    color: #888;
    width: 28px;
    height: 28px;
    font-size: 1.4rem;
    line-height: 1;
    font-weight: 400;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
    cursor: pointer;
    transition: all 0.2s ease;
    padding: 0;
}
#fp-side-cart .fp-remove-item:hover {
    background-color: #e4002b;
    border-color: #e4002b;
    color: #fff;
    transform: rotate(90deg);
}

/* NEW: The animation is now triggered by the temporary '.animate-appear' class */
#fp-side-cart .fp-remove-item.animate-appear {
    animation: fp-remove-btn-appear 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}
#fp-side-cart .fp-qty-btn.is-trash.animate-appear svg {
    animation: fp-trash-icon-appear 0.2s ease-out;
}


/* === Cart Footer === */
#fp-side-cart .fp-cart-footer {
    padding-top: 20px;
    padding-right: 20px;
    padding-left: 20px;
    padding-bottom: 25px; /* FIX: Set a reasonable default padding */
    padding-bottom: calc(25px + env(safe-area-inset-bottom)); /* FIX: Add padding to avoid device UI (like iPhone home bar) */
    border-top: 1px solid #EAEAEA;
    background-color: #fff;
    box-shadow: 0 -4px 12px rgba(0,0,0,0.05);
    flex-shrink: 0;
}
#fp-side-cart .fp-subtotal { display: flex; justify-content: space-between; font-size: 1.2rem; margin-bottom: 20px; font-weight: 500; }
#fp-side-cart .fp-subtotal .amount { font-weight: 700 !important; color: #222; }
#fp-side-cart .fp-checkout-btn {display: block;width: 100%;text-align: center;background-color: #e4002b;color: #fff;padding: 16px;border-radius: 12px;font-size: 1.1rem;font-weight: 700;text-decoration: none;transition: background-color 0.2s ease;}
#fp-side-cart .fp-checkout-btn:hover { background-color: #333; }

/* === Scoped Addon Styling === */
#fp-side-cart .fp-cart-addons-list { display: flex; flex-direction: column; gap: 4px; margin: 5px 0 0 0; padding: 0; list-style: none; }
#fp-side-cart .fp-addon-choice-name { font-family: 'Rubik', sans-serif; font-size: 14px; margin: 0 !important; padding: 0 !important; font-weight: 400; color: #666; line-height: 15px; }