/* =============================================================
   ERP FONSECAS ENG. — Estilos Customizados
   Cores: Azul Marinho (#0d3b6e) + Verde Energia (#1a6b3c)
   ============================================================= */

:root {
  --primary:        #0d3b6e;
  --primary-light:  #1a5fa8;
  --secondary:      #1a6b3c;
  --sidebar-bg:     #0d3b6e;
  --sidebar-width:  260px;
  --topbar-height:  60px;
  --transition:     .25s ease;
  --radius:         10px;
}

/* ── Base ───────────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; }

body {
  font-family: 'Inter', sans-serif;
  background: #f4f6fb;
  color: #1e293b;
  font-size: 14px;
}

/* ── Topbar ─────────────────────────────────────────────── */
.topbar {
  background: linear-gradient(90deg, var(--primary) 0%, var(--primary-light) 100%);
  height: var(--topbar-height);
  z-index: 1030;
  box-shadow: 0 2px 10px rgba(0,0,0,.15);
}

.topbar .navbar-brand {
  font-size: 1rem;
  font-weight: 700;
  letter-spacing: .5px;
}

.topbar .btn-link { text-decoration: none; }

.avatar-circle {
  width: 34px;
  height: 34px;
  border-radius: 50%;
  background: rgba(255,255,255,.25);
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  font-size: .85rem;
}

/* ── Layout ─────────────────────────────────────────────── */
.layout-wrapper {
  display: flex;
  padding-top: var(--topbar-height);
  min-height: 100vh;
  /* align-items padrão do flex é stretch — isso pode travar altura em alguns browsers */
  align-items: flex-start;
}

/* ── Sidebar ─────────────────────────────────────────────── */
.sidebar {
  width: var(--sidebar-width);
  background: var(--sidebar-bg);
  position: fixed;
  top: var(--topbar-height);
  left: 0;
  bottom: 0;
  z-index: 1020;
  display: flex;
  flex-direction: column;
  transition: width var(--transition), transform var(--transition);
  overflow: hidden;
}

.sidebar.collapsed {
  width: 0;
  transform: translateX(-100%);
}

.sidebar-header {
  padding: 1.25rem 1.5rem;
  border-bottom: 1px solid rgba(255,255,255,.1);
}

.sidebar-brand {
  display: flex;
  flex-direction: column;
}

.sidebar-brand span {
  color: #fff;
  font-weight: 700;
  font-size: .9rem;
  letter-spacing: 1px;
}

.sidebar-brand small {
  color: rgba(255,255,255,.5);
  font-size: .7rem;
}

/* Nav items */
.sidebar-nav {
  flex: 1;
  overflow-y: auto;
  padding: .75rem 0;
  scrollbar-width: thin;
  scrollbar-color: rgba(255,255,255,.1) transparent;
}

/* Seções retráteis do menu */
.nav-section { list-style: none; }

.nav-section-toggle {
  width: 100%;
  background: none;
  border: none;
  display: flex;
  align-items: center;
  justify-content: space-between;
  color: rgba(255,255,255,.62);
  font-size: .65rem;
  font-weight: 600;
  letter-spacing: 1.2px;
  text-transform: uppercase;
  padding: .9rem 1.5rem .5rem;
  cursor: pointer;
  transition: color var(--transition);
}

.nav-section-toggle:hover { color: rgba(255,255,255,.85); }

.nav-section-chevron {
  font-size: .65rem;
  transition: transform var(--transition);
}

.nav-section.open .nav-section-chevron { transform: rotate(90deg); }

.nav-section-body {
  max-height: 0;
  overflow: hidden;
  transition: max-height var(--transition);
  list-style: none;
  margin: 0;
  padding: 0;
}

.nav-section.open .nav-section-body { max-height: 600px; }

.sidebar-nav .nav-link {
  color: rgba(255,255,255,.75);
  padding: .55rem 1.5rem;
  border-radius: 0;
  display: flex;
  align-items: center;
  gap: .75rem;
  transition: background var(--transition), color var(--transition);
  white-space: nowrap;
}

.sidebar-nav .nav-link i {
  font-size: 1.1rem;
  flex-shrink: 0;
}

.sidebar-nav .nav-link:hover {
  background: rgba(255,255,255,.08);
  color: #fff;
}

.sidebar-nav .nav-link.active {
  background: rgba(255,255,255,.15);
  color: #fff;
  font-weight: 600;
  border-right: 3px solid #fff;
}

/* Sidebar footer */
.sidebar-footer {
  padding: 1rem 1.5rem;
  border-top: 1px solid rgba(255,255,255,.1);
}

.btn-logout {
  display: flex;
  align-items: center;
  gap: .75rem;
  color: rgba(255,255,255,.6);
  text-decoration: none;
  font-size: .85rem;
  transition: color var(--transition);
}

