/* ============================================================
   Rota Nordeste ERP — CSS Principal
   Design moderno com CSS Grid + Flexbox
   Identidade visual baseada na logo oficial
   ============================================================ */

/* ── Variáveis de cor ── */
:root {
  --azul:          #1E3A8A;
  --azul-escuro:   #0f172a;
  --azul-medio:    #1d4ed8;
  --azul-claro:    #dbeafe;
  --laranja:       #F97316;
  --laranja-hover: #EA580C;
  --cinza-bg:      #f1f5f9;
  --cinza-borda:   #e2e8f0;
  --cinza-texto:   #64748b;
  --branco:        #ffffff;
  --texto:         #1e293b;
  --verde:         #16a34a;
  --vermelho:      #dc2626;
  --amarelo:       #d97706;
  --sombra:        0 4px 20px rgba(0,0,0,0.08);
  --sombra-hover:  0 8px 30px rgba(0,0,0,0.14);
  --radius:        10px;
  --radius-lg:     16px;
  --transition:    all 0.2s ease;
}

/* ── Reset ── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

html {
  font-size: 15px;
  scroll-behavior: smooth;
  /* Evita scrollbar horizontal na página toda */
  overflow-x: hidden;
  /* Altura exata da viewport — evita scroll duplo */
  height: 100%;
}

body {
  font-family: 'Segoe UI', system-ui, -apple-system, sans-serif;
  background: var(--cinza-bg);
  color: var(--texto);
  line-height: 1.6;
  overflow-x: hidden;
  height: 100%;
}

a { color: inherit; text-decoration: none; }

img { max-width: 100%; display: block; }

/* ============================================================
   LOGIN
   ============================================================ */
.login-page {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  background: linear-gradient(135deg, var(--azul-escuro) 0%, var(--azul) 100%);
  padding: 20px;
}

.login-card {
  background: var(--branco);
  border-radius: var(--radius-lg);
  padding: 48px 40px;
  width: 100%;
  max-width: 400px;
  box-shadow: 0 25px 60px rgba(0,0,0,0.3);
  text-align: center;
}

.login-card .logo {
  width: 140px;
  margin: 0 auto 28px;
}

.login-card h2 {
  font-size: 1.4rem;
  color: var(--azul);
  margin-bottom: 6px;
}

.login-card p {
  color: var(--cinza-texto);
  font-size: 0.9rem;
  margin-bottom: 28px;
}

/* ============================================================
   FORMULÁRIOS
   ============================================================ */
.form-group {
  margin-bottom: 16px;
  text-align: left;
}

.form-group label {
  display: block;
  font-size: 0.82rem;
  font-weight: 600;
  color: var(--cinza-texto);
  margin-bottom: 6px;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.form-group input,
.form-group select,
.form-group textarea {
  width: 100%;
  padding: 10px 14px;
  border: 1.5px solid var(--cinza-borda);
  border-radius: var(--radius);
  font-size: 0.95rem;
  color: var(--texto);
  background: var(--branco);
  transition: var(--transition);
  outline: none;
}

.form-group input:focus,
.form-group select:focus,
.form-group textarea:focus {
  border-color: var(--azul-medio);
  box-shadow: 0 0 0 3px rgba(37,99,235,0.12);
}

.form-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 14px;
}

.form-row-3 {
  display: grid;
  grid-template-columns: 1fr 1fr 1fr;
  gap: 14px;
}

/* ============================================================
   BOTÕES
   ============================================================ */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 10px 20px;
  border: none;
  border-radius: var(--radius);
  font-size: 0.9rem;
  font-weight: 600;
  cursor: pointer;
  transition: var(--transition);
  text-decoration: none;
}

.btn-primary {
  background: var(--laranja);
  color: var(--branco);
}
.btn-primary:hover { background: var(--laranja-hover); transform: translateY(-1px); box-shadow: var(--sombra-hover); }

.btn-blue {
  background: var(--azul);
  color: var(--branco);
}
.btn-blue:hover { background: var(--azul-medio); transform: translateY(-1px); }

