/* Component Styles: Shared between Index and Admin */
detail-list, category-pills, product-card, app-toast {
    display: block;
}

/* ============================
   Product List Header
   (Search + Category Pills)
   ============================ */
.product-list-header {
    width: 100%;
    /* Ensure it breaks out of parent padding if needed, or parent handles it */
    background: white; 
    /* User said "Background extend to sides". 
       If page bg is Cloud Dancer, transparency works. 
       If they meant White background block, I'll add it. 
       Usually "Search + Pills" is just on the page background.
    */
    padding-top: 12px;
}

.search-row {
  display: flex;
  gap: 12px;
  margin-bottom: 12px;
  padding: 0 16px; /* Horizontal Padding here */
}

.search-wrap {
  flex: 1;
  position: relative;
  display: flex;
  align-items: center;
  background: white; /* Search Input BG or Container BG? */
  border-radius: 10px;
  box-shadow: 0 2px 8px rgba(0,0,0,0.03); /* Subtle shadow for search box */
}

.search-wrap .material-symbols-rounded {
  position: absolute;
  left: 10px;
  color: var(--sphinx-light);
  font-size: 1.2rem;
  pointer-events: none;
}

.search-wrap input {
  width: 100%;
  border: none;
  background: transparent; /* Input itself transparent, wrapper has white */
  padding: 12px 10px 12px 36px;
  border-radius: 10px;
  font-size: 0.95rem;
  color: var(--sphinx);
  outline: none;
}

/* Add Button (Admin Only, but style defined here) */
.add-btn {
  background: var(--nile-water);
  color: white;
  border: none;
  width: 44px;
  height: 44px; /* Match Search Height approx */
  border-radius: 10px; /* Match Search Radius */
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  flex-shrink: 0;
  box-shadow: 0 2px 8px rgba(142, 172, 163, 0.3);
}

.add-btn:active {
  transform: scale(0.95);
  filter: brightness(0.9);
}

/* ============================
   Category Tabs (Wrapper)
   ============================ */
.category-tabs {
  flex-shrink: 0;
  background: rgba(253, 252, 250, 0.95);
  padding: 12px 16px;
  backdrop-filter: blur(10px);
  overflow-x: auto;
  white-space: nowrap;
  -webkit-overflow-scrolling: touch;
  border-bottom: 1px solid var(--border-light);
}

.category-tabs::-webkit-scrollbar {
  display: none;
}

/* ============================
   Common Modal Styles (Shared)
   ============================ */
.modal {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(0, 0, 0, 0.5);
  z-index: 10000; /* Ensure on top of everything */
  display: none;
  align-items: flex-end;
  justify-content: center;
  /* Ensure it's not hidden by any parent overflow */
}

.modal.show {
  display: flex !important;
  opacity: 1 !important;
  visibility: visible !important;
}

.modal-content {
  background: white;
  width: 100%;
  max-height: 90vh;
  border-radius: 24px 24px 0 0;
  overflow: hidden;
  animation: slideUp 0.3s ease;
  display: flex;
  flex-direction: column;
}

@keyframes slideUp {
  from { transform: translateY(100%); }
  to { transform: translateY(0); }
}

.modal-header {
  padding: 20px;
  border-bottom: 1px solid var(--border-light);
  display: flex;
  align-items: center;
  justify-content: space-between;
  background: white;
  flex-shrink: 0;
}

/* Close Button (Frontend Style) */
.modal-header .close-btn {
  background: var(--cloud-dancer);
  border: none;
  width: 36px;
  height: 36px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  color: var(--sphinx); /* Ensure icon color */
}

.modal-header .close-btn:active {
    background: rgba(0,0,0,0.1);
}

/* Modal Body/Footer styles */
.modal-body {
  padding: 20px;
  overflow-y: auto;
  flex: 1;
  background: white;
}

.modal-footer {
  padding: 20px;
  border-top: 1px solid var(--border-light);
  background: white;
  flex-shrink: 0;
}

/* Animation refinement to prevent flash */
.modal.closing {
    opacity: 0 !important;
    transition: opacity 0.2s ease;
}

.modal.closing .modal-content {
    transform: translateY(100%);
    transition: transform 0.2s ease;
}


/* ============================
   Category Pills
   ============================ */
.category-scroll-view {
  display: flex;
  overflow-x: auto;
  gap: 8px;
  padding: 0 16px 8px 16px; /* Padding for scroll edges */
  -webkit-overflow-scrolling: touch;
  scrollbar-width: none;
}
.category-scroll-view::-webkit-scrollbar {
  display: none;
}

.category-pill {
  white-space: nowrap;
  padding: 8px 16px;
  background: var(--subtle-cream); /* Light BG */
  border: 1px solid rgba(0,0,0,0.05); /* Subtle border */
  border-radius: 20px;
  font-size: 0.9rem;
  color: var(--sphinx-light);
  cursor: pointer;
  transition: all 0.2s;
  flex-shrink: 0;
  height: 36px; /* Fixed Height */
  display: flex;
  align-items: center;
}

