/* --- Balance Container Styling (Now in Sheet Header) --- */
.balance-container {
    display: flex;
    align-items: center;
    gap: 12px;
}
#balance-display-button {
    display: flex;
    align-items: center;
    font-size: 0.9em;
    font-weight: 500;
    color: #333;
    cursor: default; /* Not clickable */
    background-color: transparent;
    border: none;
    box-shadow: none;
    border-radius: 0;
    padding: 0;
    height: auto;
    gap: 6px;
}
#balance-display-button img {
    width: 18px;
    height: 18px;
    filter: invert(30%); /* Make icon darker grey */
}
#balance-display-button #balance-amount {
    color: #1f9d55; /* Green for balance */
    font-weight: 600;
}

/* --- Shopping Cart Styling --- */
/* Keyframes for animations */
@keyframes slideUpFadeIn {
  from {
    opacity: 0;
    transform: translate(-50%, 100vh); /* Start from bottom, off-screen, centered horizontally */
  }
  to {
    opacity: 1;
    transform: translate(-50%, -50%); /* Centered on screen */
  }
}

@keyframes slideDownFadeOut {
  from {
    opacity: 1;
    transform: translate(-50%, -50%);
  }
  to {
    opacity: 0;
    transform: translate(-50%, 100vh);
  }
}

#shopping-cart-container {
    position: fixed;
    left: 50%;
    top: 50%; /* Target for centering with transform */
    width: 90vw; /* Responsive width */
    max-width: 550px; /* Max width of the modal */
    height: auto; /* Height based on content */
    max-height: 80vh; /* Max height relative to viewport */
    background-color: #ffffff;
    border-radius: 16px;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.1);
    z-index: 1050; /* Ensure it's above most other content */
    display: flex;
    flex-direction: column;
    overflow: hidden; /* Important for border-radius and internal scrolling */

    /* Initial state: hidden and off-screen for animation */
    opacity: 0;
    transform: translate(-50%, 100vh); /* Start off-screen at the bottom */
    pointer-events: none; /* Not interactive when hidden */
    visibility: hidden; /* Use visibility for better performance with animations */
    transition: opacity 0.3s ease, transform 0.3s ease, visibility 0s 0.3s; /* Fallback and visibility delay */
}

#shopping-cart-container.expanded {
    opacity: 1;
    transform: translate(-50%, -50%);
    pointer-events: auto;
    visibility: visible;
    animation: slideUpFadeIn 0.4s cubic-bezier(0.1, 0.7, 0.1, 1) forwards;
    transition: none; /* Disable transition when animation runs */
}

/* This class is applied by toggleCart to hide the modal */
#shopping-cart-container.collapsed {
    opacity: 0;
    transform: translate(-50%, 100vh);
    pointer-events: none;
    visibility: hidden;
    animation: slideDownFadeOut 0.3s cubic-bezier(0.1, 0.7, 0.1, 1) forwards;
    transition: none;
}

/* Styling for the cart's internal header */
#shopping-cart-container .cart-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 12px 20px; /* Reduced padding a bit */
    border-bottom: 1px solid #e8eaed;
    background-color: #f8f9fa; /* Slightly off-white header */
}

#shopping-cart-container .cart-header h2 {
    margin: 0;
    font-size: 1.15em; /* Slightly smaller */
    font-weight: 500; /* Medium weight */
    color: #202124; /* Darker text */
}

#shopping-cart-container #cart-minimize-button { /* The close button inside the modal */
    background: transparent;
    border: none;
    cursor: pointer;
    padding: 8px; /* Make clickable area larger */
    margin: -8px; /* Counteract padding to maintain alignment */
    line-height: 0; /* Prevents extra space from line height */
}

#shopping-cart-container #cart-minimize-button img {
    width: 20px; /* Adjusted size */
    height: 20px;
    display: block;
    opacity: 0.6;
    transition: opacity 0.2s;
}
#shopping-cart-container #cart-minimize-button:hover img {
    opacity: 1;
}

