/* ================== NextGen POS — mobil öncelikli tema ================== */
:root {
    --bg: #f1f5f9; --card: #ffffff; --txt: #0f172a; --mut: #64748b;
    --line: #e2e8f0; --acc: #0ea5e9; --acc-txt: #ffffff;
    --ok: #16a34a; --err: #dc2626; --warn: #d97706;
    --shadow: 0 1px 3px rgba(0, 0, 0, .08);
}
[data-theme="dark"] {
    --bg: #0b1220; --card: #16202f; --txt: #e2e8f0; --mut: #94a3b8;
    --line: #26334a; --acc: #38bdf8; --acc-txt: #04210e;
    --ok: #4ade80; --err: #f87171; --warn: #fbbf24;
    --shadow: 0 1px 3px rgba(0, 0, 0, .5);
}
* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
    margin: 0; font-family: system-ui, 'Segoe UI', Roboto, Arial, sans-serif;
    background: var(--bg); color: var(--txt); font-size: 15px;
    padding-bottom: env(safe-area-inset-bottom);
}
a { color: var(--acc); text-decoration: none; }
h1, h2, h3 { margin: 0 0 10px; }
.page-title { margin: 4px 0 16px; font-size: 21px; }
.page-title small { font-size: 13px; font-weight: 400; }
.muted { color: var(--mut); }
.text-ok { color: var(--ok); } .text-err { color: var(--err); }
.hidden { display: none !important; }

