/* ============================================================
   MAFIA SUPPLY — Stylesheet
   Tema: Preto profundo + Vermelho
   Fonte: Poppins
   ============================================================ */

/* ---------- Reset & Base ---------- */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
  --bg:         #0a0a0a;
  --surface:    #111111;
  --surface2:   #161616;
  --border:     #1e1e1e;
  --border2:    #2a2a2a;
  --red:        #c0392b;
  --red-hover:  #e74c3c;
  --red-dim:    rgba(192,57,43,0.15);
  --green:      #27ae60;
  --green-dim:  rgba(39,174,96,0.15);
  --yellow:     #f39c12;
  --yellow-dim: rgba(243,156,18,0.15);
  --text:       #f0f0f0;
  --text-muted: #666666;
  --text-sub:   #999999;
  --sidebar-w:  220px;
  --topbar-h:   56px;
  --radius:     8px;
  --radius-sm:  5px;
  --trans:      all .18s ease;
}

html { scroll-behavior: smooth; }

body {
  font-family: 'Poppins', sans-serif;
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
  font-size: 14px;
  line-height: 1.6;
}

a { color: inherit; text-decoration: none; }
button, input, select, textarea { font-family: inherit; }

/* ---------- Scrollbar ---------- */
::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: var(--surface); }
::-webkit-scrollbar-thumb { background: var(--border2); border-radius: 3px; }
::-webkit-scrollbar-thumb:hover { background: var(--red); }

/* ============================================================
   SIDEBAR
   ============================================================ */
.sidebar {
  position: fixed;
  top: 0; left: 0;
  width: var(--sidebar-w);
  height: 100vh;
  background: var(--surface);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  z-index: 200;
  transition: transform .25s ease;
}

.sidebar-logo {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 24px 20px 20px;
  border-bottom: 1px solid var(--border);
}

.logo-icon {
  color: var(--red);
  font-size: 20px;
  line-height: 1;
}

.logo-text {
  font-size: 13px;
  font-weight: 700;
  letter-spacing: 2px;
  color: var(--text);
}

.sidebar-nav {
  flex: 1;
  padding: 16px 0;
  display: flex;
  flex-direction: column;
  gap: 2px;
  overflow-y: auto;
}

.nav-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 20px;
  color: var(--text-muted);
  font-size: 13px;
  font-weight: 500;
  border-left: 3px solid transparent;
  transition: var(--trans);
  cursor: pointer;
}

.nav-item:hover {
  color: var(--text);
  background: var(--surface2);
  border-left-color: var(--border2);
}

.nav-item.active {
  color: var(--red);
  background: var(--red-dim);
  border-left-color: var(--red);
}

.nav-icon {
  font-size: 16px;
  width: 20px;
  text-align: center;
  flex-shrink: 0;
}

.sidebar-bottom {
  padding: 12px 0;
  border-top: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.nav-logout:hover {
  color: var(--red);
  background: var(--red-dim);
  border-left-color: var(--red);
}

/* ---------- Topbar (mobile) ---------- */
.topbar {
  display: none;
  position: fixed;
  top: 0; left: 0; right: 0;
  height: var(--topbar-h);
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  align-items: center;
  padding: 0 16px;
  gap: 12px;
  z-index: 100;
}

.topbar-toggle {
  background: none;
  border: none;
  color: var(--text);
  font-size: 20px;
  cursor: pointer;
  padding: 4px;
  line-height: 1;
}

.topbar-title {
  flex: 1;
  font-size: 14px;
  font-weight: 600;
}

.topbar-user {
  font-size: 12px;
  color: var(--text-muted);
}

.sidebar-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,.7);
  z-index: 150;
}

/* ---------- Main Content ---------- */
.main-content {
  margin-left: var(--sidebar-w);
  min-height: 100vh;
  padding: 32px;
}

/* ============================================================
   TIPOGRAFIA
   ============================================================ */
