/* =========================================================
   ProHair ERP — style.css
   Design tokens + reset + layout base + componentes globais
   ========================================================= */

:root {
  /* ---- Paleta: charcoal profundo + cobre (identidade "prótese capilar premium") ---- */
  --bg:            #0B0D12;
  --bg-elevated:   #10131B;
  --surface:       #151925;
  --surface-2:     #1C2130;
  --surface-hover: #212739;
  --border:        #262C3D;
  --border-soft:   #1E2330;

  --text:          #EDEFF6;
  --text-dim:      #9199B0;
  --text-faint:    #5B6278;

  --accent:        #C89B6C;   /* cobre — cor principal da marca */
  --accent-soft:   #C89B6C22;
  --accent-strong: #E0B885;
  --accent-ink:    #221708;

  --info:          #7C9CFF;
  --info-soft:     #7C9CFF1F;

  --success:       #34D399;
  --success-soft:  #34D3991F;

  --danger:        #F1596B;
  --danger-soft:   #F1596B1F;

  --warning:       #F5B754;
  --warning-soft:  #F5B7541F;

  --radius-sm: 8px;
  --radius-md: 12px;
  --radius-lg: 18px;

  --shadow-sm: 0 1px 2px rgba(0,0,0,.3);
  --shadow-md: 0 8px 24px -8px rgba(0,0,0,.55);
  --shadow-lg: 0 24px 60px -20px rgba(0,0,0,.65);

  --font-display: 'Sora', sans-serif;
  --font-body: 'Inter', sans-serif;
  --font-mono: 'JetBrains Mono', monospace;

  --sidebar-w: 248px;
  --sidebar-w-collapsed: 76px;
  --topbar-h: 68px;

  --ease: cubic-bezier(.4,0,.2,1);
}

/* Cor principal pode ser sobrescrita dinamicamente via configurações */
[data-accent] { --accent: var(--accent); }

* , *::before, *::after { box-sizing: border-box; }
html { color-scheme: dark; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font-body);
  font-size: 14px;
  -webkit-font-smoothing: antialiased;
  overflow: hidden;
}

h1, h2, h3, h4 { font-family: var(--font-display); margin: 0; color: var(--text); }
p { margin: 0; }
button { font-family: inherit; }
input, select, textarea { font-family: inherit; }

::selection { background: var(--accent-soft); color: var(--accent-strong); }

/* Scrollbars */
* { scrollbar-width: thin; scrollbar-color: var(--surface-2) transparent; }
*::-webkit-scrollbar { width: 8px; height: 8px; }
*::-webkit-scrollbar-thumb { background: var(--surface-2); border-radius: 8px; }
*::-webkit-scrollbar-thumb:hover { background: var(--border); }

/* =========================================================
   APP SHELL
   ========================================================= */
.app-shell {
  display: flex;
  height: 100vh;
  width: 100vw;
}

/* ---------- SIDEBAR ---------- */
.sidebar {
  width: var(--sidebar-w);
  flex-shrink: 0;
  background: var(--bg-elevated);
  border-right: 1px solid var(--border-soft);
  display: flex;
  flex-direction: column;
  padding: 20px 14px;
  transition: width .25s var(--ease);
  position: relative;
  z-index: 20;
}
.app-shell.is-collapsed .sidebar { width: var(--sidebar-w-collapsed); }

