/* Design system simples e responsivo do Sistema OS. Vanilla CSS, sem framework. */

:root {
  --cor-primaria: #1a5276;
  --cor-primaria-escura: #123a53;
  --cor-perigo: #922b21;
  --cor-sucesso: #1e8449;
  --cor-fundo: #f4f6f8;
  --cor-texto: #17202a;
  --cor-borda: #dfe4ea;
  --raio: 8px;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  font-family: -apple-system, Segoe UI, Arial, sans-serif;
  background: var(--cor-fundo);
  color: var(--cor-texto);
}

a { color: var(--cor-primaria); text-decoration: none; }

/* ---------- Layout geral ---------- */
#app-shell {
  display: flex;
  min-height: 100vh;
}

.sidebar {
  width: 220px;
  flex-shrink: 0;
  background: var(--cor-primaria-escura);
  color: #fff;
  display: flex;
  flex-direction: column;
}

.sidebar-brand {
  padding: 20px 16px;
  font-weight: bold;
  font-size: 18px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.15);
}

.sidebar-menu { display: flex; flex-direction: column; padding: 8px; }

.menu-item {
  color: #d6e4ef;
  padding: 10px 12px;
  border-radius: var(--raio);
  margin-bottom: 2px;
}

.menu-item:hover { background: rgba(255, 255, 255, 0.08); color: #fff; }
.menu-item-ativo { background: #fff; color: var(--cor-primaria-escura); font-weight: 600; }

.main { flex: 1; display: flex; flex-direction: column; min-width: 0; }

.topbar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  background: #fff;
  border-bottom: 1px solid var(--cor-borda);
  padding: 12px 20px;
}

.topbar-usuario { display: flex; align-items: center; gap: 12px; }

/* ---------- Notificações (sino no topbar) ---------- */
.notif-wrap { position: relative; }
.notif-sino {
  position: relative; background: none; border: none; cursor: pointer; font-size: 18px;
  padding: 6px 8px; border-radius: var(--raio); line-height: 1;
}
.notif-sino:hover { background: #eef1f5; }
.notif-badge {
  position: absolute; top: 0; right: 0; background: var(--cor-perigo); color: #fff;
  border-radius: 999px; font-size: 10px; font-weight: 700; padding: 1px 5px; line-height: 1.4;
}
.notif-dropdown {
  position: absolute; top: 100%; right: 0; margin-top: 6px; width: 320px; max-height: 380px;
  background: #fff; border: 1px solid var(--cor-borda); border-radius: var(--raio);
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.15); z-index: 1200; overflow: hidden;
  display: flex; flex-direction: column;
}
.notif-dropdown-topo {
  display: flex; justify-content: space-between; align-items: center; padding: 10px 12px;
  border-bottom: 1px solid var(--cor-borda); font-size: 13px;
}
.notif-marcar-todas { background: none; border: none; color: var(--cor-primaria); font-size: 12px; cursor: pointer; }
.notif-lista { overflow-y: auto; }
.notif-item { padding: 10px 12px; border-bottom: 1px solid var(--cor-borda); cursor: pointer; font-size: 13px; }
.notif-item:hover { background: #f8fafc; }
.notif-item-nao-lida { background: #eaf2f8; }
.notif-item-msg { margin-bottom: 2px; }
.notif-item-tempo { font-size: 11px; color: #667; }
.notif-vazio { padding: 16px 12px; color: #667; font-size: 13px; text-align: center; margin: 0; }

.breadcrumbs {
  padding: 10px 20px;
  font-size: 13px;
  color: #667;
}

.page-content { padding: 0 20px 40px; }

/* ---------- Formulários de auth (login) ---------- */
.auth-wrap {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  background: linear-gradient(135deg, var(--cor-primaria) 0%, var(--cor-primaria-escura) 100%);
}

.auth-card {
  background: #fff;
  padding: 32px;
  border-radius: var(--raio);
  width: 100%;
  max-width: 360px;
  box-shadow: 0 10px 40px rgba(0, 0, 0, 0.2);
}

.auth-card h1 { margin-top: 0; font-size: 20px; }

/* ---------- Cards de dashboard ---------- */
.cards-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
  gap: 16px;
  margin: 20px 0;
}

.card {
  background: #fff;
  border: 1px solid var(--cor-borda);
  border-radius: var(--raio);
  padding: 16px;
}

.card .card-valor { font-size: 26px; font-weight: 700; margin: 4px 0; }
.card .card-titulo { font-size: 12px; color: #667; text-transform: uppercase; letter-spacing: 0.03em; }
.card.card-alerta { border-left: 4px solid var(--cor-perigo); }
.card.card-destaque { border-left: 4px solid var(--cor-sucesso); }

/* ---------- Tabelas ---------- */
.tabela-wrap { background: #fff; border: 1px solid var(--cor-borda); border-radius: var(--raio); overflow: auto; }

table.tabela { width: 100%; border-collapse: collapse; font-size: 14px; }
table.tabela th, table.tabela td { padding: 10px 12px; border-bottom: 1px solid var(--cor-borda); text-align: left; }
table.tabela th { background: #f8f9fb; font-weight: 600; font-size: 12px; text-transform: uppercase; color: #667; }
table.tabela tbody tr:hover { background: #f8fafc; cursor: pointer; }

.dica-relatorio { font-size: 13px; color: #667; margin: 0 0 12px; }

/* ---------- Filtros ---------- */
.filtros { display: flex; gap: 10px; flex-wrap: wrap; margin: 16px 0; align-items: end; }
.filtros .campo { display: flex; flex-direction: column; gap: 4px; }
.filtros label { font-size: 12px; color: #667; }

/* ---------- Formulários ---------- */
.form-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: 14px; }
.campo { display: flex; flex-direction: column; gap: 4px; margin-bottom: 4px; }
.campo label { font-size: 13px; font-weight: 600; }
.campo .erro { color: var(--cor-perigo); font-size: 12px; }

input, select, textarea {
  padding: 9px 10px;
  border: 1px solid var(--cor-borda);
  border-radius: var(--raio);
  font-size: 14px;
  font-family: inherit;
  width: 100%;
}

input:focus, select:focus, textarea:focus { outline: 2px solid var(--cor-primaria); }

/* ---------- Botões ---------- */
.btn {
  padding: 9px 16px;
  border-radius: var(--raio);
  border: none;
  font-size: 14px;
  cursor: pointer;
  font-weight: 600;
}

.btn-primario { background: var(--cor-primaria); color: #fff; }
.btn-primario:hover { background: var(--cor-primaria-escura); }
.btn-secundario { background: #eef1f5; color: var(--cor-texto); }
.btn-secundario:hover { background: #dfe4ea; }
.btn-perigo { background: var(--cor-perigo); color: #fff; }
.btn:disabled { opacity: 0.6; cursor: not-allowed; }

.acoes-topo { display: flex; justify-content: space-between; align-items: center; margin: 20px 0 10px; }

/* ---------- Badges de status ---------- */
.badge { padding: 3px 10px; border-radius: 999px; font-size: 12px; font-weight: 600; white-space: nowrap; }
.badge-aberta { background: #eaf2f8; color: #1a5276; }
.badge-em_analise { background: #fef5e7; color: #9a7d0a; }
.badge-aguardando_aprovacao { background: #f4ecf7; color: #6c3483; }
.badge-aprovada { background: #e8f8f5; color: #0e6251; }
.badge-em_execucao { background: #eafaf1; color: #1e8449; }
.badge-aguardando_peca { background: #fdedec; color: #922b21; }
.badge-finalizada { background: #eafaf1; color: #145a32; }
.badge-cancelada { background: #f2f3f4; color: #566573; }
.badge-encerrada { background: #eaeded; color: #17202a; }

/* ---------- Abas (ordem.html) ---------- */
.tabs { display: flex; gap: 4px; border-bottom: 1px solid var(--cor-borda); margin-bottom: 16px; flex-wrap: wrap; }
.tab-btn { padding: 10px 14px; background: none; border: none; cursor: pointer; font-size: 14px; border-bottom: 2px solid transparent; }
.tab-btn.tab-ativa { border-bottom-color: var(--cor-primaria); color: var(--cor-primaria); font-weight: 600; }
.tab-btn:disabled { color: #aaa; cursor: not-allowed; }
.tab-painel { display: none; }
.tab-painel.tab-painel-ativo { display: block; }

/* ---------- Toast ---------- */
.toast-container { position: fixed; top: 16px; right: 16px; display: flex; flex-direction: column; gap: 8px; z-index: 1000; }
.toast {
  background: #17202a; color: #fff; padding: 12px 16px; border-radius: var(--raio);
  opacity: 0; transform: translateY(-8px); transition: all 0.25s ease; max-width: 340px; font-size: 14px;
}
.toast-show { opacity: 1; transform: translateY(0); }
.toast-erro { background: var(--cor-perigo); }
.toast-sucesso { background: var(--cor-sucesso); }

/* ---------- Loading ---------- */
.loading-overlay {
  position: fixed; inset: 0; background: rgba(255, 255, 255, 0.6);
  display: none; align-items: center; justify-content: center; z-index: 2000;
}
.loading-overlay.loading-visible { display: flex; }
.spinner {
  width: 36px; height: 36px; border: 4px solid var(--cor-borda); border-top-color: var(--cor-primaria);
  border-radius: 50%; animation: girar 0.8s linear infinite;
}
@keyframes girar { to { transform: rotate(360deg); } }

/* ---------- Modal ---------- */
.modal-overlay {
  position: fixed; inset: 0; background: rgba(0, 0, 0, 0.4);
  display: flex; align-items: center; justify-content: center; z-index: 1500;
}
.modal { background: #fff; padding: 24px; border-radius: var(--raio); width: 100%; max-width: 380px; }
.modal-actions { display: flex; justify-content: flex-end; gap: 8px; margin-top: 16px; }

/* ---------- Responsivo ---------- */
@media (max-width: 768px) {
  #app-shell { flex-direction: column; }
  .sidebar { width: 100%; flex-direction: row; overflow-x: auto; }
  .sidebar-menu { flex-direction: row; }
  .sidebar-brand { display: none; }
}
