/* =========================
   inventory.css (responsive)
   ========================= */
:root {
  --blue: #3f66c4;
  --black: #0b0b0b;
  --white: #fff;
  --panel-padding: 16px;
  --radius: 28px;
  --gap: 10px;
  --panel-width: 300px;
}

* {
  box-sizing: border-box;
  font-family: "Segoe UI", Roboto, Arial, sans-serif;
}

body {
  margin: 0;
  background: #fafafa;
  color: #222;
  padding: 24px;
}
#logoutBtn {
    background: #ff5252 !important;
    color: white !important;
    font-weight: bold;
}
.page {
  display: flex;
  flex-wrap: wrap;
  gap: 24px;
  align-items: flex-start;
  justify-content: center;
}

#toggleFormBtn {
    /* 1. Set position to fixed relative to the viewport */
    position: fixed;
    
    /* 2. Position it (e.g., top-left corner with some margin) */
    top: 20px;
    left: 20px;
    
    /* 3. Ensure it layers above all other content */
    z-index: 1000; 
    
    /* Optional: Add a border-radius and shadow for better visibility */
    border-radius: 8px;
    box-shadow: 0 4px 10px rgba(0, 0, 0, 0.2);
    padding: 10px 15px; /* Adjust padding as needed */
}

/* Optional: Add margin to the main content so it doesn't get covered 
   by the fixed button when it's at the very top of the page. */
.page {
    /* Ensure the body has no default margin/padding for accurate positioning */
    padding-top: 60px; /* Adjust this value to be slightly larger than the button's height + top position */
}
/* ---- Generic panel ---- */
.product-panel {
  background: var(--blue);
  color: var(--white);
  padding: var(--panel-padding);
  border-radius: var(--radius);
  box-shadow: 0 6px 18px rgba(0, 0, 0, 0.12);
}

/* Selected product panel */
.product-panel.selected {
  width: 260px;
  min-height: 300px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

/* Add product panel (bottom) */
.product-panel.add-panel {
  /* 👇 UPDATED: Smaller and responsive container width */
  width: 95%;
  max-width: 500px; 
  /* 👆 UPDATED: Smaller and responsive container width */

  display: flex;
  flex-direction: column;
  gap: 12px;

  /* 👇 ensure input container always appears BELOW rendered products */
  order: 2;
  z-index: 1;
}

/* Products area (rendered data above input panel) */
.products-area {
  flex: 1;
  min-height: 200px;
  padding: 8px 12px;
  border-radius: 12px;
  display: flex;
  flex-direction: column;
  gap: 12px;
  align-items: flex-start;

  /* 👇 force rendered products to always appear ABOVE */
  order: 1;
  z-index: 2;
}

.thumb-preview {
  background: linear-gradient(180deg, #fff, #f7f7f7);
  color: #333;
  border-radius: 18px;
  height: 90px;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 6px;
  overflow: hidden;
}

.thumb-preview.small {
  width: 170px;
  height: 90px;
  border-radius: 18px;
}

/* Labels & inputs */
.label-black {
  background: var(--black);
  color: var(--white);
  padding: 8px 10px;
  border-radius: 8px;
  width: 120px;
  text-align: center;
  display: inline-block;
  margin-bottom: 6px;
  flex-shrink: 0;
}

.text-input {
  /* 👇 UPDATED: Modernized styling for larger, rounded inputs */
  padding: 10px 12px; 
  border-radius: 10px;
  border: 0;
  outline: 0;
  min-width: 180px;
  margin-left: 8px;
  transition: all 0.2s ease-in-out;
}

.text-input:focus {
  box-shadow: 0 0 0 3px rgba(255, 255, 255, 0.5); /* Subtle white shadow on focus */
}
/* 👆 UPDATED */

.small-input {
  /* 👇 UPDATED: Modernized styling for smaller inputs */
  padding: 8px 10px;
  border-radius: 10px;
  border: 0;
  min-width: 80px;
  margin-left: 8px;
  transition: all 0.2s ease-in-out;
}

.small-input:focus {
  box-shadow: 0 0 0 3px rgba(255, 255, 255, 0.5); /* Subtle white shadow on focus */
}
/* 👆 UPDATED */

.row,
.form-row {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}

.action-row {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-top: 8px;
}

.add-row {
  text-align: center;
  margin-top: 8px;
}

/* Buttons */
.btn-black {
  background: var(--black);
  color: var(--white);
  border-radius: 10px;
  border: 0;
  padding: 10px 16px;
  cursor: pointer;
  font-weight: 600;
  transition: background 0.15s;
}

.btn-black:hover {
  background: #333;
}

.btn-black.small {
  padding: 6px 10px;
}

.btn-black.big {
  padding: 10px 24px;
  margin: 8px auto;
  display: block;
}

.hint {
  color: #777;
  margin: 16px 8px;
  text-align: center;
}
/* Add this CSS to your stylesheet or <style> block */
#inputContainer {
    /* Critical for smooth transition */
    transition: max-height 0.5s ease-out, opacity 0.4s ease-out; 
    overflow: hidden; /* Hides content when max-height is low */
    /* Initial state is set via JS, but these properties are essential for animation */
    /* If you prefer pure CSS initial hide, set max-height: 0; here */
}

/* 2. Main Product Container (holds all the swipeable rows) */
#productsContainer {
    /* Stacks the swipeable rows vertically, as before */
    display: flex;
    flex-direction: column;
    gap: 20px; /* Vertical gap between the swipeable rows */
    padding: 0; 
    margin: 0 auto;
    width: 100%; /* Ensure it occupies full width, but doesn't control the scroll */
}

