/* public/css/style.css */
:root {
  --verde: #2d5016;
  --verde-medio: #4a7c28;
  --verde-claro: #7ab648;
  --verde-bg: #f0f7ea;
  --dourado: #c9a84c;
  --dourado-claro: #e8c96a;
  --creme: #f8f4ec;
  --branco: #ffffff;
  --cinza-escuro: #1f2937;
  --cinza: #4b5563;
  --cinza-medio: #9ca3af;
  --cinza-claro: #e5e7eb;
  --cinza-bg: #f9fafb;
  --vermelho: #c0392b;
  --vermelho-bg: #fef2f2;
  --amarelo: #d97706;
  --amarelo-bg: #fffbeb;
  --azul: #1d4ed8;
  --sidebar-w: 240px;
  --header-h: 64px;
  --radius: 4px;
  --shadow: 0 1px 3px rgba(0,0,0,0.1), 0 1px 2px rgba(0,0,0,0.06);
  --shadow-md: 0 4px 6px rgba(0,0,0,0.07), 0 2px 4px rgba(0,0,0,0.06);
}

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

body {
  font-family: 'Inter', sans-serif;
  background: var(--cinza-bg);
  color: var(--cinza-escuro);
  font-size: 14px;
  line-height: 1.5;
}

/* ─── Layout ─────────────────────────────────────────────────────────────── */
#sidebar {
  position: fixed;
  left: 0; top: 0; bottom: 0;
  width: var(--sidebar-w);
  background: var(--verde);
  display: flex;
  flex-direction: column;
  z-index: 100;
  overflow-y: auto;
}

#main-content {
  margin-left: var(--sidebar-w);
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

/* ─── Sidebar ─────────────────────────────────────────────────────────────── */
.sidebar-logo {
  padding: 24px 20px;
  border-bottom: 1px solid rgba(255,255,255,0.08);
  display: flex; align-items: center; gap: 12px;
}
.sidebar-logo-icon {
  width: 36px; height: 36px;
  background: rgba(255,255,255,0.1);
  border-radius: 8px;
  display: flex; align-items: center; justify-content: center;
  font-size: 18px; flex-shrink: 0;
}
.sidebar-logo-text h2 {
  font-family: 'Cormorant Garamond', serif;
  font-size: 16px;
  font-weight: 400;
  color: var(--branco);
  line-height: 1.2;
}
.sidebar-logo-text span {
  font-size: 10px;
  color: rgba(255,255,255,0.5);
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.sidebar-section { padding: 16px 12px 4px; }
.sidebar-section-label {
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: 1px;
  color: rgba(255,255,255,0.35);
  padding: 0 8px;
  margin-bottom: 4px;
}

.nav-item {
  display: flex; align-items: center; gap: 10px;
  padding: 10px 12px;
  border-radius: var(--radius);
  color: rgba(255,255,255,0.65);
  cursor: pointer;
  transition: all 0.15s;
  font-size: 13px;
  margin-bottom: 2px;
  border: none; background: none; width: 100%; text-align: left;
}
.nav-item:hover { background: rgba(255,255,255,0.08); color: var(--branco); }
.nav-item.active { background: rgba(255,255,255,0.12); color: var(--branco); }
.nav-item .nav-icon { width: 18px; text-align: center; flex-shrink: 0; }
.nav-badge {
  margin-left: auto;
  background: var(--vermelho);
  color: white; font-size: 10px;
  font-weight: 600; min-width: 18px; height: 18px;
  border-radius: 9px; display: flex; align-items: center; justify-content: center;
  padding: 0 5px;
}

.sidebar-footer {
  margin-top: auto;
  padding: 16px 12px;
  border-top: 1px solid rgba(255,255,255,0.08);
}
.sidebar-user {
  display: flex; align-items: center; gap: 10px;
  padding: 8px 12px; border-radius: var(--radius);
}
.sidebar-user-avatar {
  width: 30px; height: 30px;
  background: var(--dourado);
  border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  font-size: 12px; font-weight: 600; color: var(--verde);
  flex-shrink: 0;
}
.sidebar-user-name { font-size: 12px; color: rgba(255,255,255,0.8); }
.btn-logout {
  margin-top: 4px;
  width: 100%;
  padding: 8px 12px;
  background: rgba(255,255,255,0.05);
  border: none; border-radius: var(--radius);
  color: rgba(255,255,255,0.5); font-size: 12px;
  cursor: pointer; transition: all 0.15s; text-align: left;
}
.btn-logout:hover { background: rgba(255,0,0,0.15); color: #f87171; }

/* ─── Header ──────────────────────────────────────────────────────────────── */
.page-header {
  background: var(--branco);
  padding: 0 32px;
  height: var(--header-h);
  border-bottom: 1px solid var(--cinza-claro);
  display: flex; align-items: center; justify-content: space-between;
  position: sticky; top: 0; z-index: 50;
}
.page-header h1 { font-size: 18px; font-weight: 600; color: var(--cinza-escuro); }
.page-header .header-right { display: flex; gap: 8px; align-items: center; }

/* ─── Page content ────────────────────────────────────────────────────────── */
.page-body { padding: 28px 32px; flex: 1; }
.page { display: none; }
.page.active { display: block; }

/* ─── Cards & Grid ────────────────────────────────────────────────────────── */
.card {
  background: var(--branco);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  overflow: hidden;
}
.card-header {
  padding: 16px 20px;
  border-bottom: 1px solid var(--cinza-claro);
  display: flex; align-items: center; justify-content: space-between;
}
.card-title { font-size: 14px; font-weight: 600; color: var(--cinza-escuro); }
.card-body { padding: 20px; }

.kpi-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); gap: 16px; margin-bottom: 24px; }
.kpi-card {
  background: var(--branco);
  border-radius: var(--radius);
  padding: 20px;
  box-shadow: var(--shadow);
  border-left: 3px solid var(--verde-claro);
}
.kpi-card.alerta { border-left-color: var(--vermelho); }
.kpi-card.dourado { border-left-color: var(--dourado); }
.kpi-card.azul { border-left-color: var(--azul); }
.kpi-label { font-size: 11px; text-transform: uppercase; letter-spacing: 0.5px; color: var(--cinza-medio); margin-bottom: 8px; }
.kpi-value { font-size: 28px; font-weight: 700; color: var(--cinza-escuro); }
.kpi-sub { font-size: 11px; color: var(--cinza-medio); margin-top: 2px; }