.sidebar__brand {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 6px 8px 22px 8px;
}
.brand-mark {
  width: 50px; height: 50px;
  border-radius: 12px;
  background: linear-gradient(135deg, var(--accent), var(--accent-strong));
  color: var(--accent-ink);
  font-family: var(--font-display);
  font-weight: 800;
  font-size: 15px;
  display: flex; align-items: center; justify-content: center;
  flex-shrink: 0;
  box-shadow: 0 4px 14px -4px var(--accent-soft);
  overflow: hidden;
}
.brand-mark.has-logo { background: #000; box-shadow: none; }
.brand-mark__img { width: 100%; height: 100%; object-fit: cover; }
.brand-text { display: flex; flex-direction: column; overflow: hidden; white-space: nowrap; }
.brand-name { font-family: var(--font-display); font-weight: 700; font-size: 15px; }
.brand-sub { font-size: 11px; color: var(--text-faint); }
.app-shell.is-collapsed .brand-text { display: none; }

.sidebar__nav {
  display: flex;
  flex-direction: column;
  gap: 2px;
  flex: 1;
  overflow-y: auto;
}

.nav-item {
  display: flex;
  align-items: center;
  gap: 12px;
  width: 100%;
  padding: 10px 12px;
  border: none;
  background: transparent;
  color: var(--text-dim);
  border-radius: var(--radius-sm);
  cursor: pointer;
  font-size: 13.5px;
  font-weight: 500;
  text-align: left;
  transition: background .15s var(--ease), color .15s var(--ease);
  position: relative;
  white-space: nowrap;
}
.nav-item:hover { background: var(--surface); color: var(--text); }
.nav-item.is-active { background: var(--surface-2); color: var(--accent-strong); }
.nav-item.is-active .nav-icon { color: var(--accent-strong); }
.nav-icon { width: 18px; height: 18px; color: var(--text-faint); flex-shrink: 0; transition: color .15s var(--ease); }
.nav-item:hover .nav-icon { color: var(--text-dim); }
.nav-item span:not(.nav-badge) { overflow: hidden; text-overflow: ellipsis; }
.app-shell.is-collapsed .nav-item span:not(.nav-badge) { display: none; }
.app-shell.is-collapsed .nav-item { justify-content: center; }

.nav-badge {
  margin-left: auto;
  background: var(--danger);
  color: #fff;
  font-size: 10px;
  font-weight: 700;
  padding: 1px 6px;
  border-radius: 10px;
}

.sidebar__collapse {
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text-dim);
  width: 30px; height: 30px;
  border-radius: 8px;
  display: flex; align-items: center; justify-content: center;
  cursor: pointer;
  align-self: flex-end;
  transition: transform .25s var(--ease), background .15s var(--ease);
}
.sidebar__collapse svg { width: 15px; height: 15px; }
.sidebar__collapse:hover { background: var(--surface-hover); }
.app-shell.is-collapsed .sidebar__collapse svg { transform: rotate(180deg); }

/* ---------- MAIN / TOPBAR ---------- */
.main {
  flex: 1;
  display: flex;
  flex-direction: column;
  min-width: 0;
  height: 100vh;
}

.topbar {
  height: var(--topbar-h);
  flex-shrink: 0;
  display: flex;
  align-items: center;
  gap: 16px;
  padding: 0 24px;
  border-bottom: 1px solid var(--border-soft);
  background: rgba(11,13,18,.7);
  backdrop-filter: blur(10px);
}

.topbar__menu-btn {
  display: none;
  background: none; border: none; color: var(--text-dim);
  width: 34px; height: 34px; align-items: center; justify-content: center;
  border-radius: 8px; cursor: pointer;
}
.topbar__menu-btn svg { width: 20px; height: 20px; }

.topbar__search {
  flex: 1;
  max-width: 440px;
  display: flex;
  align-items: center;
  gap: 10px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 0 12px;
  height: 38px;
  transition: border-color .15s var(--ease), box-shadow .15s var(--ease);
}
.topbar__search:focus-within { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
.topbar__search svg { width: 16px; height: 16px; color: var(--text-faint); flex-shrink: 0; }
.topbar__search input {
  flex: 1; background: none; border: none; outline: none;
  color: var(--text); font-size: 13px;
}
.topbar__search input::placeholder { color: var(--text-faint); }
.topbar__search kbd {
  font-family: var(--font-mono); font-size: 10px; color: var(--text-faint);
  border: 1px solid var(--border); border-radius: 4px; padding: 1px 5px;
}

.topbar__actions { display: flex; align-items: center; gap: 10px; margin-left: auto; }

.icon-btn {
  position: relative;
  width: 38px; height: 38px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text-dim);
  display: flex; align-items: center; justify-content: center;
  cursor: pointer;
  transition: background .15s var(--ease), color .15s var(--ease);
}
.icon-btn:hover { background: var(--surface-hover); color: var(--text); }
.icon-btn svg { width: 17px; height: 17px; }
.icon-btn__dot {
  position: absolute; top: 7px; right: 8px;
  width: 7px; height: 7px; border-radius: 50%;
  background: var(--danger);
  box-shadow: 0 0 0 2px var(--surface);
}