/* 3. The New Scrollable Row (Using Grid) */
.product-group-wrapper {
    /* 1. Establish Grid Container */
    display: grid;
    
    /* 2. CRITICAL: Force the Grid to be wider than the wrapper */
    /* We explicitly define 4 columns, each 260px wide (plus 14px gap).
       This calculated width (1082px) will always be wider than the 100% parent, 
       forcing the overflow to happen locally. */
    grid-template-columns: repeat(4, 300px); 
    
    /* 3. Essential Scrolling Properties */
    overflow-x: auto; /* This creates the local scrollbar */
    scroll-snap-type: x mandatory;
    -webkit-overflow-scrolling: touch;
    
    /* 4. Spacing and Containment */
    gap: 18px;
    padding: 10px;
    
    /* IMPORTANT: Ensure the wrapper itself does NOT expand the page, 
       but allows its children to overflow *it*. */
    width: 100%;
    box-sizing: border-box; 
}



/* Snap each card cleanly when swiping */
.modern-product-card {
    /* Grid item setup */
    scroll-snap-align: start;
    
    /* Ensure card doesn't try to stretch vertically */
    align-self: start; 
    
    /* Optional: Ensure card respects the column definition */
    max-width: 300px;
}

/* Class applied by JS for the smooth transition */
.newly-added {
    opacity: 0;
    /* Optional: Slight initial downward shift for a better visual effect */
    transform: translateY(-20px); 
}
.modern-product-card:hover {
    transform: translateY(-4px); /* Subtle lift effect */
    box-shadow: 0 10px 25px rgba(0, 0, 0, 0.12);
}
/* --- Thumbnail Wrapper (Aspect Ratio) --- */
.card-thumb-wrapper {
    position: relative;
    width: 100%;
    padding-top: 60%; /* 5:3 Aspect Ratio (60% of width) */
    overflow: hidden;
    background-color: #f7f7f7;
    border-bottom: 1px solid #eee;
}
/* --- Global Product Grouping Headers --- */
.promotional-video-wrapper {
    /* 🚨 CRITICAL CHANGES FOR STACKING */
    position: absolute; /* Take it out of the Flex flow */
    top: 0;
    left: 0;
    width: 100%;
    z-index: 10; /* Ensure it is layered on top of other header content */
    
    /* ❌ REMOVED FIXED HEIGHT to allow aspect ratio container to define height */
    /* height: 180px; */ 
    
    margin-bottom: 0; /* No need for margin since it's absolute */
    border-radius: 16px 16px 0 0; /* Use rounded corners that match the container */
    overflow: hidden;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
    cursor: pointer;
}

/* === ASPECT RATIO CONTAINER (New or Updated) === */
/* Assumes this class wraps the iframe in your JS */
.iframe-responsive-container {
    position: relative;
    width: 100%;
    
    /* CRITICAL: Defines the 16:9 aspect ratio (9 / 16 = 56.25%) */
    padding-top: 56.25%; 
    
    /* Ensure any inline style (like pointer-events) is overridden if necessary */
    pointer-events: auto !important; 
}

/* Ensure the iframe fills the responsive container */
.iframe-responsive-container iframe {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
}
.promotional-video-wrapper .latest-product-image {
    /* Use the same class but ensure it's slightly taller or distinct if needed */
    width: 100%;
    height: auto;
    display: block;
}

