/* ============================================================
   EsnafPOS — Ana stil
   Tailwind kullanılmıyor; her şey burada, offline çalışır.
   ============================================================ */

:root {
    /* Tema renkleri — JS ile değiştirilir */
    --primary-from: #1a1a1a;
    --primary:      #2c2c2e;
    --primary-light:#636366;
    --accent-from:  #8b6914;
    --accent:       #b8860b;

    /* Yüzeyler */
    --bg-base:     #f4f4f6;
    --bg-card:     #ffffff;
    --bg-elevated: #ffffff;
    --bg-input:    #ffffff;
    --bg-hover:    #f7f7f9;

    /* Metin */
    --text:        #17171a;
    --text-soft:   #55555e;
    --text-mute:   #8b8b95;

    /* Çizgiler */
    --line:        #e4e4e9;
    --line-strong: #d0d0d8;

    /* Durum renkleri */
    --ok:     #16a34a;
    --ok-bg:  #ecfdf5;
    --warn:   #d97706;
    --warn-bg:#fffbeb;
    --err:    #dc2626;
    --err-bg: #fef2f2;
    --info:   #2563eb;
    --info-bg:#eff6ff;

    --radius:   14px;
    --radius-sm:10px;
    --shadow:   0 2px 8px rgba(0,0,0,.05), 0 12px 32px rgba(0,0,0,.06);
    --shadow-sm:0 1px 3px rgba(0,0,0,.07);

    --sidebar-w: 248px;
}

* { box-sizing: border-box; }

html, body {
    margin: 0;
    padding: 0;
    height: 100%;
    overflow: hidden;
}

body {
    background: var(--bg-base);
    color: var(--text);
    font-family: Inter, "Segoe UI", system-ui, -apple-system, sans-serif;
    font-size: 14px;
    line-height: 1.5;
    -webkit-font-smoothing: antialiased;
}

/* Baskı sırasında ekranı gizle */
@media print {
    body { overflow: visible; height: auto; }
    .no-print { display: none !important; }
}

