/* =========================================================================
   MobilPos Depo — görsel tasarım
   Ortak tasarım değişkenleri; masaüstü (≥768px) ve mobil (<768px) için ayrı düzenler.
   ========================================================================= */
:root {
    --brand: #2f5bea;
    --brand-dark: #1f43b8;
    --brand-soft: #e8eefe;
    --ink: #0f172a;
    --ink-2: #334155;
    --muted: #64748b;
    --line: #e2e8f0;
    --line-2: #eef2f7;
    --surface: #ffffff;
    --bg: #f4f6fa;
    --ok: #12a150;
    --ok-soft: #e3f6ea;
    --warn: #c88400;
    --warn-soft: #fff4d6;
    --bad: #e5484d;
    --bad-soft: #fde8e8;
    --radius: 14px;
    --radius-sm: 10px;
    --shadow: 0 1px 2px rgba(15, 23, 42, .06), 0 1px 3px rgba(15, 23, 42, .04);
    --shadow-lg: 0 10px 30px rgba(15, 23, 42, .12);
    --topbar-h: 60px;
    --bottomnav-h: 64px;

    --bs-body-color: var(--ink);
    --bs-body-bg: var(--bg);
    --bs-border-color: var(--line);
    --bs-primary: var(--brand);
    --bs-primary-rgb: 47, 91, 234;
    --bs-link-color: var(--brand);
    --bs-link-color-rgb: 47, 91, 234;
    --bs-link-hover-color: var(--brand-dark);
    --bs-border-radius: var(--radius-sm);
}

html { font-size: 15px; -webkit-text-size-adjust: 100%; }
body { background: var(--bg); color: var(--ink); -webkit-tap-highlight-color: transparent; }
a { text-decoration: none; }
a:hover { text-decoration: underline; }
.bi { line-height: 1; vertical-align: -.125em; }

