
:root {
  --primary: #6b1d2a;
  --accent: #e8c84a;
  --surface: #f8f8f6;
  --border: #e2e2e2;
  --text: #1a1a1a;
  --text-muted: #6b6b6b;
  --success: #2d7a4f;
  --danger: #c0392b;
  --warning: #d97706;
  --sidebar-w: 220px;
}
* { box-sizing: border-box; margin: 0; padding: 0; }
body { font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Arial, sans-serif; font-size: 14px; color: var(--text); background: var(--surface); height: 100vh; overflow: hidden; }

/* LOGIN */
.login-screen { display: flex; align-items: center; justify-content: center; height: 100vh; background: var(--primary); }
.login-box { background: white; border-radius: 8px; padding: 48px 40px; width: 360px; text-align: center; box-shadow: 0 20px 60px rgba(0,0,0,0.3); }
.login-logo { width: 56px; height: 56px; background: var(--accent); border-radius: 12px; display: flex; align-items: center; justify-content: center; font-size: 28px; font-weight: bold; color: var(--primary); margin: 0 auto 16px; }
.login-box h1 { font-size: 22px; color: var(--primary); margin-bottom: 4px; }
.login-sub { color: var(--text-muted); font-size: 13px; margin-bottom: 28px; }
.login-box input { width: 100%; padding: 10px 14px; border: 1px solid var(--border); border-radius: 4px; font-size: 14px; margin-bottom: 12px; outline: none; }
.login-box input:focus { border-color: var(--primary); }

/* LAYOUT */
#main-app { display: flex; height: 100vh; }
.sidebar { width: var(--sidebar-w); background: var(--primary); display: flex; flex-direction: column; flex-shrink: 0; overflow-y: auto; }
.sidebar-header { padding: 16px; display: flex; align-items: center; justify-content: center; gap: 10px; border-bottom: 1px solid rgba(255,255,255,0.1); min-height: 72px; }
.sidebar-logo { width: 32px; height: 32px; background: var(--accent); border-radius: 6px; display: flex; align-items: center; justify-content: center; font-weight: bold; color: var(--primary); font-size: 16px; flex-shrink: 0; }
.sidebar-title { color: white; font-weight: 600; font-size: 15px; }
.sidebar-nav { flex: 1; padding: 12px 0; }
.nav-section { padding: 16px 16px 4px; font-size: 9px; letter-spacing: 1.5px; color: rgba(255,255,255,0.35); }
.nav-item { display: flex; align-items: center; gap: 10px; padding: 9px 16px; color: rgba(255,255,255,0.7); text-decoration: none; font-size: 13px; border-left: 3px solid transparent; transition: all 0.15s; }
.nav-item:hover { background: rgba(255,255,255,0.08); color: white; }
.nav-item.active { background: rgba(255,255,255,0.12); color: var(--accent); border-left-color: var(--accent); }
.nav-icon { font-size: 14px; width: 16px; text-align: center; }
.sidebar-user { padding: 12px 16px; border-top: 1px solid rgba(255,255,255,0.1); display: flex; align-items: center; justify-content: space-between; }
.sidebar-user span { color: rgba(255,255,255,0.6); font-size: 12px; }
.btn-logout { background: none; border: 1px solid rgba(255,255,255,0.2); color: rgba(255,255,255,0.5); padding: 4px 10px; border-radius: 3px; cursor: pointer; font-size: 11px; }
.btn-logout:hover { border-color: var(--accent); color: var(--accent); }
.content { flex: 1; overflow: hidden; display: flex; flex-direction: column; }
.page { height: 100%; overflow-y: auto; padding: 28px 32px; }

/* PAGE HEADER */
.page-header { display: flex; align-items: center; justify-content: space-between; margin-bottom: 24px; }
.page-title { font-size: 20px; font-weight: 700; color: var(--primary); }
.page-actions { display: flex; gap: 10px; }

