/* ─── Variáveis ───────────────────────────────────────────────────────────── */
:root {
  --est-primary:       #1847D6;
  --est-primary-dark:  #07166B;
  --est-primary-mid:   #0D2BA8;
  --est-primary-light: #2B5AE8;
  --est-bg:            #f0f4ff;
  --est-panel:         #ffffff;
  --est-text:          #0f172a;
  --est-muted:         #64748b;
  --est-border:        #dbe4f4;
  --est-success:       #10b981;
  --est-warning:       #f59e0b;
  --est-danger:        #ef4444;
  --est-shadow:        0 8px 32px rgba(7, 22, 107, 0.10);
  --est-radius-xl:     20px;
  --est-radius-lg:     14px;
  --est-radius-md:     10px;
}

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

body {
  font-family: "Segoe UI", Arial, sans-serif;
  background: var(--est-bg);
  min-height: 100vh;
  color: var(--est-text);
}

/* ─── Layout ─────────────────────────────────────────────────────────────── */
.app {
  display: grid;
  grid-template-columns: 260px 1fr;
  min-height: 100vh;
}

/* ─── Sidebar ────────────────────────────────────────────────────────────── */
.sidebar {
  background: linear-gradient(180deg, #060E4B 0%, #0D2BA8 60%, #1847D6 100%);
  color: #fff;
  display: flex;
  flex-direction: column;
  position: sticky;
  top: 0;
  height: 100vh;
  overflow-y: auto;
  border-right: 1px solid rgba(255,255,255,0.08);
  z-index: 100;
}

.sidebar-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 20px 18px 16px;
  border-bottom: 1px solid rgba(255,255,255,0.1);
  flex-shrink: 0;
}

.sidebar-logo {
  display: flex;
  align-items: center;
  gap: 12px;
}