.page-title {
  font-size: 22px;
  font-weight: 700;
  color: var(--text);
  margin-bottom: 4px;
}

.page-subtitle {
  font-size: 13px;
  color: var(--text-muted);
  margin-bottom: 28px;
}

.section-title {
  font-size: 14px;
  font-weight: 600;
  color: var(--text-sub);
  text-transform: uppercase;
  letter-spacing: 1px;
  margin-bottom: 16px;
}

/* ============================================================
   CARDS / PANELS
   ============================================================ */
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px 24px;
}

.card-sm { padding: 16px 20px; }
.card-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 16px;
}

/* ---------- KPI Cards ---------- */
.kpi-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 16px;
  margin-bottom: 28px;
}

.kpi-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px;
  display: flex;
  flex-direction: column;
  gap: 6px;
  transition: var(--trans);
}

.kpi-card:hover { border-color: var(--border2); }
.kpi-card.accent { border-left: 3px solid var(--red); }
.kpi-card.green  { border-left: 3px solid var(--green); }
.kpi-card.yellow { border-left: 3px solid var(--yellow); }

.kpi-label {
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 1px;
  color: var(--text-muted);
}

.kpi-value {
  font-size: 26px;
  font-weight: 700;
  color: var(--text);
  line-height: 1.2;
}

.kpi-sub {
  font-size: 12px;
  color: var(--text-muted);
}

/* ============================================================
   GRID LAYOUTS
   ============================================================ */
.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 20px; }
.grid-3 { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 20px; }

/* ============================================================
   TABELAS
   ============================================================ */
.table-wrap {
  overflow-x: auto;
  border-radius: var(--radius);
  border: 1px solid var(--border);
}

table {
  width: 100%;
  border-collapse: collapse;
}

thead th {
  background: var(--surface2);
  padding: 12px 16px;
  text-align: left;
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 1px;
  color: var(--text-muted);
  border-bottom: 1px solid var(--border);
  white-space: nowrap;
}

tbody tr {
  border-bottom: 1px solid var(--border);
  transition: var(--trans);
}

tbody tr:last-child { border-bottom: none; }
tbody tr:hover { background: var(--surface2); }

td {
  padding: 12px 16px;
  font-size: 13px;
  vertical-align: middle;
}

.td-right { text-align: right; }
.td-center { text-align: center; }

/* ============================================================
   BADGES / STATUS
   ============================================================ */
.badge {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 3px 10px;
  border-radius: 50px;
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: .5px;
}

.badge-ativo    { background: var(--green-dim);  color: var(--green); }
.badge-vip      { background: var(--red-dim);    color: var(--red); }
.badge-inativo  { background: rgba(100,100,100,.15); color: var(--text-muted); }
.badge-limpo    { background: var(--green-dim);  color: var(--green); }
.badge-sujo     { background: var(--red-dim);    color: var(--red); }
.badge-ok       { background: var(--green-dim);  color: var(--green); }
.badge-alerta   { background: var(--yellow-dim); color: var(--yellow); }
.badge-critico  { background: var(--red-dim);    color: var(--red); }
.badge-pendente { background: var(--yellow-dim); color: var(--yellow); }
.badge-aprovado { background: var(--green-dim);  color: var(--green); }
.badge-rejeitado{ background: var(--red-dim);    color: var(--red); }

/* ============================================================
   BOTÕES
   ============================================================ */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  padding: 9px 18px;
  border-radius: var(--radius-sm);
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  border: none;
  transition: var(--trans);
  line-height: 1;
  white-space: nowrap;
}

.btn-primary {
  background: var(--red);
  color: #fff;
}
.btn-primary:hover { background: var(--red-hover); }

.btn-ghost {
  background: transparent;
  color: var(--text-muted);
  border: 1px solid var(--border2);
}
.btn-ghost:hover { color: var(--text); border-color: var(--text-muted); }

