/* ==========================================================================
   Shop Shahar — 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;
  --line-strong: #b6bec9;
  --bg: #f7f7f8;
  --card: #ffffff;
  /* Brand greens, pulled from the logo mark (#9cc563). The light logo green
     cannot carry white text, so it stays an accent and the darker leaf green
     (4.9:1 on white) does the interactive work. */
  --brand: #4f7d28;
  --brand-dark: #3f6520;
  --brand-soft: #e8f3d9;
  --accent: #9cc563;
  /* Shared chrome tint: header, sub-nav and footer all sit on this. */
  --chrome: #f4f9ec;
  --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);
  --shadow-md: 0 4px 12px rgba(0,0,0,.08), 0 2px 4px rgba(0,0,0,.04);
  --ring: 0 0 0 3px rgba(79,125,40,.18);
  --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(--brand); 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);
       transition: background .15s, border-color .15s, box-shadow .15s; }
.btn:hover { text-decoration: none; border-color: #cbd5e1; }
.btn:focus-visible { outline: none; box-shadow: var(--ring); }
.btn-primary { background: var(--brand); border-color: var(--brand); color: #fff; }
.btn-primary:hover { background: var(--brand-dark); border-color: var(--brand-dark); color: #fff; }
.btn-lg { padding: .6rem 1.3rem; font-size: .92rem; }
.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-brand  { background: var(--brand-soft); color: var(--brand); }
.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; font-weight: 500; color: var(--muted); margin-bottom: .25rem; }
input, select, textarea { width: 100%; padding: .5rem .65rem; border: 1.5px solid var(--line-strong); border-radius: var(--radius);
                          font-family: var(--font); font-size: .9rem; color: var(--ink); background: #fff;
                          transition: border-color .15s, box-shadow .15s; }
input::placeholder, textarea::placeholder { color: #9ca3af; }
input:hover, select:hover, textarea:hover { border-color: #94a3b8; }
input:focus, select:focus, textarea:focus { outline: none; border-color: var(--brand); box-shadow: var(--ring); }
input[type="file"] { padding: .45rem .6rem; background: #fbfdfd; border-style: dashed; cursor: pointer; }
.field { margin-bottom: .95rem; }
.hint { color: var(--muted); font-size: .78rem; margin: .3rem 0 0; }
.steps { color: var(--ink); padding-left: 1.15rem; margin: 0 0 .9rem; }
.steps li { margin-bottom: .35rem; }
.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; }
.card h2 { margin-bottom: .8rem; }
.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 { background: #1f2937; color: #fff; text-decoration: none; }
/* The pale logo green is the one that reads against the dark sidebar. */
.sidebar a.active { background: #1f2937; color: #fff; box-shadow: inset 3px 0 0 var(--accent); 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; }

/* ---- admin: KYC document viewer ---- */
.doc-tabs { display: flex; flex-wrap: wrap; gap: .5rem; margin: .8rem 0; }
.doc-tab { display: block; border: 1px solid var(--line); border-radius: var(--radius);
           padding: .45rem .7rem; font-size: .82rem; line-height: 1.3; color: var(--ink); background: #fff; }
.doc-tab:hover { border-color: var(--line-strong); text-decoration: none; }
.doc-tab.active { border-color: var(--brand); box-shadow: var(--ring); }
.doc-tab strong { display: block; }
.doc-tab .muted { font-size: .74rem; }
.doc-viewer { border: 1px solid var(--line); border-radius: var(--radius); padding: .8rem; background: var(--bg); }
.doc-viewer-head { display: flex; flex-wrap: wrap; gap: .5rem; justify-content: space-between;
                   align-items: center; margin-bottom: .7rem; font-size: .85rem; }
.doc-actions { display: flex; gap: .35rem; }
/* Tall enough to read a citizenship card or a page of a PDF without scrolling
   the panel itself. */
.doc-frame { width: 100%; height: 70vh; min-height: 420px; border: 1px solid var(--line);
             border-radius: 6px; background: #fff; }
.doc-shot { max-height: 70vh; overflow: auto; background: #fff; border: 1px solid var(--line);
            border-radius: 6px; text-align: center; cursor: zoom-in; }
.doc-shot img { max-width: 100%; height: auto; display: inline-block; }
.doc-shot.zoomed { cursor: zoom-out; }
.doc-shot.zoomed img { max-width: none; }

/* ---- admin: product image editor ---- */
.thumb-strip { display: flex; flex-wrap: wrap; gap: .7rem; margin: .9rem 0 0; }
.thumb-item { display: block; width: 130px; border: 1px solid var(--line); border-radius: var(--radius);
              padding: .35rem; background: #fff; color: var(--ink); }
.thumb-item:hover { border-color: var(--line-strong); text-decoration: none; }
.thumb-item.active { border-color: var(--brand); box-shadow: var(--ring); }
.thumb-item.hidden-image .thumb-shot { opacity: .4; }
.thumb-shot { display: block; aspect-ratio: 1; background: #f1f5f9; border-radius: 6px; overflow: hidden; }
.thumb-shot img { width: 100%; height: 100%; object-fit: cover; display: block; }
.thumb-label { display: block; font-size: .72rem; line-height: 1.35; margin-top: .35rem; }
.thumb-label .muted { display: block; }

.img-edit { border: 1px solid var(--line); border-radius: var(--radius); padding: .8rem; margin-top: 1rem; }
.img-edit-head { display: flex; flex-wrap: wrap; gap: .5rem; justify-content: space-between;
                 align-items: center; margin-bottom: .7rem; font-size: .85rem; }
.img-actions { display: flex; flex-wrap: wrap; gap: .35rem; }
.img-stage { position: relative; display: inline-block; max-width: 100%; line-height: 0;
             /* Checkerboard: shows through wherever the background was cleared. */
             background-image: linear-gradient(45deg, #e5e7eb 25%, transparent 25%),
                               linear-gradient(-45deg, #e5e7eb 25%, transparent 25%),
                               linear-gradient(45deg, transparent 75%, #e5e7eb 75%),
                               linear-gradient(-45deg, transparent 75%, #e5e7eb 75%);
             background-size: 16px 16px;
             background-position: 0 0, 0 8px, 8px -8px, -8px 0; }
.img-stage img { max-width: 100%; height: auto; display: block; }
.img-stage.cropping { cursor: crosshair; touch-action: none; }
.img-stage.cropping img { user-select: none; }
.crop-box { position: absolute; border: 2px dashed #fff; outline: 1px solid var(--brand);
            background: rgba(79,125,40,.18); pointer-events: none; }
.crop-form { display: flex; flex-wrap: wrap; gap: .6rem; align-items: center; margin-top: .7rem;
             font-size: .85rem; }
.crop-square { display: flex; align-items: center; gap: .3rem; margin: 0; font-weight: 400;
               color: var(--ink); text-transform: none; }
.crop-square input { width: auto; margin: 0; box-shadow: none; }

/* ==========================================================================
   STOREFRONT
   ========================================================================== */
.shop-body { background: #fff; }

/* --- two-tier navigation: same structure, storefront skin --- */
.nav { position: sticky; top: 0; z-index: 20; background: var(--chrome); border-bottom: 1px solid var(--line); }
.nav a { color: var(--ink); text-decoration: none; }
.nav a:hover { text-decoration: none; }
.nav-main .inner { max-width: 1100px; margin: 0 auto; display: flex; align-items: center; gap: 1rem; padding: .75rem 1.2rem; }
.nav-sub { border-top: 1px solid var(--line); }
.nav-sub .inner { max-width: 1100px; margin: 0 auto; display: flex; align-items: center; gap: .2rem;
                  padding: .3rem 1.2rem; overflow-x: auto; }

.nav-item { display: block; padding: .3rem .5rem; border-radius: 6px; white-space: nowrap; }
.nav-item:hover { background: var(--brand-soft); }

.nav-logo { display: flex; align-items: center; gap: .5rem; font-size: 1.2rem; font-weight: 700; color: var(--brand); }
.nav-logo img { width: 38px; height: 38px; display: block; flex-shrink: 0; }
.nav-logo em { font-style: normal; color: var(--brand); }
.nav-logo:hover { background: none; color: var(--brand-dark); }

.nav-search { flex: 1; display: flex; min-width: 120px; margin: 0; }
.nav-search input { height: 38px; border-radius: var(--radius) 0 0 var(--radius); border-right-width: 0; }
.nav-search button { flex: 0 0 44px; height: 38px; border: 1.5px solid var(--brand); border-radius: 0 var(--radius) var(--radius) 0;
                     background: var(--brand); color: #fff; cursor: pointer; display: grid; place-items: center; }
.nav-search button:hover { background: var(--brand-dark); border-color: var(--brand-dark); }

.nav-line1 { display: block; font-size: .72rem; line-height: 1.2; color: var(--muted); }
.nav-line2 { display: block; font-size: .85rem; font-weight: 600; line-height: 1.25; }
.nav-cart { display: flex; align-items: center; gap: .35rem; font-weight: 500; font-size: .85rem; }
.nav-cart .count { color: var(--brand); font-weight: 700; }
.nav-signout { background: none; border: none; padding: 0; color: var(--muted); font-size: .76rem; cursor: pointer;
               font-family: var(--font); text-decoration: underline; }
.nav-signout:hover { color: var(--ink); }
.nav-sub .nav-item { font-size: .85rem; color: var(--ink); }
.nav-sub .nav-item:hover { background: var(--brand-soft); }
.nav-sub .sell { margin-left: auto; color: var(--brand); font-weight: 600; }

/* --- page body --- */
.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(--brand); color: #fff; border-color: var(--brand); text-decoration: none; }

.hero { background: linear-gradient(120deg, var(--brand-soft), var(--chrome)); border-radius: 12px; padding: 2rem; margin-bottom: 1.6rem; }
.hero h1 { font-size: 1.7rem; }
.hero .muted { max-width: 46rem; }

.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;
          display: flex; flex-direction: column; transition: box-shadow .15s, border-color .15s; }
.p-card:hover { box-shadow: var(--shadow-md); border-color: #cbd5e1; }
/* The card is no longer one big anchor: the shop name is its own link, so the
   product link wraps everything else. */
.p-link { display: block; color: inherit; }
.p-link:hover { text-decoration: none; }
.p-card .thumb { aspect-ratio: 1; background: #f1f5f9 center/cover no-repeat; display: block; }
.p-card .body { padding: .6rem .7rem .4rem; }
.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-link:hover .name { color: var(--brand); }
.p-card .shop { display: block; padding: 0 .7rem .7rem; margin-top: auto; color: var(--muted); font-size: .76rem; }
.p-card .shop:hover { color: var(--brand); }
.p-card .price { display: block; font-weight: 600; margin-top: .35rem; }
.p-card .price.deal { color: var(--coral); }
.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; }

/* --- vendor shop page --- */
.shop-cover { height: 200px; border-radius: var(--radius); background: #e5e7eb center/cover no-repeat; }
.shop-cover.no-photo { background: linear-gradient(120deg, var(--brand) 0%, var(--accent) 100%); }
.shop-head { display: flex; align-items: center; gap: 1rem; margin: -2.6rem 0 1rem 1.4rem; position: relative; }
.shop-avatar { width: 88px; height: 88px; border-radius: 12px; object-fit: cover; background: #fff;
               border: 3px solid #fff; box-shadow: var(--shadow-md); flex-shrink: 0; }
.shop-avatar.initials { display: grid; place-items: center; font-size: 2.2rem; font-weight: 700;
                        color: var(--brand); background: var(--brand-soft); }
.shop-id { padding-bottom: .2rem; }
.shop-id h1 { margin-bottom: .15rem; }
.shop-id .muted { margin: 0; font-size: .85rem; }
.shop-about { max-width: 60rem; margin: 0 0 1.2rem; }

/* 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 .thumbs img:hover { border-color: var(--brand); }
.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: 110px; }
.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; }

/* --- footer --- */
.site-footer { border-top: 1px solid var(--line); background: var(--chrome); margin-top: 2.5rem; }
.site-footer .inner { max-width: 1100px; margin: 0 auto; padding: 2rem 1.2rem 1.4rem;
                      display: grid; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); gap: 1.5rem; }
.foot-col h3 { font-size: .82rem; text-transform: uppercase; letter-spacing: .04em; color: var(--muted); margin-bottom: .6rem; }
.foot-col a { display: block; color: var(--ink); font-size: .86rem; padding: .18rem 0; }
.foot-col a:hover { color: var(--brand); }
.foot-col p { margin: 0; font-size: .86rem; }
.socials { display: flex; flex-wrap: wrap; gap: .4rem; }
.socials a { border: 1px solid var(--line); border-radius: 999px; padding: .25rem .75rem; font-size: .8rem; background: #fff; }
.socials a:hover { border-color: var(--brand); color: var(--brand); text-decoration: none; }
.foot-credits { border-top: 1px solid var(--line); font-size: .8rem; color: var(--muted);
                display: flex; flex-direction: column; align-items: center; gap: .25rem; text-align: center;
                max-width: 1100px; margin: 0 auto; padding: 1rem 1.2rem; }

/* --- chat widget --- */
.chat { position: fixed; right: 1.1rem; bottom: 1.1rem; z-index: 40; display: flex; flex-direction: column;
        align-items: flex-end; gap: .6rem; }
.chat-toggle { display: flex; align-items: center; gap: .45rem; border: none; cursor: pointer;
               background: var(--brand); color: #fff; font-family: var(--font); font-size: .88rem; font-weight: 500;
               padding: .65rem 1.1rem; border-radius: 999px; box-shadow: var(--shadow-md); order: 2; }
.chat-toggle:hover { background: var(--brand-dark); }
.chat-panel { display: none; order: 1; width: min(340px, calc(100vw - 2.2rem)); background: #fff;
              border: 1px solid var(--line); border-radius: 12px; box-shadow: var(--shadow-md); overflow: hidden; }
.chat.open .chat-panel { display: block; }
.chat-head { display: flex; justify-content: space-between; align-items: flex-start; gap: .5rem;
             padding: .8rem 1rem; border-bottom: 1px solid var(--line); background: var(--brand-soft); }
.chat-head strong { display: block; font-size: .92rem; }
.chat-head .muted { font-size: .76rem; }
.chat-close { background: none; border: none; font-size: 1.3rem; line-height: 1; cursor: pointer; color: var(--muted); padding: 0; }
.chat-close:hover { color: var(--ink); }
.chat-thread { max-height: 260px; overflow-y: auto; padding: .9rem 1rem; display: flex; flex-direction: column; gap: .5rem; }
.chat-empty { font-size: .84rem; margin: 0; }
.chat-msg { font-size: .85rem; padding: .5rem .7rem; border-radius: 10px; max-width: 85%; white-space: pre-line; }
.chat-msg.mine { align-self: flex-end; background: var(--brand-soft); border-bottom-right-radius: 3px; }
.chat-msg.them { align-self: flex-start; background: #f1f5f9; border-bottom-left-radius: 3px; }
.chat-time { display: block; font-size: .68rem; color: var(--muted); margin-top: .25rem; }
.chat-form { padding: .9rem 1rem 1rem; border-top: 1px solid var(--line); }
.chat-form .field { margin-bottom: .6rem; }
.chat-form textarea { resize: vertical; }

@media (max-width: 900px) {
  .nav-main .inner { flex-wrap: wrap; }
  .nav-search { order: 3; flex-basis: 100%; margin-top: .5rem; }
}
@media (max-width: 720px) {
  .chat { right: .7rem; bottom: .7rem; }
  .shop-cover { height: 130px; }
  .shop-head { margin-left: .8rem; gap: .8rem; }
  .shop-avatar { width: 64px; height: 64px; }
  .admin-body { flex-direction: column; }
  .sidebar { width: 100%; display: flex; overflow-x: auto; padding: .5rem; }
  .sidebar .brand { display: none; }
  .pd { grid-template-columns: 1fr; }
}