/* CARDS */
.cards { display: grid; grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); gap: 16px; margin-bottom: 24px; }
.card { background: white; border: 1px solid var(--border); border-radius: 6px; padding: 20px; }
.card-value { font-size: 28px; font-weight: 700; color: var(--primary); }
.card-label { font-size: 12px; color: var(--text-muted); margin-top: 4px; }
.card-accent { border-left: 4px solid var(--accent); }

/* TABLE */
.table-wrap { background: white; border: 1px solid var(--border); border-radius: 6px; overflow: hidden; }
.table-toolbar { padding: 12px 16px; display: flex; gap: 10px; align-items: center; border-bottom: 1px solid var(--border); background: white; }
table.data { width: 100%; border-collapse: collapse; }
table.data th { background: var(--surface); padding: 10px 14px; text-align: left; font-size: 11px; font-weight: 600; letter-spacing: 0.5px; color: var(--text-muted); border-bottom: 1px solid var(--border); white-space: nowrap; }
table.data td { padding: 11px 14px; border-bottom: 1px solid var(--border); vertical-align: middle; }
table.data tr:last-child td { border-bottom: none; }
table.data tr:hover td { background: var(--surface); }
.table-actions { display: flex; gap: 6px; }

/* BUTTONS */
.btn { display: inline-flex; align-items: center; gap: 6px; padding: 8px 16px; border-radius: 4px; font-size: 13px; font-weight: 500; cursor: pointer; border: none; text-decoration: none; transition: all 0.15s; white-space: nowrap; }
.btn-primary { background: var(--primary); color: white; }
.btn-primary:hover { background: #8a2535; }
.btn-accent { background: var(--accent); color: var(--primary); }
.btn-outline { background: white; border: 1px solid var(--border); color: var(--text); }
.btn-outline:hover { border-color: var(--primary); }
.btn-danger { background: var(--danger); color: white; }
.btn-sm { padding: 5px 10px; font-size: 12px; }
.btn-full { width: 100%; justify-content: center; }
.btn-icon { padding: 6px 8px; }

/* BADGES */
.badge { display: inline-block; padding: 2px 8px; border-radius: 3px; font-size: 11px; font-weight: 500; }
.badge-draft { background: #f3f4f6; color: #6b7280; }
.badge-sent { background: #dbeafe; color: #1d4ed8; }
.badge-approved { background: #d1fae5; color: #065f46; }
.badge-rejected { background: #fee2e2; color: #991b1b; }
.badge-invoiced { background: #f3e8ff; color: #6b21a8; }
.badge-pending { background: #fef3c7; color: #92400e; }
.badge-confirmed { background: #d1fae5; color: #065f46; }
.badge-shipped { background: #dbeafe; color: #1d4ed8; }

/* FORMS */
.form-group { margin-bottom: 16px; }
.form-label { display: block; font-size: 11px; font-weight: 600; color: var(--text-muted); margin-bottom: 5px; letter-spacing: 0.3px; }
.form-control { width: 100%; padding: 9px 12px; border: 1px solid var(--border); border-radius: 4px; font-size: 14px; outline: none; background: white; }
.form-control:focus { border-color: var(--primary); box-shadow: 0 0 0 2px rgba(26,26,46,0.08); }
.form-row { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
.form-row-3 { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 12px; }
textarea.form-control { resize: vertical; min-height: 80px; }
select.form-control { cursor: pointer; }

/* MODAL */
.modal-overlay { position: fixed; inset: 0; background: rgba(0,0,0,0.5); z-index: 1000; display: flex; align-items: center; justify-content: center; padding: 20px; }
.modal-box { background: white; border-radius: 8px; width: 100%; max-width: 700px; max-height: 90vh; display: flex; flex-direction: column; box-shadow: 0 25px 60px rgba(0,0,0,0.3); }
.modal-box.modal-lg { max-width: 960px; }
.modal-header { display: flex; justify-content: space-between; align-items: center; padding: 18px 24px; border-bottom: 1px solid var(--border); }
.modal-header span { font-size: 16px; font-weight: 600; color: var(--primary); }
.modal-close { background: none; border: none; font-size: 18px; cursor: pointer; color: var(--text-muted); padding: 4px 8px; border-radius: 3px; }
.modal-close:hover { background: var(--surface); }
#modal-content { padding: 24px; overflow-y: auto; flex: 1; }
.modal-footer { padding: 16px 24px; border-top: 1px solid var(--border); display: flex; justify-content: flex-end; gap: 10px; }

/* ALERT */
.alert { padding: 10px 14px; border-radius: 4px; margin-bottom: 12px; font-size: 13px; }
.alert-error { background: #fee2e2; color: var(--danger); border: 1px solid #fca5a5; }
.alert-success { background: #d1fae5; color: var(--success); border: 1px solid #6ee7b7; }
.alert-warn { background: #fef3c7; color: #92400e; border: 1px solid #fcd34d; }

/* TOAST */
#toast-container { position: fixed; bottom: 24px; right: 24px; z-index: 9999; display: flex; flex-direction: column; gap: 8px; }
.toast { padding: 12px 18px; border-radius: 6px; background: var(--primary); color: white; font-size: 13px; box-shadow: 0 4px 12px rgba(0,0,0,0.2); animation: slideIn 0.2s ease; }
.toast-success { background: var(--success); }
.toast-error { background: var(--danger); }
@keyframes slideIn { from { transform: translateX(40px); opacity: 0; } to { transform: translateX(0); opacity: 1; } }

/* SEARCH */
.search-input { padding: 8px 12px; border: 1px solid var(--border); border-radius: 4px; font-size: 13px; outline: none; width: 220px; }
.search-input:focus { border-color: var(--primary); }

/* ITEMS EDITOR (teklif kalemleri) */
.items-table { width: 100%; border-collapse: collapse; margin-bottom: 8px; }
.items-table th { background: var(--surface); padding: 8px; font-size: 11px; text-align: left; border-bottom: 1px solid var(--border); }
.items-table td { padding: 6px 4px; border-bottom: 1px solid var(--border); }
.items-table input, .items-table select { padding: 5px 7px; border: 1px solid var(--border); border-radius: 3px; font-size: 12px; width: 100%; }
.items-total { text-align: right; padding: 12px 0; font-size: 13px; }
.items-total strong { font-size: 16px; color: var(--primary); }

/* MISC */
.empty-state { text-align: center; padding: 60px 20px; color: var(--text-muted); }
.empty-state .empty-icon { font-size: 40px; margin-bottom: 12px; }
.divider { height: 1px; background: var(--border); margin: 20px 0; }
.text-muted { color: var(--text-muted); }
.text-right { text-align: right; }
.text-success { color: var(--success); }
.text-danger { color: var(--danger); }
.text-warning { color: var(--warning); }
img.product-thumb { width: 56px; height: 56px; object-fit: cover; border-radius: 6px; border: 1px solid var(--border); }
.product-thumb-placeholder { width: 56px; height: 56px; background: var(--surface); border: 1px solid var(--border); border-radius: 6px; }
.low-stock-badge { display: inline-block; width: 8px; height: 8px; background: var(--danger); border-radius: 50%; margin-right: 4px; }

/* MOBILE RESPONSIVE */
@media (max-width: 768px) {
  :root { --sidebar-w: 0px; }
  .sidebar { position: fixed; left: -260px; width: 260px; height: 100vh; z-index: 900; transition: left 0.25s ease; }
  .sidebar.open { left: 0; }
  .sidebar-overlay { display: none; position: fixed; inset: 0; background: rgba(0,0,0,0.4); z-index: 899; }
  .sidebar-overlay.show { display: block; }
  .content { width: 100%; }
  .page { padding: 58px 12px 24px; }
  .page-header { flex-direction: column; gap: 10px; align-items: stretch; }
  .page-title { font-size: 17px; }
  .page-actions { flex-wrap: wrap; width: 100%; gap: 8px; }
  .page-actions .search-input,
  .page-actions select.form-control { flex: 1 1 120px; min-width: 0; width: auto; }
  .search-input { width: 100%; }
  .form-row, .form-row-3 { grid-template-columns: 1fr; }
  .cards { grid-template-columns: repeat(2, 1fr); gap: 10px; }
  .login-box { width: calc(100% - 32px); padding: 32px 20px; }

  /* Modal — bottom sheet */
  .modal-overlay { padding: 0; align-items: flex-end; }
  .modal-box, .modal-box.modal-lg { max-width: 100%; max-height: 95vh; border-radius: 16px 16px 0 0; }
  #modal-content { padding: 16px; }
  .modal-footer { padding: 12px 16px; }

  /* Table toolbar */
  .table-toolbar { flex-wrap: wrap; gap: 8px; }

  /* Toast — bottom center */
  #toast-container { left: 12px; right: 12px; bottom: 12px; align-items: stretch; }

  .mobile-menu-btn { display: flex !important; }
  .sidebar-user { flex-direction: column; gap: 8px; align-items: flex-start; }

  /* Modal inner tables: keep horizontal scroll */
  #modal-content .table-wrap { overflow-x: auto; }
  #modal-content table.data { min-width: 420px; }
  .items-table { min-width: 700px; }

  /* ── TABLE → CARD dönüşümü (sadece sayfa listeleri) ── */
  .page .table-wrap {
    overflow-x: visible;
    background: transparent;
    border: none;
    border-radius: 0;
    box-shadow: none;
  }
  .page table.data:not(.items-table) { min-width: 0; border: none; background: transparent; }
  .page table.data:not(.items-table) thead { display: none; }
  .page table.data:not(.items-table),
  .page table.data:not(.items-table) tbody { display: block; }

  .page table.data:not(.items-table) tr {
    display: block;
    background: white;
    border: 1px solid var(--border);
    border-radius: 10px;
    margin-bottom: 10px;
    overflow: hidden;
    box-shadow: 0 1px 4px rgba(0,0,0,0.06);
  }
  .page table.data:not(.items-table) tr:last-child { margin-bottom: 0; }
  .page table.data:not(.items-table) tr:hover td { background: unset; }

  .page table.data:not(.items-table) td {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 9px 14px;
    border-bottom: 1px solid rgba(0,0,0,0.07);
    min-height: 38px;
    gap: 8px;
    text-align: right;
    vertical-align: unset;
  }
  .page table.data:not(.items-table) td:last-child { border-bottom: none; }

  /* Etiketli hücreler */
  .page table.data:not(.items-table) td[data-label]::before {
    content: attr(data-label);
    font-size: 11px;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.4px;
    font-weight: 600;
    flex-shrink: 0;
    text-align: left;
    min-width: 76px;
  }

  /* Etiketsiz hücreler (boş durum satırı vb.) */
  .page table.data:not(.items-table) td:not([data-label]):not(.table-actions) {
    justify-content: center;
  }

  /* Aksiyon hücresi — kart altı, gri zemin */
  .page table.data:not(.items-table) td.table-actions {
    justify-content: flex-end;
    flex-wrap: wrap;
    gap: 6px;
    padding: 10px 14px;
    background: var(--surface);
    border-bottom: none;
  }
  .page table.data:not(.items-table) td.table-actions::before { display: none; }
  .table-actions { flex-direction: row; flex-wrap: wrap; gap: 6px; justify-content: flex-end; }
}

@media (min-width: 769px) {
  .mobile-menu-btn { display: none !important; }
  .sidebar-overlay { display: none !important; }
}

@media (max-width: 400px) {
  .cards { grid-template-columns: 1fr 1fr; }
  .btn-sm { padding: 5px 8px; font-size: 11px; }
}