.btn-danger {
  background: transparent;
  color: var(--red);
  border: 1px solid var(--red-dim);
}
.btn-danger:hover { background: var(--red-dim); }

.btn-green {
  background: var(--green);
  color: #fff;
}
.btn-green:hover { background: #2ecc71; }

.btn-sm { padding: 6px 12px; font-size: 12px; }
.btn-icon { padding: 7px; min-width: 32px; justify-content: center; }

/* ============================================================
   INPUTS / FORMS
   ============================================================ */
.form-group { display: flex; flex-direction: column; gap: 6px; margin-bottom: 16px; }
.form-label { font-size: 12px; font-weight: 600; color: var(--text-muted); text-transform: uppercase; letter-spacing: .5px; }

.form-control {
  background: var(--surface2);
  border: 1px solid var(--border2);
  border-radius: var(--radius-sm);
  color: var(--text);
  padding: 9px 12px;
  font-size: 13px;
  width: 100%;
  transition: var(--trans);
  outline: none;
}

.form-control:focus { border-color: var(--red); background: var(--surface); }
.form-control::placeholder { color: var(--text-muted); }

select.form-control { cursor: pointer; }

textarea.form-control { resize: vertical; min-height: 80px; }

/* Input numérico na calculadora */
.qty-input {
  width: 70px;
  text-align: center;
  background: var(--surface2);
  border: 1px solid var(--border2);
  border-radius: var(--radius-sm);
  color: var(--text);
  padding: 7px 8px;
  font-size: 13px;
  font-family: inherit;
  font-weight: 600;
  outline: none;
  transition: var(--trans);
}
.qty-input:focus { border-color: var(--red); }

/* Toggle desconto */
.toggle-wrap { display: flex; align-items: center; gap: 8px; }
.toggle { position: relative; display: inline-block; width: 36px; height: 20px; }
.toggle input { opacity: 0; width: 0; height: 0; }
.toggle-slider {
  position: absolute; inset: 0;
  background: var(--border2);
  border-radius: 20px;
  cursor: pointer;
  transition: var(--trans);
}
.toggle-slider::before {
  content: '';
  position: absolute;
  width: 14px; height: 14px;
  left: 3px; top: 3px;
  background: var(--text-muted);
  border-radius: 50%;
  transition: var(--trans);
}
.toggle input:checked + .toggle-slider { background: var(--red-dim); }
.toggle input:checked + .toggle-slider::before {
  transform: translateX(16px);
  background: var(--red);
}

/* ============================================================
   MODAL
   ============================================================ */
.modal-backdrop {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,.8);
  z-index: 500;
  align-items: center;
  justify-content: center;
}
.modal-backdrop.open { display: flex; }

.modal {
  background: var(--surface);
  border: 1px solid var(--border2);
  border-radius: var(--radius);
  padding: 28px 32px;
  width: 100%;
  max-width: 480px;
  animation: fadeUp .2s ease;
}

@keyframes fadeUp {
  from { opacity: 0; transform: translateY(16px); }
  to   { opacity: 1; transform: translateY(0); }
}

.modal-title {
  font-size: 17px;
  font-weight: 700;
  margin-bottom: 6px;
}
.modal-sub {
  font-size: 12px;
  color: var(--text-muted);
  margin-bottom: 20px;
}
.modal-actions {
  display: flex;
  gap: 10px;
  justify-content: flex-end;
  margin-top: 20px;
}

/* ============================================================
   CALCULADORA
   ============================================================ */
.calc-table td { padding: 8px 12px; }
.calc-table thead th { padding: 11px 12px; }

.subtotal-cell {
  font-weight: 600;
  color: var(--red);
  min-width: 100px;
  text-align: right;
}

.total-row td {
  background: var(--surface2);
  border-top: 1px solid var(--border2) !important;
  font-weight: 700;
}

.total-label {
  text-align: right;
  font-size: 13px;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 1px;
}

