@import url('https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600;700;800&display=swap');

:root {
  --bg: #f5f4f1;
  --card: #ffffff;
  --ink: #15181f;
  --muted: #767b87;
  --line: #e8e6e1;
  --line-soft: #f0efeb;

  --brand: #b3272d;       /* Pepes red */
  --brand-dark: #8f1e23;
  --brand-soft: #fbe9e8;
  --mint: #dcf3e4;
  --mint-ink: #1f6c45;

  --sidebar-bg: #12162a;
  --sidebar-bg-alt: #171c34;
  --sidebar-ink: #a7acc2;
  --sidebar-ink-active: #ffffff;
  --sidebar-active-bg: #232a49;
  --sidebar-line: #262c48;

  --ok: #1f9d55;
  --ok-soft: #dff3e6;
  --warn: #b06a00;
  --warn-soft: #fbedd0;
  --err: #c53030;
  --err-soft: #fbe4e4;
  --off-soft: #eeedea;

  --radius: 14px;
  --radius-sm: 9px;
  --shadow-card: 0 1px 2px rgba(20, 20, 15, 0.04), 0 8px 24px -12px rgba(20, 20, 15, 0.10);
}

* { box-sizing: border-box; }

body {
  margin: 0;
  font-family: "Inter", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  background: var(--bg);
  color: var(--ink);
  -webkit-font-smoothing: antialiased;
}

a { color: inherit; text-decoration: none; }
h1, h2, h3 { margin: 0; letter-spacing: -0.01em; }

/* ═══════════════════ shared form elements ═══════════════════ */
label { display: block; font-size: 0.82rem; color: var(--muted); font-weight: 500; margin: 0 0 6px; }
input[type=text], input[type=password], input[type=email], input[type=number], textarea, select {
  width: 100%;
  padding: 10px 13px;
  border: 1.5px solid var(--line);
  border-radius: var(--radius-sm);
  font-size: 0.92rem;
  font-family: inherit;
  background: #fff;
  color: var(--ink);
  transition: border-color 0.15s ease;
}
input:focus, textarea:focus, select:focus {
  outline: none;
  border-color: var(--brand);
}
textarea { resize: vertical; min-height: 64px; }

