/* ============================================================
   QLBH – Global Styles
   ============================================================ */

*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
  --bg:        #0f1117;
  --bg2:       #161b27;
  --bg3:       #1e2535;
  --border:    #2a3147;
  --accent:    #3b82f6;
  --accent-h:  #2563eb;
  --accent-s:  #1e40af;
  --green:     #22c55e;
  --red:       #ef4444;
  --yellow:    #f59e0b;
  --purple:    #a855f7;
  --text:      #e2e8f0;
  --text2:     #94a3b8;
  --text3:     #64748b;
  --radius:    10px;
  --radius-sm: 6px;
  --shadow:    0 4px 24px rgba(0,0,0,.4);
  --sidebar-w: 220px;
  --topbar-h:  56px;
  --trans:     .18s ease;
}

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

/* ── Scrollbar ─────────────────────────────────────────── */
::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--border); border-radius: 99px; }

/* ── LOGIN ─────────────────────────────────────────────── */
.login-page { display: flex; align-items: center; justify-content: center; min-height: 100vh;
  background: radial-gradient(ellipse at 60% 20%, #1a2a4a 0%, #0f1117 70%); }

.login-screen { width: 100%; display: flex; align-items: center; justify-content: center; padding: 24px; }

.login-card {
  background: var(--bg2);
  border: 1px solid var(--border);
  border-radius: 16px;
  padding: 40px 36px;
  width: 100%;
  max-width: 380px;
  box-shadow: var(--shadow);
  text-align: center;
}
.login-logo { font-size: 48px; margin-bottom: 8px; }
.login-title { font-size: 28px; font-weight: 800; color: var(--text); letter-spacing: -0.5px; }
.login-sub { color: var(--text2); margin-bottom: 28px; font-size: 13px; }
.login-form { text-align: left; }
.login-error { color: var(--red); font-size: 13px; margin-top: 10px; text-align: center; }

/* ── APP SHELL ─────────────────────────────────────────── */
.app-shell { display: flex; height: 100vh; overflow: hidden; }

/* ── SIDEBAR ───────────────────────────────────────────── */
.sidebar {
  width: var(--sidebar-w);
  min-width: var(--sidebar-w);
  background: var(--bg2);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  padding: 0;
  overflow-y: auto;
  flex-shrink: 0;
}

.sidebar-brand {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 18px 16px 14px;
  border-bottom: 1px solid var(--border);
}
.brand-icon { font-size: 22px; }
.brand-name { font-size: 18px; font-weight: 800; color: var(--text); letter-spacing: -0.3px; }

.sidebar-nav { flex: 1; padding: 10px 8px; }

.nav-section-label {
  font-size: 10px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.8px;
  color: var(--text3);
  padding: 14px 8px 4px;
}

.nav-link {
  display: flex;
  align-items: center;
  gap: 9px;
  padding: 9px 10px;
  border-radius: var(--radius-sm);
  color: var(--text2);
  text-decoration: none;
  cursor: pointer;
  font-size: 13.5px;
  font-weight: 500;
  transition: background var(--trans), color var(--trans);
  margin-bottom: 2px;
}
.nav-link:hover { background: var(--bg3); color: var(--text); }
.nav-link.active { background: rgba(59,130,246,.15); color: var(--accent); }
.nav-icon { font-size: 16px; width: 20px; text-align: center; }

.sidebar-bottom { padding: 12px 10px; border-top: 1px solid var(--border); }
.user-pill {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 6px;
  border-radius: var(--radius-sm);
  background: var(--bg3);
}
.user-avatar {
  width: 30px; height: 30px;
  border-radius: 50%;
  background: var(--accent);
  color: #fff;
  display: flex; align-items: center; justify-content: center;
  font-weight: 700;
  font-size: 13px;
  flex-shrink: 0;
}
.user-info { flex: 1; min-width: 0; }
.user-name { display: block; font-weight: 600; font-size: 13px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.user-role { display: block; font-size: 11px; color: var(--text3); }
.logout-btn {
  background: none; border: none; color: var(--text3); cursor: pointer;
  font-size: 16px; padding: 2px 4px; border-radius: 4px;
  transition: color var(--trans);
}
.logout-btn:hover { color: var(--red); }

/* ── MAIN AREA ─────────────────────────────────────────── */
.main-area { flex: 1; display: flex; flex-direction: column; min-width: 0; overflow: hidden; }

.topbar {
  height: var(--topbar-h);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 24px;
  border-bottom: 1px solid var(--border);
  background: var(--bg2);
  flex-shrink: 0;
}
.page-heading { font-size: 18px; font-weight: 700; color: var(--text); }
.topbar-date { font-size: 12px; color: var(--text3); }

.page-content { flex: 1; overflow-y: auto; padding: 24px; }

/* ── CARDS & PANELS ────────────────────────────────────── */
.card {
  background: var(--bg2);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px;
  margin-bottom: 20px;
}
.card-title { font-size: 15px; font-weight: 700; margin-bottom: 16px; color: var(--text); }

/* ── STATS ROW ─────────────────────────────────────────── */
.stats-row { display: grid; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); gap: 14px; margin-bottom: 20px; }
.stat-card {
  background: var(--bg2);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 18px;
}
.stat-label { font-size: 12px; color: var(--text3); margin-bottom: 6px; font-weight: 500; }
.stat-value { font-size: 22px; font-weight: 800; color: var(--text); letter-spacing: -0.5px; }
.stat-value.green { color: var(--green); }
.stat-value.blue  { color: var(--accent); }
.stat-value.yellow{ color: var(--yellow); }
.stat-value.red   { color: var(--red); }

/* ── TOOLBAR ───────────────────────────────────────────── */
.toolbar {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
  margin-bottom: 16px;
}
.toolbar-search {
  position: relative; flex: 1; min-width: 200px;
}
.toolbar-search input {
  padding-left: 34px;
}
.toolbar-search .search-icon {
  position: absolute; left: 10px; top: 50%; transform: translateY(-50%);
  color: var(--text3); pointer-events: none;
}

/* ── BUTTONS ───────────────────────────────────────────── */
.btn {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 8px 14px;
  border-radius: var(--radius-sm);
  border: none;
  cursor: pointer;
  font-size: 13.5px;
  font-weight: 600;
  font-family: inherit;
  transition: all var(--trans);
  white-space: nowrap;
  text-decoration: none;
}
.btn-primary   { background: var(--accent); color: #fff; }
.btn-primary:hover { background: var(--accent-h); }
.btn-success   { background: var(--green); color: #fff; }
.btn-success:hover { filter: brightness(1.1); }
.btn-danger    { background: var(--red); color: #fff; }
.btn-danger:hover  { filter: brightness(1.1); }
.btn-warning   { background: var(--yellow); color: #000; }
.btn-ghost     { background: var(--bg3); color: var(--text2); border: 1px solid var(--border); }
.btn-ghost:hover { color: var(--text); border-color: var(--text3); }
.btn-sm        { padding: 5px 10px; font-size: 12.5px; }
.btn-full      { width: 100%; justify-content: center; padding: 11px 14px; }

/* ── FORM FIELDS ───────────────────────────────────────── */
/* Base styles applied to ALL inputs/selects in the app */
input, select, textarea {
  background: var(--bg3);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text);
  padding: 8px 11px;
  font-size: 13.5px;
  font-family: inherit;
  outline: none;
  transition: border-color var(--trans);
  box-sizing: border-box;
}
input:focus, select:focus, textarea:focus { border-color: var(--accent); }
select option { background: var(--bg2); }
textarea { resize: vertical; min-height: 70px; }

.field-group { margin-bottom: 14px; }
.field-group label { display: block; font-size: 12.5px; font-weight: 600; color: var(--text2); margin-bottom: 5px; }
.field-group input,
.field-group select,
.field-group textarea { width: 100%; }

.form-row { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.form-row-3 { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 12px; }

/* ── TABLE ─────────────────────────────────────────────── */
.table-wrap { overflow-x: auto; border-radius: var(--radius); border: 1px solid var(--border); }
table { width: 100%; border-collapse: collapse; }
thead { background: var(--bg3); }
thead th {
  padding: 10px 12px;
  text-align: left;
  font-size: 12px;
  font-weight: 700;
  color: var(--text3);
  text-transform: uppercase;
  letter-spacing: 0.5px;
  white-space: nowrap;
  border-bottom: 1px solid var(--border);
}
tbody tr { border-bottom: 1px solid var(--border); transition: background var(--trans); }
tbody tr:last-child { border-bottom: none; }
tbody tr:hover { background: var(--bg3); }
tbody td { padding: 10px 12px; font-size: 13.5px; color: var(--text); }
.td-actions { display: flex; gap: 6px; }
.td-right { text-align: right; }
.td-center { text-align: center; }

/* ── BADGES ────────────────────────────────────────────── */
.badge {
  display: inline-flex; align-items: center;
  padding: 3px 8px;
  border-radius: 99px;
  font-size: 11.5px;
  font-weight: 600;
}
.badge-green  { background: rgba(34,197,94,.15); color: var(--green); }
.badge-red    { background: rgba(239,68,68,.15); color: var(--red); }
.badge-yellow { background: rgba(245,158,11,.15); color: var(--yellow); }
.badge-blue   { background: rgba(59,130,246,.15); color: var(--accent); }
.badge-gray   { background: var(--bg3); color: var(--text3); }

/* ── MODAL ─────────────────────────────────────────────── */
.modal-backdrop {
  position: fixed; inset: 0; z-index: 1000;
  background: rgba(0,0,0,.65);
  display: flex; align-items: center; justify-content: center;
  padding: 20px;
  backdrop-filter: blur(3px);
  animation: fadeIn .15s ease;
}
.modal-box {
  background: var(--bg2);
  border: 1px solid var(--border);
  border-radius: 14px;
  width: 100%;
  max-width: 640px;
  max-height: 90vh;
  display: flex;
  flex-direction: column;
  box-shadow: var(--shadow);
  animation: slideUp .2s ease;
}
.modal-box.modal-lg { max-width: 900px; }
.modal-box.modal-xl { max-width: 1100px; }
.modal-head {
  display: flex; align-items: center; justify-content: space-between;
  padding: 16px 20px;
  border-bottom: 1px solid var(--border);
}
.modal-title { font-size: 16px; font-weight: 700; }
.modal-close-btn {
  background: none; border: none; color: var(--text3); cursor: pointer;
  font-size: 18px; padding: 2px 6px; border-radius: 4px;
  transition: color var(--trans);
}
.modal-close-btn:hover { color: var(--red); }
.modal-body { padding: 20px; overflow-y: auto; flex: 1; }

/* ── TOAST ─────────────────────────────────────────────── */
.toast-stack { position: fixed; bottom: 24px; right: 24px; z-index: 2000; display: flex; flex-direction: column; gap: 8px; }
.toast {
  background: var(--bg3);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 12px 16px;
  font-size: 13.5px;
  font-weight: 500;
  max-width: 320px;
  box-shadow: var(--shadow);
  animation: slideUp .2s ease;
  display: flex; align-items: center; gap: 8px;
}
.toast.success { border-left: 3px solid var(--green); }
.toast.error   { border-left: 3px solid var(--red); }
.toast.info    { border-left: 3px solid var(--accent); }

/* ── PAGINATION ────────────────────────────────────────── */
.pagination { display: flex; gap: 6px; align-items: center; margin-top: 16px; flex-wrap: wrap; }
.pagination button {
  padding: 5px 10px; border-radius: var(--radius-sm);
  border: 1px solid var(--border);
  background: var(--bg3); color: var(--text2);
  cursor: pointer; font-size: 13px; font-family: inherit;
  transition: all var(--trans);
}
.pagination button:hover { border-color: var(--accent); color: var(--accent); }
.pagination button.active { background: var(--accent); color: #fff; border-color: var(--accent); }
.pagination button:disabled { opacity: 0.4; cursor: not-allowed; }
.pagination-info { color: var(--text3); font-size: 12.5px; }

/* ── EMPTY STATE ───────────────────────────────────────── */
.empty-state {
  text-align: center;
  padding: 60px 20px;
  color: var(--text3);
}
.empty-icon { font-size: 48px; margin-bottom: 12px; }
.empty-msg  { font-size: 15px; font-weight: 500; }

/* ── INVOICE DETAIL TABLE ──────────────────────────────── */
.detail-table-wrap { border: 1px solid var(--border); border-radius: var(--radius-sm); overflow: hidden; margin-bottom: 12px; }
.detail-table-wrap table { min-width: 600px; }
.detail-footer { background: var(--bg3); padding: 12px; border-top: 1px solid var(--border); }

/* ── REPORT CHART AREA ─────────────────────────────────── */
.chart-bar-row { display: flex; align-items: center; gap: 10px; margin-bottom: 8px; }
.chart-bar-label { width: 90px; font-size: 12px; color: var(--text2); text-align: right; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.chart-bar-track { flex: 1; height: 22px; background: var(--bg3); border-radius: 99px; overflow: hidden; }
.chart-bar-fill  { height: 100%; border-radius: 99px; background: linear-gradient(90deg, var(--accent), var(--purple)); transition: width .4s ease; }
.chart-bar-val   { width: 100px; font-size: 12px; color: var(--text2); text-align: right; }

/* Price history table */
.price-tag { display: inline-flex; align-items: center; gap: 4px; font-size: 12px; }
.price-up   { color: var(--red); }
.price-down { color: var(--green); }

/* ── ANIMATIONS ────────────────────────────────────────── */
@keyframes fadeIn  { from { opacity: 0; } to { opacity: 1; } }
@keyframes slideUp { from { transform: translateY(12px); opacity: 0; } to { transform: translateY(0); opacity: 1; } }

/* ── PRINT STYLES ──────────────────────────────────────── */
@media print {
  body { background: #fff; color: #000; font-size: 12px; }
  .no-print { display: none !important; }
  .print-area {
    padding: 0; margin: 0;
    font-family: 'Inter', sans-serif;
  }
}

/* ── UTILS ─────────────────────────────────────────────── */
.text-right  { text-align: right; }
.text-center { text-align: center; }
.text-muted  { color: var(--text3); }
.text-green  { color: var(--green); }
.text-red    { color: var(--red); }
.text-yellow { color: var(--yellow); }
.fw-700 { font-weight: 700; }
.mt-8   { margin-top: 8px; }
.mt-16  { margin-top: 16px; }
.mb-16  { margin-bottom: 16px; }
.gap-8  { gap: 8px; }
.flex   { display: flex; align-items: center; }
.flex-wrap { flex-wrap: wrap; }
.w-full { width: 100%; }
.divider { border: none; border-top: 1px solid var(--border); margin: 16px 0; }

/* ── PRODUCT COMBOBOX ──────────────────────────────────── */
.prod-combo { position: relative; }
.prod-combo-input { width: 100%; }
.prod-combo-dropdown {
  background: var(--bg2);
  border: 1px solid var(--accent);
  border-radius: var(--radius-sm);
  max-height: 220px;
  overflow-y: auto;
  box-shadow: var(--shadow);
}
.prod-combo-item {
  padding: 8px 12px;
  cursor: pointer;
  font-size: 13px;
  border-bottom: 1px solid var(--border);
  transition: background var(--trans);
}
.prod-combo-item:last-child { border-bottom: none; }
.prod-combo-item:hover, .prod-combo-item.active { background: rgba(59,130,246,.15); }
.prod-combo-item .combo-code { font-size: 11px; color: var(--text3); font-family: monospace; }
.prod-combo-item .combo-stock { float: right; font-size: 11px; color: var(--text3); }
.prod-combo-empty { padding: 12px; color: var(--text3); font-size: 13px; text-align: center; }

/* ── SKELETON LOADING ──────────────────────────────────── */
@keyframes shimmer {
  0%   { background-position: -600px 0; }
  100% { background-position:  600px 0; }
}
.skel {
  height: 14px;
  border-radius: 6px;
  background: linear-gradient(90deg,
    var(--bg3) 25%,
    rgba(255,255,255,.06) 50%,
    var(--bg3) 75%);
  background-size: 600px 100%;
  animation: shimmer 1.4s infinite linear;
}
.skel-tbody tr td { padding: 10px 12px; border-bottom: 1px solid var(--border); }
.skel-tbody tr td .skel { width: calc(60% + var(--w, 0px)); }
.skel-tbody tr:nth-child(odd)  td .skel { --w: 30px; }
.skel-tbody tr:nth-child(even) td .skel { --w: -20px; }

/* ── CUSTOMER LOOKUP CARDS ─────────────────────────────── */
.kh-found-card, .kh-new-card {
  display: flex;
  align-items: center;
  padding: 8px 12px;
  border-radius: var(--radius-sm);
  margin: 6px 0 4px;
  gap: 4px;
  font-size: 13px;
}
.kh-found-card { background: rgba(34,197,94,.1); border: 1px solid rgba(34,197,94,.3); }
.kh-new-card   { background: rgba(251,191,36,.08); border: 1px solid rgba(251,191,36,.3); }
.kh-new-card input { background: transparent; border: none; outline: none;
  border-bottom: 1px solid var(--border); color: var(--text1); font-size: 13px; padding: 2px 4px; }
.kh-list { border: 1px solid var(--border); border-radius: var(--radius-sm); overflow: hidden; margin: 6px 0 4px; }
.kh-list-item { display: flex; justify-content: space-between; align-items: center;
  padding: 9px 12px; cursor: pointer; font-size: 13px; border-bottom: 1px solid var(--border);
  transition: background .15s; }
.kh-list-item:last-child { border-bottom: none; }
.kh-list-item:hover { background: var(--bg3); }
