/* Customizações do Portal MAIA em cima do Bootstrap 5. */

:root {
  --sidebar-bg: #00562f;
  --sidebar-bg-soft: #0a3d2a;
  --sidebar-text: #c9e6dc;
  --sidebar-text-soft: #8fc4bb;
  --brand-orange: #f2724a;
  --teal-900: #00562f;
  --teal-700: #12776e;
  --teal-600: #178077;
  --teal-500: #1ea393;
  --teal-100: #e2f2ef;

  /* Paleta do protótipo (portal-producao-maia_12.html), portada literalmente
     pra bater fonte/cor/sombra exatos em vez de valores hexadecimais soltos. */
  --bg: #f1f3f0;
  --surface: #ffffff;
  --surface-alt: #f7f8f6;
  --border: #e2e6e0;
  --ink: #1b2420;
  --ink-soft: #5c6960;
  --ink-faint: #8b968f;
  --danger: #bd4740;
  --danger-100: #fbe7e5;
  --warn: #ad7e28;
  --warn-100: #f6ecd5;
  --success: #2f8f5b;
  --success-100: #e2f4e9;
  --shadow: 0 1px 2px rgba(20, 30, 25, .04), 0 8px 24px rgba(20, 30, 25, .06);
}

body.app-body {
  background-color: var(--bg);
  margin: 0;
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
}

.app-main h1, .app-main h2, .app-main h3, .app-main h4, .app-main h5,
.auth-card h3, .auth-title {
  font-family: 'Sora', sans-serif;
}

/* ---------------- Formulários estilo protótipo (fundo cinza, sem borda visível) ---------------- */

.field { margin-bottom: 16px; }
.field label, .field-label-row label {
  display: block; font-size: 13px; font-weight: 600; margin-bottom: 6px; color: #1b2420;
}
.field input, .field select, .field textarea,
.recipe-row input, .recipe-row select {
  width: 100%; padding: 12px 14px; border: 1px solid #e2e6e0; border-radius: 12px;
  font-size: 14px; background: #f7f8f6; color: #1b2420; outline: none; transition: border-color .15s;
}
.field input:focus, .field select:focus, .field textarea:focus,
.recipe-row input:focus, .recipe-row select:focus {
  border-color: var(--teal-500); background: #fff;
}
.field input[readonly], .code-display-input {
  background: #f0f1ee !important; color: #5c6960;
}

.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
.grid-3 { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 14px; }
@media (max-width: 575.98px) {
  .grid-2, .grid-3 { grid-template-columns: 1fr; }
}

.field-label-row { display: flex; justify-content: space-between; align-items: center; margin-bottom: 6px; }

.btn-link-brand {
  background: none; border: none; color: var(--teal-700); font-weight: 600; font-size: 13px;
  cursor: pointer; padding: 0; text-decoration: none;
}
.btn-link-brand:hover { color: var(--teal-900); text-decoration: underline; }

