/* KGNPOS ortak tema: koyu lacivert/siyah zemin + turuncu aksan */
:root {
  --bg: #070b14;
  --bg-2: #0b1220;
  --surface: #111a2e;
  --surface-2: #17223a;
  --border: #22304f;
  --text: #e8edf7;
  --muted: #8d9ab8;
  --accent: #f97316;
  --accent-2: #fb923c;
  --accent-ink: #1a0d02;
  --ok: #22c55e;
  --warn: #eab308;
  --danger: #ef4444;
  --info: #38bdf8;
  --radius: 12px;
  --shadow: 0 10px 30px rgba(0, 0, 0, .45);
  color-scheme: dark;
}

* { box-sizing: border-box; }
html, body { height: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 15px/1.45 "Segoe UI", system-ui, -apple-system, Roboto, Arial, sans-serif;
  -webkit-tap-highlight-color: transparent;
}
button, input, select, textarea { font: inherit; color: inherit; }
a { color: var(--accent-2); }
h1, h2, h3 { margin: 0 0 .6em; line-height: 1.2; }
h2 { font-size: 1.25rem; }
h3 { font-size: 1.05rem; }
.muted { color: var(--muted); }
.small { font-size: .85em; }
.right { text-align: right; }
.nowrap { white-space: nowrap; }
.num { font-variant-numeric: tabular-nums; }
.hidden { display: none !important; }

/* ---------- Düzen ---------- */
.app { display: grid; grid-template-columns: 220px 1fr; grid-template-rows: 56px 1fr; height: 100vh; }
.topbar {
  grid-column: 1 / -1; display: flex; align-items: center; gap: 14px; padding: 0 16px;
  background: var(--bg-2); border-bottom: 1px solid var(--border);
}
.brand { display: flex; align-items: baseline; gap: 10px; font-weight: 700; letter-spacing: .5px; }
.brand b { color: var(--accent); font-size: 1.2rem; }
.brand span { color: var(--muted); font-weight: 400; font-size: .85rem; }
.topbar .spacer { flex: 1; }
.sidebar { background: var(--bg-2); border-right: 1px solid var(--border); padding: 10px; overflow-y: auto; }
.sidebar button {
  display: flex; width: 100%; align-items: center; gap: 10px; padding: 11px 12px; margin-bottom: 4px;
  border: 0; border-radius: 10px; background: transparent; color: var(--muted); cursor: pointer; text-align: left;
}
.sidebar button:hover { background: var(--surface); color: var(--text); }
.sidebar button.active { background: var(--surface-2); color: var(--text); box-shadow: inset 3px 0 0 var(--accent); }
.main { overflow: auto; padding: 18px; }

@media (max-width: 820px) {
  .app { grid-template-columns: 1fr; grid-template-rows: 56px auto 1fr; }
  .sidebar { display: flex; gap: 4px; overflow-x: auto; padding: 6px; border-right: 0; border-bottom: 1px solid var(--border); }
  .sidebar button { width: auto; white-space: nowrap; margin: 0; }
  .brand span { display: none; }
  .main { padding: 12px; }
}