/* Styling for the items list */
#shopping-cart-container #cart-items {
    list-style: none;
    padding: 0;
    margin: 0;
    overflow-y: auto; /* Make items scrollable */
    flex-grow: 1; /* Takes up available space */
    padding: 8px 20px; /* Padding inside the scrollable area */
}

#shopping-cart-container #cart-items li {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 10px 0; /* Slightly reduced padding */
    border-bottom: 1px solid #f1f3f4; /* Lighter border */
}
#shopping-cart-container #cart-items li:last-child {
    border-bottom: none;
}

#shopping-cart-container .cart-item-name {
    font-size: 0.95em; /* Slightly smaller item name */
    color: #3c4043;
    /* flex-grow: 1; (already set) */
    /* display: flex; align-items: center; (already set) */
}
#shopping-cart-container .item-price {
    font-size: 0.95em;
    color: #5f6368;
    margin-left: 10px;
    white-space: nowrap;
}
#shopping-cart-container .remove-item-button {
    background-color: transparent;
    border: none;
    color: #d93025; /* Google red for remove */
    font-size: 1.1em; /* Adjusted size */
    font-weight: bold;
    cursor: pointer;
    padding: 0 5px;
    margin-left: 10px;
    transition: color 0.2s;
}
#shopping-cart-container .remove-item-button:hover {
    color: #a50e0e; /* Darker red on hover */
}

/* Styling for the total and action button */
#shopping-cart-container #cart-total {
    padding: 12px 20px;
    font-size: 1.05em; /* Adjusted size */
    font-weight: 500; /* Medium weight */
    text-align: right;
    border-top: 1px solid #e8eaed;
    margin: 0;
    background-color: #f8f9fa; /* Match header */
    color: #202124;
}


#share-cart-button {
    background-color: #f0f0f0;
    color: #007aff;
    width: 100%;
    display: flex;
    justify-content: center;
    align-items: center;
    font-weight: 500;
    font-size: 1.1em;
    border-radius: 8px;
    padding: 10px 0;
    transition: background-color 0.2s ease, box-shadow 0.2s ease, transform 0.15s ease;
    cursor: pointer;
    border: none;
    line-height: 1.5;
    text-align: center;
    white-space: nowrap;
    vertical-align: middle;
    -webkit-user-select: none;
    -moz-user-select: none;
    -ms-user-select: none;
    user-select: none;
    -webkit-appearance: none;
    -moz-appearance: none;
    appearance: none;
    text-decoration: none;
    touch-action: manipulation;
    -webkit-tap-highlight-color: transparent;
    box-sizing: border-box;
    margin: 0;
    font-family: inherit;
    overflow: hidden;
    position: relative;
    z-index: 1;
    will-change: transform;
    transform: translateZ(0);
    box-shadow: 0 1px 2px rgba(0, 0, 0, 0.05);
}

#share-cart-button:active {
    transform: scale(0.98) translateZ(0) translateY(0px);
    box-shadow: 0 1px 2px rgba(0, 0, 0, 0.05);
}

#share-cart-button:focus {
    outline: none;
    box-shadow: 0 0 0 2px rgba(0, 122, 255, 0.5);
}

#share-cart-button:hover {
    background-color: #e0e0e0;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
    transform: translateY(-1px);
}




.cart-toggle-button:hover {
    background-color: #0f62fe; /* Darker blue on hover */
}

.cart-toggle-button img {
    width: 24px; /* Adjust icon size */
    height: 24px;
    filter: invert(1); /* Make icon white */
}
#shopping-cart-container.collapsed .cart-header,
#shopping-cart-container.collapsed #cart-items,
#shopping-cart-container.collapsed #cart-total,
#shopping-cart-container.collapsed .cart-toggle-button span { display: none; }