.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 20px; margin-bottom: 20px; }
.grid-3 { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 20px; margin-bottom: 20px; }

/* ─── Alertas ─────────────────────────────────────────────────────────────── */
.alert-box {
  padding: 12px 16px;
  border-radius: var(--radius);
  font-size: 13px;
  display: flex; align-items: flex-start; gap: 10px;
  margin-bottom: 8px;
}
.alert-box.danger { background: var(--vermelho-bg); color: #991b1b; border: 1px solid #fca5a5; }
.alert-box.warning { background: var(--amarelo-bg); color: #92400e; border: 1px solid #fcd34d; }
.alert-box.info { background: var(--verde-bg); color: var(--verde); border: 1px solid #86efac; }
.alert-icon { font-size: 16px; flex-shrink: 0; }
.alert-title { font-weight: 600; }
.alert-items { margin-top: 4px; }
.alert-item { font-size: 12px; padding: 2px 0; }

/* ─── Tabela ──────────────────────────────────────────────────────────────── */
.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; font-size: 13px; }
thead th {
  background: var(--cinza-bg);
  padding: 10px 14px;
  text-align: left;
  font-weight: 600;
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: var(--cinza);
  white-space: nowrap;
}
tbody tr { border-bottom: 1px solid var(--cinza-claro); transition: background 0.1s; }
tbody tr:hover { background: var(--cinza-bg); }
tbody td { padding: 11px 14px; color: var(--cinza-escuro); }
tbody tr:last-child { border-bottom: none; }

/* ─── Badges ──────────────────────────────────────────────────────────────── */
.badge {
  display: inline-flex; align-items: center;
  padding: 2px 8px;
  border-radius: 12px;
  font-size: 11px;
  font-weight: 500;
}
.badge-ok { background: #dcfce7; color: #166534; }
.badge-baixo { background: #fef9c3; color: #854d0e; }
.badge-critico { background: #fee2e2; color: #991b1b; }
.badge-zerado { background: #f3f4f6; color: #4b5563; }
.badge-verde { background: var(--verde-bg); color: var(--verde); }
.badge-cinza { background: #f3f4f6; color: #6b7280; }
.badge-dourado { background: #fef9c3; color: #854d0e; }
.badge-azul { background: #dbeafe; color: #1e40af; }
.badge-vermelho { background: #fee2e2; color: #991b1b; }

/* ─── Botões ──────────────────────────────────────────────────────────────── */
.btn {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 8px 16px;
  border-radius: var(--radius);
  font-size: 13px; font-weight: 500;
  cursor: pointer; border: none;
  transition: all 0.15s;
  font-family: 'Inter', sans-serif;
  text-decoration: none;
}
.btn-primary { background: var(--verde); color: var(--branco); }
.btn-primary:hover { background: var(--verde-medio); }
.btn-secondary { background: var(--cinza-bg); color: var(--cinza-escuro); border: 1px solid var(--cinza-claro); }
.btn-secondary:hover { background: var(--cinza-claro); }
.btn-danger { background: var(--vermelho-bg); color: var(--vermelho); border: 1px solid #fca5a5; }
.btn-danger:hover { background: #fee2e2; }
.btn-dourado { background: var(--dourado); color: var(--verde); }
.btn-dourado:hover { background: var(--dourado-claro); }
.btn-sm { padding: 5px 10px; font-size: 12px; }
.btn-icon { padding: 6px 10px; }

/* ─── Formulários ─────────────────────────────────────────────────────────── */
.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
.form-grid-3 { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 16px; }
.form-group { display: flex; flex-direction: column; gap: 6px; }
.form-group.full { grid-column: 1 / -1; }
label.form-label { font-size: 12px; font-weight: 500; color: var(--verde); text-transform: uppercase; letter-spacing: 0.4px; }
input[type=text], input[type=number], input[type=email], input[type=date], input[type=password],
select, textarea {
  padding: 9px 12px;
  border: 1.5px solid var(--cinza-claro);
  border-radius: var(--radius);
  font-size: 13px;
  font-family: 'Inter', sans-serif;
  color: var(--cinza-escuro);
  background: var(--branco);
  transition: border-color 0.2s;
  outline: none;
  width: 100%;
}
input:focus, select:focus, textarea:focus { border-color: var(--verde-medio); }
textarea { resize: vertical; min-height: 72px; }
select { cursor: pointer; }
.form-hint { font-size: 11px; color: var(--cinza-medio); }

/* ─── Modal ───────────────────────────────────────────────────────────────── */
.modal-overlay {
  position: fixed; inset: 0;
  background: rgba(0,0,0,0.5);
  display: none;
  align-items: center; justify-content: center;
  z-index: 200;
  padding: 16px;
}
.modal-overlay.open { display: flex; }
.modal {
  background: var(--branco);
  border-radius: var(--radius);
  width: 100%;
  max-width: 640px;
  max-height: 90vh;
  overflow-y: auto;
  box-shadow: 0 25px 50px rgba(0,0,0,0.3);
}
.modal-lg { max-width: 860px; }
.modal-header {
  padding: 20px 24px 16px;
  border-bottom: 1px solid var(--cinza-claro);
  display: flex; align-items: center; justify-content: space-between;
  position: sticky; top: 0; background: var(--branco); z-index: 1;
}
.modal-title { font-size: 16px; font-weight: 600; }
.modal-close {
  width: 28px; height: 28px;
  border: none; background: none;
  font-size: 20px; cursor: pointer;
  color: var(--cinza-medio);
  display: flex; align-items: center; justify-content: center;
  border-radius: 4px;
}
.modal-close:hover { background: var(--cinza-claro); }
.modal-body { padding: 24px; }
.modal-footer {
  padding: 16px 24px;
  border-top: 1px solid var(--cinza-claro);
  display: flex; gap: 8px; justify-content: flex-end;
}

/* ─── Barra de busca / filtros ────────────────────────────────────────────── */
.filters { display: flex; gap: 8px; flex-wrap: wrap; margin-bottom: 16px; }
.search-input {
  padding: 8px 12px;
  border: 1.5px solid var(--cinza-claro);
  border-radius: var(--radius);
  font-size: 13px;
  width: 240px;
  font-family: 'Inter', sans-serif;
  outline: none;
}
.search-input:focus { border-color: var(--verde-medio); }

/* ─── Status estoque inline ───────────────────────────────────────────────── */
.stock-bar { width: 80px; height: 6px; background: var(--cinza-claro); border-radius: 3px; overflow: hidden; }
.stock-fill { height: 100%; border-radius: 3px; transition: width 0.3s; }
.stock-fill.ok { background: var(--verde-claro); }
.stock-fill.baixo { background: var(--amarelo); }
.stock-fill.critico { background: var(--vermelho); }

/* ─── Tabs ────────────────────────────────────────────────────────────────── */
.tabs { display: flex; border-bottom: 1px solid var(--cinza-claro); margin-bottom: 24px; }
.tab {
  padding: 12px 20px;
  font-size: 13px; font-weight: 500;
  color: var(--cinza-medio);
  cursor: pointer;
  border-bottom: 2px solid transparent;
  transition: all 0.15s;
  background: none; border-left: none; border-right: none; border-top: none;
  font-family: 'Inter', sans-serif;
}
.tab.active { color: var(--verde); border-bottom-color: var(--verde); }
.tab:hover:not(.active) { color: var(--cinza-escuro); }
.tab-content { display: none; }
.tab-content.active { display: block; }

/* ─── Simulação de produção ───────────────────────────────────────────────── */
.sim-item {
  display: flex; align-items: center; justify-content: space-between;
  padding: 8px 12px;
  border-radius: var(--radius);
  margin-bottom: 4px;
  font-size: 13px;
}
.sim-item.ok { background: #f0fdf4; }
.sim-item.nok { background: var(--vermelho-bg); }
.sim-item .sim-name { font-weight: 500; }
.sim-item .sim-detail { font-size: 11px; color: var(--cinza); margin-top: 1px; }
.sim-item .sim-status { font-size: 18px; }

/* ─── Formulação builder ──────────────────────────────────────────────────── */
.formula-row {
  display: grid;
  grid-template-columns: 1fr 120px 90px auto;
  gap: 8px;
  align-items: center;
  margin-bottom: 8px;
}
.formula-row .btn-icon { color: var(--vermelho); }
.formula-header {
  display: grid;
  grid-template-columns: 1fr 120px 90px auto;
  gap: 8px;
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: var(--cinza-medio);
  padding: 0 0 8px;
  border-bottom: 1px solid var(--cinza-claro);
  margin-bottom: 8px;
}

/* ─── Validade highlight ──────────────────────────────────────────────────── */
.venc-vencido { color: var(--vermelho); font-weight: 600; }
.venc-alerta { color: var(--amarelo); font-weight: 500; }

/* ─── Toast ───────────────────────────────────────────────────────────────── */
#toast {
  position: fixed;
  bottom: 24px; right: 24px;
  padding: 12px 20px;
  background: var(--cinza-escuro);
  color: var(--branco);
  border-radius: var(--radius);
  font-size: 13px;
  z-index: 1000;
  transform: translateY(80px);
  opacity: 0;
  transition: all 0.3s;
  max-width: 320px;
}
#toast.show { transform: translateY(0); opacity: 1; }
#toast.success { background: var(--verde); }
#toast.error { background: var(--vermelho); }

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

/* ─── Responsive ──────────────────────────────────────────────────────────── */
@media (max-width: 900px) {
  #sidebar { width: 200px; }
  #main-content { margin-left: 200px; }
  .form-grid, .form-grid-3, .grid-2, .grid-3 { grid-template-columns: 1fr; }
}

/* ─── Categorias ──────────────────────────────────────────────────────────── */
.cat-tab-content { animation: fadeIn 0.15s ease; }
@keyframes fadeIn { from { opacity: 0; transform: translateY(4px); } to { opacity: 1; transform: translateY(0); } }

.cat-color-dot {
  display: inline-block;
  width: 10px; height: 10px;
  border-radius: 50%;
  margin-right: 6px;
  flex-shrink: 0;
  border: 1px solid rgba(0,0,0,0.1);
}
