/* ============================================================
   StockLedger · Main Stylesheet
   Theme: Industrial Utilitarian — dark sidebar, amber accents
   ============================================================ */

@import url('https://fonts.googleapis.com/css2?family=IBM+Plex+Mono:wght@400;600&family=Syne:wght@400;600;700;800&display=swap');

:root {
  --bg-base:       #0f1117;
  --bg-sidebar:    #0a0c10;
  --surface:       #161b27;
  --surface-2:     #1e2535;
  --border:        #2a3045;
  --border-light:  #1e2535;
  --accent:        #f5a623;
  --accent-dim:    rgba(245,166,35,.12);
  --accent-hover:  #f8b844;
  --text-primary:  #e8ecf4;
  --text-secondary:#9aa3b8;
  --text-muted:    #5a6480;
  --bg-input:      #0f1117;
  --success:       #22c55e;
  --danger:        #ef4444;
  --warning:       #f59e0b;
  --info:          #38bdf8;
  --font-main:     'Syne', sans-serif;
  --font-mono:     'IBM Plex Mono', monospace;
  --sidebar-w:     220px;
  --topbar-h:      56px;
  --radius:        8px;
  --shadow:        0 4px 24px rgba(0,0,0,.4);
}

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

html, body {
  height: 100%;
  font-family: var(--font-main);
  background: var(--bg-base);
  color: var(--text-primary);
  font-size: 15px;
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
}

a { color: var(--accent); text-decoration: none; }
a:hover { color: var(--accent-hover); }

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

/* ── Sidebar ── */
.sidebar {
  width: var(--sidebar-w);
  background: var(--bg-sidebar);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  flex-shrink: 0;
  z-index: 10;
}

.sidebar-brand {
  padding: 1.25rem 1.25rem 1rem;
  border-bottom: 1px solid var(--border);
}
.brand-mark {
  font-size: 1.5rem;
  font-weight: 800;
  color: var(--accent);
  letter-spacing: -1.5px;
  line-height: 1;
}
.brand-sub {
  font-size: .65rem;
  text-transform: uppercase;
  letter-spacing: 2.5px;
  color: var(--text-muted);
  margin-top: 2px;
}

.sidebar-nav {
  padding: 1rem 0;
  flex: 1;
  overflow-y: auto;
}

.nav-label {
  padding: .4rem 1.25rem;
  font-size: .65rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 2px;
  color: var(--text-muted);
}

.nav-item {
  display: flex;
  align-items: center;
  gap: .7rem;
  padding: .6rem 1.25rem;
  color: var(--text-secondary);
  font-size: .875rem;
  font-weight: 600;
  cursor: pointer;
  transition: all .15s;
  border-left: 3px solid transparent;
  text-decoration: none;
}
.nav-item:hover {
  color: var(--text-primary);
  background: rgba(255,255,255,.03);
  border-left-color: var(--border);
}
.nav-item.active {
  color: var(--accent);
  background: var(--accent-dim);
  border-left-color: var(--accent);
}
.nav-item svg { width: 16px; height: 16px; flex-shrink: 0; }

.sidebar-footer {
  padding: 1rem 1.25rem;
  border-top: 1px solid var(--border);
}
.user-info { display: flex; align-items: center; gap: .65rem; }
.user-avatar {
  width: 30px; height: 30px;
  background: var(--accent-dim);
  border: 1px solid var(--accent);
  border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  font-size: .75rem; font-weight: 700; color: var(--accent);
  flex-shrink: 0;
}
.user-name  { font-size: .8rem; font-weight: 600; color: var(--text-primary); }
.user-role  { font-size: .7rem; color: var(--text-muted); text-transform: capitalize; }
.btn-logout {
  display: block; width: 100%; margin-top: .75rem;
  padding: .5rem; text-align: center;
  background: transparent; border: 1px solid var(--border);
  color: var(--text-secondary); font-size: .8rem; font-weight: 600;
  border-radius: 6px; cursor: pointer; transition: all .15s;
  font-family: var(--font-main);
  text-decoration: none;
}
.btn-logout:hover { background: rgba(239,68,68,.1); border-color: var(--danger); color: var(--danger); }

/* ── Main Content ── */
.main-area { flex: 1; display: flex; flex-direction: column; overflow: hidden; }

.topbar {
  height: var(--topbar-h);
  padding: 0 1.75rem;
  display: flex; align-items: center; justify-content: space-between;
  border-bottom: 1px solid var(--border);
  background: var(--bg-base);
  flex-shrink: 0;
}
.topbar-title { font-size: 1.05rem; font-weight: 700; color: var(--text-primary); }
.topbar-actions { display: flex; align-items: center; gap: .75rem; }

