/* ================================================================
   Baskets Panel — css/style.css
   ================================================================ */

*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
  --bg:          #f5f4f0;
  --card:        #ffffff;
  --accent:      #c8a96e;
  --accent2:     #7c5c3e;
  --text:        #2d2a26;
  --muted:       #8a8070;
  --border:      #e4ddd3;
  --ggb:         #4a7c59;
  --ggb-light:   #e8f4ec;
  --hd:          #6b4c8a;
  --hd-light:    #f0eaf7;
  --tag-bg:      #f0ebe3;
  --green:       #2e7d32;
  --green-light: #e8f5e9;
  --shadow:      0 2px 12px rgba(0,0,0,.07);
  --shadow-lg:   0 6px 24px rgba(0,0,0,.13);
  --sidebar-w:   272px;
  --radius:      10px;
}

html, body { height: 100%; overflow: hidden; }
body {
  font-family: 'Segoe UI', system-ui, sans-serif;
  background: var(--bg);
  color: var(--text);
  display: flex;
  flex-direction: column;
}

/* ── HEADER ──────────────────────────────────────────────────── */
header {
  flex-shrink: 0;
  background: var(--accent2);
  color: #fff;
  padding: 13px 24px;
  display: flex;
  align-items: center;
  gap: 12px;
  box-shadow: 0 2px 8px rgba(0,0,0,.18);
}
header .icon        { font-size: 1.7rem; flex-shrink: 0; }
header .header-text { flex: 1; min-width: 0; }
header h1 { font-size: 1.3rem; font-weight: 700; letter-spacing: .4px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
header p  { font-size: .8rem; opacity: .72; }

.filter-toggle {
  display: none;
  align-items: center; justify-content: center;
  width: 36px; height: 36px; border-radius: 9px;
  background: rgba(255,255,255,.15); border: 1px solid rgba(255,255,255,.25);
  color: #fff; font-size: 1.1rem; cursor: pointer; flex-shrink: 0;
  transition: background .15s;
}
.filter-toggle:hover { background: rgba(255,255,255,.25); }
.filter-toggle.has-filters { background: var(--accent); border-color: var(--accent); }

/* ── LAYOUT ──────────────────────────────────────────────────── */
.layout {
  flex: 1;
  display: grid;
  grid-template-columns: var(--sidebar-w) 1fr;
  min-height: 0;
  overflow: hidden;
}

/* ── SIDEBAR BACKDROP ─────────────────────────────────────────── */
.sidebar-backdrop { display: none; position: fixed; inset: 0; background: rgba(0,0,0,.45); z-index: 59; }
.sidebar-backdrop.open { display: block; }

/* ── SIDEBAR ─────────────────────────────────────────────────── */
.sidebar {
  background: var(--card);
  border-right: 1px solid var(--border);
  padding: 16px 14px;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.sidebar-close {
  display: none;
  align-self: flex-end;
  width: 28px; height: 28px; border-radius: 50%;
  border: 1px solid var(--border); background: var(--bg);
  cursor: pointer; font-size: .95rem; color: var(--muted);
  align-items: center; justify-content: center; transition: background .15s;
}
.sidebar-close:hover { background: var(--border); }

.section-title {
  font-size: .66rem; font-weight: 700; letter-spacing: 1.2px;
  text-transform: uppercase; color: var(--muted); margin-bottom: 6px;
}

/* search */
.search-wrap { position: relative; }
.search-wrap input {
  width: 100%; padding: 8px 12px 8px 30px;
  border: 1px solid var(--border); border-radius: 8px;
  background: var(--bg); font-size: .86rem; color: var(--text);
  outline: none; transition: border .2s;
}
.search-wrap input:focus { border-color: var(--accent); }
.search-wrap .icon-search {
  position: absolute; left: 9px; top: 50%; transform: translateY(-50%);
  color: var(--muted); font-size: .9rem; pointer-events: none;
}

/* brand */
.brand-btns { display: flex; gap: 6px; flex-wrap: wrap; }
.brand-btn {
  padding: 5px 12px; border-radius: 20px; font-size: .79rem; font-weight: 600;
  cursor: pointer; border: 2px solid transparent; transition: all .18s;
}
.brand-btn.all { background: var(--tag-bg); color: var(--text); border-color: var(--border); }
.brand-btn.ggb { background: var(--ggb-light); color: var(--ggb); border-color: var(--ggb-light); }
.brand-btn.hd  { background: var(--hd-light);  color: var(--hd);  border-color: var(--hd-light); }
.brand-btn.active.all { background: var(--text); color: #fff; border-color: var(--text); }
.brand-btn.active.ggb { background: var(--ggb);  color: #fff; border-color: var(--ggb); }
.brand-btn.active.hd  { background: var(--hd);   color: #fff; border-color: var(--hd); }

/* price range */
.price-range { display: flex; flex-direction: column; gap: 4px; }
.price-range input[type=range] { accent-color: var(--accent2); width: 100%; }
.price-labels { display: flex; justify-content: space-between; font-size: .74rem; color: var(--muted); }
.price-labels span { font-weight: 600; color: var(--accent2); }

/* product tags */
.product-tags { display: flex; flex-wrap: wrap; gap: 5px; max-height: 160px; overflow-y: auto; }
.prod-tag {
  padding: 3px 8px; border-radius: 14px; font-size: .72rem; cursor: pointer;
  background: var(--tag-bg); color: var(--text); border: 1px solid var(--border);
  transition: all .14s; white-space: nowrap;
}
.prod-tag.active { background: var(--accent2); color: #fff; border-color: var(--accent2); }
.prod-tag:hover:not(.active) { border-color: var(--accent); }

/* stats */
.stats-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 6px; }
.stat-card {
  background: var(--bg); border-radius: var(--radius); padding: 9px 10px;
  border: 1px solid var(--border); text-align: center;
}
.stat-card .val { font-size: 1.25rem; font-weight: 700; color: var(--accent2); line-height: 1; }
.stat-card .lbl { font-size: .65rem; color: var(--muted); margin-top: 2px; }

/* ── MAIN ────────────────────────────────────────────────────── */
.main { display: flex; flex-direction: column; min-height: 0; overflow: hidden; }

.toolbar {
  flex-shrink: 0; padding: 9px 18px;
  background: var(--card); border-bottom: 1px solid var(--border);
  display: flex; align-items: center; gap: 8px; flex-wrap: wrap;
}
.toolbar .count      { font-size: .79rem; color: var(--muted); }
.toolbar .spacer     { flex: 1; }
.toolbar .sort-label { font-size: .79rem; color: var(--muted); }

.sort-select {
  padding: 5px 9px; border-radius: 7px; border: 1px solid var(--border);
  background: var(--bg); font-size: .79rem; color: var(--text);
  outline: none; cursor: pointer;
}
.sort-select:focus { border-color: var(--accent); }

.view-btns { display: flex; gap: 4px; }
.view-btn {
  width: 29px; height: 29px; border-radius: 7px; border: 1px solid var(--border);
  background: var(--bg); cursor: pointer; font-size: .93rem; color: var(--muted);
  display: flex; align-items: center; justify-content: center; transition: all .14s;
}
.view-btn.active { background: var(--accent2); color: #fff; border-color: var(--accent2); }
.view-btn:hover:not(.active) { border-color: var(--accent); }

/* ── CARDS VIEW ──────────────────────────────────────────────── */
.content-wrap { flex: 1; min-height: 0; overflow-y: auto; padding: 16px; }
.cards-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(250px, 1fr));
  gap: 13px;
}
.loading-msg { grid-column: 1/-1; text-align: center; padding: 60px 20px; color: var(--muted); }
.empty-msg   { grid-column: 1/-1; text-align: center; padding: 60px 20px; color: var(--muted); }

.basket-card {
  background: var(--card); border-radius: 13px; padding: 15px;
  border: 1.5px solid var(--border); cursor: pointer;
  transition: box-shadow .18s, transform .14s, border-color .18s;
  display: flex; flex-direction: column; gap: 8px;
  box-shadow: var(--shadow);
}
.basket-card:hover { box-shadow: var(--shadow-lg); transform: translateY(-2px); border-color: var(--accent); }

.card-top { display: flex; align-items: flex-start; justify-content: space-between; gap: 8px; }
.card-name { font-size: .92rem; font-weight: 700; color: var(--text); line-height: 1.3; }

.badge {
  padding: 3px 8px; border-radius: 9px; font-size: .69rem; font-weight: 700;
  white-space: nowrap; flex-shrink: 0;
}
.badge.ggb { background: var(--ggb-light); color: var(--ggb); }
.badge.hd  { background: var(--hd-light);  color: var(--hd); }

.card-prices { display: flex; flex-direction: column; gap: 3px; }
.card-price      { font-size: 1.15rem; font-weight: 800; color: var(--accent2); }
.card-cost-row   { display: flex; align-items: center; gap: 6px; }
.card-cost       { font-size: .85rem; font-weight: 600; color: var(--green); }
.card-cost-ratio { font-size: .7rem; color: var(--muted); }

.card-products { display: flex; flex-wrap: wrap; gap: 3px; }
.mini-tag { font-size: .67rem; padding: 2px 7px; border-radius: 9px; background: var(--tag-bg); color: var(--muted); border: 1px solid var(--border); }
.mini-tag.more { font-style: italic; }

.card-footer {
  display: flex; align-items: center; gap: 6px;
  border-top: 1px solid var(--border); padding-top: 7px;
  font-size: .72rem; color: var(--muted);
}

/* ── LIST VIEW ───────────────────────────────────────────────── */
.list-table-wrap { flex: 1; min-height: 0; overflow: auto; }

table.list-table { width: 100%; border-collapse: collapse; font-size: .84rem; }
table.list-table thead {
  position: sticky; top: 0; z-index: 2;
  background: var(--card);
  box-shadow: 0 1px 0 var(--border), 0 2px 4px rgba(0,0,0,.05);
}
table.list-table th {
  padding: 9px 13px; text-align: left; font-size: .66rem; font-weight: 700;
  letter-spacing: .8px; text-transform: uppercase; color: var(--muted);
  white-space: nowrap; user-select: none;
}
table.list-table th.sortable { cursor: pointer; }
table.list-table th.sortable:hover { color: var(--accent2); }
table.list-table th .sort-arrow { margin-left: 3px; opacity: .38; }
table.list-table th.sorted .sort-arrow { opacity: 1; color: var(--accent2); }

table.list-table td {
  padding: 8px 13px; vertical-align: middle; border-bottom: 1px solid var(--border);
}
table.list-table tbody tr { cursor: pointer; transition: background .1s; }
table.list-table tbody tr:hover { background: #faf7f3; }
table.list-table tbody tr:nth-child(even) { background: #fdfcfb; }
table.list-table tbody tr:nth-child(even):hover { background: #faf7f3; }

.tbl-num    { color: var(--muted); font-size: .74rem; font-weight: 600; width: 36px; }
.tbl-name   { font-weight: 600; color: var(--text); min-width: 150px; }
.tbl-price  { font-weight: 700; color: var(--accent2); white-space: nowrap; }
.tbl-cost   { font-weight: 700; color: var(--green); white-space: nowrap; }
.tbl-cost.empty { color: var(--muted); font-weight: 400; font-size: .78rem; }
.tbl-config { white-space: nowrap; }
.config-ratio { font-size: .75rem; color: var(--muted); }
.config-ratio.full { color: var(--green); font-weight: 600; }
.tbl-qty    { text-align: center; color: var(--muted); width: 50px; }
.tbl-prods  { font-size: .79rem; line-height: 1.5; }
.prod-pill  {
  display: inline-block; padding: 1px 7px; border-radius: 9px; margin: 1px 2px;
  background: var(--tag-bg); border: 1px solid var(--border);
  font-size: .71rem; color: var(--muted);
}
.loading-cell { text-align: center; padding: 50px; color: var(--muted); }

/* ── MODAL ───────────────────────────────────────────────────── */
.modal-overlay {
  display: none; position: fixed; inset: 0;
  background: rgba(0,0,0,.45); z-index: 100;
  align-items: center; justify-content: center; padding: 20px;
}
.modal-overlay.open { display: flex; }

.modal {
  background: var(--card); border-radius: 16px;
  max-width: 760px; width: 100%;
  max-height: 90vh; overflow-y: auto;
  box-shadow: 0 20px 60px rgba(0,0,0,.25);
  animation: popIn .18s ease;
}
@keyframes popIn { from { transform: scale(.94); opacity: 0; } to { transform: scale(1); opacity: 1; } }

.modal-header {
  padding: 18px 22px 14px; border-bottom: 1px solid var(--border);
  display: flex; align-items: flex-start; gap: 12px;
}
.modal-header .info { flex: 1; }
.modal-header h2 { font-size: 1.08rem; font-weight: 700; color: var(--text); }
.modal-header .modal-brand { margin-top: 5px; }

.modal-close {
  width: 29px; height: 29px; border-radius: 50%; border: 1px solid var(--border);
  background: var(--bg); cursor: pointer; font-size: .95rem; color: var(--muted);
  display: flex; align-items: center; justify-content: center;
  flex-shrink: 0; transition: background .14s;
}
.modal-close:hover { background: var(--border); }

.modal-body { padding: 16px 22px; display: flex; flex-direction: column; gap: 14px; }

/* Cost summary */
.cost-summary {
  display: flex; flex-wrap: wrap; gap: 0;
  background: var(--bg); border-radius: var(--radius);
  border: 1px solid var(--border); overflow: hidden;
}
.cost-item {
  flex: 1; min-width: 110px;
  display: flex; flex-direction: column; gap: 3px;
  padding: 12px 16px;
}
.cost-sep { width: 1px; background: var(--border); align-self: stretch; }
.cost-label { font-size: .64rem; font-weight: 700; text-transform: uppercase; letter-spacing: .8px; color: var(--muted); }
.cost-value { font-size: 1.15rem; font-weight: 700; color: var(--text); }
.cost-value.highlight { color: var(--green); }
.cost-value.small { font-size: .95rem; }

/* Products edit table */
.products-table-wrap { overflow-x: auto; }

table.products-edit-table {
  width: 100%; border-collapse: collapse; font-size: .83rem;
}
table.products-edit-table thead {
  background: var(--bg);
  border-bottom: 2px solid var(--border);
}
table.products-edit-table th {
  padding: 7px 10px; text-align: left; font-size: .64rem;
  font-weight: 700; letter-spacing: .8px; text-transform: uppercase;
  color: var(--muted); white-space: nowrap;
}
table.products-edit-table td {
  padding: 5px 8px; vertical-align: middle;
  border-bottom: 1px solid var(--border);
}
table.products-edit-table tbody tr:hover { background: #faf7f3; }

.p-code-cell {
  font-family: monospace; font-size: .73rem; font-weight: 700;
  color: var(--muted);
  background: var(--card); padding: 2px 6px; border-radius: 5px;
  border: 1px solid var(--border); display: inline-block;
}
.p-name-cell { font-weight: 600; color: var(--text); white-space: nowrap; }

/* Inputs editables */
.inp-qty, .inp-cost, .inp-store {
  border: 1px solid var(--border); border-radius: 6px;
  padding: 5px 8px; font-size: .82rem; color: var(--text);
  background: var(--card); outline: none; transition: border .14s, box-shadow .14s;
}
.inp-qty:focus, .inp-cost:focus, .inp-store:focus {
  border-color: var(--accent); box-shadow: 0 0 0 3px rgba(200,169,110,.15);
}
.inp-qty  { width: 64px;  text-align: center; }
.inp-cost { width: 90px;  text-align: right; }
.inp-store{ width: 130px; }

.line-total { text-align: right; font-weight: 700; color: var(--accent2); white-space: nowrap; }
.line-total.empty { color: var(--muted); font-weight: 400; }

/* Save status indicator */
.save-status { font-size: .75rem; width: 20px; text-align: center; }
.save-status.saving { color: var(--muted); }
.save-status.saved  { color: var(--green); }
.save-status.error  { color: #c0392b; }

.modal-detail-note {
  font-size: .76rem; color: var(--muted); font-style: italic;
  border-top: 1px solid var(--border); padding-top: 10px;
}

/* ── TOAST ───────────────────────────────────────────────────── */
.toast-container {
  position: fixed; bottom: 20px; right: 20px;
  display: flex; flex-direction: column; gap: 8px; z-index: 200;
}
.toast {
  background: #2d2a26; color: #fff; border-radius: 9px;
  padding: 10px 16px; font-size: .83rem; max-width: 320px;
  box-shadow: 0 4px 16px rgba(0,0,0,.25);
  animation: slideIn .2s ease;
}
.toast.error   { background: #c0392b; }
.toast.success { background: var(--green); }
@keyframes slideIn { from { transform: translateY(12px); opacity: 0; } to { transform: translateY(0); opacity: 1; } }

/* ── SCROLLBAR ───────────────────────────────────────────────── */
::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--border); border-radius: 10px; }
::-webkit-scrollbar-thumb:hover { background: var(--accent); }

/* ── RESPONSIVE ──────────────────────────────────────────────── */
@media (max-width: 768px) {
  header { padding: 10px 13px; }
  header h1 { font-size: 1.05rem; }
  header p  { display: none; }
  .filter-toggle { display: flex; }

  .layout { grid-template-columns: 1fr; }

  .sidebar {
    position: fixed;
    top: 0; bottom: 0; left: calc(-1 * var(--sidebar-w) - 10px);
    width: var(--sidebar-w);
    z-index: 60;
    transition: left .25s ease, box-shadow .25s ease;
    border-right: none;
  }
  .sidebar.open { left: 0; box-shadow: 4px 0 24px rgba(0,0,0,.22); }
  .sidebar-close { display: flex; }

  .toolbar { padding: 7px 11px; gap: 6px; }
  .toolbar .sort-label { display: none; }
  .sort-select { flex: 1; min-width: 0; font-size: .77rem; }

  .cards-grid { grid-template-columns: 1fr; }
  .content-wrap { padding: 11px; }

  .col-hide-mobile { display: none; }

  .modal-overlay { padding: 0; align-items: flex-end; }
  .modal { border-radius: 16px 16px 0 0; max-height: 92vh; max-width: 100%; }

  .inp-store { width: 100px; }
  .cost-sep  { display: none; }
  .cost-item { min-width: 90px; }
}

@media (max-width: 400px) {
  header h1 { font-size: .92rem; }
}