.video-label {
    position: absolute;
    top: 10px;
    left: 10px;
    background: #007bff; /* Primary blue for video */
    color: white;
    padding: 4px 8px;
    border-radius: 6px;
    font-size: 0.85rem;
    font-weight: bold;
    z-index: 5;
}

.play-button-overlay {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: 60px;
    height: 60px;
    background: rgba(0, 0, 0, 0.7);
    border-radius: 50%;
    z-index: 10;
    transition: transform 0.2s ease;
}

.play-button-overlay::before {
    content: '';
    position: absolute;
    top: 50%;
    left: 55%;
    transform: translate(-50%, -50%);
    width: 0;
    height: 0;
    border-top: 10px solid transparent;
    border-bottom: 10px solid transparent;
    border-left: 15px solid white;
}

.promotional-video-wrapper:hover .play-button-overlay {
    transform: translate(-50%, -50%) scale(1.1);
}
/* The main Business Name header (H2) */
.business-group-header {
    margin-top: 30px;
    margin-bottom: 15px;
    padding: 10px 0;
    font-size: 1.8em;
    color: #333; /* Dark color for prominence */
    border-bottom: 3px solid #4285f4; /* Primary blue underline */
    text-transform: uppercase;
    letter-spacing: 1px;
    font-weight: 700;
    /* --- CENTERING ADDED HERE --- */
    text-align: center; 
}

/* The Category Name sub-header (H3) */
.category-group-header {
    margin-top: 25px;
    margin-bottom: 15px;
    padding: 5px 15px;
    font-size: 1.4em;
    color: #4CAF50; /* A friendly green for category */
    background-color: #f0fff0; /* Light background for contrast */
    /* Remove border-left which interferes with center alignment */
    /* border-left: 5px solid #4CAF50; */ 
    font-weight: 600;
    /* --- CENTERING ADDED HERE --- */
    text-align: center;
    /* Center the background block using auto margins for block-level element */
    margin-left: auto;
    margin-right: auto;
    /* To prevent the element from stretching across the page if it's a block, we'll set a max-width */
    max-width: 80%; 
}

/* --- Per-Product Card Tags (Customer View) --- */

/* Style for the Business Name inside the product card */
.product-business {
    /* Positioned at the top of the card's info area */
    font-size: 0.9em;
    font-weight: 600;
    color: #666; /* Subdued color */
    padding-bottom: 3px;
    border-bottom: 1px dashed #eee;
    margin-bottom: 5px;
    text-transform: capitalize;
}

/* Style for the Category Name inside the product card */
.product-category {
    /* Use as a small tag */
    display: inline-block;
    padding: 2px 8px;
    margin-bottom: 8px;
    font-size: 0.75em;
    font-weight: 700;
    color: #fff;
    background-color: #f4b400; /* Yellowish background for visibility */
    border-radius: 12px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

/* Ensure the product card info area has padding for the tags */
.card-info {
    padding: 15px;
}
.product-image {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    object-fit: contain; /* Shows entire image, centered */
}

/* --- Placeholder Text --- */
.placeholder-image {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    color: #a0a0a0;
    font-size: 1.1rem;
    font-weight: 500;
    text-align: center;
    padding: 10px;
}

/* --- Quantity Badge --- */
.quantity-badge {
    position: absolute;
    top: 12px;
    right: 12px;
    background: var(--blue); /* Uses your defined variable */
    color: var(--white);
    padding: 6px 10px;
    border-radius: 20px;
    font-size: 0.8em;
    font-weight: 700;
    z-index: 10;
    box-shadow: 0 2px 5px rgba(0, 0, 0, 0.2);
}

.quantity-badge.low-stock {
    background: #e74c3c; /* Red color for warning */
}

.quantity-badge .icon {
    margin-right: 4px;
}
/* --- Info Area --- */
.card-info {
    padding: 15px 20px 20px;
    flex-grow: 1;
    display: flex;
    flex-direction: column;
}

/* Styling for the product description below the name (E) */
.product-description {
    font-size: 0.85rem;
    color: #555;
    margin: 5px 0 10px 0;
    line-height: 1.3;
    /* Center the text */
    text-align: center;
    /* Limit height for brief display */
    max-height: 3.9rem; /* Approx 3 lines */
    overflow: hidden;
    text-overflow: ellipsis;
}

/* Styling for specific product details/specs (F) */
.product-details {
    font-size: 0.8rem;
    color: #333;
    padding: 5px 0;
    border-top: 1px solid #eee;
    margin-bottom: 10px;
    /* Center the text */
    text-align: center;
    /* Ensure no wrapping issues on the label */
    word-break: break-word;
}

/* Style for the 'Details' label within the details block */
.product-details .details-label {
    font-weight: bold;
    color: #000;
    margin-right: 5px;
    /* Keep the label inline with the details value */
    display: inline;
}
/* === BUSINESS GROUP CONTAINER === */
.business-group-container {
    margin: 0 auto 40px auto;     /* vertical margin + horizontal auto = centering */
    max-width: 1100px;            /* or 1400px, 1100px – whatever you prefer */
    width: 100%;                  /* keeps it responsive inside the max-width */
    border: 1px solid #e2e8f0;
    border-radius: 16px;
    overflow: hidden;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.06);
    background: #f4f2f2;
    transition: all 0.3s ease;
    box-sizing: border-box;
}