.logo-mark {
  width: 36px;
  height: 36px;
  border-radius: 8px;
  overflow: hidden;
  background: rgba(255,255,255,0.12);
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.sidebar-logo-img { width: 100%; height: 100%; object-fit: contain; }
.logo-text strong  { display: block; font-size: 15px; font-weight: 700; color: #fff; line-height: 1.2; }
.logo-text small   { font-size: 11px; color: rgba(255,255,255,0.6); }

.sidebar-close-btn {
  background: none;
  border: none;
  color: rgba(255,255,255,0.7);
  cursor: pointer;
  padding: 6px;
  border-radius: 6px;
  display: none;
  line-height: 0;
  transition: background 0.15s;
  flex-shrink: 0;
}
.sidebar-close-btn:hover { background: rgba(255,255,255,0.12); color: #fff; }

.sidebar-nav {
  flex: 1;
  padding: 10px;
  overflow-y: auto;
}

.sidebar-nav ul {
  list-style: none;
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.nav-section-title {
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: rgba(255,255,255,0.4);
  padding: 14px 12px 6px;
}

.nav-link {
  display: flex;
  align-items: center;
  gap: 10px;
  color: rgba(255,255,255,0.75);
  text-decoration: none;
  padding: 10px 12px;
  border-radius: 10px;
  font-size: 14px;
  font-weight: 500;
  transition: background 0.18s, color 0.18s;
  white-space: nowrap;
}
.nav-link:hover  { background: rgba(255,255,255,0.10); color: #fff; }
.nav-link.active { background: rgba(255,255,255,0.16); color: #fff; font-weight: 600; }

.nav-icon {
  width: 20px;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.sidebar-footer {
  padding: 10px 10px 14px;
  border-top: 1px solid rgba(255,255,255,0.1);
  display: flex;
  flex-direction: column;
  gap: 4px;
  flex-shrink: 0;
}

.dark-mode-toggle {
  display: flex;
  align-items: center;
  gap: 8px;
  width: 100%;
  padding: 9px 12px;
  border: 1px solid rgba(255,255,255,0.18);
  border-radius: 8px;
  background: rgba(255,255,255,0.08);
  color: rgba(255,255,255,0.85);
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  transition: background 0.18s;
  font-family: inherit;
  text-align: left;
}
.dark-mode-toggle:hover { background: rgba(255,255,255,0.16); }

.back-link {
  display: flex;
  align-items: center;
  gap: 8px;
  color: rgba(255,255,255,0.6);
  text-decoration: none;
  font-size: 12px;
  padding: 7px 12px;
  border-radius: 8px;
  transition: background 0.15s, color 0.15s;
}
.back-link:hover { background: rgba(255,255,255,0.08); color: rgba(255,255,255,0.9); }

.sidebar-footer > span {
  font-size: 11px;
  color: rgba(255,255,255,0.3);
  text-align: center;
  padding: 2px 12px;
}

/* ─── Mobile overlay e hamburger ────────────────────────────────────────── */
.menu-toggle-btn {
  display: none;
  align-items: center;
  justify-content: center;
  background: none;
  border: none;
  cursor: pointer;
  color: var(--est-text);
  padding: 6px;
  border-radius: 8px;
  transition: background 0.15s;
  flex-shrink: 0;
  line-height: 0;
}
.menu-toggle-btn:hover { background: rgba(0,0,0,0.06); }

.sidebar-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.45);
  z-index: 99;
}
.sidebar-overlay.open { display: block; }

/* ─── Main ───────────────────────────────────────────────────────────────── */
.main { padding: 28px; min-width: 0; }

/* ─── Topbar ─────────────────────────────────────────────────────────────── */
.topbar {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  flex-wrap: wrap;
  margin-bottom: 24px;
}

.topbar-title { flex: 1; min-width: 0; }
.topbar-title h1 { font-size: 26px; font-weight: 700; color: var(--est-primary-dark); }
.topbar-title p  { color: var(--est-muted); font-size: 14px; margin-top: 4px; }

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

/* ─── Stat cards ─────────────────────────────────────────────────────────── */
.stats {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 16px;
  margin-bottom: 20px;
}

.stat-card {
  background: var(--est-panel);
  border-radius: var(--est-radius-xl);
  padding: 20px;
  box-shadow: var(--est-shadow);
  border: 1px solid var(--est-border);
}
.stat-card span   { display: block; font-size: 13px; color: var(--est-muted); margin-bottom: 8px; }
.stat-card strong { font-size: 28px; font-weight: 700; color: var(--est-primary); }
.stat-card.warning strong { color: #d97706; }
.stat-card.success strong { color: #059669; }

/* ─── Panel ──────────────────────────────────────────────────────────────── */
.panel {
  background: var(--est-panel);
  border-radius: var(--est-radius-xl);
  box-shadow: var(--est-shadow);
  padding: 22px;
  border: 1px solid var(--est-border);
}
.margin-top { margin-top: 20px; }

.panel-header          { margin-bottom: 18px; }
.panel-header h2       { font-size: 18px; font-weight: 700; color: var(--est-text); margin-bottom: 4px; }
.panel-header p        { color: var(--est-muted); font-size: 13px; }

/* ─── Content grid (equipamentos) ────────────────────────────────────────── */
.content-grid {
  display: grid;
  grid-template-columns: 340px 1fr;
  gap: 20px;
  align-items: start;
}

/* ─── Formulário ─────────────────────────────────────────────────────────── */
.product-form { display: flex; flex-direction: column; gap: 14px; }

.form-group label { display: block; font-size: 13px; font-weight: 600; margin-bottom: 6px; color: var(--est-text); }

.form-group input,
.search,
.form-select,
.prioridade-select {
  width: 100%;
  border: 1.5px solid var(--est-border);
  outline: none;
  border-radius: var(--est-radius-lg);
  padding: 12px 14px;
  font-size: 14px;
  background: #fff;
  color: var(--est-text);
  transition: border-color 0.18s, box-shadow 0.18s;
  font-family: inherit;
}
.form-group input:focus,
.search:focus,
.form-select:focus,
.prioridade-select:focus {
  border-color: var(--est-primary);
  box-shadow: 0 0 0 3px rgba(24, 71, 214, 0.12);
}

.form-row     { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
.form-actions { display: flex; gap: 10px; flex-wrap: wrap; margin-top: 6px; }

/* ─── Botões ─────────────────────────────────────────────────────────────── */
.btn {
  border: none;
  border-radius: var(--est-radius-lg);
  padding: 11px 18px;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.18s, transform 0.1s;
  font-family: inherit;
  white-space: nowrap;
}
.btn:active { transform: scale(0.97); }

.btn-primary         { background: var(--est-primary);   color: #fff; }
.btn-primary:hover   { background: var(--est-primary-dark); }
.btn-secondary       { background: #edf1fb;              color: var(--est-text); }
.btn-secondary:hover { background: #dbe4f4; }
.btn-danger-ghost     { color: var(--est-danger); background: transparent; }
.btn-danger-ghost:hover { background: rgba(239,68,68,0.1); }
.full-width { width: 100%; }

/* ─── Tabelas ────────────────────────────────────────────────────────────── */
.table-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 16px;
  flex-wrap: wrap;
  margin-bottom: 4px;
}
.search { max-width: 300px; }
.table-wrapper { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; min-width: 700px; }

thead th {
  text-align: left;
  font-size: 12px;
  font-weight: 600;
  color: var(--est-muted);
  padding: 12px 14px;
  border-bottom: 1.5px solid var(--est-border);
  white-space: nowrap;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}
tbody td {
  padding: 14px 14px;
  border-bottom: 1px solid #f1f5f9;
  font-size: 14px;
  vertical-align: middle;
}
tbody tr:hover { background: #f8fafc; }
.produto-nome { font-weight: 600; }

/* ─── Status badges ──────────────────────────────────────────────────────── */
.status {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: 999px;
  padding: 4px 12px;
  font-size: 12px;
  font-weight: 700;
  white-space: nowrap;
}
.status.ok      { background: rgba(16, 185, 129, 0.12); color: #059669; }
.status.low     { background: rgba(245, 158, 11, 0.14); color: #d97706; }
.status.warning { background: rgba(37,  99, 235, 0.12); color: #1847D6; }
.status.danger  { background: rgba(239,  68,  68, 0.12); color: #dc2626; }

/* ─── Empty state ────────────────────────────────────────────────────────── */
.empty {
  padding: 40px 20px;
  text-align: center;
  color: var(--est-muted);
  background: #f8fafc;
  border: 1.5px dashed var(--est-border);
  border-radius: var(--est-radius-xl);
}

/* ─── Gráficos ───────────────────────────────────────────────────────────── */
.charts-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 20px;
  margin-top: 20px;
}
.chart-panel  { min-height: 380px; }
.chart-box    { position: relative; width: 100%; height: 280px; }
.chart-box-lg { height: 340px; }

/* ─── Inventário ─────────────────────────────────────────────────────────── */
.card {
  background: var(--est-panel);
  border-radius: var(--est-radius-xl);
  padding: 24px;
  margin-top: 20px;
  box-shadow: var(--est-shadow);
  border: 1px solid var(--est-border);
}
.card-header    { margin-bottom: 18px; }
.card-header h2 { font-size: 18px; font-weight: 700; }
.card-header p  { color: var(--est-muted); font-size: 13px; margin-top: 4px; }

.cards-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
  gap: 14px;
  margin: 16px 0 22px;
}
.small-card    { background: #f3f6fd; border-radius: var(--est-radius-lg); padding: 16px; border: 1px solid var(--est-border); }
.small-card p  { color: var(--est-muted); font-size: 12px; margin-bottom: 6px; }
.small-card h3 { color: var(--est-primary); font-size: 26px; font-weight: 700; }

.input-table {
  width: 100%;
  padding: 8px 10px;
  border-radius: var(--est-radius-md);
  border: 1.5px solid var(--est-border);
  background: #fff;
  font-size: 13px;
  outline: none;
  font-family: inherit;
}
.input-table:focus { border-color: var(--est-primary); }

/* ─── Alertas ────────────────────────────────────────────────────────────── */
.alerta-inventario {
  border-radius: var(--est-radius-xl);
  padding: 18px 22px;
  margin-bottom: 18px;
  border-left: 5px solid;
  background: #fff;
  box-shadow: 0 4px 14px rgba(0,0,0,0.06);
}
.alerta-inventario.pendente  { border-color: var(--est-warning); background: #fff8e6; }
.alerta-inventario.andamento { border-color: var(--est-primary);  background: #eff4ff; }
.alerta-inventario.concluido { border-color: var(--est-success);  background: #ecfdf5; }
.alerta-inventario h3 { font-size: 17px; margin-bottom: 8px; }
.alerta-inventario p  { color: #475569; font-size: 14px; margin: 4px 0; }

.alert-success {
  background: #dcfce7; color: #166534;
  padding: 14px 18px; border-radius: var(--est-radius-lg);
  margin-bottom: 16px; border-left: 4px solid #22c55e;
  font-size: 14px;
}

.alert-warning.compras-alerta {
  background: #fff; color: var(--est-text);
  border-left: 5px solid var(--est-warning);
  border-radius: var(--est-radius-xl);
  padding: 20px 22px; margin-bottom: 18px;
  box-shadow: 0 4px 14px rgba(0,0,0,0.07);
}
.alert-warning.compras-alerta h2 { font-size: 18px; margin-bottom: 8px; }
.alert-warning.compras-alerta p  { color: #475569; margin: 5px 0; font-size: 14px; }
.alert-warning.compras-alerta ul { margin-top: 10px; padding-left: 20px; }
.alert-warning.compras-alerta li { margin-bottom: 5px; font-size: 14px; }

/* ─── Paginação ──────────────────────────────────────────────────────────── */
.pagination {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 12px;
  margin-top: 16px;
}
.pagination span { font-weight: 600; color: var(--est-muted); font-size: 14px; }
.pagination button:disabled { opacity: 0.45; cursor: not-allowed; }

/* ─── Toast ──────────────────────────────────────────────────────────────── */
.estoque-toast {
  position: fixed;
  top: 20px;
  right: 20px;
  padding: 14px 22px;
  border-radius: var(--est-radius-lg);
  color: #fff;
  font-weight: 600;
  font-size: 14px;
  z-index: 9999;
  opacity: 0;
  transform: translateY(-8px);
  transition: opacity 0.25s, transform 0.25s;
  max-width: 320px;
  box-shadow: 0 8px 24px rgba(0,0,0,0.18);
}
.estoque-toast.show         { opacity: 1; transform: translateY(0); }
.estoque-toast--success     { background: #059669; }
.estoque-toast--error       { background: #dc2626; }
.estoque-toast--warning     { background: #d97706; }

/* ─── Modo impressão ─────────────────────────────────────────────────────── */
@media print {
  body { background: #fff; }
  .sidebar, .sidebar-overlay, .menu-toggle-btn, .topbar-actions, .form-panel, .search { display: none !important; }
  .app, .main, .content-grid { display: block; padding: 0; }
  .panel, .stat-card { box-shadow: none; border: 1px solid #ddd; }
  table { min-width: 100%; }
}

/* ─── Responsividade ─────────────────────────────────────────────────────── */
@media (max-width: 1200px) {
  .stats        { grid-template-columns: repeat(2, 1fr); }
  .content-grid { grid-template-columns: 1fr; }
  .charts-grid  { grid-template-columns: 1fr; }
}

@media (max-width: 900px) {
  .app { grid-template-columns: 1fr; }

  .sidebar {
    position: fixed;
    left: -280px;
    top: 0;
    width: 260px;
    height: 100vh;
    transition: left 0.25s ease;
  }
  .sidebar.open      { left: 0; }
  .sidebar-close-btn { display: flex; }
  .menu-toggle-btn   { display: flex; }

  .main { padding: 16px; }
  .topbar-title h1 { font-size: 22px; }
  .stats { grid-template-columns: 1fr 1fr; }
}

@media (max-width: 480px) {
  .stats    { grid-template-columns: 1fr; }
  .form-row { grid-template-columns: 1fr; }
}

/* ─── Dark Mode ──────────────────────────────────────────────────────────── */
[data-theme="dark"] {
  --est-bg:     #0F172A;
  --est-panel:  #1E293B;
  --est-border: #334155;
  --est-text:   #F1F5F9;
  --est-muted:  #94A3B8;
}

[data-theme="dark"] body        { background: var(--est-bg); color: var(--est-text); }
[data-theme="dark"] .main       { background: var(--est-bg); }

[data-theme="dark"] .panel,
[data-theme="dark"] .stat-card,
[data-theme="dark"] .card,
[data-theme="dark"] .small-card {
  background: var(--est-panel);
  border-color: var(--est-border);
}

[data-theme="dark"] .topbar-title h1 { color: var(--est-text); }
[data-theme="dark"] .topbar-title p  { color: var(--est-muted); }

[data-theme="dark"] .input-table,
[data-theme="dark"] .form-group input,
[data-theme="dark"] .form-group select,
[data-theme="dark"] .search,
[data-theme="dark"] .form-select,
[data-theme="dark"] .prioridade-select {
  background: #0F172A;
  border-color: #334155;
  color: var(--est-text);
}
[data-theme="dark"] .form-group input::placeholder,
[data-theme="dark"] .search::placeholder { color: #64748B; }

[data-theme="dark"] table thead           { background: #0F172A; }
[data-theme="dark"] table thead th        { color: var(--est-muted); border-bottom-color: #334155; }
[data-theme="dark"] table tbody tr:hover  { background: #273549; }
[data-theme="dark"] table tbody td        { border-bottom-color: #1E293B; color: var(--est-text); }

[data-theme="dark"] .btn-secondary        { background: #1E293B; border: 1px solid #334155; color: var(--est-text); }
[data-theme="dark"] .btn-secondary:hover  { background: #273549; }

[data-theme="dark"] .pagination button           { background: #1E293B; border-color: #334155; color: var(--est-text); }
[data-theme="dark"] .pagination button:hover:not(:disabled) { background: #273549; }

[data-theme="dark"] .empty                { color: var(--est-muted); background: #1E293B; border-color: #334155; }
[data-theme="dark"] .small-card p         { color: var(--est-muted); }
[data-theme="dark"] .small-card h3        { color: var(--est-text); }
[data-theme="dark"] .small-card           { background: #0F172A; }
[data-theme="dark"] .panel-header h2      { color: var(--est-text); }
[data-theme="dark"] .panel-header p       { color: var(--est-muted); }
[data-theme="dark"] .stat-card span       { color: var(--est-muted); }
[data-theme="dark"] .stat-card strong     { color: var(--est-text); }
[data-theme="dark"] .alerta-inventario    { background: var(--est-panel); }
[data-theme="dark"] .alert-success        { background: rgba(16,185,129,0.12); border-color: rgba(16,185,129,0.3); color: #a7f3d0; }
[data-theme="dark"] .compras-alerta       { background: rgba(245,158,11,0.10); }
[data-theme="dark"] .menu-toggle-btn      { color: var(--est-text); }