.total-value {
  font-size: 20px;
  font-weight: 700;
  color: var(--red);
  text-align: right;
  padding-right: 16px !important;
}

/* ============================================================
   DETALHES DA VENDA (expansível)
   ============================================================ */
.venda-detail {
  display: none;
  background: var(--surface2);
  padding: 12px 16px;
  border-top: 1px solid var(--border);
}
.venda-detail.open { display: block; }
.venda-detail table { margin: 0; }
.venda-detail thead th { background: transparent; font-size: 10px; }
.venda-detail td { font-size: 12px; padding: 6px 10px; color: var(--text-sub); }

.expand-btn {
  background: none;
  border: none;
  color: var(--text-muted);
  cursor: pointer;
  font-size: 16px;
  padding: 2px 6px;
  transition: var(--trans);
  line-height: 1;
}
.expand-btn:hover { color: var(--text); }
.expand-btn.open { transform: rotate(90deg); color: var(--red); }

/* ============================================================
   ALERTAS / TOAST
   ============================================================ */
.toast-container {
  position: fixed;
  bottom: 24px;
  right: 24px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  z-index: 999;
}

.toast {
  background: var(--surface);
  border: 1px solid var(--border2);
  border-left: 3px solid var(--red);
  border-radius: var(--radius-sm);
  padding: 12px 16px;
  font-size: 13px;
  min-width: 260px;
  animation: slideIn .2s ease;
  display: flex;
  align-items: center;
  gap: 10px;
}

.toast.success { border-left-color: var(--green); }
.toast.warning { border-left-color: var(--yellow); }

@keyframes slideIn {
  from { opacity: 0; transform: translateX(30px); }
  to   { opacity: 1; transform: translateX(0); }
}

/* ============================================================
   ESTOQUE
   ============================================================ */
.estoque-bar-wrap {
  display: flex;
  align-items: center;
  gap: 8px;
  min-width: 120px;
}
.estoque-bar {
  flex: 1;
  height: 6px;
  background: var(--border2);
  border-radius: 3px;
  overflow: hidden;
}
.estoque-bar-fill {
  height: 100%;
  border-radius: 3px;
  transition: width .4s ease;
}
.estoque-bar-fill.ok      { background: var(--green); }
.estoque-bar-fill.alerta  { background: var(--yellow); }
.estoque-bar-fill.critico { background: var(--red); }

/* ============================================================
   LOG DE MOVIMENTAÇÕES
   ============================================================ */
.mov-list { display: flex; flex-direction: column; gap: 6px; }
.mov-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 14px;
  background: var(--surface2);
  border-radius: var(--radius-sm);
  font-size: 13px;
  border: 1px solid var(--border);
}
.mov-icon { font-size: 16px; width: 22px; text-align: center; flex-shrink: 0; }
.mov-info { flex: 1; }
.mov-qty { font-weight: 700; white-space: nowrap; }
.mov-qty.entrada { color: var(--green); }
.mov-qty.saida   { color: var(--red); }
.mov-qty.ajuste  { color: var(--yellow); }
.mov-date { font-size: 11px; color: var(--text-muted); }

/* ============================================================
   PERFIL DO CLIENTE
   ============================================================ */
.client-header {
  display: flex;
  align-items: flex-start;
  gap: 20px;
  margin-bottom: 24px;
}
.client-avatar {
  width: 56px; height: 56px;
  background: var(--red-dim);
  border: 2px solid var(--red);
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 22px;
  font-weight: 700;
  color: var(--red);
  flex-shrink: 0;
}
.client-info-main { flex: 1; }
.client-name { font-size: 20px; font-weight: 700; }
.client-gang { font-size: 13px; color: var(--text-muted); margin-top: 2px; }

/* ============================================================
   FILTROS / SEARCH BAR
   ============================================================ */
