/* ==========================================================================
   Marketplace — plain CSS, no framework. One file, two skins:
   .admin-body for the panel, .shop-body for the storefront.
   ========================================================================== */

:root {
  --ink: #1a1a1a;
  --muted: #6b7280;
  --line: #e5e7eb;
  --bg: #f7f7f8;
  --card: #ffffff;
  --teal: #0f766e;
  --teal-soft: #ccfbf1;
  --coral: #b91c1c;
  --coral-soft: #fee2e2;
  --amber: #b45309;
  --amber-soft: #fef3c7;
  --green: #15803d;
  --green-soft: #dcfce7;
  --purple: #6d28d9;
  --radius: 8px;
  --shadow: 0 1px 2px rgba(0,0,0,.06), 0 1px 3px rgba(0,0,0,.04);
  --font: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
}

* { box-sizing: border-box; }
body { margin: 0; font-family: var(--font); color: var(--ink); background: var(--bg); font-size: 14px; line-height: 1.5; }
a { color: var(--teal); text-decoration: none; }
a:hover { text-decoration: underline; }
h1, h2, h3 { margin: 0 0 .5rem; font-weight: 600; }
h1 { font-size: 1.4rem; }
h2 { font-size: 1.1rem; }
table { width: 100%; border-collapse: collapse; }
th, td { padding: .6rem .75rem; text-align: left; border-bottom: 1px solid var(--line); vertical-align: top; }
th { font-weight: 500; color: var(--muted); font-size: .8rem; text-transform: uppercase; letter-spacing: .03em; }

/* ---- buttons & badges ---- */
.btn { display: inline-block; padding: .45rem .9rem; border: 1px solid var(--line); border-radius: var(--radius);
       background: var(--card); color: var(--ink); cursor: pointer; font-size: .85rem; font-family: var(--font); }