.page-content {
  flex: 1;
  overflow-y: auto;
  padding: 1.75rem;
}

/* ── Buttons ── */
.btn {
  display: inline-flex; align-items: center; gap: .4rem;
  padding: .55rem 1.1rem;
  border-radius: var(--radius);
  font-family: var(--font-main);
  font-size: .85rem;
  font-weight: 600;
  cursor: pointer;
  border: none;
  transition: all .15s;
  text-decoration: none;
  white-space: nowrap;
}
.btn-primary   { background: var(--accent); color: #000; }
.btn-primary:hover { background: var(--accent-hover); color: #000; }
.btn-secondary { background: var(--surface-2); color: var(--text-primary); border: 1px solid var(--border); }
.btn-secondary:hover { background: var(--surface); border-color: var(--accent); color: var(--accent); }
.btn-success   { background: rgba(34,197,94,.15); color: var(--success); border: 1px solid rgba(34,197,94,.3); }
.btn-success:hover { background: rgba(34,197,94,.25); }
.btn-danger    { background: rgba(239,68,68,.1); color: var(--danger); border: 1px solid rgba(239,68,68,.25); }
.btn-danger:hover { background: rgba(239,68,68,.2); }
.btn-sm        { padding: .35rem .75rem; font-size: .8rem; }
.btn-xs        { padding: .25rem .6rem; font-size: .75rem; }

/* ── Cards ── */
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 10px;
  overflow: hidden;
}
.card-header {
  padding: 1rem 1.25rem;
  border-bottom: 1px solid var(--border);
  display: flex; align-items: center; justify-content: space-between;
  gap: 1rem;
}
.card-title { font-size: .875rem; font-weight: 700; text-transform: uppercase; letter-spacing: 1px; color: var(--text-secondary); }
.card-body  { padding: 1.25rem; }

/* ── Stats row ── */
.stat-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 1rem;
  margin-bottom: 1.5rem;
}
.stat-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 1.25rem;
  position: relative;
  overflow: hidden;
}
.stat-card::before {
  content: '';
  position: absolute;
  top: 0; left: 0; right: 0;
  height: 3px;
  background: var(--accent);
  opacity: .5;
}
.stat-label { font-size: .72rem; font-weight: 700; text-transform: uppercase; letter-spacing: 1.5px; color: var(--text-muted); margin-bottom: .4rem; }
.stat-value { font-size: 1.75rem; font-weight: 800; color: var(--text-primary); font-family: var(--font-mono); line-height: 1.1; }
.stat-sub   { font-size: .75rem; color: var(--text-muted); margin-top: .25rem; }

/* ── Tables ── */
.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; font-size: .875rem; }
thead th {
  padding: .65rem .9rem;
  text-align: left;
  font-size: .7rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 1px;
  color: var(--text-muted);
  border-bottom: 1px solid var(--border);
  white-space: nowrap;
}
tbody td {
  padding: .7rem .9rem;
  border-bottom: 1px solid var(--border-light);
  color: var(--text-primary);
  vertical-align: middle;
}
tbody tr:last-child td { border-bottom: none; }
tbody tr:hover td { background: rgba(255,255,255,.02); }

/* ── Forms ── */
.form-row { display: flex; gap: 1rem; flex-wrap: wrap; margin-bottom: 1rem; }
.form-group { flex: 1; min-width: 160px; }
.form-group label {
  display: block; font-size: .75rem; font-weight: 700;
  text-transform: uppercase; letter-spacing: 1px;
  color: var(--text-muted); margin-bottom: .35rem;
}
.form-control {
  width: 100%; padding: .6rem .85rem;
  background: var(--bg-input); border: 1px solid var(--border);
  border-radius: var(--radius); color: var(--text-primary);
  font-size: .875rem; font-family: var(--font-main);
  transition: border-color .15s;
}
.form-control:focus { outline: none; border-color: var(--accent); }
.form-control::placeholder { color: var(--text-muted); }
select.form-control { cursor: pointer; }
textarea.form-control { resize: vertical; min-height: 70px; }

/* ── Daily Entry Table ── */
.entry-table { min-width: 900px; }
.entry-table thead th { background: var(--surface-2); }
.entry-table td { padding: .45rem .55rem; }
.entry-table .product-name { font-weight: 600; white-space: nowrap; min-width: 160px; }
.entry-input {
  width: 100%; min-width: 80px; padding: .4rem .6rem;
  background: var(--bg-input); border: 1px solid var(--border);
  border-radius: 5px; color: var(--text-primary); font-size: .875rem;
  font-family: var(--font-mono); text-align: right;
  transition: border-color .15s;
}
.entry-input:focus { outline: none; border-color: var(--accent); }
.closing-cell { font-family: var(--font-mono); font-weight: 600; text-align: right; padding-right: .9rem; }
.closing-cell.negative { color: var(--danger); }
.closing-cell.zero { color: var(--text-muted); }
.row-saved { opacity: .7; }
.row-saved .entry-input { background: rgba(34,197,94,.05); border-color: rgba(34,197,94,.2); cursor: default; }

