/* RESET & CSS VARIABLES */
@import url('https://fonts.googleapis.com/css2?family=Inter:wght@300;400;500;600;700&display=swap');

:root {
  --cor-primaria: #0f4c81;     /* Azul Escuro / Título */
  --cor-secundaria: #f58220;   /* Laranja de Destaque */
  --cor-fundo: #f5f7fa;        /* Cinza de fundo principal */
  --cor-borda: #d8dee9;        /* Borda padrão */
  --cor-texto: #243447;        /* Cor de fonte primária */
  --cor-texto-secundario: #6b7280;
  --cor-sucesso: #15803d;
  --cor-alerta: #b45309;
  --cor-erro: #b91c1c;

  /* Sidebar Vars */
  --cor-sidebar: #1f2f46;
  --cor-sidebar-panel: rgba(255, 255, 255, 0.05);
  --cor-sidebar-border: rgba(255, 255, 255, 0.08);
  --cor-sidebar-hover: #2e435f;
  --cor-texto-claro: #fff;
  --cor-texto-muted: #9fb3c8;
}

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

body {
  font-family: 'Inter', 'Poppins', sans-serif;
  font-size: 13px;
  background: var(--cor-fundo);
  color: var(--cor-texto);
}

/* LAYOUT PRINCIPAL */
.layout {
  display: flex;
  min-height: 100vh;
}
/* Layout Grid Específico para calculadoras (ex: Silo / Plano de Carga) */
.layout.grid-layout {
  display: grid;
  grid-template-columns: 246px 1fr;
}
.layout.grid-layout.sidebar-collapsed {
  grid-template-columns: minmax(0, 1fr);
}
.layout.sidebar-collapsed .sidebar {
  display: none !important;
}
.layout.grid-layout > .content {
  min-width: 0;
}
@media (max-width: 1200px) {
  .layout.grid-layout { grid-template-columns: 1fr; }
  .sidebar { display: none !important; }
}

/* SIDEBAR DA APLICAÇÃO (Unificado) */
.sidebar {
  width: 250px;
  background: var(--cor-sidebar);
  color: var(--cor-texto-claro);
  padding: 20px 12px;
  display: flex;
  flex-direction: column;
  gap: 18px;
  min-height: 100vh;
  align-self: stretch;
  overflow-y: auto;
}
.layout.grid-layout .sidebar {
  width: auto;
}

.logo {
  display: flex;
  align-items: center;
  justify-content: center;
  flex-direction: column;
  text-align: center;
  width: 100%;
  gap: 10px;
  margin-bottom: 10px;
}
.logo a {
  display: block;
}
.logo img {
  width: 100%;
  max-width: 180px;
  max-height: 60px;
  object-fit: contain;
  display: block;
}
.logo span {
  font-weight: 600;
  font-size: 11px;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: #dbe6f2;
  margin-top: 5px;
}

/* PAINÉIS DO SIDEBAR */
.sidebar-panel {
  background: var(--cor-sidebar-panel);
  border: 1px solid var(--cor-sidebar-border);
  border-radius: 12px;
  padding: 12px;
}
.sidebar-panel h4 {
  font-size: 12px;
  margin-bottom: 10px;
  color: var(--cor-texto-muted);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  font-weight: 700;
}