.btn:hover { text-decoration: none; border-color: #cbd5e1; }
.btn-primary { background: var(--teal); border-color: var(--teal); color: #fff; }
.btn-primary:hover { background: #0d635c; }
.btn-danger { background: var(--coral); border-color: var(--coral); color: #fff; }
.btn-sm { padding: .3rem .6rem; font-size: .78rem; }
.btn:disabled { opacity: .5; cursor: not-allowed; }

.badge { display: inline-block; padding: .15rem .55rem; border-radius: 999px; font-size: .72rem; font-weight: 500; }
.badge-teal   { background: var(--teal-soft); color: var(--teal); }
.badge-green  { background: var(--green-soft); color: var(--green); }
.badge-amber  { background: var(--amber-soft); color: var(--amber); }
.badge-coral  { background: var(--coral-soft); color: var(--coral); }
.badge-gray   { background: #f1f5f9; color: var(--muted); }

/* ---- flash ---- */
.flash { padding: .7rem 1rem; border-radius: var(--radius); margin-bottom: 1rem; font-size: .88rem; }
.flash-success { background: var(--green-soft); color: var(--green); }
.flash-error   { background: var(--coral-soft); color: var(--coral); }
.flash-warning { background: var(--amber-soft); color: var(--amber); }

/* ---- forms ---- */
label { display: block; font-size: .82rem; color: var(--muted); margin-bottom: .2rem; }
input, select, textarea { width: 100%; padding: .45rem .6rem; border: 1px solid var(--line); border-radius: var(--radius);
                          font-family: var(--font); font-size: .88rem; background: #fff; }
input:focus, select:focus, textarea:focus { outline: none; border-color: var(--teal); }
.field { margin-bottom: .85rem; }
.inline-form { display: inline; }
.error-text { color: var(--coral); font-size: .78rem; margin-top: .2rem; }

/* ---- card & layout ---- */
.card { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow);
        padding: 1.1rem; margin-bottom: 1.1rem; }
.row { display: flex; gap: 1rem; flex-wrap: wrap; }
.col { flex: 1; min-width: 0; }
.muted { color: var(--muted); }
.right { text-align: right; }
.stat-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 1rem; margin-bottom: 1.2rem; }
.stat { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 1rem; }
.stat .n { font-size: 1.6rem; font-weight: 600; }
.stat .l { color: var(--muted); font-size: .8rem; }
.filters { display: flex; gap: .6rem; flex-wrap: wrap; align-items: end; margin-bottom: 1rem; }
.filters .field { margin: 0; min-width: 150px; }

/* ==========================================================================
   ADMIN shell
   ========================================================================== */
.admin-body { display: flex; min-height: 100vh; }
.sidebar { width: 210px; background: #111827; color: #d1d5db; flex-shrink: 0; padding: 1rem 0; }
.sidebar .brand { font-weight: 600; color: #fff; padding: .3rem 1.2rem 1rem; font-size: 1.05rem; }
.sidebar a { display: flex; justify-content: space-between; color: #d1d5db; padding: .55rem 1.2rem; font-size: .88rem; }
.sidebar a:hover, .sidebar a.active { background: #1f2937; color: #fff; text-decoration: none; }
.sidebar a .count { background: var(--coral); color: #fff; border-radius: 999px; padding: 0 .45rem; font-size: .72rem; }
.admin-main { flex: 1; padding: 1.4rem 1.8rem; max-width: 1200px; }
.topbar { display: flex; justify-content: space-between; align-items: center; margin-bottom: 1.2rem; }

/* ==========================================================================
   STOREFRONT
   ========================================================================== */
.shop-body { background: #fff; }
.shop-header { border-bottom: 1px solid var(--line); position: sticky; top: 0; background: #fff; z-index: 10; }
.shop-header .inner { max-width: 1100px; margin: 0 auto; display: flex; align-items: center; gap: 1.2rem; padding: .8rem 1.2rem; }
.shop-header .logo { font-weight: 700; font-size: 1.2rem; color: var(--teal); }
.shop-header form { flex: 1; margin: 0; }
.shop-header .cart-link { white-space: nowrap; font-weight: 500; }
.shop-wrap { max-width: 1100px; margin: 0 auto; padding: 1.4rem 1.2rem; }
.cat-strip { display: flex; gap: .5rem; overflow-x: auto; padding-bottom: .5rem; margin-bottom: 1.2rem; }
.cat-chip { border: 1px solid var(--line); border-radius: 999px; padding: .35rem .9rem; white-space: nowrap; color: var(--ink); font-size: .85rem; }
.cat-chip:hover, .cat-chip.active { background: var(--teal); color: #fff; border-color: var(--teal); text-decoration: none; }

.hero { background: linear-gradient(120deg, var(--teal-soft), #e0f2fe); border-radius: 12px; padding: 2rem; margin-bottom: 1.6rem; }
.hero h1 { font-size: 1.7rem; }

.section-head { display: flex; justify-content: space-between; align-items: baseline; margin: 1.6rem 0 .8rem; }
.product-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(170px, 1fr)); gap: 1rem; }
.p-card { border: 1px solid var(--line); border-radius: var(--radius); overflow: hidden; background: #fff; transition: box-shadow .15s; }
.p-card:hover { box-shadow: var(--shadow); text-decoration: none; }
.p-card .thumb { aspect-ratio: 1; background: #f1f5f9 center/cover no-repeat; display: block; }
.p-card .body { padding: .6rem .7rem .8rem; }
.p-card .name { color: var(--ink); font-size: .9rem; margin-bottom: .25rem; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.p-card .shop { color: var(--muted); font-size: .76rem; }
.p-card .price { font-weight: 600; margin-top: .35rem; }
.p-card .price .was { color: var(--muted); font-weight: 400; text-decoration: line-through; font-size: .8rem; margin-left: .3rem; }
.oos { color: var(--coral); font-size: .78rem; }

/* product detail */
.pd { display: grid; grid-template-columns: 1fr 1fr; gap: 2rem; }
.pd .gallery img { width: 100%; border-radius: var(--radius); border: 1px solid var(--line); }
.pd .thumbs { display: flex; gap: .5rem; margin-top: .6rem; }
.pd .thumbs img { width: 60px; height: 60px; object-fit: cover; border-radius: 6px; border: 1px solid var(--line); cursor: pointer; }
.pd .price-lg { font-size: 1.6rem; font-weight: 700; }
.qty-row { display: flex; align-items: center; gap: .6rem; margin: 1rem 0; }
.qty-row input { width: 70px; }

/* cart & checkout */
.cart-line { display: flex; gap: 1rem; align-items: center; padding: .8rem 0; border-bottom: 1px solid var(--line); }
.cart-line img { width: 64px; height: 64px; object-fit: cover; border-radius: 6px; }
.summary { position: sticky; top: 80px; }
.summary .line { display: flex; justify-content: space-between; padding: .35rem 0; }
.summary .total { font-weight: 700; font-size: 1.1rem; border-top: 1px solid var(--line); padding-top: .6rem; margin-top: .4rem; }

@media (max-width: 720px) {
  .admin-body { flex-direction: column; }
  .sidebar { width: 100%; display: flex; overflow-x: auto; padding: .5rem; }
  .sidebar .brand { display: none; }
  .pd { grid-template-columns: 1fr; }
}