/* ---------- CONTENT / VIEWS ---------- */
.content {
  flex: 1;
  overflow-y: auto;
  padding: 24px 28px 60px;
  position: relative;
}

.view { display: none; animation: viewIn .28s var(--ease); }
.view.is-active { display: block; }
@keyframes viewIn {
  from { opacity: 0; transform: translateY(6px); }
  to { opacity: 1; transform: translateY(0); }
}

.view-loading { color: var(--text-faint); font-size: 13px; padding: 40px 0; text-align: center; }

/* ---------- PAGE HEADER (usado por todos os módulos) ---------- */
.page-header {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 22px;
  flex-wrap: wrap;
}
.page-header h1 { font-size: 21px; font-weight: 700; }
.page-header .page-sub { color: var(--text-faint); font-size: 12.5px; margin-top: 4px; }
.page-header__actions { display: flex; gap: 10px; align-items: center; }

/* =========================================================
   COMPONENTES GLOBAIS
   ========================================================= */

/* ---- Botões ---- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  height: 38px; padding: 0 16px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text);
  font-size: 13px; font-weight: 600;
  cursor: pointer;
  transition: all .15s var(--ease);
  white-space: nowrap;
}
.btn svg { width: 15px; height: 15px; }
.btn:hover { background: var(--surface-hover); }
.btn:active { transform: translateY(1px); }
.btn--primary { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
.btn--primary:hover { background: var(--accent-strong); border-color: var(--accent-strong); }
.btn--ghost { background: transparent; border-color: transparent; color: var(--text-dim); }
.btn--ghost:hover { background: var(--surface); color: var(--text); }
.btn--danger { background: var(--danger-soft); border-color: var(--danger); color: var(--danger); }
.btn--danger:hover { background: var(--danger); color: #fff; }
.btn--sm { height: 32px; padding: 0 12px; font-size: 12px; }
.btn--icon { width: 34px; padding: 0; }
.btn:disabled { opacity: .5; cursor: not-allowed; }

/* ---- Cards ---- */
.card {
  background: var(--surface);
  border: 1px solid var(--border-soft);
  border-radius: var(--radius-lg);
  padding: 20px;
  transition: border-color .2s var(--ease), transform .2s var(--ease);
}
.card--interactive:hover { border-color: var(--border); transform: translateY(-2px); }

/* ---- Grid utilitário ---- */
.grid { display: grid; gap: 16px; }
.grid-2 { grid-template-columns: repeat(2, 1fr); }
.grid-3 { grid-template-columns: repeat(3, 1fr); }
.grid-4 { grid-template-columns: repeat(4, 1fr); }

/* ---- Formulários ---- */
.field { display: flex; flex-direction: column; gap: 6px; }
.field label { font-size: 12px; font-weight: 600; color: var(--text-dim); }
.field .hint { font-size: 11px; color: var(--text-faint); }
.input, select.input, textarea.input {
  height: 40px;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 0 12px;
  color: var(--text);
  font-size: 13.5px;
  outline: none;
  transition: border-color .15s var(--ease), box-shadow .15s var(--ease);
  width: 100%;
}
textarea.input { height: auto; padding: 10px 12px; resize: vertical; min-height: 72px; }
.input:focus { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
.input::placeholder { color: var(--text-faint); }
.form-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 14px 16px; }
.form-grid--3 { grid-template-columns: repeat(3, 1fr); }
.form-actions { display: flex; justify-content: flex-end; gap: 10px; margin-top: 18px; padding-top: 16px; border-top: 1px solid var(--border-soft); }

/* ---- Badges / Status ---- */
.badge {
  display: inline-flex; align-items: center; gap: 5px;
  font-size: 11px; font-weight: 700; text-transform: uppercase; letter-spacing: .03em;
  padding: 3px 9px; border-radius: 20px;
}
.badge::before { content: ''; width: 6px; height: 6px; border-radius: 50%; background: currentColor; }
.badge--ok { color: var(--success); background: var(--success-soft); }
.badge--warn { color: var(--warning); background: var(--warning-soft); }
.badge--danger { color: var(--danger); background: var(--danger-soft); }
.badge--info { color: var(--info); background: var(--info-soft); }