/* ---------- Genel yardımcılar ---------- */
.row      { display: flex; align-items: center; }
.row-gap  { display: flex; align-items: center; gap: 8px; }
.col      { display: flex; flex-direction: column; }
.grow     { flex: 1; }
.spacer   { flex: 1; }
.hidden   { display: none !important; }
.center   { display: flex; align-items: center; justify-content: center; }
.nowrap   { white-space: nowrap; }
.truncate { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.mono     { font-variant-numeric: tabular-nums; }
.text-mute{ color: var(--text-mute); }
.text-soft{ color: var(--text-soft); }
.text-ok  { color: var(--ok); }
.text-err { color: var(--err); }
.text-warn{ color: var(--warn); }
.right    { text-align: right; }
.center-t { text-align: center; }

/* ---------- Düğmeler ---------- */
.btn {
    display: inline-flex; align-items: center; justify-content: center; gap: 7px;
    padding: 9px 15px;
    border: 1px solid var(--line-strong);
    border-radius: var(--radius-sm);
    background: var(--bg-elevated);
    color: var(--text);
    font: inherit; font-weight: 600;
    cursor: pointer;
    transition: background .13s, border-color .13s, transform .07s;
    white-space: nowrap;
    user-select: none;
}
.btn:hover:not(:disabled)  { background: var(--bg-hover); border-color: var(--primary-light); }
.btn:active:not(:disabled) { transform: translateY(1px); }
.btn:disabled              { opacity: .5; cursor: not-allowed; }

.btn-primary {
    background: linear-gradient(135deg, var(--primary-from), var(--primary));
    color: #fff; border-color: transparent;
}
.btn-primary:hover:not(:disabled) { filter: brightness(1.15); background: linear-gradient(135deg, var(--primary-from), var(--primary)); }

.btn-accent  { background: linear-gradient(135deg, var(--accent-from), var(--accent)); color:#fff; border-color: transparent; }
.btn-ok      { background: var(--ok);   color: #fff; border-color: transparent; }
.btn-err     { background: var(--err);  color: #fff; border-color: transparent; }
.btn-warn    { background: var(--warn); color: #fff; border-color: transparent; }
.btn-ok:hover:not(:disabled), .btn-err:hover:not(:disabled), .btn-warn:hover:not(:disabled),
.btn-accent:hover:not(:disabled) { filter: brightness(1.1); }

.btn-sm  { padding: 6px 11px;  font-size: 13px; }
.btn-xs  { padding: 4px 9px;   font-size: 12px; border-radius: 8px; }
.btn-lg  { padding: 13px 22px; font-size: 16px; }
.btn-block { width: 100%; }

/* ---------- Form elemanları ---------- */
.inp, .sel, .txt {
    width: 100%;
    padding: 9px 12px;
    border: 1px solid var(--line-strong);
    border-radius: var(--radius-sm);
    background: var(--bg-input);
    color: var(--text);
    font: inherit;
    transition: border-color .13s, box-shadow .13s;
}
.inp:focus, .sel:focus, .txt:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(0,0,0,.06);
}
.inp:disabled, .sel:disabled { background: var(--bg-hover); color: var(--text-mute); }
.txt { resize: vertical; min-height: 72px; }
.inp-lg { padding: 12px 15px; font-size: 17px; font-weight: 600; }

.field { margin-bottom: 13px; }
.field > label {
    display: block;
    font-size: 12.5px; font-weight: 700;
    color: var(--text-soft);
    margin-bottom: 5px;
    letter-spacing: .01em;
}
.field-row { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.field-row-3 { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 12px; }

.chk { display: flex; align-items: center; gap: 9px; cursor: pointer; font-weight: 600; padding: 5px 0; }
.chk input { width: 17px; height: 17px; accent-color: var(--primary); cursor: pointer; }

/* ---------- Kartlar ---------- */
.card {
    background: var(--bg-card);
    border: 1px solid var(--line);
    border-radius: var(--radius);
    box-shadow: var(--shadow-sm);
}
.card-pad { padding: 18px; }

.kpi {
    background: var(--bg-card);
    border: 1px solid var(--line);
    border-radius: var(--radius);
    padding: 15px 17px;
    box-shadow: var(--shadow-sm);
}
.kpi-label { font-size: 11.5px; font-weight: 800; color: var(--text-mute); letter-spacing: .05em; text-transform: uppercase; }
.kpi-value { font-size: 25px; font-weight: 900; margin-top: 5px; letter-spacing: -.02em; }
.kpi-sub   { font-size: 12px; color: var(--text-mute); margin-top: 2px; }
.kpi-grid  { display: grid; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); gap: 13px; }

/* ---------- Tablolar ---------- */
.tbl-wrap { overflow: auto; border-radius: var(--radius); border: 1px solid var(--line); background: var(--bg-card); }
table.tbl { width: 100%; border-collapse: collapse; font-size: 13.5px; }
table.tbl thead th {
    position: sticky; top: 0; z-index: 2;
    background: var(--bg-hover);
    padding: 11px 13px;
    text-align: left;
    font-size: 11.5px; font-weight: 800;
    color: var(--text-soft);
    letter-spacing: .04em; text-transform: uppercase;
    border-bottom: 1px solid var(--line);
    white-space: nowrap;
}
table.tbl tbody td { padding: 10px 13px; border-bottom: 1px solid var(--line); vertical-align: middle; }
table.tbl tbody tr:last-child td { border-bottom: 0; }
table.tbl tbody tr:hover { background: var(--bg-hover); }
table.tbl tbody tr.sel-row { background: var(--info-bg); }
.tbl-empty { padding: 44px 20px; text-align: center; color: var(--text-mute); }

/* ---------- Rozetler ---------- */
.badge {
    display: inline-flex; align-items: center; gap: 4px;
    padding: 3px 9px; border-radius: 999px;
    font-size: 11.5px; font-weight: 700;
    background: var(--bg-hover); color: var(--text-soft);
    white-space: nowrap;
}
.badge-ok   { background: var(--ok-bg);   color: var(--ok); }
.badge-err  { background: var(--err-bg);  color: var(--err); }
.badge-warn { background: var(--warn-bg); color: var(--warn); }
.badge-info { background: var(--info-bg); color: var(--info); }

/* ---------- Sekmeler ---------- */
.tabs { display: flex; gap: 5px; flex-wrap: wrap; border-bottom: 1px solid var(--line); padding-bottom: 0; }
.tab {
    padding: 9px 15px;
    border: 0; border-bottom: 2.5px solid transparent;
    background: none; color: var(--text-mute);
    font: inherit; font-weight: 700;
    cursor: pointer; white-space: nowrap;
}
.tab:hover  { color: var(--text); }
.tab.active { color: var(--primary); border-bottom-color: var(--primary); }

.seg { display: inline-flex; background: var(--bg-hover); border-radius: var(--radius-sm); padding: 3px; gap: 2px; }
.seg button {
    padding: 6px 13px; border: 0; border-radius: 8px;
    background: none; color: var(--text-soft);
    font: inherit; font-weight: 700; font-size: 13px; cursor: pointer; white-space: nowrap;
}
.seg button.active { background: var(--bg-elevated); color: var(--text); box-shadow: var(--shadow-sm); }

/* ---------- Uygulama düzeni ---------- */
/* Uygulama her zaman ekranın tamamını kaplar.
   .app-shell'e flex:1 verilmezse içerik genişliğinde kalıp sağda boşluk bırakır. */
#app {
    width: 100%;
    height: 100vh;
    height: 100dvh;          /* mobilde adres çubuğu payı */
    display: flex;
    overflow: hidden;
}
.app-shell {
    flex: 1 1 auto;
    width: 100%;
    min-width: 0;
    height: 100%;
    display: flex;
    overflow: hidden;
}

.sidebar {
    width: var(--sidebar-w);
    flex-shrink: 0;
    background: var(--bg-elevated);
    border-right: 1px solid var(--line);
    display: flex; flex-direction: column;
    overflow: hidden;
}
.sidebar-brand {
    padding: 17px 18px;
    border-bottom: 1px solid var(--line);
    display: flex; align-items: center; gap: 11px;
}
.sidebar-brand .logo {
    width: 40px; height: 40px; flex-shrink: 0;
    border-radius: 11px;
    background: linear-gradient(135deg, var(--primary-from), var(--primary));
    color: #fff;
    display: grid; place-items: center;
    font-size: 20px;
    overflow: hidden;
}
.sidebar-brand .logo img { width: 100%; height: 100%; object-fit: cover; }
.sidebar-brand .name { font-size: 14.5px; font-weight: 900; letter-spacing: -.01em; }
.sidebar-brand .ver  { font-size: 10.5px; font-weight: 700; color: var(--accent); letter-spacing: .06em; }

.sidebar-nav { flex: 1; overflow-y: auto; padding: 9px; }
.nav-item {
    display: flex; align-items: center; gap: 11px;
    padding: 10px 12px; margin-bottom: 2px;
    border-radius: var(--radius-sm);
    cursor: pointer;
    font-weight: 600; color: var(--text-soft);
    user-select: none;
    transition: background .12s, color .12s;
}
.nav-item:hover  { background: var(--bg-hover); color: var(--text); }
.nav-item.active {
    background: linear-gradient(135deg, var(--primary-from), var(--primary));
    color: #fff;
}
.nav-item .ico  { font-size: 17px; width: 21px; text-align: center; flex-shrink: 0; }
.nav-item .lbl  { flex: 1; }
.nav-badge {
    min-width: 20px; padding: 1px 6px;
    border-radius: 999px; background: var(--err); color: #fff;
    font-size: 11px; font-weight: 800; text-align: center;
}
.nav-item.active .nav-badge { background: rgba(255,255,255,.25); }

.sidebar-user {
    border-top: 1px solid var(--line);
    padding: 12px;
    display: flex; align-items: center; gap: 10px;
}
.avatar {
    width: 36px; height: 36px; border-radius: 10px; flex-shrink: 0;
    background: linear-gradient(135deg, var(--accent-from), var(--accent));
    color: #fff; display: grid; place-items: center; font-weight: 800;
}

.main {
    flex: 1;
    display: flex; flex-direction: column;
    overflow: hidden;
    min-width: 0;
}
.page {
    flex: 1;
    overflow-y: auto;
    padding: 20px 22px 40px;
}
.page-head { margin-bottom: 18px; display: flex; align-items: flex-start; gap: 14px; flex-wrap: wrap; }
.page-title { font-size: 21px; font-weight: 900; letter-spacing: -.02em; }
.page-sub   { font-size: 13px; color: var(--text-mute); margin-top: 2px; }
.page-actions { margin-left: auto; display: flex; gap: 8px; flex-wrap: wrap; }
.toolbar { display: flex; gap: 9px; flex-wrap: wrap; align-items: center; margin-bottom: 15px; }

/* ---------- Çevrimdışı çubuğu ---------- */
.offline-bar {
    padding: 8px 16px;
    font-weight: 700; font-size: 13px;
    display: flex; align-items: center; justify-content: center; gap: 10px;
    flex-shrink: 0;
}
.offline-bar.off  { background: var(--err);  color: #fff; }
.offline-bar.sync { background: var(--warn); color: #3b2600; }

/* ---------- Modal ---------- */
.modal-back {
    position: fixed; inset: 0; z-index: 100;
    background: rgba(15,15,20,.45);
    backdrop-filter: blur(3px);
    display: flex; align-items: center; justify-content: center;
    padding: 22px;
    animation: fadeIn .12s ease;
}
.modal {
    background: var(--bg-elevated);
    border-radius: 18px;
    box-shadow: 0 20px 60px rgba(0,0,0,.28);
    width: 100%; max-width: 560px;
    max-height: 92vh;
    display: flex; flex-direction: column;
    overflow: hidden;
    animation: popIn .15s cubic-bezier(.2,.9,.3,1.2);
}
.modal-lg { max-width: 860px; }
.modal-xl { max-width: 1140px; }
.modal-sm { max-width: 420px; }
.modal-head {
    padding: 16px 20px;
    border-bottom: 1px solid var(--line);
    display: flex; align-items: center; gap: 12px;
    flex-shrink: 0;
}
.modal-title { font-size: 16.5px; font-weight: 800; flex: 1; }
.modal-body { padding: 20px; overflow-y: auto; flex: 1; }
.modal-foot {
    padding: 14px 20px;
    border-top: 1px solid var(--line);
    display: flex; gap: 9px; justify-content: flex-end;
    flex-shrink: 0;
    background: var(--bg-hover);
}
.modal-x {
    width: 32px; height: 32px; border-radius: 9px;
    border: 0; background: var(--bg-hover); color: var(--text-soft);
    font-size: 17px; cursor: pointer; flex-shrink: 0;
}
.modal-x:hover { background: var(--err-bg); color: var(--err); }

@keyframes fadeIn { from { opacity: 0 } to { opacity: 1 } }
@keyframes popIn  { from { opacity: 0; transform: scale(.96) translateY(8px) } to { opacity: 1; transform: none } }

/* ---------- Bildirim ---------- */
.toast-wrap {
    position: fixed; bottom: 22px; right: 22px; z-index: 200;
    display: flex; flex-direction: column; gap: 9px;
    pointer-events: none;
}
.toast {
    padding: 12px 18px;
    border-radius: var(--radius-sm);
    background: var(--text);
    color: #fff;
    font-weight: 700;
    box-shadow: 0 10px 32px rgba(0,0,0,.25);
    animation: slideUp .18s ease;
    max-width: 420px;
    pointer-events: auto;
}
.toast.ok   { background: var(--ok); }
.toast.err  { background: var(--err); }
.toast.warn { background: var(--warn); color: #2b1c00; }
@keyframes slideUp { from { opacity: 0; transform: translateY(14px) } to { opacity: 1; transform: none } }

/* ---------- Yükleniyor ---------- */
.spinner {
    width: 17px; height: 17px;
    border: 2.5px solid rgba(0,0,0,.12);
    border-top-color: var(--primary);
    border-radius: 50%;
    animation: spin .7s linear infinite;
    display: inline-block;
}
.spinner-light { border-color: rgba(255,255,255,.3); border-top-color: #fff; }
@keyframes spin { to { transform: rotate(360deg) } }

.loading-box { padding: 44px; text-align: center; color: var(--text-mute); }

/* ---------- Sayfalama ---------- */
.pager { display: flex; gap: 4px; flex-wrap: wrap; align-items: center; margin-top: 14px; justify-content: center; }
.pager button {
    min-width: 34px; padding: 6px 10px;
    border: 1px solid var(--line-strong); border-radius: 8px;
    background: var(--bg-elevated); color: var(--text-soft);
    font: inherit; font-weight: 700; font-size: 13px; cursor: pointer;
}
.pager button:hover:not(:disabled) { background: var(--bg-hover); }
.pager button.active { background: var(--primary); color: #fff; border-color: var(--primary); }
.pager button:disabled { opacity: .4; cursor: not-allowed; }

/* ---------- Giriş ekranı ---------- */
.login-wrap {
    flex: 1;
    height: 100vh; height: 100dvh; width: 100%;
    display: grid; place-items: center;
    background:
        radial-gradient(1100px 520px at 15% -10%, rgba(184,134,11,.10), transparent 60%),
        radial-gradient(900px 460px at 100% 110%, rgba(26,26,26,.10), transparent 60%),
        var(--bg-base);
    padding: 20px;
}
.login-card {
    width: 100%; max-width: 400px;
    background: var(--bg-elevated);
    border-radius: 22px;
    padding: 34px 30px;
    box-shadow: 0 22px 64px rgba(0,0,0,.13);
    border: 1px solid var(--line);
}
.login-logo {
    width: 62px; height: 62px; margin: 0 auto 16px;
    border-radius: 18px;
    background: linear-gradient(135deg, var(--primary-from), var(--primary));
    color: #fff; display: grid; place-items: center; font-size: 30px;
    overflow: hidden;
}
.login-logo img { width: 100%; height: 100%; object-fit: cover; }
.login-title { text-align: center; font-size: 22px; font-weight: 900; letter-spacing: -.02em; }
.login-sub   { text-align: center; color: var(--text-mute); font-size: 13px; margin: 3px 0 24px; }
.login-note  { text-align: center; color: var(--text-mute); font-size: 11.5px; margin-top: 18px; }
.login-err {
    background: var(--err-bg); color: var(--err);
    padding: 10px 13px; border-radius: var(--radius-sm);
    font-size: 13px; font-weight: 600; margin-bottom: 14px;
}

/* ---------- Boş durum ---------- */
.empty { padding: 50px 20px; text-align: center; color: var(--text-mute); }
.empty .ico  { font-size: 42px; opacity: .5; }
.empty .ttl  { font-weight: 800; color: var(--text-soft); margin-top: 10px; font-size: 15px; }
.empty .desc { font-size: 13px; margin-top: 4px; }

/* ---------- Küçük ekran ---------- */

/* Menü düğmesi içeren üst çubuk — yalnızca dar ekranlarda görünür */
.mobile-bar {
    display: none;
    align-items: center;
    gap: 10px;
    padding: 8px 12px;
    background: var(--bg-elevated);
    border-bottom: 1px solid var(--line);
    flex-shrink: 0;
}
.sidebar-backdrop {
    display: none;
    position: fixed; inset: 0; z-index: 55;
    background: rgba(15,15,20,.4);
}

@media (max-width: 1000px) {
    .mobile-bar { display: flex; }
    .sidebar-backdrop { display: block; }

    .sidebar {
        position: fixed; top: 0; left: 0;
        z-index: 60; height: 100%;
        transform: translateX(-100%);
        transition: transform .22s ease;
        box-shadow: var(--shadow);
    }
    .sidebar.open { transform: none; }

    .page { padding: 14px 13px 32px; }
    .page-head { gap: 10px; }
    .page-title { font-size: 18px; }
    .page-actions { margin-left: 0; width: 100%; }
    .page-actions .btn { flex: 1 1 auto; }
    .field-row, .field-row-3 { grid-template-columns: 1fr; }
    .kpi-grid { grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); }
    .modal-back { padding: 10px; }
    .modal { max-height: 94vh; }
}

@media (max-width: 620px) {
    .kpi-value { font-size: 21px; }
    .kpi-grid { grid-template-columns: repeat(2, 1fr); }
    .toolbar > .inp, .toolbar > .sel { max-width: none; width: 100%; }
    .toast-wrap { left: 12px; right: 12px; bottom: 12px; }
    .toast { max-width: none; }
    /* Geniş tablolar kendi içinde yatay kayar; sayfa gövdesi kaymaz */
    .tbl-wrap { overflow-x: auto; -webkit-overflow-scrolling: touch; }
    table.tbl { min-width: 620px; }
}