.modal-sub { color: #5c6960; font-size: 14px; margin: 0 0 20px; }

.recipe-row { border-top: 1px solid #eef0ed; padding-top: 14px; margin-top: 14px; }
.recipe-row:first-child { border-top: none; padding-top: 0; margin-top: 0; }
.recipe-row-code { flex: 0 0 76px; }
.recipe-row-material { flex: 1; min-width: 0; }
.recipe-row-qty { flex: 0 0 90px; }
.recipe-row-remove {
  background: none; border: none; color: #b3261e; font-size: 18px; line-height: 1;
  padding: 10px 4px; flex-shrink: 0;
}
.recipe-row-remove:hover { color: #7a1912; }

.add-row-btn {
  display: block; width: 100%; background: none; border: 1px dashed var(--teal-500); color: var(--teal-700);
  padding: 10px; border-radius: 10px; font-size: 13.5px; font-weight: 600; text-align: center;
  cursor: pointer; margin-top: 6px;
}
.add-row-btn:hover { background: var(--teal-100); }

.btn-delete-inline {
  background: none; border: 1px solid #dc3545; color: #dc3545; border-radius: 10px;
  padding: 9px 16px; font-weight: 600; font-size: 13.5px;
}
.btn-delete-inline:hover { background: #dc3545; color: #fff; }

.form-actions { display: flex; justify-content: flex-end; gap: 10px; margin-top: 20px; flex-wrap: wrap; }
.form-actions.has-delete { justify-content: space-between; }
.form-actions .form-actions-right { display: flex; gap: 10px; flex-wrap: wrap; }

.btn-cancel-inline {
  background: #fff; color: #5c6960; border: 1px solid #e2e6e0; border-radius: 10px;
  padding: 10px 18px; font-weight: 600; font-size: 13.5px;
}
.btn-cancel-inline:hover { background: #f7f8f6; }

.inline-create-row {
  display: none; gap: 8px; margin-top: 8px; align-items: center;
}
.inline-create-row.show { display: flex; }
.inline-create-row input { flex: 1; }
.inline-create-error { color: #b3261e; font-size: 12.5px; margin-top: 4px; display: none; }

/* ---------------- Abas dentro do modal (estilo protótipo) ---------------- */

.brand-tabs { display: flex; gap: 4px; margin: 2px 0 16px; border-bottom: 2px solid #e2e6e0; }
.brand-tab-btn {
  padding: 9px 18px 10px; border: 1px solid #e2e6e0; border-bottom: none; border-radius: 10px 10px 0 0;
  background: #f7f8f6; color: #5c6960; font-size: 13px; font-weight: 600; cursor: pointer;
  margin-bottom: -2px; transition: background .12s, color .12s;
}
.brand-tab-btn:hover { background: var(--teal-100); color: var(--teal-900); }
.brand-tab-btn.active { background: #fff; color: var(--teal-900); border-color: #e2e6e0; border-bottom: 2px solid #fff; }
.brand-tab-panel { display: none; }
.brand-tab-panel.active { display: block; }

/* ---------------- Modal estilo protótipo (sobreposto, fundo escurecido) ---------------- */

.brand-modal {
  border: none;
  border-radius: 20px;
  box-shadow: 0 12px 40px rgba(20, 30, 25, 0.25);
  max-height: 90vh;
  overflow-y: auto;
  position: relative;
  scrollbar-width: none; /* Firefox */
  -ms-overflow-style: none; /* versões antigas do Edge/IE */
}
.brand-modal::-webkit-scrollbar { display: none; } /* Chrome/Edge/Safari */
.modal-close-btn {
  position: absolute;
  top: 14px;
  right: 14px;
  z-index: 5;
  width: 32px;
  height: 32px;
  border-radius: 50%;
  border: 1px solid #e2e6e0;
  background: #fff;
  color: #5c6960;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 20px;
  line-height: 1;
  cursor: pointer;
}
.modal-close-btn:hover { background: #f7f8f6; color: #1b2420; }
.modal-backdrop.show { opacity: .55; }

/* ---------------- Botões e badges na cor da marca (protótipo) ---------------- */

.btn-brand-solid { background: var(--teal-700); color: #fff; border: 1px solid var(--teal-700); }
.btn-brand-solid:hover { background: var(--teal-900); border-color: var(--teal-900); color: #fff; }
.btn-brand-outline { background: #fff; color: var(--teal-700); border: 1px solid var(--teal-500); }
.btn-brand-outline:hover { background: var(--teal-100); color: var(--teal-900); border-color: var(--teal-500); }

.badge-brand-muted { background: var(--teal-100); color: var(--teal-700); font-weight: 600; }

.page-title { color: #1b2420; font-weight: 700; }
.page-subtitle { color: #5c6960; }

.pagination .page-link { color: var(--teal-700); }
.pagination .page-item.active .page-link { background: var(--teal-700); border-color: var(--teal-700); }
.pagination .page-link:hover { color: var(--teal-900); }

/* ---------------- "Panel" (protótipo): caixa branca arredondada com sombra ---------------- */

.panel { background: #fff; border-radius: 18px; padding: 22px 24px; box-shadow: 0 1px 3px rgba(20, 30, 25, .06); border: 1px solid #e2e6e0; margin-bottom: 22px; }
.panel h2 { font-size: 16px; margin: 0; font-weight: 700; color: #1b2420; }
.panel-total { background: var(--teal-100); border-color: var(--teal-500); }
.empty-state { text-align: center; padding: 36px 20px; font-size: 14px; }
.mono { font-family: 'JetBrains Mono', 'Courier New', monospace; }

/* ---------------- Ações em ícone nas linhas de tabela (protótipo: ver/editar/excluir) ---------------- */

.row-actions { display: inline-flex; gap: 6px; justify-content: flex-end; }
.icon-btn {
  background: #f7f8f6; border: 1px solid #e2e6e0; width: 28px; height: 28px; border-radius: 8px;
  cursor: pointer; display: inline-flex; align-items: center; justify-content: center;
  color: #5c6960; font-size: 14px; line-height: 1; padding: 0;
}
.icon-btn:hover { background: var(--teal-100); color: var(--teal-700); }
.icon-btn.danger:hover { background: #f8d7da; color: #b42318; }

/* ---------------- Caixa de informação (protótipo: bloco cinza dentro de modal) ---------------- */

.info-box { background: #f7f8f6; border: 1px solid #eef0ed; border-radius: 12px; padding: 14px 16px; font-size: 12.5px; color: #5c6960; margin-bottom: 6px; }
.info-box strong { color: #1b2420; }
.import-preview-table { max-height: 380px; overflow-y: auto; border: 1px solid #e2e6e0; border-radius: 12px; }
.import-preview-table table { table-layout: fixed; width: 100%; margin-bottom: 14px; }
.import-preview-table table:last-child { margin-bottom: 0; }
.import-preview-table th:nth-child(1), .import-preview-table td:nth-child(1) { width: 15%; }
.import-preview-table th:nth-child(2), .import-preview-table td:nth-child(2) { width: 43%; word-break: break-word; }
.import-preview-table th:nth-child(3), .import-preview-table td:nth-child(3) { width: 12%; }
.import-preview-table th:nth-child(4), .import-preview-table td:nth-child(4) { width: 30%; }
.import-preview-section-title { font-size: 13.5px; margin: 0 0 8px; font-weight: 700; }

/* ---------------- Layout / sidebar ---------------- */

.app-shell {
  display: flex;
  min-height: 100vh;
  align-items: stretch;
}

.sidebar {
  width: 260px;
  flex-shrink: 0;
  background: var(--sidebar-bg);
  padding: 26px 18px;
  display: flex;
  flex-direction: column;
  position: sticky;
  top: 0;
  height: 100vh;
  overflow-y: auto;
  scrollbar-width: none; /* Firefox */
  -ms-overflow-style: none; /* versões antigas do Edge/IE */
}
.sidebar::-webkit-scrollbar { display: none; } /* Chrome/Edge/Safari */

.sidebar-brand { text-align: center; margin-bottom: 8px; }
.sidebar-brand-icon { width: 76px; height: auto; margin-bottom: 4px; }
.sidebar-brand-industrias {
  font-size: 10px; font-weight: 600; letter-spacing: 3px; color: #eafaf6;
}
.sidebar-brand-aiam { font-size: 20px; font-weight: 800; color: #fff; line-height: 1.1; }
.sidebar-brand-underline { width: 46px; height: 3px; background: var(--brand-orange); border-radius: 2px; margin: 6px auto 0; }
.sidebar-tagline { font-size: 12px; color: var(--sidebar-text-soft); margin-top: 10px; text-align: center; }

.sidebar-user { display: flex; align-items: center; gap: 10px; margin-top: 20px; }
.sidebar-avatar {
  width: 36px; height: 36px; border-radius: 50%; background: var(--brand-orange); color: #fff;
  display: flex; align-items: center; justify-content: center; font-weight: 700; flex-shrink: 0;
}
.sidebar-user-name { color: #fff; font-weight: 600; font-size: 14px; line-height: 1.2; }
.sidebar-user-role { color: var(--sidebar-text-soft); font-size: 12px; }

.sidebar-logout {
  display: flex; align-items: center; gap: 8px; color: #eafaf6; text-decoration: none;
  font-size: 13.5px; font-weight: 600; margin-top: 14px; padding: 6px 4px; border-radius: 8px;
}
.sidebar-logout:hover { background: rgba(255,255,255,0.08); color: #fff; }

.sidebar-divider { border: none; border-top: 1px solid rgba(255,255,255,0.15); margin: 18px 0; }

.sidebar-nav { display: flex; flex-direction: column; gap: 2px; }
.sidebar-nav-item {
  display: flex; align-items: center; gap: 12px; padding: 10px 12px; border-radius: 10px;
  color: var(--sidebar-text); text-decoration: none; font-size: 14px; font-weight: 500;
}
.sidebar-nav-item:hover { background: rgba(255,255,255,0.08); color: #fff; }
.sidebar-nav-item.active { background: rgba(255,255,255,0.16); color: #fff; font-weight: 700; }
.sidebar-nav-icon { display: flex; flex-shrink: 0; }

.app-main { flex: 1; min-width: 0; }

.sidebar-burger {
  position: fixed; top: 14px; left: 14px; z-index: 1050;
  background: var(--sidebar-bg); color: #fff; border: none; border-radius: 10px;
  padding: 9px 10px; box-shadow: 0 2px 8px rgba(0,0,0,0.2);
}
.sidebar-backdrop {
  display: none; position: fixed; inset: 0; background: rgba(0,0,0,0.45); z-index: 1030;
}
.sidebar-backdrop.show { display: block; }

@media (max-width: 991.98px) {
  .sidebar {
    position: fixed; left: -280px; top: 0; height: 100vh; z-index: 1040;
    transition: left .2s ease; box-shadow: 4px 0 16px rgba(0,0,0,0.2);
  }
  .sidebar.open { left: 0; }
  .app-main { width: 100%; }
  main.container-fluid { padding-top: 56px !important; }
}
@media (min-width: 992px) {
  .sidebar-burger { display: none !important; }
}

/* ---------------- Cards de estatística do dashboard (protótipo: .grid-cards/.stat-card) ---------------- */

.grid-cards { display: grid; grid-template-columns: repeat(auto-fit, minmax(190px, 1fr)); gap: 16px; margin-bottom: 26px; }
.stat-card { background: var(--surface); border-radius: 16px; padding: 18px 20px; box-shadow: var(--shadow); border: 1px solid var(--border); }
.stat-card:hover { border-color: var(--teal-500); box-shadow: 0 4px 16px rgba(20, 30, 25, .1); }
.stat-card .label { font-size: 12.5px; color: var(--ink-soft); font-weight: 600; text-transform: uppercase; letter-spacing: .03em; margin-bottom: 8px; }
.stat-card .value { font-family: 'JetBrains Mono', monospace; font-size: 26px; font-weight: 600; color: var(--ink); }
.stat-card .sub { font-size: 12.5px; color: var(--ink-faint); margin-top: 4px; }
.stat-card.alert .value { color: var(--danger); }
.stat-card.ok .value { color: var(--success); }

/* Link de linha de tabela (ex.: nome da programação) com aparência de texto
   normal -- sem azul/sublinhado padrão do navegador, só um leve destaque
   teal ao passar o mouse pra continuar dando pra perceber que é clicável. */
.row-name-link { color: var(--ink); text-decoration: none; }
.row-name-link:hover { color: var(--teal-700); text-decoration: underline; }

/* Botão secundário neutro (protótipo: usado no dashboard pra "Baixar Relatório",
   diferente do .btn-brand-outline em teal usado nas telas de cadastro). */
.btn-secondary {
  background: var(--surface-alt); border: 1px solid var(--border); color: var(--ink);
  padding: 11px; border-radius: 11px; font-weight: 600; font-size: 14px; cursor: pointer;
}
.btn-secondary:hover { background: var(--border); color: var(--ink); }