#shopping-cart-container.expanded .cart-header { display: flex; justify-content: space-between; align-items: center; padding: 10px 15px; font-size: 1.25em; color: #1f2937; font-weight: 600; border-bottom: 1px solid #eee; flex-shrink: 0; position: relative; }
#shopping-cart-container.expanded .cart-header h2 { margin: 0; font-size: inherit; font-weight: inherit; flex-grow: 1; text-align: center; padding-right: 24px; /* Space for minimize btn */ }
#shopping-cart-container.expanded #cart-minimize-button { background: none; border: none; padding: 5px; cursor: pointer; display: flex; align-items: center; justify-content: center; position: absolute; top: 50%; right: 10px; transform: translateY(-50%); }
#shopping-cart-container.expanded #cart-minimize-button img { width: 20px; height: 20px; color: #555; }
#shopping-cart-container.expanded #cart-minimize-button:hover img { color: #000; }

#shopping-cart-container.expanded #cart-items { display: block; list-style: none; padding: 0 5px 0 20px; margin: 0; flex-grow: 1; overflow-y: auto; scrollbar-width: thin; scrollbar-color: #cbd5e1 #f9fafb; }
#shopping-cart-container.expanded #cart-items::-webkit-scrollbar { width: 6px; }
#shopping-cart-container.expanded #cart-items::-webkit-scrollbar-track { background: #f9fafb; border-radius: 3px; }
#shopping-cart-container.expanded #cart-items::-webkit-scrollbar-thumb { background-color: #cbd5e1; border-radius: 3px; }
#shopping-cart-container.expanded #cart-items li { display: flex; justify-content: space-between; align-items: center; padding: 10px 15px 10px 0; border-bottom: 1px solid #f3f4f6; font-size: 0.95em; color: #4b5563; }
#shopping-cart-container.expanded #cart-items li:last-child { border-bottom: none; }
#shopping-cart-container.expanded #cart-items li .cart-item-name { flex-grow: 1; margin-right: 10px; font-weight: 500; color: #374151; }
#shopping-cart-container.expanded #cart-items li .item-price { min-width: 65px; text-align: right; font-weight: 600; color: #1f2937; }
#shopping-cart-container.expanded #cart-total { display: block; margin: 0; padding: 12px 20px; font-size: 1.1em; font-weight: 600; color: #111827; text-align: right; border-top: 1px solid #e5e7eb; flex-shrink: 0; background-color: #f9fafb; }

/* Message for empty lists (cart and shopping list) */
.shopping-list-empty-message { text-align: center; color: #6b7280; padding: 20px 0; font-style: italic; border-bottom: none !important; }

/* --- Shopping Cart Item Clickability --- */
#shopping-cart-container.expanded #cart-items li.clickable-cart-item {
    cursor: pointer;
    transition: background-color 0.2s ease;
    
}
#shopping-cart-container.expanded #cart-items li.clickable-cart-item:hover,
#shopping-cart-container.expanded #cart-items li.clickable-cart-item:focus {
    background-color: #f0f7ff; /* Light blue highlight */
    outline: none;
}
/* These might not be needed if the LI itself handles the click fully */
/* .cart-item-details { flex-grow: 1; display: flex; justify-content: space-between; align-items: center; margin-right: 10px; pointer-events: none; } */
/* .cart-item-details > span { pointer-events: auto; } */
/* .cart-item-name { margin-right: 10px; } */
.item-price { white-space: nowrap; }

/* Remove button styling within cart/list */
.remove-item-button, .remove-shopping-list-item {
    background-color: #f1f3f4;
    color: #5f6368;
    border: none;
    padding: 0;
    border-radius: 50%;
    cursor: pointer;
    font-size: 18px;
    line-height: 1;
    font-weight: normal;
    width: 36px;
    height: 36px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    margin-left: 8px;
    transition: background-color 0.2s ease, color 0.2s ease;
    flex-shrink: 0;
    box-shadow: none;
    -webkit-tap-highlight-color: transparent;
}

.remove-item-button:hover, .remove-shopping-list-item:hover {
    background-color: #e8eaed;
    color: #202124;
}

.remove-item-button:active, .remove-shopping-list-item:active {
    background-color: #dadce0;
}

