/* assets/css/pages/products.css */
/* Scope: products.php page-only refinements (no inline styles) */

.products-page > * + *{
  margin-top: var(--space-3);
}

.products-topbar .row .btn{
  height:40px;
  padding:0 12px;
  font-weight:700;
}

.products-messages .msg{
  border: 1px solid var(--glass-border);
  background: var(--glass-bg);
  -webkit-backdrop-filter: blur(var(--glass-blur)) saturate(var(--glass-saturation));
  backdrop-filter: blur(var(--glass-blur)) saturate(var(--glass-saturation));
  box-shadow: var(--shadow-3);
}
.products-messages .msg--err{
  border-color: rgba(199,74,69,.4);
  background: rgba(255,240,238,.92);
}
.products-messages .msg--ok{
  border-color: rgba(46,157,91,.35);
  background: rgba(239,255,246,.9);
}

.products-messages{
  position: fixed;
  top: calc(var(--space-3, 12px) + env(safe-area-inset-top) + 64px);
  left: 12px;
  right: 12px;
  z-index: 1200;
  display: grid;
  gap: 10px;
  pointer-events: none;
}
.products-messages .msg{
  position: relative;
  padding-inline-end: 36px;
  transition: opacity .2s ease, transform .2s ease;
  pointer-events: auto;
}
.products-messages .toast{
  position: relative;
  left: auto;
  right: auto;
  top: auto;
  opacity: 1;
  transform: none;
  pointer-events: auto;
}
.products-messages .msg.is-hide{
  opacity: 0;
  transform: translateY(-6px);
}
.products-messages .msg:not(.toast)::before{
  content: "";
  position: absolute;
  inset: 0;
  border-radius: inherit;
  pointer-events: none;
  background: linear-gradient(180deg, rgba(255,255,255,.65), rgba(255,255,255,.15));
  opacity: .7;
}
.products-messages .msg > *{
  position: relative;
  z-index: 1;
}
.msg__close{
  position: absolute;
  inset-inline-end: 10px;
  top: 8px;
  width: 28px;
  height: 28px;
  border: 0;
  border-radius: 8px;
  background: transparent;
  font-size: 18px;
  line-height: 1;
  cursor: pointer;
  color: inherit;
}
.msg__close:hover{
  background: rgba(42,38,33,.06);
}

@supports not ((backdrop-filter: blur(1px)) or (-webkit-backdrop-filter: blur(1px))){
  .products-messages .msg{
    background: rgba(255,255,255,.98);
  }
}

.form-hint{
  margin-top:8px;
}

.product-add{
  background:
    linear-gradient(180deg, rgba(229,170,23,.1), rgba(229,170,23,.03));
  border: 1px dashed rgba(229,170,23,.42);
}
.product-add__head{
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}
.product-add__sub{
  margin-top: 6px;
  font-size: 12px;
}
.product-add__meta{
  margin-top: 4px;
  font-size: 12px;
}
.product-add__upgrade{
  margin-top: 8px;
}
.product-add__form{
  margin-top: 12px;
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  align-items: center;
}
.product-add__field{
  flex: 3 1 240px;
}
.product-add__action{
  flex: 1 1 160px;
}
.product-add__action .btn,
.product-add__upgrade .btn{
  height: var(--control-h-sm);
}

.table{
  width:100%;
  border-collapse: collapse;
}
.table th,
.table td{
  padding: 10px 8px;
  border-bottom: 1px solid rgba(31,31,31,.08);
  text-align: right;
  font-size: 14px;
}
.table th{
  font-size: 12px;
  color: var(--text-muted);
  font-weight: 700;
}

.product-tools{
  margin-top: 10px;
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}

.product-tools__input{
  flex: 1 1 220px;
  height: var(--control-h-sm);
  border-radius: var(--control-radius);
}

.product-tools__sort{
  flex: 0 0 132px;
  width: 132px;
  min-width: 132px;
  max-width: 132px;
  height: var(--control-h-sm);
  padding: 0 8px;
  border-radius: var(--radius-md);
  font-size: 12px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.product-tools__meta{
  font-size: 12px;
  white-space: nowrap;
  margin-inline-start: auto;
}
.product-list__sub{
  margin-top: 6px;
}
.product-list__gap{
  height: 12px;
}

.actions{
  display:flex;
  gap:8px;
  flex-wrap: wrap;
  justify-content: flex-start;
  align-items:center;
}

.inline-edit{
  display:flex;
  gap:8px;
  align-items:center;
  flex-wrap: wrap;
}
.inline-edit .input{
  min-width: 220px;
}

/* --- Products: card layout + recipe accordion --- */
.products-list{
  display: grid;
  gap: 10px;
}
#productsListCard{
  scroll-margin-top: 92px;
}
#productsListCard.is-focus-reveal{
  animation: productsListFocusReveal 900ms cubic-bezier(.2,.75,.2,1);
}
@keyframes productsListFocusReveal{
  0%{
    box-shadow: var(--shadow-1);
    border-color: var(--border-soft);
  }
  30%{
    box-shadow: 0 12px 28px rgba(229,170,23,.2), 0 0 0 2px rgba(229,170,23,.32) inset;
    border-color: rgba(229,170,23,.62);
  }
  100%{
    box-shadow: var(--shadow-1);
    border-color: var(--border-soft);
  }
}