.btn-logout:hover { color: #fff; }

/* ── Main Content ───────────────────────────────────────── */
.main-content {
  flex: 1;
  margin-left: var(--sidebar-width);
  transition: margin var(--transition);
  min-width: 0;
  /* garante que o conteúdo longo possa rolar normalmente */
  overflow-x: hidden;
}

/* Compensa a topbar fixa ao usar scrollIntoView / âncoras */
* { scroll-margin-top: calc(var(--topbar-height) + 12px); }

/* Tabela de itens — garante que as linhas tenham altura mínima visível */
#tabelaItens tbody tr td { padding-top: 6px; padding-bottom: 6px; }
#tabelaItens tbody tr td input.form-control { min-height: 34px; }

.main-content.expanded {
  margin-left: 0;
}

/* ── Cards de Estatística ───────────────────────────────── */
.stat-card {
  border: none;
  border-radius: var(--radius);
  box-shadow: 0 2px 8px rgba(0,0,0,.06);
  transition: transform .2s, box-shadow .2s;
}

.stat-card:hover {
  transform: translateY(-2px);
  box-shadow: 0 6px 20px rgba(0,0,0,.1);
}

.stat-label {
  font-size: .75rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: .5px;
  margin-bottom: .25rem;
  opacity: .7;
}

.stat-value {
  font-size: 1.75rem;
  font-weight: 700;
  margin-bottom: .1rem;
  line-height: 1;
}

.stat-sub {
  font-size: .72rem;
  opacity: .65;
}

.stat-icon {
  width: 52px;
  height: 52px;
  border-radius: 50%;
  background: rgba(255,255,255,.2);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.5rem;
}

/* Variantes de cor */
.stat-primary { background: linear-gradient(135deg, #0d3b6e, #1a5fa8); color: #fff; }
.stat-success { background: linear-gradient(135deg, #1a6b3c, #27ae60); color: #fff; }
.stat-info    { background: linear-gradient(135deg, #1565c0, #1e88e5); color: #fff; }
.stat-warning { background: linear-gradient(135deg, #e65100, #fb8c00); color: #fff; }

/* ── Cards gerais ───────────────────────────────────────── */
.card {
  border: none;
  border-radius: var(--radius);
  box-shadow: 0 2px 8px rgba(0,0,0,.06);
}

.card-header {
  background: transparent;
  border-bottom: 1px solid #f0f0f0;
}

/* ── Page Header ────────────────────────────────────────── */
.page-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: .75rem;
}

/* ── Botões ─────────────────────────────────────────────── */
.btn-primary {
  background: var(--primary);
  border-color: var(--primary);
}

.btn-primary:hover, .btn-primary:focus {
  background: var(--primary-light);
  border-color: var(--primary-light);
}

.btn-outline-primary {
  color: var(--primary);
  border-color: var(--primary);
}

.btn-outline-primary:hover {
  background: var(--primary);
  border-color: var(--primary);
}

/* ── Badges ─────────────────────────────────────────────── */
.badge {
  font-weight: 500;
  font-size: .7rem;
  padding: .35em .65em;
}

.bg-success-subtle { background: #d1f0e0 !important; }
.text-success       { color: #1a6b3c !important; }
.bg-primary-subtle  { background: #d0e4f7 !important; }
.bg-warning-subtle  { background: #fff3cd !important; }
.bg-danger-subtle   { background: #fde8e8 !important; }
.bg-secondary-subtle{ background: #e9ecef !important; }

/* ── Tabelas ─────────────────────────────────────────────── */
.table th {
  font-size: .72rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: .5px;
  color: #64748b;
}

.table td { font-size: .85rem; vertical-align: middle; }
.table-hover tbody tr:hover { background: #f8faff; }

/* ── Formulários ─────────────────────────────────────────── */
.form-label { font-weight: 500; font-size: .82rem; color: #374151; }
.form-control:focus, .form-select:focus {
  border-color: var(--primary-light);
  box-shadow: 0 0 0 .2rem rgba(13,59,110,.15);
}

/* ── Progress ───────────────────────────────────────────── */
.progress { background: #e9ecef; }
.progress-bar.bg-primary { background: var(--primary) !important; }

/* ── Scrollbar ───────────────────────────────────────────── */
::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: #cbd5e1; border-radius: 3px; }

/* ── Responsivo ─────────────────────────────────────────── */
@media (max-width: 991px) {
  .sidebar {
    transform: translateX(-100%);
  }

  .sidebar:not(.collapsed) {
    transform: translateX(0);
    box-shadow: 5px 0 20px rgba(0,0,0,.2);
  }

  .main-content {
    margin-left: 0;
  }
}

@media (max-width: 575px) {
  .stat-value { font-size: 1.4rem; }
}