.btn-success {
  background: var(--verde);
  color: var(--branco);
}
.btn-success:hover { background: #15803d; }

.btn-danger {
  background: var(--vermelho);
  color: var(--branco);
}
.btn-danger:hover { background: #b91c1c; }

.btn-outline {
  background: transparent;
  border: 1.5px solid var(--cinza-borda);
  color: var(--texto);
}
.btn-outline:hover { border-color: var(--azul); color: var(--azul); }

.btn-sm { padding: 6px 12px; font-size: 0.8rem; }
.btn-full { width: 100%; justify-content: center; }
.btn-lg { padding: 13px 28px; font-size: 1rem; }

/* ============================================================
   LAYOUT PRINCIPAL (SIDEBAR + CONTEÚDO)
   ============================================================ */
.app-layout {
  display: grid;
  grid-template-columns: 240px 1fr;
  min-height: 100vh;
  /* Garante que o layout não ultrapasse a largura da tela */
  max-width: 100vw;
  overflow: hidden;
}

/* ── Sidebar ── */
.sidebar {
  background: var(--azul-escuro);
  color: var(--branco);
  display: flex;
  flex-direction: column;
  position: sticky;
  top: 0;
  height: 100vh;
  overflow-y: auto;
  overflow-x: hidden;
  /* Scrollbar invisível — todos os browsers */
  scrollbar-width: none;        /* Firefox */
  -ms-overflow-style: none;     /* IE / Edge legado */
}

/* Chrome, Safari, Opera */
.sidebar::-webkit-scrollbar {
  display: none;
  width: 0;
}

.sidebar-brand {
  padding: 18px 20px 14px;
  border-bottom: 1px solid rgba(255,255,255,0.08);
  flex-shrink: 0;
}

.sidebar-brand img {
  width: 100px;
  margin-bottom: 6px;
}

.sidebar-brand span {
  font-size: 0.68rem;
  color: rgba(255,255,255,0.4);
  text-transform: uppercase;
  letter-spacing: 0.08em;
}

.sidebar-nav {
  flex: 1;
  padding: 10px 0;
  overflow-y: auto;
  overflow-x: hidden;
  scrollbar-width: none;
  -ms-overflow-style: none;
}

.sidebar-nav::-webkit-scrollbar {
  display: none;
  width: 0;
}

.nav-section {
  padding: 8px 20px 3px;
  font-size: 0.65rem;
  font-weight: 700;
  color: rgba(255,255,255,0.28);
  text-transform: uppercase;
  letter-spacing: 0.1em;
}

.nav-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 9px 20px;
  color: rgba(255,255,255,0.7);
  font-size: 0.875rem;
  transition: var(--transition);
  cursor: pointer;
  border-left: 3px solid transparent;
  white-space: nowrap;
}

.nav-item:hover,
.nav-item.active {
  background: rgba(255,255,255,0.07);
  color: var(--branco);
  border-left-color: var(--laranja);
}

.nav-item .icon {
  font-size: 1rem;
  width: 20px;
  text-align: center;
  flex-shrink: 0;
}

.sidebar-footer {
  padding: 12px 20px;
  border-top: 1px solid rgba(255,255,255,0.08);
  font-size: 0.78rem;
  color: rgba(255,255,255,0.35);
  flex-shrink: 0;
}

/* ── Área principal ── */
.main-area {
  display: flex;
  flex-direction: column;
  min-height: 100vh;
  /* Scroll apenas aqui, não na página toda */
  overflow-y: auto;
  overflow-x: hidden;
  /* Scrollbar fina e discreta */
  scrollbar-width: thin;
  scrollbar-color: var(--cinza-borda) transparent;
}

.main-area::-webkit-scrollbar {
  width: 5px;
}

.main-area::-webkit-scrollbar-track {
  background: transparent;
}

.main-area::-webkit-scrollbar-thumb {
  background: var(--cinza-borda);
  border-radius: 10px;
}

.main-area::-webkit-scrollbar-thumb:hover {
  background: var(--cinza-texto);
}

/* ── Topbar ── */
.topbar {
  background: var(--branco);
  padding: 14px 28px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  border-bottom: 1px solid var(--cinza-borda);
  position: sticky;
  top: 0;
  z-index: 100;
  box-shadow: 0 1px 8px rgba(0,0,0,0.05);
}

.topbar-title {
  font-size: 1.1rem;
  font-weight: 700;
  color: var(--azul);
}

.topbar-right {
  display: flex;
  align-items: center;
  gap: 16px;
}

.user-info {
  display: flex;
  align-items: center;
  gap: 10px;
  cursor: pointer;
}

.avatar {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  object-fit: cover;
  border: 2px solid var(--laranja);
}

.user-name { font-size: 0.88rem; font-weight: 600; }
.user-role { font-size: 0.75rem; color: var(--cinza-texto); }

/* ── Conteúdo ── */
.content {
  padding: 28px;
  flex: 1;
}

.page-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 24px;
}

.page-title {
  font-size: 1.5rem;
  font-weight: 700;
  color: var(--texto);
}

.page-subtitle {
  font-size: 0.88rem;
  color: var(--cinza-texto);
  margin-top: 2px;
}

/* ============================================================
   CARDS
   ============================================================ */
.card {
  background: var(--branco);
  border-radius: var(--radius-lg);
  padding: 24px;
  box-shadow: var(--sombra);
  margin-bottom: 24px;
}

.card-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 20px;
  padding-bottom: 16px;
  border-bottom: 1px solid var(--cinza-borda);
}