/* Shopping Cart Analyze Button Visibility */
#analyze-cart-button {
    display: none; /* Hidden by default */
    /* Retain existing button styles if any, or add new ones */
    /* Example: these were in the HTML style attribute previously */
    margin-top: 10px;
    width: calc(100% - 20px); /* Adjust as needed for padding within cart */
    margin-left: 10px;
    margin-right: 10px;
    padding: 10px 15px; /* Example padding */
    font-size: 0.95em; /* Example font size */
    margin-bottom: 20px;
    background-color: #005a9e;
    /* Add other button styling as per your .button-primary or other classes */
}

#shopping-cart-container.expanded #analyze-cart-button {
    display: block; /* Or inline-block, flex, etc., based on your button's desired flow */
}

/* Analyze Cart Button Container & Spinner */
.analyze-button-container {
    display: flex; /* Align button and spinner inline */
    align-items: center;
    justify-content: center; /* Center the button if spinner is not taking space or for general alignment */
    margin-top: 10px;
    width: calc(100% - 20px);
    margin-left: 10px;
    margin-right: 10px;
}

#analyze-cart-button {
    /* Styles for the button itself - it's a .button-primary */
    /* Ensure it doesn't have conflicting display properties if .button-primary sets them */
    flex-grow: 1; /* Allow button to take available space if spinner is small */
    margin-right: 10px; /* Space between button and spinner */
}

.analyze-button-container .analyze-spinner {
    /* Spinner styles are already defined globally by .spinner.small */
    /* display: none; /* Initially hidden - JS will control this */
    /* margin-left: 10px; /* Space from the button text */
    /* Ensure spinner is vertically centered with button text if button has padding */
    /* height: 20px; /* Match button text line-height approx */
    /* width: 20px; */
}

/* Shopping Cart Enhancements */
#shopping-cart-container {
    /* max-width: 350px; /* Original width, adjust as needed */
    max-width: 450px; /* Increased width */
    /* Other existing styles for #shopping-cart-container should remain,
       such as position, bottom, right, background, etc.
       This rule just adds/overrides max-width. */
}

.cart-item-name {
    display: flex; /* Allows image and text to align nicely */
    align-items: center; /* Vertically aligns items in the flex container */
    flex-grow: 1; /* Allows the name to take available space */
}

.cart-item-logo {
    width: 32px;
    height: 32px;
    margin-right: 8px;
    vertical-align: middle; /* Good for inline-block or if not using flex */
    border-radius: 4px; /* Optional: slightly rounded corners for the logo */
    object-fit: contain; /* Ensures logo isn't stretched if aspect ratio differs */
}

/* Ensure the remove button in the cart is styled appropriately if needed */
#cart-items .remove-item-button {
    /* Styles for remove button if they were not globally defined or need override */
    margin-left: auto; /* Pushes button to the right if cart-item-name is flex-grow */
    padding: 4px 8px;
    /* Add other styles like background, color, border, border-radius, cursor */
}

/* Floating Action Button for Cart Toggle */
#cart-toggle-button {
    position: fixed;
    bottom: 136px; /* Positioned below language button (200px - 48px - 16px), above bottom sheet */
    right: 20px;
    width: 56px; /* Standard FAB size */
    height: 56px;
    /* background-color: #1a73e8;  */
    color: white;
    border: none;
    /* border-radius: 50%;  Circular */
    border-radius: 50%;
    box-shadow: 0 4px 8px rgba(0,0,0,0.2);
    cursor: pointer;
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 999; /* Above map, behind bottom sheet */
    transition: background-color 0.2s ease, transform 0.2s ease;
    padding: 0; /* Remove default button padding */
}

#cart-toggle-button:hover {
    /* background-color: #1669c9; */
    transform: scale(1.00);
}

#cart-toggle-button img {
    width: 28px; /* Adjusted for 56px FAB */
    height: 28px;
    filter: brightness(0) invert(1); /* Make icon white */
    display: block;
}

#cart-toggle-button span {
    display: none; /* Hide text for FAB style */
    display: none; /* Hide the text span to make it an icon-only button */
}