button, .btn {
  cursor: pointer;
  border: none;
  border-radius: var(--radius-sm);
  padding: 10px 18px;
  font-size: 0.88rem;
  font-weight: 600;
  font-family: inherit;
  transition: background 0.15s ease, border-color 0.15s ease, transform 0.05s ease;
  white-space: nowrap;
}
button:active { transform: translateY(1px); }
.btn-primary { background: var(--brand); color: #fff; }
.btn-primary:hover { background: var(--brand-dark); }
.btn-secondary { background: #fff; border: 1.5px solid var(--line); color: var(--ink); }
.btn-secondary:hover { border-color: #c7c4bc; }
.btn-danger { background: #fff; border: 1.5px solid var(--err-soft); color: var(--err); }
.btn-danger:hover { background: var(--err-soft); }
.btn-dark { background: var(--sidebar-bg); color: #fff; }
.btn-dark:hover { background: var(--sidebar-bg-alt); }
.btn-block { width: 100%; }

.error { color: var(--err); font-size: 0.85rem; margin-top: 10px; min-height: 1em; }
.ok-msg { color: var(--ok); font-size: 0.85rem; margin-top: 10px; }
.muted { color: var(--muted); font-size: 0.85rem; }

.pill { display: inline-flex; align-items: center; padding: 3px 10px; border-radius: 999px; font-size: 0.72rem; font-weight: 600; letter-spacing: 0.01em; }
.pill.ok { background: var(--ok-soft); color: var(--mint-ink); }
.pill.warn { background: var(--warn-soft); color: var(--warn); }
.pill.off { background: var(--off-soft); color: var(--muted); }

/* ═══════════════════ login ═══════════════════ */
.login-wrap {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  background: radial-gradient(circle at 20% 20%, #fff 0%, var(--bg) 55%);
  padding: 20px;
}
.login-card {
  background: var(--card);
  padding: 40px 36px;
  border-radius: 20px;
  box-shadow: var(--shadow-card);
  width: 100%;
  max-width: 380px;
  border: 1px solid var(--line-soft);
  text-align: center;
}
.login-logo {
  height: 56px;
  width: auto;
  margin: 0 auto 20px;
  display: block;
}
.login-card h1 { font-size: 1.3rem; font-weight: 800; margin-bottom: 4px; line-height: 1.25; }
.login-card p.sub { margin: 0 0 26px; color: var(--muted); font-size: 0.9rem; }
.login-card label, .login-card .error { text-align: left; }
.login-card .btn-primary { margin-top: 20px; padding: 11px 18px; }

/* ═══════════════════ app shell (admin) ═══════════════════ */
.app-shell { display: flex; min-height: 100vh; }

.sidebar {
  width: 232px;
  flex-shrink: 0;
  background: var(--sidebar-bg);
  color: var(--sidebar-ink);
  display: flex;
  flex-direction: column;
  position: fixed;
  top: 0; bottom: 0; left: 0;
  padding: 22px 14px;
}
.sidebar .brand {
  display: flex; align-items: center; gap: 10px;
  padding: 0 8px 20px;
  margin-bottom: 12px;
  border-bottom: 1px solid var(--sidebar-line);
}
.sidebar .brand .mark {
  width: 32px; height: 32px; border-radius: 9px;
  background: var(--brand);
  color: #fff; font-weight: 800; font-size: 0.9rem;
  display: flex; align-items: center; justify-content: center;
}
.brand-logo-chip {
  background: #fff;
  border-radius: 8px;
  padding: 4px 7px;
  display: flex; align-items: center; justify-content: center;
  flex-shrink: 0;
}
.brand-logo-chip img { height: 22px; width: auto; display: block; }
.sidebar .brand .name { color: #fff; font-weight: 700; font-size: 0.98rem; letter-spacing: -0.01em; }
.sidebar .brand .sub { font-size: 0.68rem; color: var(--sidebar-ink); text-transform: uppercase; letter-spacing: 0.06em; }

.sidebar nav { display: flex; flex-direction: column; gap: 2px; flex: 1; }
.sidebar nav a, .sidebar nav button {
  all: unset;
  display: flex; align-items: center; gap: 10px;
  padding: 10px 12px;
  border-radius: 9px;
  font-size: 0.87rem; font-weight: 500;
  color: var(--sidebar-ink);
  cursor: pointer;
}
.sidebar nav a svg, .sidebar nav button svg { width: 17px; height: 17px; flex-shrink: 0; opacity: 0.85; }
.sidebar nav a:hover, .sidebar nav button:hover { background: var(--sidebar-bg-alt); color: #fff; }
.sidebar nav a.active, .sidebar nav button.active { background: var(--sidebar-active-bg); color: #fff; }
.sidebar nav a.active svg, .sidebar nav button.active svg { opacity: 1; }

.sidebar .foot { border-top: 1px solid var(--sidebar-line); padding-top: 12px; display: flex; flex-direction: column; gap: 2px; }
.sidebar .foot a, .sidebar .foot button.linklike {
  all: unset; cursor: pointer;
  display: flex; align-items: center; gap: 10px;
  padding: 9px 12px; border-radius: 9px;
  font-size: 0.83rem; color: var(--sidebar-ink);
}
.sidebar .foot a:hover, .sidebar .foot button.linklike:hover { background: var(--sidebar-bg-alt); color: #fff; }
.sidebar .foot svg { width: 16px; height: 16px; opacity: 0.8; }

.main { flex: 1; margin-left: 232px; min-width: 0; }

.topbar {
  display: flex; align-items: center; justify-content: space-between;
  padding: 18px 32px;
  background: #fff;
  border-bottom: 1px solid var(--line);
  position: sticky; top: 0; z-index: 10;
}
.topbar .eyebrow { font-size: 0.72rem; color: var(--muted); text-transform: uppercase; letter-spacing: 0.06em; margin-bottom: 2px; }
.topbar h1 { font-size: 1.3rem; font-weight: 800; }
.topbar-right { display: flex; align-items: center; gap: 14px; }
.topbar .user-chip { display: flex; align-items: center; gap: 10px; }
.topbar .avatar {
  width: 36px; height: 36px; border-radius: 50%;
  background: var(--brand-soft); color: var(--brand-dark);
  display: flex; align-items: center; justify-content: center;
  font-weight: 700; font-size: 0.85rem;
}
.topbar .user-chip .who { line-height: 1.25; }
.topbar .user-chip .who .name { font-weight: 600; font-size: 0.85rem; }
.topbar .user-chip .who .role { font-size: 0.72rem; color: var(--muted); }

.content { padding: 28px 32px 60px; max-width: 1680px; }

/* ── customer topbar (storefront, not sidebar) ── */
header.topbar-store {
  display: flex; align-items: center; justify-content: space-between;
  background: var(--sidebar-bg); color: #fff;
  padding: 16px 24px;
  position: sticky; top: 0; z-index: 10;
}
header.topbar-store .brand { display: flex; align-items: center; gap: 10px; font-weight: 700; font-size: 1.02rem; }
header.topbar-store .brand .mark { width: 30px; height: 30px; border-radius: 8px; background: var(--brand); display: flex; align-items: center; justify-content: center; font-weight: 800; font-size: 0.85rem; }
header.topbar-store .right { display: flex; align-items: center; gap: 14px; font-size: 0.88rem; color: var(--sidebar-ink); }
header.topbar-store .right button {
  background: rgba(255,255,255,0.08);
  border: 1px solid rgba(255,255,255,0.16);
  color: #fff;
}
header.topbar-store .right button:hover { background: rgba(255,255,255,0.16); }

main.store { max-width: 1180px; margin: 0 auto; padding: 24px; }

/* ═══════════════════ dashboard welcome banner + stat tiles ═══════════════════ */
.banner {
  background: linear-gradient(135deg, var(--mint) 0%, #eef8f0 100%);
  border-radius: 18px;
  padding: 30px 32px;
  display: flex; align-items: center; justify-content: space-between;
  gap: 24px;
  margin-bottom: 22px;
  border: 1px solid #cdeada;
}
.banner .eyebrow { color: var(--brand); font-weight: 700; font-size: 0.72rem; text-transform: uppercase; letter-spacing: 0.07em; margin-bottom: 8px; }
.banner h2 { font-size: 1.7rem; font-weight: 800; margin-bottom: 8px; }
.banner p { margin: 0; color: #3c4a41; font-size: 0.92rem; max-width: 46ch; }

.stat-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); gap: 14px; margin-bottom: 22px; }
.stat-tile {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 18px 20px;
}
.stat-tile .label { font-size: 0.78rem; color: var(--muted); margin-bottom: 10px; }
.stat-tile .value { font-size: 2rem; font-weight: 800; letter-spacing: -0.02em; }
.stat-tile .hint { font-size: 0.76rem; color: var(--muted); margin-top: 6px; }

.section-head { display: flex; align-items: center; justify-content: space-between; margin: 30px 0 14px; }
.section-head .eyebrow { color: var(--brand); font-weight: 700; font-size: 0.72rem; text-transform: uppercase; letter-spacing: 0.06em; margin-bottom: 4px; }
.section-head h3 { font-size: 1.2rem; font-weight: 800; }
.section-head a.view-all { color: var(--brand); font-size: 0.85rem; font-weight: 600; }

/* ═══════════════════ cards, tables ═══════════════════ */
.card {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 20px 22px;
  margin-bottom: 18px;
}
.card:has(table) { overflow-x: auto; }
.card h3.card-title { font-size: 0.95rem; font-weight: 700; margin-bottom: 14px; }

table { width: 100%; min-width: 640px; border-collapse: collapse; font-size: 0.87rem; }
th, td { text-align: left; padding: 11px 12px; border-bottom: 1px solid var(--line-soft); word-break: break-word; }
td.nowrap, th.nowrap { white-space: nowrap; }
/* Tables with a <colgroup> giving each column a fixed % width — stops a
   nowrap column's natural content width from starving its neighbours (the
   default auto layout algorithm hands leftover space to whichever columns
   already want the most, which can squeeze a wrapping text column down to
   a single character's width). Nowrap cells get an ellipsis instead of
   visually spilling into the next column when content doesn't fit. */
table.fixed-cols { table-layout: fixed; min-width: 900px; }
table.fixed-cols td.nowrap, table.fixed-cols th.nowrap,
table.fixed-cols td.nowrap { overflow: hidden; text-overflow: ellipsis; }
th { color: var(--muted); font-weight: 600; font-size: 0.72rem; text-transform: uppercase; letter-spacing: 0.04em; }
tbody tr:hover { background: #fbfaf8; }
tbody tr:last-child td { border-bottom: none; }

.row-list { display: flex; flex-direction: column; }
.row-item {
  display: flex; align-items: center; gap: 14px;
  padding: 12px 0;
  border-bottom: 1px solid var(--line-soft);
}
.row-item:last-child { border-bottom: none; }
.row-item .thumb { width: 40px; height: 40px; border-radius: 9px; background: var(--off-soft); object-fit: cover; flex-shrink: 0; }
.row-item .info { flex: 1; min-width: 0; }
.row-item .info .t { font-size: 0.88rem; font-weight: 600; }
.row-item .info .s { font-size: 0.78rem; color: var(--muted); }
.row-item .arrow { color: var(--brand); font-size: 1rem; }

.inline-form { display: flex; gap: 10px; flex-wrap: wrap; align-items: flex-end; }
.inline-form > div { display: flex; flex-direction: column; min-width: 140px; }
.row-actions button, .row-actions a.btn { margin-right: 6px; padding: 6px 12px; font-size: 0.8rem; display: inline-block; }

/* ═══════════════════ admin tabs (legacy support, hidden once sidebar nav used) ═══════════════════ */
.tabs { display: none; }
.panel { display: none; }
.panel.active { display: block; }

/* ═══════════════════ storefront catalogue ═══════════════════ */
.store-layout { display: flex; align-items: flex-start; gap: 24px; }
.store-main { flex: 1; min-width: 0; }
.searchbar { margin-bottom: 18px; max-width: 420px; }
.grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(230px, 1fr)); gap: 16px; }
.item-card {
  background: var(--card);
  border-radius: var(--radius);
  overflow: hidden;
  border: 1px solid var(--line);
  display: flex; flex-direction: column;
  transition: box-shadow 0.15s ease, transform 0.15s ease;
}
.item-card:hover { box-shadow: var(--shadow-card); transform: translateY(-1px); }
.item-card img { width: 100%; height: 136px; object-fit: cover; background: var(--off-soft); }
.item-card .body { padding: 14px; flex: 1; display: flex; flex-direction: column; gap: 6px; }
.item-card .no { font-size: 0.7rem; color: var(--muted); letter-spacing: 0.03em; font-weight: 600; }
.item-card .desc { font-size: 0.9rem; font-weight: 600; line-height: 1.3; flex: 1; }
.item-card .price { font-size: 1.08rem; color: var(--brand); font-weight: 800; }
.item-card .uom { font-size: 0.76rem; color: var(--muted); }
.item-card .addrow { display: flex; gap: 6px; margin-top: 6px; }
.item-card .addrow input { width: 60px; text-align: center; padding: 8px; }
.item-card .addrow button { flex: 1; }

/* Always-open cart panel — sticky down the right side on desktop, stacks
   as a normal block below the product grid on narrow screens (no
   open/close toggle at all; simpler than a drawer and matches how the
   admin asked for it: "hep açık kalsin"). */
.cart-panel-fixed {
  width: 340px;
  flex-shrink: 0;
  position: sticky;
  top: 84px;
  max-height: calc(100vh - 104px);
  overflow-y: auto;
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 20px;
}
.cart-panel-fixed h2 { margin: 0 0 12px; font-size: 1.1rem; font-weight: 800; }
.cart-line { display: flex; align-items: center; gap: 10px; padding: 9px 0; border-bottom: 1px solid var(--line-soft); }
.cart-line .desc { flex: 1; font-size: 0.87rem; }
.cart-line .desc .no { display: block; font-size: 0.7rem; color: var(--muted); font-weight: 600; }
.cart-line input { width: 54px; text-align: center; padding: 7px; }
.cart-line .lt { width: 70px; text-align: right; font-weight: 700; font-size: 0.87rem; }
.cart-total { display: flex; justify-content: space-between; padding: 16px 0 6px; font-size: 1.08rem; font-weight: 800; }

@media (max-width: 860px) {
  .store-layout { flex-direction: column; }
  .cart-panel-fixed { width: 100%; position: static; max-height: none; }
  .sidebar { display: none; }
  .main { margin-left: 0; }
  .content { padding: 20px; }
  .banner { flex-direction: column; align-items: flex-start; }
}
