/* =============================================================
   Barkodlu Market Yönetim Sistemi - Genel Stil
   ============================================================= */

:root {
    --bg: #f1f5f9;
    --surface: #ffffff;
    --border: #e2e8f0;
    --text: #0f172a;
    --text-soft: #64748b;
    --primary: #16a34a;
    --primary-dark: #15803d;
    --accent: #2563eb;
    --danger: #dc2626;
    --warning: #d97706;
    --sidebar-bg: #0f172a;
    --sidebar-text: #cbd5e1;
    --radius: 12px;
    --shadow: 0 1px 3px rgba(15, 23, 42, .08), 0 4px 14px rgba(15, 23, 42, .06);
}

* { box-sizing: border-box; margin: 0; padding: 0; }

body {
    font-family: 'Segoe UI', system-ui, -apple-system, sans-serif;
    background: var(--bg);
    color: var(--text);
    font-size: 14px;
}

.hidden { display: none !important; }

/* ---------- Giriş ekranı ---------- */
.login-wrap {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    background: linear-gradient(135deg, #0f172a 0%, #1e3a2f 100%);
    padding: 20px;
}
.login-card {
    background: var(--surface);
    border-radius: 18px;
    padding: 40px 36px;
    width: 100%;
    max-width: 380px;
    box-shadow: 0 25px 60px rgba(0, 0, 0, .35);
    text-align: center;
}
.login-logo { font-size: 44px; margin-bottom: 8px; }
.login-card h1 { font-size: 22px; margin-bottom: 4px; }
.login-sub { color: var(--text-soft); font-size: 13px; margin-bottom: 24px; }
.login-card label { display: block; text-align: left; font-size: 13px; font-weight: 600; margin-bottom: 14px; color: var(--text-soft); }
.login-card input { width: 100%; margin-top: 6px; }
.form-error { color: var(--danger); font-size: 13px; margin-top: 12px; min-height: 18px; }

/* ---------- Uygulama iskeleti ---------- */
.app { display: flex; min-height: 100vh; }

.sidebar {
    width: 240px;
    background: var(--sidebar-bg);
    color: var(--sidebar-text);
    display: flex;
    flex-direction: column;
    position: sticky;
    top: 0;
    height: 100vh;
    flex-shrink: 0;
}
.sidebar-brand { display: flex; gap: 10px; align-items: center; padding: 20px 18px; border-bottom: 1px solid #1e293b; }
.brand-icon { font-size: 28px; }
.brand-name { color: #fff; font-weight: 700; font-size: 15px; line-height: 1.2; }
.brand-sub { font-size: 11px; color: #64748b; }

.nav { flex: 1; padding: 14px 10px; overflow-y: auto; }
.nav-item {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px 12px;
    border-radius: 10px;
    color: var(--sidebar-text);
    text-decoration: none;
    font-size: 14px;
    margin-bottom: 4px;
    transition: background .15s;
}
.nav-item span { font-size: 16px; width: 22px; text-align: center; }
.nav-item:hover { background: #1e293b; color: #fff; }
.nav-item.active { background: var(--primary); color: #fff; font-weight: 600; }
.nav-ai { border: 1px dashed #334155; }

.sidebar-footer { padding: 14px; border-top: 1px solid #1e293b; }
.user-chip { display: flex; gap: 10px; align-items: center; margin-bottom: 12px; }
.user-avatar {
    width: 36px; height: 36px; border-radius: 50%;
    background: var(--primary); color: #fff;
    display: flex; align-items: center; justify-content: center;
    font-weight: 700; flex-shrink: 0;
}
.user-name { color: #fff; font-size: 13px; font-weight: 600; }
.user-role { font-size: 11px; color: #64748b; }

.main { flex: 1; display: flex; flex-direction: column; min-width: 0; }

.topbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 16px 24px;
    background: var(--surface);
    border-bottom: 1px solid var(--border);
    position: sticky;
    top: 0;
    z-index: 10;
}
.topbar h2 { font-size: 18px; }
.topbar-date { color: var(--text-soft); font-size: 13px; }

.view { padding: 24px; flex: 1; }

/* ---------- Bileşenler ---------- */
.btn {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    border: none;
    border-radius: 10px;
    padding: 9px 16px;
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    text-decoration: none;
    transition: filter .15s, background .15s;
    font-family: inherit;
}
.btn:hover { filter: brightness(1.08); }
.btn:disabled { opacity: .55; cursor: not-allowed; }
.btn-primary { background: var(--primary); color: #fff; }
.btn-accent { background: var(--accent); color: #fff; }
.btn-danger { background: var(--danger); color: #fff; }
.btn-warn { background: var(--warning); color: #fff; }
.btn-light { background: #e2e8f0; color: var(--text); }
.btn-ghost { background: transparent; color: var(--sidebar-text); border: 1px solid #334155; }
.btn-block { width: 100%; justify-content: center; }
.btn-sm { padding: 5px 10px; font-size: 12px; border-radius: 8px; }

.card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    padding: 18px;
    margin-bottom: 18px;
}
.card-title { font-size: 15px; font-weight: 700; margin-bottom: 14px; display: flex; align-items: center; justify-content: space-between; gap: 10px; }

input, select, textarea {
    padding: 9px 12px;
    border: 1px solid var(--border);
    border-radius: 10px;
    font-size: 14px;
    font-family: inherit;
    background: #fff;
    color: var(--text);
    outline: none;
    transition: border-color .15s, box-shadow .15s;
}
input:focus, select:focus, textarea:focus { border-color: var(--primary); box-shadow: 0 0 0 3px rgba(22, 163, 74, .15); }
label.field { display: block; font-size: 13px; font-weight: 600; color: var(--text-soft); margin-bottom: 12px; }
label.field input, label.field select, label.field textarea { width: 100%; margin-top: 5px; }

.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.grid-3 { display: grid; grid-template-columns: repeat(3, 1fr); gap: 12px; }

/* ---------- İstatistik kartları ---------- */
.stat-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); gap: 14px; margin-bottom: 18px; }
.stat-card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    padding: 16px;
    display: flex;
    flex-direction: column;
    gap: 6px;
}
.stat-card .stat-label { font-size: 12px; color: var(--text-soft); font-weight: 600; text-transform: uppercase; letter-spacing: .3px; }
.stat-card .stat-value { font-size: 22px; font-weight: 800; }
.stat-card .stat-sub { font-size: 12px; color: var(--text-soft); }
.stat-green .stat-value { color: var(--primary); }
.stat-red .stat-value { color: var(--danger); }
.stat-blue .stat-value { color: var(--accent); }

/* ---------- Tablolar ---------- */
.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; }
th, td { padding: 10px 12px; text-align: left; border-bottom: 1px solid var(--border); white-space: nowrap; }
th { font-size: 12px; text-transform: uppercase; letter-spacing: .3px; color: var(--text-soft); background: #f8fafc; position: sticky; top: 0; }
tr:hover td { background: #f8fafc; }
td.num, th.num { text-align: right; font-variant-numeric: tabular-nums; }
.empty-row { text-align: center; color: var(--text-soft); padding: 24px !important; }

.badge { display: inline-block; padding: 3px 10px; border-radius: 999px; font-size: 11px; font-weight: 700; }
.badge-green { background: #dcfce7; color: #15803d; }
.badge-red { background: #fee2e2; color: #b91c1c; }
.badge-blue { background: #dbeafe; color: #1d4ed8; }
.badge-orange { background: #ffedd5; color: #c2410c; }
.badge-gray { background: #e2e8f0; color: #475569; }

/* ---------- Araç çubuğu ---------- */
.toolbar { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; margin-bottom: 16px; }
.toolbar input[type="search"] { min-width: 240px; }
.toolbar .spacer { flex: 1; }

/* ---------- Kasa (POS) ---------- */
.pos-layout { display: grid; grid-template-columns: 1fr 380px; gap: 18px; align-items: start; }
.pos-barcode { display: flex; gap: 10px; margin-bottom: 14px; }
.pos-barcode input { flex: 1; font-size: 16px; padding: 12px 14px; }
.pos-barcode #posAddAmount { font-size: 20px; font-weight: 700; line-height: 1; padding: 0 18px; }
.pos-results { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 10px; max-height: 460px; overflow-y: auto; }
.product-tile {
    border: 1px solid var(--border);
    border-radius: 10px;
    padding: 12px;
    cursor: pointer;
    background: #fff;
    transition: border-color .15s, transform .1s;
}
.product-tile:hover { border-color: var(--primary); transform: translateY(-1px); }
.product-tile .pt-name { font-weight: 600; font-size: 13px; margin-bottom: 4px; min-height: 32px; }
.product-tile .pt-price { color: var(--primary); font-weight: 800; }
.product-tile .pt-stock { font-size: 11px; color: var(--text-soft); }
.product-tile.low .pt-stock { color: var(--danger); font-weight: 700; }

.cart-table td { padding: 8px 6px; }
.cart-total-box {
    background: #0f172a;
    color: #fff;
    border-radius: 10px;
    padding: 16px;
    margin-top: 12px;
}
.cart-total-row { display: flex; justify-content: space-between; font-size: 13px; margin-bottom: 6px; color: #cbd5e1; }
.cart-total-row.big { font-size: 20px; font-weight: 800; color: #fff; border-top: 1px solid #334155; padding-top: 10px; margin-top: 10px; }
.pay-buttons { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; margin-top: 12px; }
.pay-buttons .btn-veresiye { grid-column: 1 / -1; }

/* ---------- Modal ---------- */
.modal-backdrop {
    position: fixed;
    inset: 0;
    background: rgba(15, 23, 42, .55);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 100;
    padding: 20px;
}
.modal {
    background: var(--surface);
    border-radius: 14px;
    width: 100%;
    max-width: 520px;
    max-height: 88vh;
    display: flex;
    flex-direction: column;
    box-shadow: 0 25px 60px rgba(0, 0, 0, .35);
}
.modal.wide { max-width: 760px; }
.modal-header { display: flex; align-items: center; justify-content: space-between; padding: 16px 20px; border-bottom: 1px solid var(--border); }
.modal-header h3 { font-size: 16px; }
.modal-close { background: none; border: none; font-size: 16px; cursor: pointer; color: var(--text-soft); }
.modal-body { padding: 20px; overflow-y: auto; }
.modal-actions { display: flex; gap: 10px; justify-content: flex-end; margin-top: 16px; }

/* ---------- Toast ---------- */
.toast {
    position: fixed;
    bottom: 24px;
    left: 50%;
    transform: translateX(-50%) translateY(20px);
    background: #0f172a;
    color: #fff;
    padding: 12px 20px;
    border-radius: 10px;
    font-size: 14px;
    opacity: 0;
    pointer-events: none;
    transition: opacity .25s, transform .25s;
    z-index: 200;
    max-width: 90vw;
}
.toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }
.toast.err { background: var(--danger); }
.toast.ok { background: var(--primary); }

/* ---------- Grafik ---------- */
.chart-box { width: 100%; height: 240px; }
canvas { width: 100%; height: 100%; }

/* ---------- Yapay Zekâ ---------- */
.ai-layout { display: grid; grid-template-columns: 1fr 1fr; gap: 18px; align-items: start; }
.chat-box { display: flex; flex-direction: column; height: 520px; }
.chat-messages { flex: 1; overflow-y: auto; padding: 4px; display: flex; flex-direction: column; gap: 10px; }
.chat-msg { max-width: 82%; padding: 10px 14px; border-radius: 14px; font-size: 14px; line-height: 1.45; white-space: pre-wrap; }
.chat-msg.user { align-self: flex-end; background: var(--primary); color: #fff; border-bottom-right-radius: 4px; }
.chat-msg.bot { align-self: flex-start; background: #f1f5f9; border: 1px solid var(--border); border-bottom-left-radius: 4px; }
.chat-msg.bot .ai-cards { display: flex; gap: 8px; margin-top: 8px; flex-wrap: wrap; }
.chat-msg.bot .ai-card { background: #fff; border: 1px solid var(--border); border-radius: 8px; padding: 6px 10px; font-size: 12px; }
.chat-msg.bot .ai-card b { display: block; font-size: 14px; }
.chat-input { display: flex; gap: 8px; margin-top: 12px; }
.chat-input input { flex: 1; }
.chat-chips { display: flex; gap: 6px; flex-wrap: wrap; margin-top: 10px; }
.chip { background: #e2e8f0; border: none; border-radius: 999px; padding: 6px 12px; font-size: 12px; cursor: pointer; font-family: inherit; }
.chip:hover { background: #cbd5e1; }

.reminder-item { border: 1px solid var(--border); border-radius: 10px; padding: 14px; margin-bottom: 12px; background: #fff; }
.reminder-item .ri-head { display: flex; justify-content: space-between; align-items: center; margin-bottom: 8px; }
.reminder-item .ri-name { font-weight: 700; }
.reminder-item .ri-balance { color: var(--danger); font-weight: 800; }
.reminder-item textarea { width: 100%; min-height: 74px; font-size: 13px; resize: vertical; }
.reminder-actions { display: flex; gap: 8px; margin-top: 8px; align-items: center; }
.reminder-actions select { padding: 6px 10px; }

/* ---------- Fiş (yazdırma) ---------- */
.receipt { font-family: 'Courier New', monospace; font-size: 13px; padding: 10px; }
.receipt .rc-center { text-align: center; }
.receipt hr { border: none; border-top: 1px dashed #94a3b8; margin: 8px 0; }
.receipt table { font-size: 12px; }
.receipt th, .receipt td { border: none; padding: 2px 4px; }

/* ---------- Duyarlılık ---------- */
@media (max-width: 1100px) {
    .pos-layout, .ai-layout { grid-template-columns: 1fr; }
}
@media (max-width: 860px) {
    .app { flex-direction: column; }
    .sidebar { width: 100%; height: auto; position: static; }
    .nav { display: flex; flex-wrap: wrap; }
    .nav-item { margin: 2px; }
    .sidebar-footer { display: flex; align-items: center; gap: 12px; }
    .user-chip { margin-bottom: 0; }
    .grid-2, .grid-3 { grid-template-columns: 1fr; }
}

@media print {
    body * { visibility: hidden; }
    .modal, .modal * { visibility: visible; }
    .modal { position: absolute; left: 0; top: 0; box-shadow: none; max-height: none; }
    .modal-header, .modal-actions { display: none; }
    /* Barkod etiketi yazdırma: yalnızca #printArea içeriği görünür */
    body.print-labels .modal-backdrop { display: none !important; }
    body.print-labels #printArea, body.print-labels #printArea * { visibility: visible; }
    body.print-labels #printArea { position: absolute; left: 0; top: 0; width: 100%; }
}

/* ---------- Kayıt sayfası ---------- */
.login-card-wide { max-width: 520px; }
.form-section-title {
    font-size: 12px; font-weight: 700; text-transform: uppercase; letter-spacing: .04em;
    color: var(--text-soft); margin: 14px 0 10px; padding-top: 12px; border-top: 1px solid var(--border);
}
.form-section-title:first-of-type { border-top: none; margin-top: 4px; padding-top: 0; }
.form-row { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.login-register { margin-top: 16px; font-size: 13px; color: var(--text-soft); }
.login-register a { color: var(--primary); font-weight: 600; text-decoration: none; }
.login-register a:hover { text-decoration: underline; }

/* ---------- Kg / tartı girişi ---------- */
.weight-chips { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 8px; }

/* ---------- Barkod etiketleri ---------- */
.label-preview { margin-bottom: 12px; }
.label-sheet {
    display: grid; grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
    gap: 8px; padding: 8px;
}
.label-item {
    border: 1px dashed #94a3b8; border-radius: 8px; padding: 10px 12px;
    text-align: center; background: #fff; break-inside: avoid;
}
.label-name {
    font-size: 12px; font-weight: 700; color: #111;
    white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.label-price { font-size: 18px; font-weight: 800; color: #111; margin: 2px 0 6px; }
.label-unit { font-size: 12px; font-weight: 600; color: #475569; }
.label-barcode { display: flex; justify-content: center; }
.barcode-svg { width: 100%; max-width: 190px; }
.label-code { font-size: 10px; letter-spacing: .14em; color: #111; margin-top: 2px; font-family: 'Courier New', monospace; }
.label-more { font-size: 12px; color: var(--text-soft); align-self: center; padding: 8px; }
#printArea { position: absolute; left: -9999px; top: 0; }

/* Süper admin nav vurgusu */
.nav-item.nav-admin span { filter: none; }

/* Hızlı yeni ürün oluşturma (mal alışı) */
.quick-add {
    border: 1px dashed var(--border, #d6dbe4);
    background: var(--bg-soft, #f7f9fc);
    border-radius: 10px;
    padding: 12px;
}
.quick-add .qa-title { font-size: 13px; font-weight: 600; margin-bottom: 10px; }
.quick-add .qa-grid {
    display: grid;
    grid-template-columns: 2fr 1.2fr 1fr 1fr auto auto;
    gap: 8px;
    align-items: center;
}
@media (max-width: 900px) {
    .quick-add .qa-grid { grid-template-columns: 1fr 1fr; }
}
.quick-add input, .quick-add select { padding: 8px 10px; }
.quick-add .qa-err { color: var(--danger, #d33); font-size: 12px; margin-top: 6px; min-height: 0; }