/* ---- Tabelas ---- */
.table-wrap {
  border: 1px solid var(--border-soft);
  border-radius: var(--radius-lg);
  overflow: hidden;
  background: var(--surface);
}
.table-toolbar {
  display: flex; align-items: center; gap: 10px; flex-wrap: wrap;
  padding: 14px 16px;
  border-bottom: 1px solid var(--border-soft);
}
.table-toolbar .search-mini {
  display: flex; align-items: center; gap: 8px;
  background: var(--surface-2); border: 1px solid var(--border);
  border-radius: var(--radius-sm); padding: 0 10px; height: 34px; flex: 1; max-width: 320px;
}
.table-toolbar .search-mini svg { width: 14px; height: 14px; color: var(--text-faint); }
.table-toolbar .search-mini input { background: none; border: none; outline: none; color: var(--text); font-size: 12.5px; width: 100%; }
.table-toolbar .spacer { flex: 1; }

table.data-table { width: 100%; border-collapse: collapse; font-size: 13px; }
.data-table thead th {
  text-align: left;
  font-size: 11px; text-transform: uppercase; letter-spacing: .04em;
  color: var(--text-faint); font-weight: 700;
  padding: 10px 16px;
  border-bottom: 1px solid var(--border-soft);
  background: var(--bg-elevated);
  cursor: pointer;
  user-select: none;
  white-space: nowrap;
}
.data-table thead th:hover { color: var(--text-dim); }
.data-table thead th .sort-arrow { margin-left: 4px; opacity: .4; font-size: 10px; }
.data-table thead th.is-sorted .sort-arrow { opacity: 1; color: var(--accent-strong); }
.data-table tbody td { padding: 11px 16px; border-bottom: 1px solid var(--border-soft); color: var(--text); vertical-align: middle; }
.data-table tbody tr:last-child td { border-bottom: none; }
.data-table tbody tr { transition: background .12s var(--ease); }
.data-table tbody tr:hover { background: var(--surface-hover); }
.data-table .num { font-family: var(--font-mono); font-variant-numeric: tabular-nums; }
.data-table .row-actions { display: flex; gap: 6px; justify-content: flex-end; }
.table-empty { padding: 46px 20px; text-align: center; color: var(--text-faint); font-size: 13px; }

.pagination { display: flex; align-items: center; justify-content: space-between; padding: 12px 16px; border-top: 1px solid var(--border-soft); }
.pagination .info { font-size: 12px; color: var(--text-faint); }
.pagination .controls { display: flex; gap: 6px; }

/* ---- Modal ---- */
.modal-overlay {
  position: fixed; inset: 0; background: rgba(4,5,8,.6);
  backdrop-filter: blur(3px);
  display: flex; align-items: center; justify-content: center;
  z-index: 100;
  animation: fadeIn .18s var(--ease);
}
.modal-overlay[hidden] { display: none; }
@keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }
.modal {
  width: 460px; max-width: calc(100vw - 32px);
  max-height: calc(100vh - 64px);
  overflow-y: auto;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-lg);
  animation: modalIn .22s var(--ease);
}
.modal--wide { width: 640px; }
@keyframes modalIn { from { opacity: 0; transform: translateY(10px) scale(.98); } to { opacity: 1; transform: translateY(0) scale(1); } }
.modal__header { display: flex; align-items: center; justify-content: space-between; padding: 18px 20px; border-bottom: 1px solid var(--border-soft); }
.modal__header h3 { font-size: 15.5px; }
.modal__close { background: none; border: none; color: var(--text-faint); font-size: 20px; cursor: pointer; line-height: 1; padding: 4px; }
.modal__close:hover { color: var(--text); }
.modal__body { padding: 20px; }
.modal__footer { display: flex; justify-content: flex-end; gap: 10px; padding: 16px 20px; border-top: 1px solid var(--border-soft); }

/* ---- Toasts ---- */
.toast-stack { position: fixed; bottom: 20px; right: 20px; display: flex; flex-direction: column; gap: 10px; z-index: 200; }
.toast {
  display: flex; align-items: center; gap: 10px;
  background: var(--surface-2); border: 1px solid var(--border);
  border-left: 3px solid var(--accent);
  padding: 12px 16px; border-radius: var(--radius-sm);
  box-shadow: var(--shadow-md);
  font-size: 13px; min-width: 260px;
  animation: toastIn .22s var(--ease);
}
.toast--success { border-left-color: var(--success); }
.toast--error { border-left-color: var(--danger); }
.toast--warning { border-left-color: var(--warning); }
@keyframes toastIn { from { opacity: 0; transform: translateX(20px); } to { opacity: 1; transform: translateX(0); } }
.toast.is-leaving { animation: toastOut .18s var(--ease) forwards; }
@keyframes toastOut { to { opacity: 0; transform: translateX(20px); } }