/* ---- Düğmeler ---- */
.btn { --bs-btn-border-radius: var(--radius-sm); font-weight: 500; display: inline-flex; align-items: center; justify-content: center; gap: .45rem; white-space: nowrap; }
.btn-sm { --bs-btn-border-radius: 8px; gap: .35rem; }
.btn-lg { --bs-btn-border-radius: 12px; font-weight: 600; }
.btn-primary { --bs-btn-bg: var(--brand); --bs-btn-border-color: var(--brand); --bs-btn-hover-bg: var(--brand-dark); --bs-btn-hover-border-color: var(--brand-dark); --bs-btn-active-bg: var(--brand-dark); --bs-btn-disabled-bg: var(--brand); --bs-btn-disabled-border-color: var(--brand); }
.btn-success { --bs-btn-bg: var(--ok); --bs-btn-border-color: var(--ok); --bs-btn-hover-bg: #0e8541; --bs-btn-hover-border-color: #0e8541; --bs-btn-active-bg: #0b7136; }
.btn-outline-primary { --bs-btn-color: var(--brand); --bs-btn-border-color: #c9d6fb; --bs-btn-hover-bg: var(--brand-soft); --bs-btn-hover-color: var(--brand-dark); --bs-btn-hover-border-color: #b3c5fa; --bs-btn-active-bg: var(--brand-soft); --bs-btn-active-color: var(--brand-dark); }
.btn-outline-secondary { --bs-btn-color: var(--ink-2); --bs-btn-border-color: var(--line); --bs-btn-bg: var(--surface); --bs-btn-hover-bg: var(--line-2); --bs-btn-hover-color: var(--ink); --bs-btn-hover-border-color: #cfd8e3; --bs-btn-active-bg: var(--line); --bs-btn-active-color: var(--ink); }
.btn-outline-success { --bs-btn-color: var(--ok); --bs-btn-border-color: #b9e6c9; --bs-btn-hover-bg: var(--ok-soft); --bs-btn-hover-color: #0b7136; --bs-btn-hover-border-color: #9edbb4; }
.btn-outline-danger { --bs-btn-color: var(--bad); --bs-btn-border-color: #f6c4c5; --bs-btn-hover-bg: var(--bad-soft); --bs-btn-hover-color: #c22d32; --bs-btn-hover-border-color: #f0a9ab; }
.btn-icon { padding: .375rem .55rem; }
.btn-soft { background: var(--brand-soft); color: var(--brand-dark); border: 0; }
.btn-soft:hover { background: #dbe5fd; color: var(--brand-dark); }

/* ---- Kart, form ---- */
.card { border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); }
.card-header { background: var(--surface); border-bottom: 1px solid var(--line); border-radius: var(--radius) var(--radius) 0 0 !important; padding: .8rem 1rem; font-weight: 600; display: flex; align-items: center; gap: .5rem; }
.card-header .count { margin-left: auto; }
.form-control, .form-select { border-color: #d5dce6; border-radius: var(--radius-sm); }
.form-control:focus, .form-select:focus { border-color: #8ba5f5; box-shadow: 0 0 0 .2rem rgba(47, 91, 234, .15); }
.form-label { font-weight: 500; color: var(--ink-2); margin-bottom: .3rem; }
.form-hint { color: var(--muted); font-size: .85rem; }
.alert { border-radius: var(--radius-sm); border: 0; }
.alert-success { background: var(--ok-soft); color: #0b6b33; }
.alert-warning { background: var(--warn-soft); color: #7a5300; }
.alert-danger { background: var(--bad-soft); color: #a3262a; }
.alert-info { background: var(--brand-soft); color: var(--brand-dark); }
.alert-secondary { background: var(--line-2); color: var(--ink-2); }

/* ---- Rozetler / durum ---- */
.badge { font-weight: 600; letter-spacing: .01em; border-radius: 999px; padding: .38em .7em; }
.status { display: inline-flex; align-items: center; gap: .3rem; font-size: .8rem; font-weight: 600; border-radius: 999px; padding: .25rem .65rem; white-space: nowrap; }
.status-draft { background: var(--line-2); color: var(--ink-2); }
.status-transit { background: var(--warn-soft); color: #8a5c00; }
.status-done { background: var(--ok-soft); color: #0b6b33; }
.status-cancel { background: var(--bad-soft); color: #b42a2f; }
.code { font-family: ui-monospace, "Cascadia Mono", Consolas, monospace; font-size: .92em; letter-spacing: .01em; }
.num { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }
.text-muted { color: var(--muted) !important; }

/* ---- Üst çubuk ---- */
.app-topbar { position: sticky; top: 0; z-index: 1030; height: var(--topbar-h); background: var(--surface); border-bottom: 1px solid var(--line); }
.app-topbar > .container-xl { height: 100%; display: flex; align-items: center; gap: 1rem; }
.brand { display: inline-flex; align-items: center; gap: .55rem; color: var(--ink); font-size: 1.05rem; font-weight: 700; white-space: nowrap; }
.brand:hover { text-decoration: none; color: var(--ink); }
.brand-mark { width: 34px; height: 34px; border-radius: 10px; display: inline-grid; place-items: center; background: linear-gradient(135deg, var(--brand), #6a8bff); color: #fff; font-size: 1.1rem; box-shadow: 0 2px 6px rgba(47, 91, 234, .35); }
.brand b { color: var(--brand); font-weight: 700; }
.topnav { display: flex; align-items: stretch; height: 100%; gap: .15rem; }
.topnav > a, .topnav-drop > a { display: inline-flex; align-items: center; gap: .45rem; padding: 0 .75rem; color: var(--ink-2); font-weight: 500; border-bottom: 2px solid transparent; margin-bottom: -1px; height: 100%; }
.topnav > a:hover, .topnav-drop > a:hover { color: var(--brand); text-decoration: none; background: var(--line-2); }
.topnav > a.active, .topnav-drop > a.active { color: var(--brand); border-bottom-color: var(--brand); }
.topnav > a .bi, .topnav-drop > a .bi { font-size: 1.05rem; }
.topnav-drop { display: flex; }
.topnav-drop > a::after { margin-left: .1rem; }
.avatar { width: 34px; height: 34px; border-radius: 50%; display: inline-grid; place-items: center; background: var(--brand-soft); color: var(--brand-dark); font-weight: 700; font-size: .85rem; }
.user-button { display: inline-flex; align-items: center; gap: .5rem; background: none; border: 1px solid var(--line); border-radius: 999px; padding: .2rem .6rem .2rem .2rem; color: var(--ink-2); font-weight: 500; }
.user-button:hover { background: var(--line-2); }
.dropdown-menu { border: 1px solid var(--line); border-radius: 12px; box-shadow: var(--shadow-lg); padding: .4rem; }
.dropdown-item { border-radius: 8px; padding: .5rem .7rem; display: flex; align-items: center; gap: .6rem; }
.dropdown-item .bi { color: var(--muted); }

/* ---- Sayfa ---- */
.app-main { padding-top: 1.25rem; padding-bottom: 2rem; }
.page-head { display: flex; flex-wrap: wrap; align-items: flex-end; justify-content: space-between; gap: .75rem 1rem; margin-bottom: 1.1rem; }
.page-head-main { min-width: 0; }
.back-link { display: inline-flex; align-items: center; gap: .35rem; color: var(--muted); font-size: .9rem; font-weight: 500; margin-bottom: .25rem; }
.back-link:hover { color: var(--brand); text-decoration: none; }
.page-title { font-size: 1.6rem; font-weight: 700; margin: 0; display: flex; flex-wrap: wrap; align-items: center; gap: .5rem .7rem; letter-spacing: -.01em; }
.page-sub { color: var(--muted); margin-top: .2rem; }
.page-actions { display: flex; flex-wrap: wrap; gap: .5rem; }
.section-title { font-size: .8rem; font-weight: 700; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); margin: 1.25rem 0 .6rem; }

/* ---- Tablolar ---- */
.table-card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); overflow: hidden; }
.table-card .table { margin: 0; }
.table { --bs-table-bg: transparent; --bs-table-hover-bg: #f7f9fd; vertical-align: middle; }
.table > thead th { background: #f8fafc; color: var(--muted); font-size: .75rem; font-weight: 700; text-transform: uppercase; letter-spacing: .05em; border-bottom: 1px solid var(--line); padding-top: .65rem; padding-bottom: .65rem; white-space: nowrap; }
.table > tbody td { border-color: var(--line-2); }
.table > tfoot td { background: #f8fafc; font-weight: 600; border-top: 1px solid var(--line); }
.table tr.row-link { cursor: pointer; }
.table tr.row-warn > td { background: #fffbeb; }
.table tr.inactive td { color: #94a3b8; }
.cell-title { font-weight: 600; color: var(--ink); }
.cell-sub { color: var(--muted); font-size: .85rem; }
.empty { text-align: center; color: var(--muted); padding: 2rem 1rem !important; }
.empty .bi { display: block; font-size: 1.8rem; margin-bottom: .4rem; color: #cbd5e1; }

/* ---- İstatistik kutuları ---- */
.stat-card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); padding: .9rem 1rem; display: flex; gap: .8rem; align-items: center; height: 100%; }
.stat-icon { width: 42px; height: 42px; border-radius: 12px; display: grid; place-items: center; font-size: 1.25rem; flex: none; }
.stat-icon.blue { background: var(--brand-soft); color: var(--brand); }
.stat-icon.green { background: var(--ok-soft); color: var(--ok); }
.stat-icon.amber { background: var(--warn-soft); color: var(--warn); }
.stat-icon.red { background: var(--bad-soft); color: var(--bad); }
.stat-label { color: var(--muted); font-size: .82rem; }
.stat-value { font-size: 1.45rem; font-weight: 700; line-height: 1.2; font-variant-numeric: tabular-nums; }

/* ---- Hızlı işlem kutuları (ana sayfa) ---- */
.action-tile { display: flex; align-items: center; gap: .8rem; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); padding: 1rem; color: var(--ink); height: 100%; transition: transform .08s ease, box-shadow .15s ease, border-color .15s; }
.action-tile:hover { text-decoration: none; color: var(--ink); border-color: #c9d6fb; box-shadow: 0 6px 18px rgba(47, 91, 234, .12); transform: translateY(-1px); }
.action-tile .stat-icon { width: 46px; height: 46px; font-size: 1.35rem; }
.action-tile strong { display: block; font-size: 1rem; }
.action-tile span.small { color: var(--muted); }

/* ---- Liste (ana sayfa kartları) ---- */
.list-row { display: flex; align-items: center; gap: .75rem; padding: .75rem 1rem; border-top: 1px solid var(--line-2); color: var(--ink); }
.list-row:first-child { border-top: 0; }
.list-row:hover { background: #f8fafc; text-decoration: none; color: var(--ink); }
.list-row .chev { margin-left: auto; color: #cbd5e1; }

/* ---- Okutma alanı ---- */
.scan-box { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); padding: .9rem; margin-bottom: 1rem; }
.scan-row { display: flex; gap: .5rem; align-items: stretch; }
.scan-input { font-size: 1.35rem; padding: .55rem .85rem; min-width: 0; }
.scan-input::placeholder { color: #9aa7b8; }
.scan-qty { width: 5.5rem; flex: none; font-size: 1.2rem; text-align: center; }
.scan-submit { flex: none; padding-left: 1.2rem; padding-right: 1.2rem; font-size: 1.05rem; }
.scan-hint { color: var(--muted); font-size: .85rem; margin-top: .5rem; }
.scan-location { display: flex; flex-wrap: wrap; align-items: center; gap: .5rem; margin-bottom: .6rem; padding: .55rem .7rem; background: var(--brand-soft); border-radius: var(--radius-sm); }
.scan-location .label { color: var(--brand-dark); font-size: .8rem; font-weight: 600; text-transform: uppercase; letter-spacing: .05em; }
.scan-location .value { font-weight: 700; color: var(--ink); }
.scan-location select { margin-left: auto; max-width: 100%; }

.scan-tools { margin-bottom: .7rem; }
.scan-modes { display: inline-flex; background: var(--line-2); border-radius: 12px; padding: 3px; gap: 2px; }
.scan-modes button { border: 0; background: none; color: var(--ink-2); font-weight: 600; font-size: .88rem; padding: .4rem .85rem; border-radius: 9px; display: inline-flex; align-items: center; gap: .4rem; }
.scan-modes button:hover { color: var(--ink); }
.scan-modes button.active { background: var(--surface); color: var(--brand); box-shadow: 0 1px 3px rgba(15, 23, 42, .12); }
.scan-camera { position: relative; margin-top: .6rem; border-radius: 12px; overflow: hidden; background: #0b1220; }
.scan-camera-view { width: 100%; max-height: 42vh; }
.scan-camera-view video { width: 100% !important; max-height: 42vh; object-fit: cover; display: block; }
.scan-camera-bar { display: flex; align-items: center; gap: .5rem; padding: .5rem .6rem; background: rgba(11, 18, 32, .9); color: #e2e8f0; font-size: .88rem; }
.scan-camera-status { flex: 1; }
.scan-camera-bar .btn-light { --bs-btn-bg: rgba(255, 255, 255, .12); --bs-btn-border-color: transparent; --bs-btn-color: #fff; --bs-btn-hover-bg: rgba(255, 255, 255, .22); --bs-btn-hover-color: #fff; }
.scan-camera-bar .btn.active { --bs-btn-bg: #ffc107; --bs-btn-color: #111; }
.scan-camera.hit { animation: scan-hit .45s ease; }
@keyframes scan-hit { from { box-shadow: 0 0 0 5px #22c55e inset; } to { box-shadow: 0 0 0 0 transparent inset; } }

/* Barkod birden fazla üründe: seçim kartları */
.choice-box { background: var(--warn-soft); border-radius: var(--radius); padding: .9rem; margin-bottom: 1rem; }
.choice-box .choice { text-align: left; background: var(--surface); border: 1px solid #f1d58a; border-radius: 12px; padding: .6rem .8rem; display: block; width: 100%; }
.choice-box .choice:hover { border-color: var(--warn); }

/* ---- Bildirim ---- */
.scan-toast {
    position: fixed; left: 50%; bottom: 1.25rem; transform: translateX(-50%) translateY(150%);
    min-width: 260px; max-width: min(92vw, 560px); padding: .8rem 1.1rem; border-radius: 14px; color: #fff;
    font-weight: 600; box-shadow: var(--shadow-lg); transition: transform .2s ease, opacity .2s ease; z-index: 2000; text-align: center;
    opacity: 0; pointer-events: none;
}
.scan-toast.show { transform: translateX(-50%) translateY(0); opacity: 1; }
.scan-toast.bg-success { background: #0f8a44 !important; }
.scan-toast.bg-danger { background: #d63b40 !important; }

/* ---- Giriş sayfası ---- */
.auth-wrap { min-height: calc(100vh - var(--topbar-h) - 3rem); display: grid; place-items: center; }
.auth-card { width: 100%; max-width: 410px; }
.auth-card .card-body { padding: 2rem; }
.auth-title { font-size: 1.4rem; font-weight: 700; }

/* ---- Yardımcılar ---- */
.min-w-0 { min-width: 0; }

/* ---- Ağaç ---- */
.tree .loc-name { white-space: nowrap; }
.tree .indent { display: inline-block; }
.tree .twig { color: #cbd5e1; margin-right: .25rem; }

/* ---- QR ---- */
.qr svg { width: 190px; height: 190px; }
.qr-sm svg { width: 120px; height: 120px; }

/* ---- Alt menü / mobil ---- */
.bottom-nav { display: none; }
@media (min-width: 768px) { .mobile-only { display: none !important; } }

@media (max-width: 767.98px) {
    html { font-size: 15.5px; }
    .desktop-only { display: none !important; }
    body.signed-in { padding-bottom: calc(var(--bottomnav-h) + env(safe-area-inset-bottom)); }
    .app-topbar { height: 56px; }
    .app-main { padding-top: .9rem; padding-left: .8rem; padding-right: .8rem; }
    .brand { font-size: 1rem; }
    .topbar-back { width: 40px; height: 40px; display: inline-grid; place-items: center; border-radius: 12px; color: var(--ink); font-size: 1.3rem; margin-left: -.35rem; }
    .topbar-back:hover { background: var(--line-2); text-decoration: none; }

    .page-head { margin-bottom: .8rem; align-items: stretch; }
    .page-title { font-size: 1.3rem; }
    .page-actions { width: 100%; }
    .page-actions > .btn, .page-actions > form, .page-actions > a { flex: 1 1 auto; }
    .page-actions > form > .btn { width: 100%; }
    .back-link { display: none; }

    .btn { min-height: 44px; }
    .btn-sm { min-height: 38px; }
    .btn-icon { min-width: 44px; }

    .scan-box { padding: .7rem; border-radius: 16px; }
    .scan-input { font-size: 1.15rem; }
    .scan-qty { width: 4.2rem; font-size: 1.1rem; }
    .scan-submit .label { display: none; }
    .scan-modes { display: flex; width: 100%; }
    .scan-modes button { flex: 1; justify-content: center; padding: .55rem .4rem; font-size: .9rem; }
    .scan-camera-view, .scan-camera-view video { max-height: 34vh; }
    .scan-location select { margin-left: 0; width: 100%; }

    /* Tablolar mobilde kart listesi olur: her satır bir kart, hücre etiketleri data-label'dan */
    .table-stack thead { display: none; }
    .table-card:has(.table-stack) { background: none; border: 0; box-shadow: none; overflow: visible; }
    .table-stack, .table-stack tbody, .table-stack tfoot, .table-stack tr, .table-stack td { display: block; width: 100%; }
    .table-stack tr { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); margin-bottom: .6rem; padding: .65rem .85rem; }
    .table-stack tr.row-warn { border-color: #f1d58a; background: #fffbeb; }
    .table-stack tr.row-warn > td { background: none; }
    .table-stack td { border: 0 !important; padding: .18rem 0 !important; display: flex; align-items: center; justify-content: space-between; gap: 1rem; text-align: right; min-height: 1.6rem; }
    .table-stack td::before { content: attr(data-label); color: var(--muted); font-size: .82rem; font-weight: 500; text-align: left; flex: none; }
    .table-stack td:not([data-label])::before, .table-stack td[data-label=""]::before { content: none; }
    .table-stack td.cell-main { display: block; text-align: left; padding-bottom: .35rem !important; font-size: 1rem; }
    .table-stack td.cell-main::before { content: none; }
    .table-stack td.cell-hide-sm { display: none; }
    .table-stack td.empty { display: block; text-align: center; }
    .table-stack tfoot tr { background: var(--line-2); box-shadow: none; }
    .table-stack tfoot td { background: none; }
    .table-stack .num { text-align: right; }
    .tree.table-stack tr { margin-left: calc(var(--depth, 0) * .9rem); width: calc(100% - var(--depth, 0) * .9rem); }
    .tree.table-stack tr td:last-child .btn { flex: 1; }
    .table-stack td.cell-action { position: absolute; right: .85rem; bottom: .55rem; width: auto; min-height: 0; }
    .table-stack tr:has(td.cell-action) { position: relative; padding-right: 4.2rem; }

    /* Ekranın altına sabit ana işlemler (Gönder, Teslim al, Onayla) */
    .action-bar { position: sticky; bottom: calc(var(--bottomnav-h) + env(safe-area-inset-bottom) + .5rem); z-index: 1010; display: flex; flex-wrap: wrap; gap: .5rem; background: rgba(255, 255, 255, .92); backdrop-filter: blur(8px); border: 1px solid var(--line); border-radius: 16px; box-shadow: var(--shadow-lg); padding: .55rem; margin-top: 1rem; }
    .action-bar > form, .action-bar > a, .action-bar > .btn { flex: 1 1 auto; }
    .action-bar .btn { width: 100%; }

    .bottom-nav {
        display: flex; position: fixed; left: 0; right: 0; bottom: 0; z-index: 1035; height: calc(var(--bottomnav-h) + env(safe-area-inset-bottom));
        padding-bottom: env(safe-area-inset-bottom); background: rgba(255, 255, 255, .96); backdrop-filter: blur(10px); border-top: 1px solid var(--line);
    }
    .bottom-nav a, .bottom-nav button { flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: .15rem; color: var(--muted); font-size: .72rem; font-weight: 600; background: none; border: 0; }
    .bottom-nav .bi { font-size: 1.35rem; }
    .bottom-nav a.active, .bottom-nav button.active { color: var(--brand); }
    .bottom-nav a:hover { text-decoration: none; }
    .scan-toast { bottom: calc(var(--bottomnav-h) + env(safe-area-inset-bottom) + .75rem); }
    body:has(.action-bar) .scan-toast { bottom: calc(var(--bottomnav-h) + env(safe-area-inset-bottom) + 5.5rem); }

    .offcanvas-menu .list-row { padding: .9rem 1rem; font-weight: 500; }
    .offcanvas-menu .list-row .bi { font-size: 1.2rem; color: var(--muted); width: 1.5rem; }
    .stat-value { font-size: 1.25rem; }
}

@media (min-width: 768px) {
    .action-bar { display: flex; flex-wrap: wrap; gap: .5rem; margin-top: 1.25rem; }
    .action-bar .ms-md-auto { margin-left: auto; }
}

@media print {
    body { background: #fff; padding: 0 !important; }
    .app-topbar, .bottom-nav, .action-bar, .scan-box, .scan-tools { display: none !important; }
    .card, .table-card { box-shadow: none; }
}