.product-card{
  padding: 12px;
  border: 1px solid var(--border-soft);
  border-radius: var(--radius-lg);
  background: rgba(255,255,255,.9);
  box-shadow: var(--shadow-1);
  transition: box-shadow .25s ease, border-color .25s ease, background-color .25s ease;
}

.product-card.is-editing{
  border-color: rgba(229,170,23,.36);
  box-shadow: var(--shadow-2);
  background: rgba(255,255,255,.96);
}

.product-card.is-open{
  border-color: rgba(229,170,23,.36);
  box-shadow: var(--shadow-2);
  background: rgba(255,255,255,.96);
}

.product-head{
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  flex-wrap: wrap;
}

.product-title-text{
  font-size: 16px;
  margin: 0;
}

.product-title{
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.product-title-view{
  display: inline-flex;
  align-items: center;
  gap: 6px;
  flex-wrap: wrap;
}

.product-title-row{
  display: inline-flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}

.product-title-date{
  font-size: 11px;
  white-space: nowrap;
}

.product-edit{
  display: inline-flex;
  align-items: center;
  gap: 6px;
  flex-wrap: wrap;
}

.product-edit .input{
  min-width: 0;
}

.product-edit .btn{
  height: var(--control-h-sm);
  padding: 0 10px;
  font-size: 12px;
}

.product-card:not(.is-editing) .product-edit{
  display: none;
}

.product-card.is-editing .product-title-view{
  display: none;
}

.input--title{
  width: auto;
  max-width: 100%;
  font-size: 16px;
  font-weight: 700;
  height: var(--control-h-sm);
  padding: 0 10px;
}

.btn--icon{
  width: 30px;
  height: 30px;
  padding: 0;
  border-radius: 999px;
  font-size: 14px;
}

.product-edit-toggle{
  height: auto;
  padding: 0 4px;
  border: 0;
  background: transparent;
  font-size: 12px;
  line-height: 1;
  opacity: .7;
}
.product-edit-toggle:hover{
  background: rgba(42,38,33,.05);
  opacity: 1;
}
.product-edit-toggle:focus-visible{
  box-shadow: var(--focus-ring);
}

.product-actions{
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  align-items: center;
  width: 100%;
}

.product-actions .btn{
  height: var(--control-h-sm);
  padding: 0 12px;
  border-radius: var(--radius-md);
}

.product-toggle{
  background: rgba(229,170,23,.16);
  border-color: rgba(229,170,23,.46);
  font-weight: 800;
  font-size: 12px;
  white-space: nowrap;
  flex: 1 1 100%;
  width: 100%;
}

.product-card.is-open .product-toggle{
  background: rgba(229,170,23,.24);
  border-color: rgba(229,170,23,.62);
}

.product-actions .inline-form{
  margin: 0;
}

.product-summary{
  margin-top: 8px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  flex-wrap: wrap;
  font-size: 12px;
  color: var(--text-muted);
  max-height: 140px;
  overflow: hidden;
  transition: max-height .25s ease, opacity .2s ease, transform .2s ease;
}
.product-summary__line{
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 4px 8px;
  border-radius: 10px;
  background: rgba(42,38,33,.04);
  border: 1px dashed var(--border-soft);
  white-space: nowrap;
  font-variant-numeric: tabular-nums;
}
.product-summary__count,
.product-summary__total{
  color: var(--text-main);
  font-weight: 700;
}
.product-summary__sep{
  opacity: .6;
}
.product-summary__actions{
  display: flex;
  justify-content: flex-end;
  justify-self: end;
  margin-inline-start: auto;
}
.product-summary__actions .inline-form{
  margin: 0;
}
.product-summary__actions .btn{
  height: 32px;
  padding: 0 10px;
  font-size: 12px;
  border-radius: 10px;
}
.product-card.is-open .product-summary{
  max-height: 0;
  opacity: 0;
  transform: translateY(-4px);
  margin-top: 0;
  pointer-events: none;
}

.product-recipe{
  max-height: 0;
  overflow: hidden;
  opacity: 0;
  transform: translateY(-4px);
  transition: max-height .35s ease, opacity .25s ease, transform .25s ease;
}

.product-card.is-open .product-recipe{
  max-height: 900px;
  opacity: 1;
  transform: translateY(0);
}

.product-recipe__inner{
  margin-top: 10px;
  padding-top: 10px;
  border-top: 1px dashed var(--border-soft);
  display: grid;
  gap: 10px;
}

.product-recipe__sheet{
  border: 1px dashed rgba(229,170,23,.35);
  border-radius: 14px;
  padding: 8px;
  background:
    linear-gradient(180deg, rgba(229,170,23,.08), rgba(229,170,23,.02)),
    repeating-linear-gradient(180deg, rgba(42,38,33,.03), rgba(42,38,33,.03) 1px, transparent 1px, transparent 30px);
}

.product-recipe__list{
  display: grid;
  gap: 4px;
}

.prod-line{
  display: grid;
  grid-template-columns: 1.6fr .7fr .7fr;
  gap: 6px;
  align-items: center;
  padding: 6px 8px;
  border-bottom: 1px dashed var(--border-soft);
}

.prod-line:last-child{
  border-bottom: none;
}

.prod-line--head{
  font-size: 11px;
  font-weight: 800;
  color: var(--text-muted);
  background: rgba(229,170,23,.16);
  border: 1px solid rgba(229,170,23,.26);
  border-radius: 10px;
  margin-bottom: 6px;
  padding: 6px 8px;
}

.prod-line__name{
  font-weight: 700;
}

.prod-line__qty{
  text-align: center;
  white-space: nowrap;
}

.prod-line__cost{
  text-align: left;
  white-space: nowrap;
  font-variant-numeric: tabular-nums;
}

.product-recipe__summary-line{
  display: inline-flex;
  align-items: center;
  gap: 6px;
  justify-content: center;
  padding: 6px 10px;
  border-radius: 12px;
  border: 1px dashed var(--border-soft);
  background: rgba(42,38,33,.03);
  font-variant-numeric: tabular-nums;
  font-size: 12px;
  color: var(--text-muted);
  margin-inline: auto;
}
.product-recipe__summary-count,
.product-recipe__summary-total{
  color: var(--text-main);
  font-weight: 700;
}
.product-recipe__summary-sep{
  opacity: .6;
}

.product-recipe__loading,
.product-recipe__empty,
.product-recipe__error{
  text-align: center;
  font-size: 12px;
}

.product-recipe__actions{
  display: flex;
  justify-content: center;
  width: 100%;
}

.product-recipe__actions .btn{
  height: 36px;
  border-radius: 12px;
  width: 100%;
  max-width: 260px;
}

.product-recipe__note{
  font-size: 12px;
  margin-inline-end: auto;
}

.product-recipe__footer{
  display: flex;
  flex-direction: column;
  align-items: stretch;
  justify-content: flex-start;
  gap: 8px;
  flex-wrap: wrap;
}

.product-recipe__sell{
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  flex-wrap: wrap;
  padding: 6px 8px;
  border-radius: 12px;
  border: 1px dashed rgba(229,170,23,.28);
  background: rgba(229,170,23,.06);
}

.product-recipe__sell-label{
  font-size: 12px;
  font-weight: 700;
}

.product-recipe__sell-controls{
  display: inline-flex;
  align-items: center;
  gap: 6px;
  flex-wrap: wrap;
}

.product-recipe__sell-input{
  width: 56px;
  height: 32px;
  text-align: center;
  padding: 0 6px;
}

.btn--mini{
  height: 32px;
  padding: 0 8px;
  font-size: 12px;
}

.product-recipe__sell-out{
  white-space: nowrap;
  font-variant-numeric: tabular-nums;
}

@media (max-width: 640px){
  .products-messages{
    top: calc(var(--space-3, 12px) + env(safe-area-inset-top) + 56px);
  }

  .product-tools{
    gap: 6px;
  }

  .product-head{
    align-items: stretch;
  }

  .product-actions{
    width: 100%;
  }

  .product-actions .btn{
    width: 100%;
  }

  .product-add__action .btn{
    width: 100%;
  }

  .product-summary{
    flex-wrap: wrap;
  }

  .product-summary__actions{
    justify-content: stretch;
    justify-self: stretch;
    width: 100%;
  }

  .product-summary__actions .btn{
    width: 100%;
  }

  .product-summary__line{
    width: 100%;
    justify-content: center;
  }

  .prod-line{
    grid-template-columns: 1.4fr .8fr .8fr;
    gap: 4px;
    padding: 6px;
  }

  .prod-line--head{
    font-size: 10px;
  }

  .product-recipe__sheet{
    padding: 6px;
  }

  .product-recipe__sell{
    align-items: stretch;
  }

  .product-recipe__sell-controls{
    width: 100%;
    justify-content: space-between;
  }

  /* table -> card view */
  .table, .table thead, .table tbody, .table th, .table td, .table tr{ display:block; }
  .table thead{ display:none; }
  .table tr{
    border: 1px solid rgba(31,31,31,.08);
    border-radius: var(--radius-md);
    padding: 12px;
    margin-bottom: 10px;
    background: var(--surface-1);
    box-shadow: 0 6px 18px rgba(0,0,0,.05);
  }
  .table td{
    border: none;
    padding: 6px 0;
  }
  .table td[data-label]::before{
    content: attr(data-label) ": ";
    color: var(--text-muted);
    font-size: 12px;
    font-weight: 700;
  }

  .actions{
    margin-top: 8px;
  }
}

@media (prefers-reduced-motion: reduce){
  #productsListCard.is-focus-reveal{
    animation: none !important;
  }
}