.category-pill.active {
  background: var(--nile-water); 
  color: white;
  border-color: var(--nile-water);
  font-weight: 500;
  box-shadow: 0 2px 6px rgba(142, 172, 163, 0.3);
}

/* Edit Pill (Plus Icon) */
.category-pill.edit-pill {
    padding: 0;
    width: 36px;
    justify-content: center;
    border-radius: 50%; /* Circle */
    background: white;
    color: var(--nile-water);
    border: 1px solid var(--nile-water);
}

/* ============================
   Product Card (Unified Style - Frontend Look)
   ============================ */

/* ============================
   Product Area & Grid
   ============================ */

/* .product-area removed */


/* ============================
   Product Area & Grid
   ============================ */

.product-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr) !important; /* STRICTLY 3 columns as requested */
  gap: 8px; 
  padding: 8px;
  overflow-y: auto;
  flex: 1; 
  -webkit-overflow-scrolling: touch;
}

/* User explicitly requested 3 columns even on mobile */
@media (max-width: 360px) {
  .product-grid {
     grid-template-columns: repeat(3, 1fr) !important;
  }
}


.product-card {
  background: rgba(253, 252, 250, 0.95);
  border-radius: 12px;
  overflow: hidden;
  cursor: pointer;
  transition: transform 0.2s;
  position: relative;
  backdrop-filter: blur(8px);
}


.product-card:active {
  transform: scale(0.97);
}

.product-card.sold-out {
  opacity: 0.5;
  pointer-events: none;
}

.product-card .img-wrap {
  width: 100%;
  aspect-ratio: 1; /* Square Image */
  background: var(--cloud-dancer);
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
  position: relative;
}

.product-card .img-wrap img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.product-card .img-wrap .no-img {
  color: var(--sphinx-light);
  font-size: 1.8rem;
  width: 100%;
  height: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
}

/* Info Overlay Style (Frontend Standard) */
.product-card .info {
  position: absolute;
  bottom: 0;
  left: 0;
  right: 0;
  padding: 8px 10px;
  background: rgba(0, 0, 0, 0.45);
  text-align: center;
  display: flex;
  flex-direction: column;
  justify-content: center;
}

.product-card .name {
  font-size: 0.85rem;
  font-weight: 600;
  color: white;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  margin-bottom: 2px;
}

.product-card .price {
    font-weight: 600;
    color: white; 
    font-size: 0.95rem;
}

/* Badges */
.product-card .badge {
  position: absolute;
  top: 6px;
  right: 6px;
  background: rgba(0, 0, 0, 0.6);
  color: white;
  font-size: 0.6rem;
  padding: 2px 6px;
  border-radius: 8px;
}

.product-card .badge.low {
  background: var(--warning);
  color: var(--sphinx);
}

.product-card .badge.out {
  background: var(--danger);
  color: white;
}

.product-card .cart-qty {
  position: absolute;
  top: 6px;
  left: 6px;
  background: var(--nile-water);
  color: white;
  font-size: 0.7rem;
  font-weight: 600;
  width: 20px;
  height: 20px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
}

.product-card.inactive {
    opacity: 0.6;
}

/* Unified DetailList Styles for Frontend & Backend */
.detail-list {
    display: flex;
    flex-direction: column;
    width: 100%;
    border-radius: 12px;
    overflow: hidden; /* For zebra styling */
    background: white;
}

/* List Header (column mode) */
.detail-list .list-header {
    display: flex;
    align-items: center;
    padding: 10px 14px;
    background: rgba(242, 240, 235, 0.6);
    font-weight: 600;
    font-size: 0.85rem;
    color: var(--sphinx-light);
    border-bottom: 1px solid rgba(74, 70, 68, 0.1);
}

.detail-list .list-header > div {
    min-width: 0; /* Allow flex shrink */
}

/* List Body (column mode) */
.detail-list .list-body {
    display: flex;
    flex-direction: column;
}

/* Item Row - Base Styles */
.detail-list .item-row {
    display: flex;
    align-items: center;
    padding: 14px;
    margin-bottom: 0;
    border-radius: 0;
    border-bottom: 1px solid rgba(74, 70, 68, 0.06);
    background: transparent;
    transition: background-color 0.15s ease;
}

.detail-list .item-row > div {
    min-width: 0; /* Allow text overflow/ellipsis */
}

.detail-list .item-row:last-child {
    border-bottom: none;
}

/* Zebra Striping */
.detail-list .list-body .item-row:nth-child(even),
.detail-list > .item-row:nth-child(even) {
    background-color: rgba(242, 240, 235, 0.4);
}
.detail-list .list-body .item-row:nth-child(odd),
.detail-list > .item-row:nth-child(odd) {
    background-color: white;
}

/* Active State - Theme Color & White Text */
.detail-list .item-row.active {
    background-color: var(--nile-water) !important;
    color: white !important;
}

/* Ensure ALL text/elements inside active row are white */
.detail-list .item-row.active,
.detail-list .item-row.active * {
    color: white !important;
}

.detail-list .item-row.active img {
    border: 2px solid white;
}