.card-title {
  font-size: 1rem;
  font-weight: 700;
  color: var(--texto);
}

/* ── Cards de estatística ── */
.stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 20px;
  margin-bottom: 28px;
}

.stat-card {
  background: var(--branco);
  border-radius: var(--radius-lg);
  padding: 22px;
  box-shadow: var(--sombra);
  display: flex;
  align-items: center;
  gap: 16px;
  transition: var(--transition);
}

.stat-card:hover { transform: translateY(-2px); box-shadow: var(--sombra-hover); }

.stat-icon {
  width: 52px;
  height: 52px;
  border-radius: 12px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.5rem;
  flex-shrink: 0;
}

.stat-icon.blue   { background: var(--azul-claro); }
.stat-icon.orange { background: #fff7ed; }
.stat-icon.green  { background: #dcfce7; }
.stat-icon.red    { background: #fee2e2; }

.stat-value {
  font-size: 1.5rem;
  font-weight: 800;
  color: var(--texto);
  line-height: 1;
}

.stat-label {
  font-size: 0.8rem;
  color: var(--cinza-texto);
  margin-top: 4px;
}

/* ============================================================
   TABELAS
   ============================================================ */
.table-wrapper {
  overflow-x: auto;
  border-radius: var(--radius);
}

table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.9rem;
}

thead th {
  background: var(--cinza-bg);
  padding: 12px 16px;
  text-align: left;
  font-size: 0.78rem;
  font-weight: 700;
  color: var(--cinza-texto);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  border-bottom: 1px solid var(--cinza-borda);
}

tbody td {
  padding: 13px 16px;
  border-bottom: 1px solid var(--cinza-borda);
  color: var(--texto);
}

tbody tr:last-child td { border-bottom: none; }

tbody tr:hover { background: #f8fafc; }

/* ============================================================
   BADGES / STATUS
   ============================================================ */
.badge {
  display: inline-flex;
  align-items: center;
  padding: 3px 10px;
  border-radius: 20px;
  font-size: 0.75rem;
  font-weight: 600;
}

.badge-success { background: #dcfce7; color: #15803d; }
.badge-danger  { background: #fee2e2; color: #b91c1c; }
.badge-warning { background: #fef9c3; color: #a16207; }
.badge-info    { background: var(--azul-claro); color: var(--azul); }
.badge-gray    { background: #f1f5f9; color: var(--cinza-texto); }

/* ============================================================
   ALERTAS
   ============================================================ */
.alert {
  padding: 12px 16px;
  border-radius: var(--radius);
  margin-bottom: 16px;
  font-size: 0.9rem;
  display: flex;
  align-items: center;
  gap: 10px;
}

.alert-success { background: #dcfce7; color: #15803d; border-left: 4px solid #16a34a; }
.alert-danger  { background: #fee2e2; color: #b91c1c; border-left: 4px solid #dc2626; }
.alert-warning { background: #fef9c3; color: #a16207; border-left: 4px solid #d97706; }
.alert-info    { background: var(--azul-claro); color: var(--azul); border-left: 4px solid var(--azul-medio); }

/* ============================================================
   CÁLCULO DE SERVIÇO (PREVIEW)
   ============================================================ */
.calc-preview {
  background: linear-gradient(135deg, var(--azul-escuro), var(--azul));
  color: var(--branco);
  border-radius: var(--radius-lg);
  padding: 20px 24px;
  margin-top: 16px;
}

.calc-preview h4 {
  font-size: 0.8rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  opacity: 0.6;
  margin-bottom: 14px;
}

.calc-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 6px 0;
  font-size: 0.9rem;
  border-bottom: 1px solid rgba(255,255,255,0.1);
}

.calc-row:last-child { border-bottom: none; }

.calc-row.total {
  font-size: 1.1rem;
  font-weight: 800;
  padding-top: 12px;
  margin-top: 4px;
  color: var(--laranja);
}

/* ============================================================
   RELATÓRIO (IMPRESSÃO)
   ============================================================ */
.relatorio-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 24px;
  padding-bottom: 16px;
  border-bottom: 3px solid var(--azul);
}

.relatorio-totais {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 16px;
  margin: 20px 0;
}

.total-box {
  background: var(--cinza-bg);
  border-radius: var(--radius);
  padding: 16px;
  text-align: center;
}

.total-box .valor {
  font-size: 1.4rem;
  font-weight: 800;
  color: var(--azul);
}

.total-box .label {
  font-size: 0.78rem;
  color: var(--cinza-texto);
  margin-top: 4px;
}

.total-box.destaque { background: var(--azul); }
.total-box.destaque .valor { color: var(--branco); }
.total-box.destaque .label { color: rgba(255,255,255,0.7); }

/* ============================================================
   PAGINAÇÃO
   ============================================================ */
.pagination {
  display: flex;
  gap: 6px;
  justify-content: center;
  margin-top: 20px;
}

.pagination a,
.pagination span {
  padding: 7px 13px;
  border-radius: var(--radius);
  font-size: 0.85rem;
  border: 1.5px solid var(--cinza-borda);
  color: var(--texto);
  transition: var(--transition);
}

.pagination a:hover { border-color: var(--azul); color: var(--azul); }
.pagination .active { background: var(--azul); color: var(--branco); border-color: var(--azul); }

/* ============================================================
   MODAL
   ============================================================ */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.5);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1000;
  padding: 20px;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.2s;
}

.modal-overlay.open { opacity: 1; pointer-events: all; }

.modal {
  background: var(--branco);
  border-radius: var(--radius-lg);
  padding: 28px;
  width: 100%;
  max-width: 560px;
  max-height: 90vh;
  overflow-y: auto;
  transform: translateY(20px);
  transition: transform 0.2s;
}

.modal-overlay.open .modal { transform: translateY(0); }

.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 20px;
}

.modal-title { font-size: 1.1rem; font-weight: 700; }

.modal-close {
  background: none;
  border: none;
  font-size: 1.4rem;
  cursor: pointer;
  color: var(--cinza-texto);
  line-height: 1;
}

/* ============================================================
   RESPONSIVO
   ============================================================ */
/* ── Botão menu mobile ── */
.menu-toggle-btn {
  display: none;
  background: none;
  border: none;
  font-size: 1.4rem;
  cursor: pointer;
  padding: 4px 8px;
  border-radius: 6px;
  color: var(--texto);
  transition: var(--transition);
}
.menu-toggle-btn:hover { background: var(--cinza-bg); }

@media (max-width: 900px) {
  .app-layout {
    grid-template-columns: 1fr;
  }

  .sidebar {
    position: fixed;
    left: -260px;
    top: 0;
    z-index: 200;
    transition: left 0.28s ease;
    height: 100vh;
    width: 240px;
  }

  .sidebar.open { left: 0; box-shadow: 4px 0 20px rgba(0,0,0,0.3); }

  #sidebarOverlay.open { display: block !important; }

  .menu-toggle-btn { display: block; }

  .form-row,
  .form-row-3 { grid-template-columns: 1fr; }

  .stats-grid { grid-template-columns: 1fr 1fr; }

  .relatorio-totais { grid-template-columns: 1fr; }
}

@media (max-width: 480px) {
  .content { padding: 16px; }
  .stats-grid { grid-template-columns: 1fr; }
  .login-card { padding: 32px 24px; }
}

/* ============================================================
   IMPRESSÃO
   ============================================================ */
@media print {
  .sidebar, .topbar, .btn, .no-print { display: none !important; }
  .app-layout { grid-template-columns: 1fr; }
  .content { padding: 0; }
  body { background: white; }
}

/* ============================================================
   UTILITÁRIOS
   ============================================================ */
.text-center { text-align: center; }
.text-right  { text-align: right; }
.text-muted  { color: var(--cinza-texto); }
.text-success { color: var(--verde); }
.text-danger  { color: var(--vermelho); }
.text-warning { color: var(--amarelo); }
.fw-bold { font-weight: 700; }
.mt-1 { margin-top: 8px; }
.mt-2 { margin-top: 16px; }
.mt-3 { margin-top: 24px; }
.mb-1 { margin-bottom: 8px; }
.mb-2 { margin-bottom: 16px; }
.mb-3 { margin-bottom: 24px; }
.d-flex { display: flex; }
.align-center { align-items: center; }
.gap-2 { gap: 8px; }
.gap-3 { gap: 16px; }
.w-100 { width: 100%; }

/* ============================================================
   UTILITÁRIOS
   ============================================================ */
.text-center { text-align: center; }
.text-right  { text-align: right; }
.text-muted  { color: var(--cinza-texto); }
.text-success { color: var(--verde); }
.text-danger  { color: var(--vermelho); }
.text-warning { color: var(--amarelo); }
.fw-bold { font-weight: 700; }
.mt-1 { margin-top: 8px; }
.mt-2 { margin-top: 16px; }
.mt-3 { margin-top: 24px; }
.mb-1 { margin-bottom: 8px; }
.mb-2 { margin-bottom: 16px; }
.mb-3 { margin-bottom: 24px; }
.d-flex { display: flex; }
.align-center { align-items: center; }
.gap-2 { gap: 8px; }
.gap-3 { gap: 16px; }
.w-100 { width: 100%; }

/* ── Indicador online (topbar) ── */
@keyframes pulse-green {
  0%, 100% { box-shadow: 0 0 0 0 rgba(34,197,94,0.4); }
  50%       { box-shadow: 0 0 0 5px rgba(34,197,94,0); }
}