/* SUBMENUS / ACORDEÃO (MOCKUP STYLE) */
.sidebar-submenu {
  display: none;
  flex-direction: column;
  gap: 4px;
  padding-left: 28px;
  margin-top: 4px;
  margin-bottom: 10px;
}
.sidebar-panel.is-open .sidebar-submenu {
  display: flex;
}
.accordion-btn {
  width: 100%;
  display: flex;
  align-items: center;
  justify-content: space-between;
  color: var(--cor-texto-muted);
  background: transparent;
  border: none;
  padding: 8px;
  font-family: inherit;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  border-radius: 8px;
  transition: .2s;
}
.accordion-btn:hover { background: rgba(255,255,255,0.05); color: #fff;}
.accordionLine { display: flex; align-items: center; gap: 8px; }

.sidebar-actions {
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.tool-btn {
  width: 100%;
  display: flex;
  align-items: center;
  justify-content: flex-start;
  gap: 8px;
  color: var(--cor-texto-claro);
  text-decoration: none;
  padding: 10px 12px;
  border-radius: 8px;
  border: 1px solid rgba(255, 255, 255, 0.1);
  background: rgba(255, 255, 255, 0.06);
  font-family: inherit;
  font-size: 13px;
  font-weight: 600;
  transition: all 0.2s ease;
  cursor: pointer;
}
.tool-btn:hover:not(:disabled):not(.is-disabled) {
  background: var(--cor-sidebar-hover);
  border-color: rgba(255, 255, 255, 0.16);
}
.tool-btn.is-disabled,
.tool-btn[aria-disabled="true"],
.tool-btn:disabled {
  opacity: 0.45;
  cursor: not-allowed;
  pointer-events: none;
  background: rgba(255,255,255,0.02);
  color: #8b9fb6;
}
.tool-btn.active, .tab-btn.active {
  background: #2f6ea9;
  border-color: #2f6ea9;
  color: #fff;
  font-weight: 700;
}
.tool-symbol {
  width: 18px;
  min-width: 18px;
  text-align: center;
  font-size: 16px;
  line-height: 1;
}

/* ÁREA CENTRAL E CONTEÚDO */
.content {
  flex: 1;
  display: flex;
  flex-direction: column;
  min-width: 0;
}
.layout.grid-layout .content {
  width: 100%;
}
.layout.grid-layout .page,
.layout.grid-layout .header,
.layout.grid-layout .tab-content,
.layout.grid-layout .card,
.layout.grid-layout .grid-2 {
  min-width: 0;
}

/* TOPBAR */
.topbar {
  height: 64px;
  background: #fff;
  border-bottom: 1px solid var(--cor-borda);
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 0 24px;
}
.topbar-left {
  display: flex;
  align-items: center;
  gap: 16px;
}
.menu-hamburguer {
  background: transparent;
  border: none;
  color: var(--cor-texto-secundario);
  font-size: 24px;
  cursor: pointer;
  transition: .2s;
}
.menu-hamburguer:hover { color: var(--cor-primaria); }

.user {
  display: flex;
  align-items: center;
  gap: 20px;
  font-size: 14px;
}
.usuario, .usuario-link {
  font-weight: 600;
  cursor: pointer;
  color: var(--cor-texto-secundario);
  transition: color 0.2s ease;
}
.usuario:hover, .usuario-link:hover {
  color: var(--cor-primaria);
}
.logout-btn {
  padding: 8px 16px;
  border: none;
  border-radius: 8px;
  background: var(--cor-primaria);
  color: #fff;
  font-weight: 600;
  cursor: pointer;
  transition: .2s;
}
.logout-btn:hover { background: #245784; }
.logout-btn[hidden] { display: none; }

/* DASHBOARD CARDS (GRID) */
.page {
  padding: 24px;
}
.welcome {
  padding: 10px 0 20px;
}
.welcome h1 {
  font-size: 26px;
  font-weight: 700;
  color: var(--cor-primaria);
  margin-bottom: 6px;
}
.welcome p {
  font-size: 14px;
  color: var(--cor-texto-secundario);
}
.cards {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(320px, 1fr));
  gap: 24px;
  padding-bottom: 40px;
}
.home-groups {
  display: flex;
  flex-direction: column;
  gap: 26px;
  padding-bottom: 40px;
}
.home-group {
  display: flex;
  flex-direction: column;
  gap: 16px;
}
.home-group-header {
  background: #fff;
  border: 1px solid var(--cor-borda);
  border-radius: 14px;
  padding: 18px 20px;
}
.home-group-header h2 {
  font-size: 18px;
  font-weight: 700;
  color: var(--cor-primaria);
  margin-bottom: 6px;
}
.home-group-header p {
  font-size: 13px;
  color: var(--cor-texto-secundario);
  line-height: 1.45;
}
.home-group .cards {
  padding-bottom: 0;
}
.card-module {
  background: #fff;
  border: 1px solid var(--cor-borda);
  border-radius: 12px;
  padding: 20px;
  box-shadow: 0 4px 15px rgba(0,0,0,0.02);
  transition: 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275);
  display: flex;
  flex-direction: column;
}
.card-module:hover:not(.disabled) {
  transform: translateY(-4px);
  box-shadow: 0 10px 25px rgba(15, 76, 129, 0.1);
  border-color: #aebfd1;
}
.card-module.disabled {
  opacity: 0.55;
}

.card-header-view {
  display: flex;
  gap: 16px;
  margin-bottom: 18px;
}
.icon-box {
  width: 50px;
  height: 50px;
  background: var(--cor-fundo);
  color: var(--cor-primaria);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 26px;
  border-radius: 10px;
  flex-shrink: 0;
}
.icon-box img {
    max-width: 32px;
    max-height: 32px;
    object-fit: contain;
}
.card-text-view h2 {
  font-size: 16px;
  font-weight: 700;
  color: var(--cor-texto);
  margin-bottom: 4px;
}
.card-text-view p {
  font-size: 13px;
  color: var(--cor-texto-secundario);
  line-height: 1.4;
}

.card-module button {
  width: 100%;
  padding: 12px;
  background: var(--cor-primaria);
  color: white;
  border: none;
  border-radius: 8px;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.2s ease;
  margin-top: auto;
}
.card-module button:hover { background: #0c3e69; }
.card-module.disabled button { background: #9ca3af; cursor: not-allowed; }

/* ESTRUTURA INTERNA (Módulos Silo e Plano) */
.header {
  background: #fff;
  border: 1px solid var(--cor-borda);
  border-radius: 16px;
  padding: 20px;
  margin-bottom: 18px;
  display: flex;
  flex-direction: column;
}
.header-top {
  display: flex;
  align-items: center;
  gap: 16px;
  margin-bottom: 10px;
}
.header-top img {
  width: auto;
  max-width: 160px;
  height: auto;
  object-fit: contain;
}
.title {
  font-size: 24px;
  font-weight: 700;
  color: var(--cor-primaria);
}

.tab-content {
  display: none;
  background: #fff;
  border: 1px solid var(--cor-borda);
  border-radius: 16px;
  padding: 24px;
}
.tab-content.active { display: block; }

.section-title {
  font-size: 18px;
  font-weight: 700;
  color: var(--cor-primaria);
  margin-bottom: 8px;
}
.line {
  height: 2px;
  background: linear-gradient(90deg, var(--cor-secundaria), transparent);
  margin-bottom: 24px;
  border-radius: 999px;
  width: 100%;
}

/* Grids modulares internos */
.grid-2 {
  display: grid;
  grid-template-columns: 1.2fr 1fr;
  gap: 24px;
}
.grid-3 {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 14px;
}
.card {
  border: 1px solid var(--cor-borda);
  border-radius: 16px;
  padding: 20px;
  background: #fff;
}
.subtitle {
  font-size: 15px;
  font-weight: 700;
  margin-bottom: 16px;
  color: var(--cor-primaria);
}

/* Elementos de Formulário */
.row {
  display: grid;
  grid-template-columns: minmax(170px, 1fr) minmax(180px, 220px) 44px;
  align-items: center;
  gap: 10px;
  margin-bottom: 12px;
}
.row input[type="text"], .row input[type="number"], .row select, .row textarea, .dim-input, .filtro-input {
  width: 100%;
  padding: 10px 12px;
  border: 1px solid var(--cor-borda);
  border-radius: 8px;
  font-family: inherit;
  font-size: 13px;
  background: #fbfdff;
  color: var(--cor-texto);
  transition: .2s;
}
.row select {
  appearance: auto;
  -webkit-appearance: menulist;
  line-height: 1.2;
  -webkit-text-fill-color: var(--cor-texto);
}
.row select option {
  color: #243447;
  background: #ffffff;
}
.row select.is-placeholder {
  color: #6b7280;
  -webkit-text-fill-color: #6b7280;
}
.native-select {
  appearance: auto !important;
  -webkit-appearance: menulist !important;
  -moz-appearance: menulist !important;
  background: #ffffff !important;
  background-image: none !important;
  color: #000000 !important;
  -webkit-text-fill-color: #000000 !important;
  border: 1px solid #767676 !important;
  border-radius: 2px !important;
  box-shadow: none !important;
  text-shadow: none !important;
  opacity: 1 !important;
  visibility: visible !important;
  line-height: normal !important;
  font: 13px Arial, sans-serif !important;
  padding: 1px 2px !important;
  min-height: 24px !important;
}
.native-select option {
  color: #000000 !important;
  background: #ffffff !important;
}
.native-select:focus {
  outline: 1px solid Highlight !important;
  outline: 1px auto -webkit-focus-ring-color !important;
  border-color: #767676 !important;
  box-shadow: none !important;
}

input[type="checkbox"], input[type="radio"] {
  appearance: auto;
  -webkit-appearance: checkbox;
  width: 16px;
  height: 16px;
  margin: 0;
  cursor: pointer;
  background: revert;
  border: revert;
}
input[type="radio"] {
  -webkit-appearance: radio;
}
.row input:focus, .row select:focus, .row textarea:focus {
  outline: none;
  border-color: var(--cor-primaria);
  background: #fff;
  box-shadow: 0 0 0 3px rgba(15, 76, 129, 0.1);
}
.row textarea {
  min-height: 100px;
  resize: vertical;
  grid-column: 2 / 4;
}
.unit {
  color: var(--cor-texto-secundario);
  font-size: 13px;
  white-space: nowrap;
  font-weight: 500;
}

/* Ajustes especificos do modulo Silo para prevalecer sobre formularios.css */
.silo-layout .grid-2 {
  grid-template-columns: minmax(0, 1.15fr) minmax(0, 0.95fr);
  align-items: start;
}
.silo-layout .card {
  min-width: 0;
}
.silo-layout .row {
  grid-template-columns: minmax(180px, 1fr) minmax(180px, 220px) 56px;
  gap: 12px;
}
.silo-layout .row input[type="text"],
.silo-layout .row input[type="number"],
.silo-layout .row select,
.silo-layout .row textarea {
  width: 100%;
  min-width: 0;
}
.silo-layout .row textarea {
  grid-column: 2 / 4;
}
.silo-layout #norma {
  min-width: 220px;
}
.silo-layout .silo-select {
  appearance: auto;
  -webkit-appearance: menulist;
  -moz-appearance: menulist;
  min-width: 220px;
  width: 100%;
  height: 24px;
  padding: 2px 6px;
  border: 1px solid #cfd8e3;
  border-radius: 4px;
  background: #ffffff;
  color: var(--cor-texto);
  -webkit-text-fill-color: var(--cor-texto);
  font-family: inherit;
  font-size: 13px;
  line-height: normal;
  box-shadow: none;
  text-shadow: none;
}
.silo-layout .silo-select:focus {
  outline: 1px auto -webkit-focus-ring-color;
  outline-offset: 0;
  border-color: #cfd8e3;
  box-shadow: none;
}
.silo-layout .silo-select option {
  color: var(--cor-texto);
  background: #ffffff;
}
.plano-layout .plano-select {
  appearance: auto;
  -webkit-appearance: menulist;
  -moz-appearance: menulist;
  background: #ffffff;
  color: var(--cor-texto);
  -webkit-text-fill-color: var(--cor-texto);
  border: 1px solid #cfd8e3;
  border-radius: 4px;
  box-shadow: none;
  text-shadow: none;
  font-family: inherit;
  font-size: 13px;
  line-height: normal;
  padding: 2px 6px;
}
.plano-layout .plano-select:focus {
  outline: 1px auto -webkit-focus-ring-color;
  outline-offset: 0;
  border-color: #cfd8e3;
  box-shadow: none;
}
.plano-layout .plano-select option {
  color: var(--cor-texto);
  background: #ffffff;
}
.silo-layout #material_nome,
.silo-layout #proj_nome,
.silo-layout #proj_cliente,
.silo-layout #proj_silo {
  min-width: 220px;
}
.silo-layout .footer-aba {
  justify-content: flex-end;
}
@media (max-width: 1100px) {
  .silo-layout .grid-2 {
    grid-template-columns: 1fr;
  }
}

/* Botões Inferiores (Módulos de calculo) */
.toolbar-acoes, .footer-aba {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  justify-content: space-between;
  margin-top: 24px;
}
.btn-primario, .btn-secundario, .btn-proxima, .btn-light {
  border: 0;
  border-radius: 8px;
  padding: 12px 18px;
  font-family: inherit;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  transition: .2s;
}
.btn-primario, .btn-proxima {
  background: var(--cor-primaria);
  color: #fff;
}
.btn-primario:hover, .btn-proxima:hover { background: #0c3e69; }
.btn-secundario, .btn-light {
  background: #e2e8f0;
  color: #1e293b;
}
.btn-secundario:hover, .btn-light:hover { background: #cbd5e1; }
.btn-primario:disabled, .btn-proxima:disabled, button:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

/* Modais */
.modal-shell {
  position: fixed;
  inset: 0;
  background: rgba(15, 23, 42, 0.6);
  backdrop-filter: blur(4px);
  display: none;
  align-items: center;
  justify-content: center;
  padding: 24px;
  z-index: 1000;
}
.modal-shell.modal-open { display: flex; }
.modal-card {
  width: min(520px, 100%);
  background: #fff;
  border-radius: 16px;
  padding: 30px;
  box-shadow: 0 24px 60px rgba(15, 23, 42, 0.2);
}
.modal-card h2 { margin-bottom: 8px; color: var(--cor-primaria); }
.modal-card p { color: var(--cor-texto-secundario); margin-bottom: 24px; line-height: 1.5; }
.login-card { width: min(420px, 100%); }
.modal-label { display: block; margin: 12px 0 6px; font-weight: 600; }
.modal-input {
  width: 100%;
  border: 1px solid var(--cor-borda);
  border-radius: 8px;
  padding: 12px;
  font-family: inherit;
}
.modal-actions { display: flex; justify-content: flex-end; gap: 12px; margin-top: 24px; }
.login-erro { color: var(--cor-erro); margin: 12px 0 0; font-weight: 600; }

/* Tabelas */
.table-wrap {
  overflow-x: auto;
  border-radius: 12px;
  border: 1px solid var(--cor-borda);
}
table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
}
th, td {
  border-bottom: 1px solid var(--cor-borda);
  padding: 12px;
  text-align: left;
}
thead th {
  background: #edf4fb;
  color: var(--cor-primaria);
  font-weight: 700;
  text-transform: uppercase;
  font-size: 12px;
  letter-spacing: 0.05em;
}

/* ESPECÍFICO RESULTADOS E FIGURAS */
.resultado-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
  gap: 14px;
  margin-bottom: 20px;
}
.resultado-item {
  border: 1px solid var(--cor-borda);
  border-radius: 12px;
  padding: 16px;
  background: #f8fbff;
}
.resultado-item small {
  display: block;
  color: var(--cor-texto-secundario);
  margin-bottom: 6px;
}
.resultado-item strong {
  display: block;
  color: var(--cor-primaria);
  font-size: 17px;
}

.figure-box {
  position: relative;
  border: 1px solid var(--cor-borda);
  border-radius: 16px;
  padding: 14px;
  min-height: 480px;
  background: #fbfdff;
  overflow: hidden;
}
.silo-figure {
  width: 100%;
  max-width: 420px;
  margin: 0 auto;
  display: block;
}
.dim-input {
  position: absolute;
  width: 110px !important;
  background: rgba(255,255,255,.95) !important;
  box-shadow: 0 8px 20px rgba(15,76,129,.08) !important;
  z-index: 10;
}
.dim-diametro { left: 50%; bottom: 40px; transform: translateX(-50%); }
.dim-hcil { right: 16px; top: 130px; }
.dim-hcone { right: 16px; top: 330px; }
.dim-htotal { left: 16px; top: 220px; }

.figure-note {
  margin-top: 16px;
  font-size: 13px;
  color: #475569;
  line-height: 1.5;
}

/* Modifiers for Status */
.status-ok { color: var(--cor-sucesso) !important; font-weight: 700; }
.status-alerta { color: var(--cor-alerta) !important; font-weight: 700; }
.status-erro { color: var(--cor-erro) !important; font-weight: 700; }

/* TITULOS PADRONIZADOS DOS MÓDULOS */
.section-title {
  margin-top: 20px;
  font-size: 20px;
  font-weight: 700;
  color: var(--cor-primaria);
  margin-bottom: 6px;
}

.line {
  height: 2px;
  background: linear-gradient(90deg, var(--cor-secundaria), transparent);
  margin-bottom: 20px;
  border-radius: 999px;
}

.subtitle {
  font-size: 16px;
  font-weight: 700;
  margin-bottom: 14px;
  color: var(--cor-primaria);
}

/* Rodapé */
.footer {
  margin-top: auto;
  text-align: center;
  padding: 20px;
  color: var(--cor-texto-secundario);
  font-size: 13px;
}

/* Helpers */
.hidden { display: none !important; }