/* ---------- Bileşenler ---------- */
.card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 16px; }
.grid { display: grid; gap: 14px; }
.grid-2 { grid-template-columns: repeat(auto-fit, minmax(320px, 1fr)); }
.stats { display: grid; gap: 12px; grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); }
.stat { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 14px 16px; }
.stat .label { color: var(--muted); font-size: .85rem; }
.stat .value { font-size: 1.6rem; font-weight: 700; margin-top: 4px; font-variant-numeric: tabular-nums; }
.stat.accent .value { color: var(--accent); }
.row { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.row.between { justify-content: space-between; }
.stack > * + * { margin-top: 10px; }

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  padding: 10px 16px; border-radius: 10px; border: 1px solid var(--border);
  background: var(--surface-2); color: var(--text); cursor: pointer; font-weight: 600; min-height: 42px;
}
.btn:hover { border-color: #33466f; }
.btn:disabled { opacity: .5; cursor: not-allowed; }
.btn.primary { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
.btn.primary:hover { background: var(--accent-2); }
.btn.danger { background: transparent; border-color: var(--danger); color: #fca5a5; }
.btn.ghost { background: transparent; }
.btn.big { min-height: 56px; font-size: 1.1rem; padding: 12px 22px; }
.btn.sm { min-height: 32px; padding: 5px 10px; font-size: .85rem; }
.btn.block { width: 100%; }

label.field { display: block; }
label.field > span { display: block; color: var(--muted); font-size: .85rem; margin-bottom: 4px; }
input, select, textarea {
  width: 100%; padding: 10px 12px; border-radius: 10px; border: 1px solid var(--border);
  background: var(--bg-2); outline: none; min-height: 42px;
}
input:focus, select:focus, textarea:focus { border-color: var(--accent); box-shadow: 0 0 0 3px rgba(249, 115, 22, .2); }
input[type=checkbox] { width: auto; min-height: 0; accent-color: var(--accent); }
.form { display: grid; gap: 12px; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); }
.form .full { grid-column: 1 / -1; }

.table-wrap { overflow-x: auto; }
table.data { width: 100%; border-collapse: collapse; }
table.data th, table.data td { padding: 9px 10px; border-bottom: 1px solid var(--border); text-align: left; vertical-align: middle; }
table.data th { color: var(--muted); font-weight: 600; font-size: .85rem; position: sticky; top: 0; background: var(--surface); }
table.data tr.click { cursor: pointer; }
table.data tr.click:hover td { background: var(--surface-2); }

.badge { display: inline-block; padding: 2px 9px; border-radius: 99px; font-size: .78rem; font-weight: 600; background: var(--surface-2); color: var(--muted); }
.badge.ok { background: rgba(34, 197, 94, .15); color: #86efac; }
.badge.warn { background: rgba(234, 179, 8, .15); color: #fde047; }
.badge.danger { background: rgba(239, 68, 68, .15); color: #fca5a5; }
.badge.accent { background: rgba(249, 115, 22, .18); color: var(--accent-2); }
.badge.info { background: rgba(56, 189, 248, .15); color: #7dd3fc; }

.banner { padding: 10px 16px; background: rgba(234, 179, 8, .12); border-bottom: 1px solid rgba(234, 179, 8, .35); color: #fde047; grid-column: 1 / -1; }
.banner.danger { background: rgba(239, 68, 68, .12); border-color: rgba(239, 68, 68, .4); color: #fca5a5; }
.empty { padding: 30px; text-align: center; color: var(--muted); }

/* ---------- Bildirim ve pencere ---------- */
/* Bildirimler tıklamayı engellemez; dar ekranda alt butonları kapatmasın diye üstte durur. */
#toasts { position: fixed; right: 16px; bottom: 16px; display: grid; gap: 8px; z-index: 1000; pointer-events: none; }
@media (max-width: 820px) { #toasts { top: 64px; bottom: auto; left: 12px; right: 12px; justify-items: center; } }
.toast { padding: 12px 16px; border-radius: 10px; background: var(--surface-2); border: 1px solid var(--border); box-shadow: var(--shadow); max-width: 380px; animation: pop .15s ease-out; }
.toast.error { border-color: var(--danger); }
.toast.ok { border-color: var(--ok); }
@keyframes pop { from { transform: translateY(8px); opacity: 0; } }

.modal-back { position: fixed; inset: 0; background: rgba(0, 0, 0, .6); display: flex; align-items: center; justify-content: center; z-index: 900; padding: 16px; }
.modal { background: var(--surface); border: 1px solid var(--border); border-radius: 16px; box-shadow: var(--shadow); width: min(560px, 100%); max-height: 92vh; overflow: auto; }
.modal.wide { width: min(900px, 100%); }
.modal header { display: flex; align-items: center; justify-content: space-between; padding: 14px 18px; border-bottom: 1px solid var(--border); }
.modal header h3 { margin: 0; }
.modal .body { padding: 18px; }
.modal footer { display: flex; justify-content: flex-end; gap: 10px; padding: 14px 18px; border-top: 1px solid var(--border); }

/* ---------- Giriş ekranı ---------- */
.login-wrap { min-height: 100vh; display: grid; place-items: center; padding: 16px;
  background: radial-gradient(1200px 600px at 80% -10%, rgba(249, 115, 22, .12), transparent 60%), var(--bg); }
.login { width: min(400px, 100%); }
.login .logo { text-align: center; margin-bottom: 20px; }
.login .logo b { font-size: 2.2rem; color: var(--accent); letter-spacing: 1px; }
.login .logo div { color: var(--muted); }

/* ---------- Grafik ---------- */
.chart svg { width: 100%; height: 220px; display: block; }
.chart .bar { fill: var(--accent); }
.chart .bar:hover { fill: var(--accent-2); }
.chart text { fill: var(--muted); font-size: 11px; }
.chart .grid-line { stroke: var(--border); stroke-width: 1; }

/* ---------- Satış ekranı ---------- */
.pos { display: grid; grid-template-columns: 1fr 380px; gap: 14px; height: calc(100vh - 56px - 36px); }
.pos .left { display: flex; flex-direction: column; min-height: 0; }
.pos .cats { display: flex; gap: 6px; overflow-x: auto; padding-bottom: 8px; flex-shrink: 0; }
.pos .cats button { white-space: nowrap; }
.pos .cats button.active { background: var(--accent); color: var(--accent-ink); border-color: var(--accent); }
.products { display: grid; grid-template-columns: repeat(auto-fill, minmax(140px, 1fr)); gap: 10px; overflow-y: auto; align-content: start; padding: 2px; }
.product {
  background: var(--surface); border: 1px solid var(--border); border-radius: 12px; padding: 12px; cursor: pointer;
  min-height: 86px; display: flex; flex-direction: column; justify-content: space-between; text-align: left;
}
.product:hover { border-color: var(--accent); }
.product:active { transform: scale(.98); }
.product .name { font-weight: 600; }
.product .price { color: var(--accent-2); font-weight: 700; font-variant-numeric: tabular-nums; }
.product .stock { font-size: .75rem; color: var(--muted); }
.product.out { opacity: .55; }
.cart { display: flex; flex-direction: column; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); min-height: 0; }
.cart header { padding: 12px 14px; border-bottom: 1px solid var(--border); }
.cart .lines { flex: 1; overflow-y: auto; }
.cart .line { display: grid; grid-template-columns: 1fr auto; gap: 4px 8px; padding: 10px 14px; border-bottom: 1px solid var(--border); }
.cart .line.cancelled { opacity: .45; text-decoration: line-through; }
.cart .line .qty { display: flex; align-items: center; gap: 6px; }
.cart .line .qty button { width: 32px; height: 32px; border-radius: 8px; border: 1px solid var(--border); background: var(--surface-2); cursor: pointer; }
.cart .totals { padding: 12px 14px; border-top: 1px solid var(--border); }
.cart .totals .grand { font-size: 1.7rem; font-weight: 800; color: var(--accent); font-variant-numeric: tabular-nums; }
.cart .actions { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; padding: 0 14px 14px; }
@media (max-width: 1000px) { .pos { grid-template-columns: 1fr; height: auto; } .products { max-height: 50vh; } }

/* ---------- Masalar ---------- */
.area-title { margin: 18px 0 8px; color: var(--muted); font-weight: 600; }
.tables { display: grid; grid-template-columns: repeat(auto-fill, minmax(130px, 1fr)); gap: 10px; }
.tbl {
  border-radius: 14px; padding: 14px; min-height: 100px; cursor: pointer; border: 2px solid var(--border);
  background: var(--surface); display: flex; flex-direction: column; justify-content: space-between; text-align: left;
}
.tbl .t-name { font-weight: 700; font-size: 1.1rem; }
.tbl .t-info { font-size: .82rem; color: var(--muted); }
.tbl .t-total { font-weight: 700; font-variant-numeric: tabular-nums; }
.tbl.occupied { border-color: var(--accent); background: linear-gradient(180deg, rgba(249, 115, 22, .16), var(--surface)); }
.tbl.occupied .t-total { color: var(--accent-2); }
.tbl.reserved { border-color: var(--info); background: linear-gradient(180deg, rgba(56, 189, 248, .12), var(--surface)); }
.tbl.free .t-total { color: var(--ok); }
.legend { display: flex; gap: 14px; flex-wrap: wrap; color: var(--muted); font-size: .85rem; }
.legend i { display: inline-block; width: 10px; height: 10px; border-radius: 3px; margin-right: 5px; vertical-align: -1px; }

/* ---------- Fiş (yazdırma) ---------- */
#receipt { display: none; }
/* Rapor yazdırma / PDF: açık zemin, menüler gizli */
@media print {
  body.print-page { --bg: #fff; --bg-2: #fff; --surface: #fff; --surface-2: #f3f4f6; --border: #d1d5db; --text: #111; --muted: #4b5563; background: #fff; color: #111; }
  body.print-page .sidebar, body.print-page .topbar, body.print-page .banner, body.print-page button, body.print-page #toasts, body.print-page .no-print { display: none !important; }
  body.print-page .app { display: block; height: auto; }
  body.print-page .main { overflow: visible; padding: 0; }
  body.print-page .card, body.print-page .stat { break-inside: avoid; }
  body.print-page #receipt { display: none; }
}

@media print {
  /* Sayfa boyutu yazdırma anında kgn.js tarafından verilir: fiş 80 mm, rapor A4. */
  body:not(.print-page) * { visibility: hidden !important; }
  body:not(.print-page) #receipt, body:not(.print-page) #receipt * { visibility: visible !important; }
  #receipt { display: block; position: absolute; left: 0; top: 0; width: 74mm; color: #000; background: #fff; font: 12px/1.35 "Courier New", monospace; }
  #receipt .c { text-align: center; }
  #receipt .r { text-align: right; }
  #receipt hr { border: 0; border-top: 1px dashed #000; }
  #receipt table { width: 100%; border-collapse: collapse; }
  #receipt .big { font-size: 15px; font-weight: bold; }
}