.business-group-container:hover {
    box-shadow: 0 8px 30px rgba(0, 0, 0, 0.1);
    transform: translateY(-2px);
}

/* === HEADER (CLICKABLE) === */
.business-card-header {
    background: linear-gradient(135deg, #9b9bf9 0%, #144efe 100%); 
    color: #050505;
    /* 🚨 ADJUSTED PADDING: Padding removed from top and added back to the sides/bottom. */
    /* We must calculate the required padding-top based on the video's aspect ratio. */
    padding: 24px 5px; 
    
    display: flex;
    align-items: center;
    gap: 2px;
    cursor: pointer;
    position: relative; 
    transition: background 0.3s ease;
    user-select: none;
    
    /* 🚨 UPDATED PADDING-TOP: Estimate space for video + the original 24px content padding.
       (e.g., if the video max-width is 1100px, 56.25% of that is ~618px, but this
       padding is for the collapsed state, so a fixed, safe size works better.)
       Let's use a safe, generous fixed value that covers the video area.
    */
    padding-top: 250px; /* Increased from 200px to accommodate the full 16:9 area */
}

.business-card-header:hover {
    background: linear-gradient(135deg, #6573ab 0%, #3550c0 100%);
}
@media (min-width: 900px) {
    /* For wider PC screens where the card takes up more space */
    .business-card-header {
        padding-top: 500px; /* Example value for wider screens */
    }
}

@media (min-width: 1200px) {
    /* For very wide screens, matching the max-width of your container */
    .business-card-header {
        padding-top: 650px; /* Covers the 1100px max-width 16:9 video */
    }
}
.subscriber-count {
    /* Layout - Reduced Padding for smaller size */
    display: inline-flex;
    align-items: center;
    padding: 4px 10px; /* Reduced padding */
    margin: 8px 0 10px 0;
    
    /* Appearance - Blue Gradient */
    background: linear-gradient(45deg, #1A73E8, #4285F4); /* Google Blue-style gradient */
    color: white; 
    border-radius: 16px; /* Slightly smaller pill shape */
    box-shadow: 0 3px 6px rgba(26, 115, 232, 0.3); /* Subtle blue lift */
    
    /* Typography - Smaller Text */
    font-size: 0.8rem; /* Reduced font size (e.g., 0.8rem) */
    font-weight: 700; 
    letter-spacing: 0.3px; /* Slightly tighter letter spacing */
    text-transform: uppercase;
    width: fit-content;
}

/* Optional: Icon for visual interest */
.subscriber-count::before {
    content: "\1F465"; /* Two People Icon (Unicode for 'busts in silhouette') */
    margin-right: 5px; 
    font-size: 1em; 
}
/* Image container */
.latest-product-image-container {
    width: 130px;
    height: 110px;
    border-radius: 12px;
    overflow: hidden;
    border: 3px solid rgba(255, 255, 255, 0.3);
    background: #ffffff;
    flex-shrink: 0;
    box-shadow: 0 8px 20px rgba(0, 0, 0, 0.18);
    transition: all 0.3s ease;
}

.latest-product-image-container:hover {
    transform: translateY(-4px);
    box-shadow: 0 14px 30px rgba(0, 0, 0, 0.25);
}

.latest-product-image {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.placeholder-image-large {
    width: 100%;
    height: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
    background: #f0f0f0;
    color: #aaa;
    font-size: 0.9rem;
}

/* BADGE — now cleanly separated below the image */
.latest-product-label {
    margin-top: 5px;                  /* Perfect breathing space */
    text-align: center;
    
    display: inline-block;
    background: linear-gradient(135deg, #4169e1, #2a4bb8);
    color: white;
    font-size: 0.75rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 1.2px;
    padding: 7px 16px;
    border-radius: 30px;
    box-shadow: 0 4px 15px rgba(65, 105, 225, 0.35);
    border: 2px solid rgba(255, 255, 255, 0.25);
    transition: all 0.3s ease;
}

/* Hover effect — makes it pop */
.latest-product-label:hover {
    transform: translateY(-2px);
    box-shadow: 0 8px 20px rgba(65, 105, 225, 0.5);
}

/* Optional shine line */
.latest-product-label::before {
    content: "";
    position: absolute;
    top: 3px;
    left: 50%;
    transform: translateX(-50%);
    width: 40%;
    height: 2px;
    background: rgba(255, 255, 255, 0.4);
    border-radius: 2px;
}
.business-card-header:hover .latest-product-image {
    transform: scale(1.08);
}

.placeholder-image-large {
    display: flex;
    align-items: center;
    justify-content: center;
    background: #f8fafc;
    color: #94a3b8;
    font-size: 13px;
    font-weight: 500;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.business-info-below {
    padding: 1.4rem 1.4rem 2rem;
    text-align: center;
}

.business-name-wrapper {
    margin-bottom: 0.6rem;
    display: flex;
    flex-direction: column;
    gap: 4px;
    align-items: center;
}

.name-label {
      margin-top: 5px;                  /* Perfect breathing space */
    text-align: center;
    
    display: inline-block;
    background: linear-gradient(135deg, #4169e1, #2a4bb8);
    color: white;
    font-size: 0.75rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 1.2px;
    padding: 7px 16px;
    border-radius: 30px;
    box-shadow: 0 4px 15px rgba(65, 105, 225, 0.35);
    border: 2px solid rgba(255, 255, 255, 0.25);
    transition: all 0.3s ease;
}

.business-name {
    font-size: 20px;
    font-weight: 700;
    margin: 0;
    color: #1a1a1a;
    line-height: 1.2;
}


/* Categories styling */
.product-categories {
    font-size: 0.95rem;
    margin: 8px 0 0;
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    align-items: center;
    gap: 8px;
    line-height: 1.4;
}

.categories-label {
    font-weight: 600;
    color: #222;
}

.categories-list {
    color: #f0eff4;
    font-weight: 500;
}

.product-categories.empty {
    color: #999;
    font-style: italic;
    font-size: 0.9rem;
}
/* Open / View button – top-right corner */
.open-business-card-btn {
    position: absolute;
    top: 0;
    right: 0;
    background: #000000;
    color: #ffffff;
    border: none;
    padding: 8px 16px;
    border-radius: 0 14px 0 14px;
    font-size: 13px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.8px;
    cursor: pointer;
    transition: all 0.3s ease;
    box-shadow: -2px 2px 8px rgba(0, 0, 0, 0.2);
}

.open-business-card-btn:hover {
    background: #1a1a1a;
    padding-right: 20px;
}

/* Arrow indicator (optional – add ▼ or ► via ::after in HTML/JS) */
.business-card-header::after {
    content: "▼";
    position: absolute;
    right: 70px;
    top: 50%;
    transform: translateY(-50%);
    font-size: 14px;
    transition: transform 0.3s ease;
}

.business-group-container.is-open .business-card-header::after {
    transform: translateY(-50%) rotate(180deg);
}

/* === COLLAPSIBLE CONTENT AREA === */
.product-card-display-area {
    padding: 0 24px;
    max-height: 0;
    opacity: 0;
    overflow: hidden;
    transition: max-height 0.6s ease, opacity 0.5s ease, padding 0.4s ease;
    background: #fafafa;
}

.business-group-container.is-open .product-card-display-area {
    max-height: 3000px; /* Adjust if you have very tall content */
    opacity: 1;
    padding: 24px;
    background: #ffffff;
}

/* Small category headers inside the expanded area */
.category-group-header-small {
    font-size: 1.25rem;
    font-weight: 600;
    color: #1e293b;
    margin: 28px 0 12px;
    padding-bottom: 8px;
    border-bottom: 2px solid #4169e1;
    position: relative;
}

.category-group-header-small::before {
    content: "";
    position: absolute;
    bottom: -2px;
    left: 0;
    width: 50px;
    height: 2px;
    background: #3550c0;
}

/* Optional: enhance your existing modern-product-card */
.modern-product-card {
    border: none;
    border-radius: 12px;
    overflow: hidden;
    box-shadow: 0 4px 16px rgba(0, 0, 0, 0.08);
    transition: transform 0.3s ease, box-shadow 0.3s ease;
}

.modern-product-card:hover {
    transform: translateY(-4px);
    box-shadow: 0 12px 28px rgba(0, 0, 0, 0.12);
}

/* 🚀 MEDIA QUERY: MOBILE RESPONSIVENESS FIX */
@media (max-width: 300px) {
    /* --- Header Layout Change: Stack elements vertically --- */
    .business-card-header {
        flex-direction: column; 
        align-items: flex-start; 
        padding: 20px 20px 100px 20px; /* Adjusted bottom padding for relocated button */
        gap: 15px;
    }
    
   .latest-product-image-container {
        width: 100%; 
        /* REMOVE FIXED HEIGHT and replace with aspect ratio padding */
        height: 0; /* Set height to 0 to enable padding trick */
        padding-top: 84.6%; /* (110 / 130) * 100% = 84.6% Aspect Ratio */
        order: -1; 
        position: relative; /* REQUIRED for the absolute positioning of the image inside */
    }

    /* --- Ensure the image itself scales correctly within the new container --- */
    .latest-product-image {
        position: absolute; /* Position relative to the container padding trick */
        top: 0;
        left: 0;
        width: 100%;
        height: 100%;
        object-fit: cover; /* This is essential to fill the container without distortion/cropping */
        /* transition property is already defined outside the media query */
    }
}
    
    /* --- Business Name Font Size Reduction --- */
    .business-name {
        font-size: 20px; 
    }

    /* --- Button Position Fix: Move to bottom-right corner --- */
    .open-business-card-btn {
        top: auto; 
        bottom: 0; 
        right: 0;
        border-radius: 0 0 14px 0; 
        box-shadow: 0 -2px 8px rgba(0, 0, 0, 0.2);
    }
    .open-business-card-btn:hover {
        padding-right: 16px; /* Reset the padding change on hover for mobile to keep button size stable */
    }

    /* --- Collapse Indicator Repositioning --- */
    .business-card-header::after {
        right: 20px;
        top: 80px; /* Position it below the image */
        transform: translateY(0); 
    }
    .business-group-container.is-open .business-card-header::after {
        transform: rotate(180deg);
    }

    /* --- Collapsible Content Padding Adjustment --- */
    .product-card-display-area {
        padding: 0 20px;
    }
    .business-group-container.is-open .product-card-display-area {
        padding: 20px;
    }

/* Small category headers inside the expanded area */
.category-group-header-small {
    font-size: 1.25rem;
    font-weight: 600;
    color: #1e293b;
    margin: 28px 0 12px;
    padding-bottom: 8px;
    border-bottom: 2px solid #4169e1;
    position: relative;
}

.category-group-header-small::before {
    content: "";
    position: absolute;
    bottom: -2px;
    left: 0;
    width: 50px;
    height: 2px;
    background: #3550c0;
}

/* Optional: enhance your existing modern-product-card */
.modern-product-card {
    border: none;
    border-radius: 12px;
    overflow: hidden;
    box-shadow: 0 4px 16px rgba(0, 0, 0, 0.08);
    transition: transform 0.3s ease, box-shadow 0.3s ease;
}

.modern-product-card:hover {
    transform: translateY(-4px);
    box-shadow: 0 12px 28px rgba(0, 0, 0, 0.12);
}

.product-action-buttons {
    display: flex;
    gap: 10px;
    margin-top: 10px;
}
.btn-red {
    background-color: #dc3545; /* Red color for danger */
    color: white;
    border: none;
    padding: 8px 12px;
    border-radius: 4px;
    cursor: pointer;
    flex: 1; 
    text-align: center;
}
.btn-red:hover {
    background-color: #c82333;
}

/* Styling for the Action Menu Wrapper */
.action-menu-wrapper {
    position: relative; /* Essential for positioning the dropdown */
    display: inline-block;
    flex: 1;
}

/* Base button style for the menu trigger */
.action-menu-btn {
    width: 100%;
    background-color: #dc3545; /* btn-red */
    color: white;
    border: none;
    padding: 8px 12px;
    border-radius: 4px;
    cursor: pointer;
    text-align: center;
}

/* Dropdown Menu Styles */
.delete-action-menu {
    position: absolute;
    bottom: 100%; /* Position above the button */
    left: 0;
    z-index: 10;
    min-width: 250px;
    border: 1px solid #ccc;
    background-color: white;
    box-shadow: 0 4px 8px rgba(0, 0, 0, 0.1);
    border-radius: 4px;
    overflow: hidden;
    margin-bottom: 5px; /* Small space above the button */
}

/* Buttons inside the dropdown */
.delete-action-menu button {
    display: block;
    width: 100%;
    padding: 10px;
    text-align: left;
    background: none;
    border: none;
    border-bottom: 1px solid #eee;
    cursor: pointer;
    font-size: 14px;
    color: #333;
}

.delete-action-menu button:hover {
    background-color: #f0f0f0;
}

.delete-action-menu button:last-child {
    border-bottom: none;
    color: #dc3545; /* Highlight the delete business option */
    font-weight: bold;
}
.product-name {
    font-size: 1.3rem;
    font-weight: 700;
    color: var(--black);
    margin: 0 0 12px 0;
    line-height: 1.3;
}

/* --- Price Grid --- */
.price-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 15px;
    margin-bottom: 15px;
    padding-bottom: 15px;
    border-bottom: 1px solid #f0f0f0;
}

.price-item .label {
    display: block;
    font-size: 0.8rem;
    color: #777;
    margin-bottom: 3px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.price-item .value {
    font-size: 1.15rem;
    font-weight: 600;
    color: #1a1a1a;
}

/* --- Profit Margin --- */
.profit-margin {
    padding-top: 10px;
    font-size: 1.25rem;
    font-weight: 700;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.profit-margin .label {
    font-size: 0.95rem;
    font-weight: 500;
    color: #555;
}

.profit-positive .value {
    color: #2ecc71; /* Profit Green */
}

.profit-negative .value {
    color: #e74c3c; /* Loss Red */
}

.profit-neutral .value {
    color: #95a5a6; /* Neutral Grey */
    font-style: italic;
}

/* --- Link Gallery Dialog Styles --- */

/* Style for the dialog backdrop and container */
#linkGalleryDialog {
    padding: 0;
    border: none;
    border-radius: var(--radius);
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.2);
    width: 90%;
    max-width: 800px;
    max-height: 90vh;
    overflow: hidden;
    background: var(--white); /* Ensure a clean white background */
}

/* Backgrop when the dialog is open */
#linkGalleryDialog::backdrop {
    background-color: rgba(0, 0, 0, 0.6);
    backdrop-filter: blur(4px);
}

/* Header within the gallery dialog */
.gallery-header {
    background: var(--black);
    color: var(--white);
    padding: 15px var(--panel-padding);
    border-top-left-radius: var(--radius);
    border-top-right-radius: var(--radius);
    display: flex;
    justify-content: space-between;
    align-items: center;
    position: sticky;
    top: 0;
    z-index: 100;
}

.gallery-header h2 {
    margin: 0;
    font-size: 1.5rem;
}

/* Gallery Container within the dialog */
#linkGalleryDialog .products-area {
    /* Changed to CSS Grid for easier fixed-size alignment */
    display: grid; 
    grid-template-columns: repeat(auto-fill, minmax(130px, 1fr)); /* Auto-fit columns */
    justify-items: center; /* Center items in the grid */
    padding: 20px;
    gap: 20px 15px; /* Added slight vertical gap */
    overflow-y: auto;
    height: 100%;
}

/* Style for individual link items (The Fixed Frame Container) */
.gallery-link-item {
    /* Fixed Frame Size: 130px */
    width: 130px; 
    
    /* Reduced noise: simpler styling */
    border: 1px solid #ddd; 
    border-radius: 8px;
    background: #ffffff;
    cursor: pointer;
    transition: box-shadow 0.2s, transform 0.2s;
    overflow: hidden; /* Necessary for clean corners */
}

.gallery-link-item:hover {
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
    transform: translateY(-2px);
    background: #f9f9f9; /* Subtle hover effect */
}


/* --- Image Framing for Uniformity --- */

/* Wrapper for the image to enforce a 1:1 square aspect ratio */
.gallery-image-wrapper {
    position: relative;
    width: 100%;
    padding-top: 100%; /* Creates a perfect square (1:1 ratio) based on width */
    overflow: hidden;
    background: #f7f7f7; /* Background for non-square images */
}

/* The actual image element inside the wrapper */
.gallery-image {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    
    /* KEY CHANGE: Forces image to cover the entire frame without distortion */
    object-fit: cover; 
}

/* Optional: Text Label beneath the image frame (less noisy design) */
.gallery-link-item p {
    margin: 5px 0 0;
    padding: 5px 8px;
    font-size: 0.85rem;
    color: #333;
    /* Optional: ellipsis for long file names */
    white-space: nowrap; 
    overflow: hidden;
    text-overflow: ellipsis; 
}

/* Styling the native <dialog> element */
.modal {
    /* Centering the dialog content and setting basic size/style */
    border: none;
    padding: 0;
    border-radius: 12px;
    box-shadow: 0 10px 25px rgba(0, 0, 0, 0.2);
    width: 90%;
    max-width: 450px;
    background-color: #ffffff;
    
    /* Ensure it's centered when shown via dialog.showModal() */
    margin: auto;
}

/* Style for the semi-transparent overlay when the dialog is open */
.modal::backdrop {
    background: rgba(0, 0, 0, 0.6);
    backdrop-filter: blur(4px); /* Modern subtle blur effect */
}

/* --- Layout and Component Styling --- */
.modal-header {
    display: flex;
    justify-content: space-between; /* Puts title and button far apart */
    align-items: center;
    padding: 15px 20px;
    border-bottom: 1px solid #eeeeee;
    background-color: #f7f7f7;
    border-radius: 12px 12px 0 0;
}

.close-btn {
    background: none;
    border: none;
    font-size: 24px;
    cursor: pointer;
    color: #333;
    line-height: 1;
    padding: 0; /* Remove default button padding */
}

.modal-body {
    padding: 20px;
}

.product-title {
    font-size: 1.1rem;
    color: #555;
    margin-bottom: 15px;
}

.input-group {
    margin-bottom: 15px;
}

.input-field {
    width: 100%;
    padding: 10px;
    margin-top: 5px;
    border: 1px solid #ccc;
    border-radius: 6px;
    box-sizing: border-box; /* Crucial for padding/border within width */
    font-size: 1rem;
}

.button-container {
    padding-top: 10px;
    text-align: right;
}

.btn-primary {
    padding: 10px 20px;
    background-color: #007bff; /* Primary action color */
    color: white;
    border: none;
    border-radius: 6px;
    cursor: pointer;
    font-size: 1rem;
    transition: background-color 0.2s;
}

.btn-primary:hover {
    background-color: #0056b3;
}
/* ---------- RESPONSIVE ADJUSTMENTS ---------- */

/* Tablets and small laptops */
@media (max-width: 768px) {
  body {
    padding: 16px;
  }

  .page {
    flex-direction: column;
    align-items: center;
  }

  .product-panel.selected {
    width: 90%;
    max-width: 400px;
  }

  .product-panel.add-panel {
    width: 95%;
    max-width: 600px;
  }

  .text-input,
  .small-input {
    min-width: 140px;
    font-size: 0.95rem;
  }

  .label-black {
    width: auto;
    padding: 6px 8px;
    font-size: 0.9rem;
  }

  .thumb-preview.small {
    width: 150px;
    height: 80px;
  }

  .product-card {
    width: 90%;
  }
}

/* Phones (narrow screens) */
@media (max-width: 480px) {
  .page {
    gap: 16px;
  }

  .product-panel {
    padding: 12px;
    border-radius: 20px;
  }

  .product-panel.selected {
    width: 100%;
  }

  .product-panel.add-panel {
    width: 100%;
    order: 2; /* still below rendered list */
  }

  .products-area {
    order: 1; /* stays above */
  }

  .label-black {
    font-size: 0.85rem;
    padding: 6px;
  }

  .text-input,
  .small-input {
    width: 100%;
    margin: 4px 0;
  }

  .row,
  .form-row,
  .action-row {
    flex-direction: column;
    align-items: stretch;
  }

  .thumb-preview.small,
  .thumb-preview {
    width: 100%;
    height: 140px;
  }

  .btn-black.big,
  .btn-black.small {
    width: 100%;
  }

  .product-card {
    flex-direction: column;
    width: 100%;
    text-align: center;
  }

  .product-card .p-thumb {
    width: 100%;
    height: 160px;
  }

  .p-info h4 {
    font-size: 1.1rem;
  }
}