.filter-bar {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 20px;
  flex-wrap: wrap;
}
.search-input {
  flex: 1;
  min-width: 180px;
  background: var(--surface);
  border: 1px solid var(--border2);
  border-radius: var(--radius-sm);
  color: var(--text);
  padding: 8px 14px;
  font-size: 13px;
  font-family: inherit;
  outline: none;
  transition: var(--trans);
}
.search-input:focus { border-color: var(--red); }
.search-input::placeholder { color: var(--text-muted); }

/* ============================================================
   EMPTY STATE
   ============================================================ */
.empty-state {
  text-align: center;
  padding: 48px 24px;
  color: var(--text-muted);
}
.empty-icon { font-size: 36px; margin-bottom: 12px; opacity: .4; }
.empty-text { font-size: 14px; }

/* ============================================================
   DASHBOARD CHART
   ============================================================ */
.chart-wrap {
  position: relative;
  height: 200px;
}

/* ============================================================
   LOGIN / AUTH PAGES
   ============================================================ */
.auth-page {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--bg);
  padding: 24px;
}

.auth-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 40px 36px;
  width: 100%;
  max-width: 400px;
}

.auth-logo {
  text-align: center;
  margin-bottom: 32px;
}
.auth-logo-icon { font-size: 32px; color: var(--red); display: block; margin-bottom: 8px; }
.auth-logo-text { font-size: 15px; font-weight: 700; letter-spacing: 2px; }
.auth-logo-sub  { font-size: 12px; color: var(--text-muted); margin-top: 4px; }

.auth-footer {
  text-align: center;
  margin-top: 20px;
  font-size: 12px;
  color: var(--text-muted);
}
.auth-footer a { color: var(--red); }
.auth-footer a:hover { color: var(--red-hover); }

/* ============================================================
   UTILIDADES
   ============================================================ */
.mt-0 { margin-top: 0 !important; }
.mt-1 { margin-top: 8px !important; }
.mt-2 { margin-top: 16px !important; }
.mt-3 { margin-top: 24px !important; }
.mb-0 { margin-bottom: 0 !important; }
.mb-1 { margin-bottom: 8px !important; }
.mb-2 { margin-bottom: 16px !important; }
.mb-3 { margin-bottom: 24px !important; }

.flex { display: flex; }
.flex-center { display: flex; align-items: center; }
.flex-between { display: flex; align-items: center; justify-content: space-between; }
.gap-1 { gap: 8px; }
.gap-2 { gap: 16px; }
.gap-3 { gap: 24px; }

.text-red    { color: var(--red) !important; }
.text-green  { color: var(--green) !important; }
.text-yellow { color: var(--yellow) !important; }
.text-muted  { color: var(--text-muted) !important; }
.text-right  { text-align: right; }
.text-center { text-align: center; }
.font-bold   { font-weight: 700; }
.font-mono   { font-family: 'Courier New', monospace; }

.divider {
  border: none;
  border-top: 1px solid var(--border);
  margin: 20px 0;
}

.tag {
  display: inline-block;
  padding: 2px 8px;
  border-radius: 50px;
  font-size: 11px;
  background: var(--surface2);
  color: var(--text-sub);
  border: 1px solid var(--border2);
}

/* ============================================================
   RESPONSIVO
   ============================================================ */
@media (max-width: 900px) {
  .sidebar { transform: translateX(-100%); }
  .sidebar.open { transform: translateX(0); }
  .sidebar-overlay.open { display: block; }
  .main-content { margin-left: 0; padding: 16px; padding-top: calc(var(--topbar-h) + 16px); }
  .topbar { display: flex; }
  .grid-2 { grid-template-columns: 1fr; }
  .grid-3 { grid-template-columns: 1fr; }
  .kpi-grid { grid-template-columns: repeat(2, 1fr); }
}

@media (max-width: 500px) {
  .kpi-grid { grid-template-columns: 1fr; }
  .auth-card { padding: 28px 20px; }
  .filter-bar { flex-direction: column; align-items: stretch; }
}