/* ---------- Üst bar ---------- */
.topbar {
    display: flex; align-items: center; gap: 10px; position: sticky; top: 0; z-index: 50;
    background: var(--card); border-bottom: 1px solid var(--line); padding: 9px 14px; box-shadow: var(--shadow);
}
.brand { font-weight: 800; color: var(--txt); font-size: 16px; white-space: nowrap; }
.topbar-right { margin-left: auto; display: flex; align-items: center; gap: 8px; }
.user-chip { font-size: 12.5px; color: var(--mut); display: none; }
.user-chip em { font-style: normal; text-transform: lowercase; }
.burger { display: none; background: none; border: 0; font-size: 20px; cursor: pointer; color: var(--txt); }
.btn-quick { background: var(--acc); color: #fff; border-radius: 8px; padding: 7px 12px; font-weight: 700; }

/* ---------- Yerleşim ---------- */
.layout { display: flex; min-height: calc(100vh - 55px); }
.sidebar {
    width: 215px; background: var(--card); border-right: 1px solid var(--line);
    padding: 12px 8px; flex-shrink: 0; position: sticky; top: 55px; height: calc(100vh - 55px); overflow-y: auto;
}
.sidebar a {
    display: flex; align-items: center; gap: 10px; padding: 10px 12px; border-radius: 9px;
    color: var(--txt); font-weight: 600; font-size: 14px; margin-bottom: 2px;
}
.sidebar a span { width: 20px; text-align: center; }
.sidebar a:hover { background: color-mix(in srgb, var(--acc) 12%, transparent); }
.sidebar a.active { background: var(--acc); color: #fff; }
.content { flex: 1; padding: 16px; min-width: 0; max-width: 1200px; }

/* Mobil alt navigasyon */
.mobilenav {
    display: none; position: fixed; bottom: 0; left: 0; right: 0; z-index: 60;
    background: var(--card); border-top: 1px solid var(--line);
    padding: 5px 0 calc(5px + env(safe-area-inset-bottom));
}
.mobilenav a {
    flex: 1; display: flex; flex-direction: column; align-items: center; gap: 2px;
    color: var(--mut); font-size: 10px; padding: 4px 0;
}
.mobilenav a span { font-size: 19px; }
.mobilenav a.active { color: var(--acc); }

@media (max-width: 900px) {
    .sidebar { display: none; }
    .sidebar.open {
        display: block; position: fixed; top: 55px; left: 0; bottom: 0; z-index: 70;
        height: auto; width: 240px; box-shadow: 4px 0 20px rgba(0,0,0,.3);
    }
    .burger { display: block; }
    .content { padding: 12px 10px 90px; }
    .mobilenav { display: flex; }
    .user-chip { display: none; }
}
@media (min-width: 901px) { .user-chip { display: block; } }

/* ---------- Bileşenler ---------- */
.panel {
    background: var(--card); border: 1px solid var(--line); border-radius: 13px;
    padding: 16px; margin-bottom: 16px; box-shadow: var(--shadow);
}
.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
@media (max-width: 980px) { .grid-2 { grid-template-columns: 1fr; } }

.stat-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 12px; margin-bottom: 16px; }
.stat-card {
    background: var(--card); border: 1px solid var(--line); border-radius: 13px; padding: 14px 16px;
    display: flex; flex-direction: column; gap: 2px; box-shadow: var(--shadow);
}
.stat-card small { color: var(--mut); font-size: 12px; text-transform: uppercase; letter-spacing: .4px; }
.stat-card b { font-size: 21px; }
.stat-card span { font-size: 12px; color: var(--mut); }
.stat-card.warn { border-color: var(--warn); }
.stat-card.warn b { color: var(--warn); }

.table { width: 100%; border-collapse: collapse; font-size: 14px; }
.table th { text-align: left; color: var(--mut); font-size: 12px; text-transform: uppercase; padding: 7px 8px; border-bottom: 2px solid var(--line); }
.table td { padding: 9px 8px; border-bottom: 1px solid var(--line); vertical-align: top; }
.table tr:last-child td { border-bottom: 0; }
.table-scroll { overflow-x: auto; }
.row-muted { opacity: .45; }
.row-actions { white-space: nowrap; }
.thumb { width: 34px; height: 34px; object-fit: cover; border-radius: 7px; vertical-align: middle; margin-right: 6px; }

.badge {
    display: inline-block; font-size: 11px; font-weight: 700; border-radius: 99px;
    padding: 2px 9px; background: color-mix(in srgb, var(--mut) 18%, transparent); color: var(--mut); vertical-align: middle;
}
.badge-cash { background: #16a34a22; color: var(--ok); }
.badge-card { background: #0ea5e922; color: var(--acc); }
.badge-credit { background: #f59e0b22; color: var(--warn); }
.badge-ref { background: #dc262622; color: var(--err); }
.badge-admin { background: #8b5cf622; color: #8b5cf6; }
.badge-cashier { background: #0ea5e922; color: var(--acc); }
.badge-m-in { background: #16a34a22; color: var(--ok); }
.badge-m-out { background: #dc262622; color: var(--err); }
.badge-m-sale { background: #0ea5e922; color: var(--acc); }
.badge-m-return { background: #f59e0b22; color: var(--warn); }
.badge-m-count { background: #8b5cf622; color: #8b5cf6; }
.dot { display: inline-block; width: 9px; height: 9px; border-radius: 50%; margin-right: 5px; }
.dot-on { background: #22c55e; box-shadow: 0 0 5px #22c55e; }
.dot-off { background: #94a3b8; }

.btn {
    display: inline-block; border: 1px solid var(--line); background: var(--card); color: var(--txt);
    padding: 9px 14px; border-radius: 9px; font-weight: 600; font-size: 14px; cursor: pointer;
    vertical-align: middle; transition: filter .15s;
}
.btn:hover { filter: brightness(.95); }
.btn-primary { background: var(--acc); border-color: var(--acc); color: #fff; }
.btn-danger-ghost { color: var(--err); border-color: color-mix(in srgb, var(--err) 40%, transparent); }
.btn-sm { padding: 5px 9px; font-size: 12.5px; border-radius: 7px; }
.btn-block { width: 100%; }
.btn-icon { padding: 9px 11px; }
.btn-icon.rec { background: var(--err); color: #fff; animation: pulse 1s infinite; }
@keyframes pulse { 50% { opacity: .55; } }

.alert { padding: 11px 15px; border-radius: 10px; margin-bottom: 14px; font-size: 14px; }
.alert-ok { background: color-mix(in srgb, var(--ok) 14%, transparent); color: var(--ok); border: 1px solid color-mix(in srgb, var(--ok) 35%, transparent); }
.alert-err { background: color-mix(in srgb, var(--err) 14%, transparent); color: var(--err); border: 1px solid color-mix(in srgb, var(--err) 35%, transparent); }

.toolbar { display: flex; flex-wrap: wrap; gap: 9px; align-items: center; margin-bottom: 14px; }
input, select, textarea {
    padding: 10px 12px; border-radius: 9px; border: 1px solid var(--line);
    background: var(--bg); color: var(--txt); font-size: 14px; font-family: inherit; width: 100%;
}
input:focus, select:focus { outline: 2px solid var(--acc); border-color: transparent; }
label { display: block; font-size: 12.5px; color: var(--mut); margin-bottom: 4px; font-weight: 600; }
.inline { display: inline-flex; align-items: center; gap: 6px; font-size: 13.5px; width: auto; }
.inline-form { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
.inline-form input, .inline-form select { width: auto; min-width: 140px; }
.form-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(190px, 1fr)); gap: 12px; align-items: end; }
.form-grid .span2 { grid-column: span 2; }
.form-actions { grid-column: 1 / -1; display: flex; gap: 8px; }
@media (max-width: 640px) { .form-grid .span2 { grid-column: span 1; } }
.chk { display: flex; align-items: center; gap: 8px; font-size: 13px; color: var(--mut); width: auto; }
.chk input { width: auto; }
.kv-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(140px, 1fr)); gap: 12px; }
.kv-grid small { color: var(--mut); display: block; font-size: 11.5px; text-transform: uppercase; }
.list { list-style: none; margin: 0; padding: 0; }
.list li { padding: 8px 0; border-bottom: 1px dashed var(--line); }

/* ---------- Giriş ekranı ---------- */
.login-wrap { min-height: 100vh; display: flex; align-items: center; justify-content: center; padding: 16px; }
.login-card {
    background: var(--card); border: 1px solid var(--line); border-radius: 18px; padding: 30px 26px;
    width: 100%; max-width: 380px; box-shadow: 0 18px 50px rgba(0,0,0,.18); text-align: center;
}
.login-logo { font-size: 44px; }
.login-card h1 { margin: 6px 0 2px; }
.login-sub { color: var(--mut); margin: 0 0 18px; font-size: 13.5px; }
.login-card label { text-align: left; }
.login-card input { margin-bottom: 10px; }
.login-hint { font-size: 12px; color: var(--mut); margin-top: 14px; }

/* ================== POS EKRANI ================== */
.pos { display: flex; gap: 14px; align-items: flex-start; position: relative; }
.pos-products { flex: 1; min-width: 0; }
.pos-searchrow { display: flex; gap: 8px; margin-bottom: 10px; }
.pos-search { flex: 1; font-size: 16px; padding: 13px 15px; }
.pos-cats { display: flex; gap: 7px; overflow-x: auto; padding-bottom: 9px; }
.cat-chip {
    border: 1px solid var(--line); background: var(--card); color: var(--txt); border-radius: 99px;
    padding: 7px 15px; font-weight: 600; font-size: 13px; cursor: pointer; white-space: nowrap; flex-shrink: 0;
}
.cat-chip.active { background: var(--acc); border-color: var(--acc); color: #fff; }
.pos-grid {
    display: grid; grid-template-columns: repeat(auto-fill, minmax(135px, 1fr)); gap: 10px;
    max-height: calc(100vh - 235px); overflow-y: auto; padding: 2px;
}
.prod-card {
    background: var(--card); border: 1px solid var(--line); border-radius: 12px; padding: 12px 10px;
    display: flex; flex-direction: column; gap: 4px; cursor: pointer; text-align: left;
    color: var(--txt); font-family: inherit; min-height: 92px; transition: transform .08s;
}
.prod-card:active { transform: scale(.96); }
.prod-card:hover { border-color: var(--acc); }
.prod-card.lowstock { border-color: var(--warn); }
.prod-name { font-weight: 700; font-size: 13px; line-height: 1.25; }
.prod-price { font-size: 15px; font-weight: 800; color: var(--acc); }
.prod-card small { font-size: 10.5px; }

.pos-cart { width: 350px; flex-shrink: 0; position: sticky; top: 70px; display: flex; flex-direction: column; max-height: calc(100vh - 90px); }
.pos-carthead { display: flex; align-items: center; justify-content: space-between; }
.pos-carthead h3 { margin-bottom: 4px; }
.pos-cartitems { flex: 1; overflow-y: auto; min-height: 110px; margin: 6px 0; }
.pos-empty { text-align: center; padding: 30px 0; }
.cart-line {
    display: grid; grid-template-columns: 1fr auto auto auto; gap: 7px; align-items: center;
    padding: 8px 4px; border-bottom: 1px dashed var(--line);
}
.cl-info b { font-size: 13.5px; display: block; line-height: 1.2; }
.cl-info small { color: var(--mut); font-size: 11px; }
.cl-qty { display: flex; align-items: center; gap: 4px; }
.cl-qty button {
    width: 30px; height: 30px; border-radius: 8px; border: 1px solid var(--line);
    background: var(--bg); color: var(--txt); font-size: 16px; cursor: pointer; font-weight: 700;
}
.cl-qty span { min-width: 26px; text-align: center; font-weight: 700; }
.cl-total { font-weight: 800; font-size: 13.5px; min-width: 62px; text-align: right; }
.cl-del { border: 0; background: none; color: var(--err); cursor: pointer; font-size: 14px; }
.pos-totals { border-top: 2px solid var(--line); padding-top: 8px; }
.lrow { display: flex; justify-content: space-between; font-size: 13.5px; padding: 3px 0; color: var(--mut); }
.lrow b { color: var(--txt); }
.lrow-big { font-size: 18px; font-weight: 800; }
.lrow-big b { color: var(--acc); font-size: 21px; }
.pos-actions { display: flex; gap: 7px; margin: 10px 0; flex-wrap: wrap; }
.pos-actions .btn { flex: 1; text-align: center; padding: 9px 6px; font-size: 12.5px; }
.btn-pay { width: 100%; font-size: 19px !important; padding: 15px !important; border-radius: 13px !important; }

/*POS mobil: sepet altta tam genişlik */
@media (max-width: 900px) {
    .pos { flex-direction: column; }
    .pos-cart { width: 100%; position: static; max-height: none; }
    .pos-grid { max-height: 42vh; }
    body.show-cart .pos-products { display: none; }
    .pos-mobtabs { display: block !important; }
}

/* Tuş takımı */
.pos-keypad { position: fixed; inset: 0; background: rgba(0,0,0,.5); z-index: 90; display: flex; align-items: center; justify-content: center; padding: 16px; }
.keypad-box { background: var(--card); border-radius: 16px; padding: 16px; width: 100%; max-width: 320px; }
.keypad-box input { text-align: right; font-size: 22px; margin-bottom: 10px; }
.keypad-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
.keypad-grid .key, .pay-pad .key {
    padding: 15px 0; font-size: 19px; font-weight: 700; border-radius: 11px;
    border: 1px solid var(--line); background: var(--bg); color: var(--txt); cursor: pointer;
}
.keypad-grid .key:active, .pay-pad .key:active { background: var(--acc); color: #fff; }
.keypad-actions { display: flex; gap: 7px; margin-top: 10px; flex-wrap: wrap; }
.keypad-actions .btn { flex: 1; font-size: 12.5px; }

/* Modallar */
.modal { position: fixed; inset: 0; background: rgba(2,6,23,.6); z-index: 100; display: flex; align-items: center; justify-content: center; padding: 14px; }
.modal-card {
    background: var(--card); border-radius: 17px; padding: 20px; width: 100%; max-width: 420px;
    max-height: 92vh; overflow-y: auto; box-shadow: 0 25px 60px rgba(0,0,0,.4);
}
.modal-sm { max-width: 320px; }
.modal-card h3 { margin-bottom: 14px; }
.modal-actions { display: flex; gap: 9px; margin-top: 16px; }
.modal-actions .btn { flex: 1; text-align: center; }
.pay-total { font-size: 24px; text-align: center; margin-bottom: 12px; }
.pay-total b { color: var(--acc); }
.pay-tabs { display: flex; gap: 7px; margin-bottom: 13px; }
.pay-tab {
    flex: 1; padding: 11px 5px; border-radius: 10px; border: 1px solid var(--line);
    background: var(--bg); color: var(--txt); font-weight: 700; cursor: pointer; font-size: 13.5px;
}
.pay-tab.active { background: var(--acc); border-color: var(--acc); color: #fff; }
.pay-quick { display: flex; gap: 6px; margin: 9px 0; flex-wrap: wrap; }
.pay-quick button {
    flex: 1; min-width: 48px; padding: 10px 4px; border-radius: 9px; border: 1px solid var(--line);
    background: var(--bg); color: var(--txt); font-weight: 700; cursor: pointer;
}
.pay-pad { margin-top: 8px; }
.pay-change { text-align: center; font-size: 17px; margin-top: 11px; }
.pay-change b { color: var(--ok); font-size: 22px; }
#payPaid { font-size: 20px; text-align: right; }
.held-list { min-height: 60px; }
.held-row {
    display: flex; justify-content: space-between; align-items: center; gap: 8px;
    padding: 10px 0; border-bottom: 1px dashed var(--line);
}
.pos-toast {
    position: fixed; bottom: 80px; left: 50%; transform: translateX(-50%); z-index: 120;
    padding: 12px 22px; border-radius: 99px; font-weight: 700; font-size: 14px;
    box-shadow: 0 8px 24px rgba(0,0,0,.3); max-width: 90vw; text-align: center;
}
.pos-toast-ok { background: var(--ok); color: #fff; }
.pos-toast-err { background: var(--err); color: #fff; }
.pos-toast-warn { background: var(--warn); color: #fff; }

/* ---------- Satış sonrası fiş modalı ---------- */
.receipt-card { max-width: 440px; }
.done-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; margin-bottom: 12px; }
.done-grid > div {
    background: var(--bg); border: 1px solid var(--line); border-radius: 11px;
    padding: 9px 6px; text-align: center;
}
.done-grid small { display: block; color: var(--mut); font-size: 11px; margin-bottom: 3px; }
.done-grid b { font-size: 15px; }
.receipt-preview {
    border: 1px solid var(--line); border-radius: 12px; overflow: hidden;
    background: #525659; padding: 10px; display: flex; justify-content: center;
}
.receipt-preview iframe {
    width: 100%; height: 340px; border: 0; background: #fff; border-radius: 6px; display: block;
}
@media (max-width: 460px) {
    .receipt-preview iframe { height: 260px; }
}

/* ---------- Etiketler ---------- */
.labels-sheet { display: grid; grid-template-columns: repeat(auto-fill, minmax(180px, 1fr)); gap: 8px; }
.label-card {
    border: 1px dashed #999; border-radius: 6px; padding: 8px; text-align: center; background: #fff; color: #000;
    display: flex; flex-direction: column; align-items: center; gap: 3px; page-break-inside: avoid;
}
.label-name { font-weight: 700; font-size: 12px; font-family: Arial, sans-serif; }
.label-card svg { max-width: 100%; height: 55px; }
.label-price { font-weight: 800; font-size: 15px; font-family: Arial, sans-serif; }
.label-price small { font-weight: 400; font-size: 10px; }

/* ---------- Yazdırma (etiket sayfası) ---------- */
@media print {
    body { background: #fff; }
    .topbar, .sidebar, .mobilenav, .no-print, .page-title, .alert, .toolbar { display: none !important; }
    .layout { display: block; }
    .content { padding: 0; max-width: none; }
    .labels-sheet { grid-template-columns: repeat(3, 66mm); }
    .label-card { border: 1px dashed #bbb; }
}