/* ── Badges ── */
.badge {
  display: inline-block; padding: .2rem .55rem;
  border-radius: 20px; font-size: .72rem; font-weight: 700;
  text-transform: uppercase; letter-spacing: .5px;
}
.badge-active   { background: rgba(34,197,94,.12); color: var(--success); }
.badge-disabled { background: rgba(239,68,68,.1); color: var(--danger); }
.badge-admin    { background: var(--accent-dim); color: var(--accent); }

/* ── Toast ── */
#toast-container { position: fixed; bottom: 1.5rem; right: 1.5rem; z-index: 9999; display: flex; flex-direction: column; gap: .5rem; }
.toast {
  background: var(--surface-2); border: 1px solid var(--border);
  border-radius: 8px; padding: .75rem 1.1rem;
  font-size: .875rem; font-weight: 500;
  box-shadow: var(--shadow);
  display: flex; align-items: center; gap: .5rem;
  animation: slideIn .25s ease;
  max-width: 320px;
}
.toast.success { border-left: 3px solid var(--success); }
.toast.error   { border-left: 3px solid var(--danger); }
.toast.warning { border-left: 3px solid var(--warning); }
.toast.info    { border-left: 3px solid var(--info); }
@keyframes slideIn { from { transform: translateX(20px); opacity: 0; } to { transform: translateX(0); opacity: 1; } }

/* ── Spinner ── */
.spinner {
  width: 16px; height: 16px;
  border: 2px solid var(--border);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin .6s linear infinite;
  display: inline-block;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ── Modal ── */
.modal-overlay {
  position: fixed; inset: 0; background: rgba(0,0,0,.65);
  display: flex; align-items: center; justify-content: center;
  z-index: 1000; opacity: 0; pointer-events: none; transition: opacity .2s;
}
.modal-overlay.open { opacity: 1; pointer-events: all; }
.modal {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: 12px; padding: 1.75rem;
  width: 100%; max-width: 480px;
  transform: translateY(10px); transition: transform .2s;
  box-shadow: var(--shadow);
}
.modal-overlay.open .modal { transform: translateY(0); }
.modal-title { font-size: 1rem; font-weight: 700; margin-bottom: 1.25rem; }
.modal-actions { display: flex; justify-content: flex-end; gap: .75rem; margin-top: 1.5rem; }

/* ── Alert inline ── */
.alert { padding: .7rem 1rem; border-radius: var(--radius); margin-bottom: 1rem; font-size: .85rem; }
.alert-warning { background: rgba(245,158,11,.1); border: 1px solid rgba(245,158,11,.3); color: #fbbf24; }
.alert-success { background: rgba(34,197,94,.1); border: 1px solid rgba(34,197,94,.3); color: #4ade80; }
.alert-danger  { background: rgba(239,68,68,.1); border: 1px solid rgba(239,68,68,.3); color: #f87171; }

/* ── Chart containers ── */
.chart-wrap { position: relative; height: 280px; }

/* ── Misc ── */
.text-muted   { color: var(--text-muted); }
.text-accent  { color: var(--accent); }
.text-success { color: var(--success); }
.text-danger  { color: var(--danger); }
.text-right   { text-align: right; }
.text-center  { text-align: center; }
.mono         { font-family: var(--font-mono); }
.d-flex       { display: flex; }
.align-center { align-items: center; }
.gap-1        { gap: .5rem; }
.gap-2        { gap: 1rem; }
.mb-1         { margin-bottom: .5rem; }
.mb-2         { margin-bottom: 1rem; }
.mb-3         { margin-bottom: 1.5rem; }
.mt-auto      { margin-top: auto; }
.flex-1       { flex: 1; }
.fw-700       { font-weight: 700; }
.empty-state { text-align: center; padding: 3rem 1rem; color: var(--text-muted); font-size: .9rem; }
.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 1.25rem; }
.page-header { display: flex; align-items: center; justify-content: space-between; margin-bottom: 1.5rem; }
.page-title  { font-size: 1.25rem; font-weight: 800; }
.separator   { border: none; border-top: 1px solid var(--border); margin: 1.25rem 0; }

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

/* ── Responsive: collapse sidebar on small screens ── */
@media (max-width: 768px) {
  .sidebar { position: fixed; left: -220px; height: 100%; transition: left .25s; }
  .sidebar.open { left: 0; }
  .main-area { width: 100%; }
}