/* ---- Empty states ---- */
.empty-state { text-align: center; padding: 60px 20px; color: var(--text-faint); }
.empty-state svg { width: 40px; height: 40px; margin-bottom: 12px; opacity: .5; }
.empty-state p { font-size: 13px; }

/* ---- Responsividade ---- */
@media (max-width: 980px) {
  .sidebar { position: fixed; left: 0; top: 0; bottom: 0; transform: translateX(-100%); box-shadow: var(--shadow-lg); }
  .app-shell.is-mobile-open .sidebar { transform: translateX(0); }
  .sidebar__collapse { display: none; }
  .topbar__menu-btn { display: flex; }
  .grid-4, .grid-3, .grid-2 { grid-template-columns: 1fr 1fr; }
  .form-grid, .form-grid--3 { grid-template-columns: 1fr; }
}
@media (max-width: 620px) {
  .content { padding: 16px; }
  .grid-4, .grid-3, .grid-2 { grid-template-columns: 1fr; }
  .topbar__search { display: none; }
  .modal { width: calc(100vw - 24px); }
}

/* Reduced motion */
@media (prefers-reduced-motion: reduce) {
  * { animation-duration: .001ms !important; transition-duration: .001ms !important; }
}

/* ---- Nova Venda: linhas de itens (múltiplos produtos por venda) ---- */
.venda-item-row {
  display: grid;
  grid-template-columns: 2fr 90px 130px 160px 36px;
  gap: 10px;
  align-items: center;
  margin-bottom: 10px;
}
.venda-item-subtotal {
  font-family: var(--font-mono);
  font-size: 13px;
  font-weight: 600;
  color: var(--accent-strong);
  display: flex;
  flex-direction: column;
  line-height: 1.3;
}
.venda-item-stock {
  font-family: var(--font-sans);
  font-size: 10.5px;
  font-weight: 400;
  color: var(--text-faint);
}
@media (max-width: 780px) {
  .venda-item-row {
    grid-template-columns: 1fr 1fr;
    grid-template-areas: "produto produto" "qtd preco" "subtotal remover";
  }
}

/* ---- Impressão: relatório diário de operação ---- */
.print-area { display: none; }

@media print {
  html, body {
    overflow: visible !important;
    height: auto !important;
  }
  .app-shell, .main, .content, .view {
    overflow: visible !important;
    height: auto !important;
  }
  body * { visibility: hidden; }
  .print-area, .print-area * { visibility: visible; }
  .print-area {
    display: block;
    position: absolute;
    top: 0; left: 0;
    width: 100%;
    padding: 24px;
    background: #fff;
    color: #000;
  }
  .print-area h1 { font-size: 20px; margin-bottom: 4px; color: #000; }
  .print-area .print-meta { font-size: 12px; color: #444; margin-bottom: 20px; }
  .print-area h2 { font-size: 14px; margin: 22px 0 8px; color: #000; border-bottom: 1px solid #ccc; padding-bottom: 4px; }
  .print-area .print-destaque { font-size: 22px; font-weight: 700; color: #000; margin-bottom: 6px; }
  .print-table { width: 100%; border-collapse: collapse; font-size: 12.5px; margin-bottom: 10px; }
  .print-table th, .print-table td { border: 1px solid #ccc; padding: 6px 10px; text-align: left; color: #000; }
  .print-table th { background: #f0f0f0; }
}

/* ---- Dashboard Gerencial: variação percentual entre meses ---- */
.ger-variacao--up { color: var(--success); font-weight: 600; }
.ger-variacao--down { color: var(--danger); font-weight: 600; }
.ger-variacao--neutro { color: var(--text-faint); font-weight: 500; }

/* ---- Badge extra: Esgotado (nível mais crítico) ---- */
.badge--esgotado { color: #fff; background: #1a1a1a; border: 1px solid #3a3a3a; }
