/* =========================
   Tema e Variáveis Globais
   ========================= */
:root {
  --bg: #f2f3f5;
  --surface: #ffffff;
  --text: #2c3e50;
  --muted: #7f8c8d;
  --primary: #27ae60; /* Verde Estrela de Canaã */
  --primary-light: #e9f7ef;
  --accent: #f1c40f; /* Amarelo Estrela de Canaã */
  --border: #dcdde1;
  --shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.1), 0 2px 4px -1px rgba(0, 0, 0, 0.06);
  --shadow-hover: 0 10px 15px -3px rgba(0, 0, 0, 0.1), 0 4px 6px -2px rgba(0, 0, 0, 0.05);
  --radius: 12px;
  --pdf-primary: #1b5e20; /* Verde escuro institucional para PDF */
  --pdf-secondary: #fbc02d; /* Amarelo institucional para PDF */
}

[data-theme="dark"] {
  --bg: #1a1a1a;
  --surface: #2d2d2d;
  --text: #ecf0f1;
  --muted: #95a5a6;
  --primary: #2ecc71; /* Verde brilhante para tema escuro */
  --primary-light: #1e3d2b;
  --border: #404040;
  --shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.3);
  --shadow-hover: 0 10px 15px -3px rgba(0, 0, 0, 0.4);
}

/* Estilos Gerais de Input */
input, select, textarea {
  width: 100%;
  padding: 12px 15px;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: var(--surface) !important;
  color: var(--text) !important;
  font-family: inherit;
  font-size: 16px;
  transition: all 0.2s;
  box-sizing: border-box;
  display: block;
  -webkit-appearance: none;
  opacity: 1 !important;
  visibility: visible !important;
}

input:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(0, 74, 153, 0.2);
}

/* Login Page */
.login-page {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 100vh;
  background: var(--bg);
  padding: 20px;
}

.login-card {
  background: var(--surface);
  padding: 40px;
  border-radius: 12px;
  box-shadow: var(--shadow-hover);
  width: 100%;
  max-width: 400px;
  text-align: center;
  border: 1px solid var(--border);
}

.login-form {
  margin-top: 30px;
  display: flex;
  flex-direction: column;
  gap: 20px;
  text-align: left;
}

.login-field {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.login-field label {
  font-weight: 600;
  font-size: 14px;
  color: var(--text);
  opacity: 0.8;
}

.btn-login {
  background: var(--primary);
  color: white;
  padding: 14px;
  border-radius: 8px;
  border: none;
  font-weight: 700;
  font-size: 16px;
  cursor: pointer;
  margin-top: 10px;
  transition: background 0.2s;
}

.btn-login:hover {
  background: #003a7a;
}

.login-footer {
  margin-top: 25px;
  font-size: 13px;
  color: var(--muted);
}

.error-msg {
  background: #fdeaea;
  color: #e74c3c;
  padding: 10px;
  border-radius: 8px;
  font-size: 14px;
  margin-bottom: 15px;
  border: 1px solid #f5c6cb;
  display: none;
  animation: shake 0.4s ease-in-out;
}

@keyframes shake {
  0%, 100% { transform: translateX(0); }
  25% { transform: translateX(-5px); }
  75% { transform: translateX(5px); }
}

/* PDF & Print Styles */
@media print {
  @page {
    margin: 2cm;
  }
  
  body { 
    background: white !important;
    color: black !important;
  }
  
  #app, #toasts, .modal, #loading, .btn { display: none !important; }
  
  /* -----------------------------
     PDF / Print Styles (Elegant)
     ----------------------------- */
  .print-area { 
    display: block !important;
    width: 100%;
    background: white;
    color: #333;
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
  }

  .pdf-container {
    padding: 40px;
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    position: relative;
  }

  .pdf-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    border-bottom: 3px solid var(--pdf-primary);
    padding-bottom: 20px;
    margin-bottom: 40px;
  }

  .pdf-logo {
    display: flex;
    align-items: center;
    gap: 20px;
  }

  .pdf-logo svg {
    color: var(--pdf-primary);
    filter: drop-shadow(0 2px 4px rgba(0,0,0,0.1));
  }

  .pdf-logo-text h1 {
    font-size: 32px;
    margin: 0;
    color: var(--pdf-primary);
    font-weight: 900;
    letter-spacing: -1px;
    line-height: 1;
  }

  .pdf-logo-text .subtitle {
    font-size: 10px;
    color: var(--pdf-primary);
    letter-spacing: 3px;
    font-weight: 700;
    margin-top: 4px;
    opacity: 0.8;
  }

  .pdf-info {
    text-align: right;
    line-height: 1.5;
  }

  .pdf-info .chapter-name {
    font-weight: 800;
    font-size: 16px;
    color: var(--pdf-primary);
  }

  .pdf-info .location {
    font-size: 13px;
    color: #666;
  }

  .pdf-info .gen-date {
    font-size: 11px;
    color: #999;
    margin-top: 5px;
    font-style: italic;
  }

  .pdf-title-area {
    text-align: center;
    margin-bottom: 40px;
    position: relative;
  }

  .pdf-main-title {
    font-size: 26px;
    color: #222;
    text-transform: uppercase;
    margin-bottom: 10px;
    font-weight: 800;
    letter-spacing: 1px;
  }

  .pdf-title-line {
    width: 60px;
    height: 4px;
    background: var(--pdf-secondary);
    margin: 0 auto;
    border-radius: 2px;
  }

  /* Summary Grid */
  .pdf-summary-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 20px;
    margin-bottom: 40px;
  }

  .pdf-summary-card {
    background: #fcfcfc;
    border: 1px solid #eee;
    padding: 15px;
    border-radius: 8px;
    text-align: center;
    border-top: 4px solid var(--pdf-primary);
  }

  .pdf-summary-card .label {
    font-size: 11px;
    text-transform: uppercase;
    color: #777;
    margin-bottom: 5px;
    font-weight: 700;
  }

  .pdf-summary-card .value {
    font-size: 18px;
    font-weight: 800;
  }

  .pdf-summary-card .value.primary { color: var(--pdf-primary); }
  .pdf-summary-card .value.success { color: #27ae60; }
  .pdf-summary-card .value.danger { color: #e74c3c; }

  /* Tables */
  .pdf-table {
    width: 100%;
    border-collapse: collapse;
    margin-bottom: 50px;
    background: white;
  }

  .pdf-table th {
    background: #f4f4f4;
    color: #333;
    font-size: 12px;
    text-transform: uppercase;
    padding: 15px 12px;
    text-align: left;
    border-bottom: 2px solid var(--pdf-primary);
    font-weight: 800;
  }

  .pdf-table td {
    padding: 12px;
    border-bottom: 1px solid #eee;
    font-size: 13px;
    color: #444;
  }

  .pdf-table tr:nth-child(even) {
    background-color: #fafafa;
  }

  .pdf-table tr:last-child td {
    border-bottom: 2px solid #eee;
  }

  /* Badges */
  .badge {
    padding: 4px 8px;
    border-radius: 4px;
    font-size: 10px;
    font-weight: 700;
    text-transform: uppercase;
    background: #eee;
    color: #666;
  }

  .badge.ativo, .badge.entrada, .badge.success { background: #e8f5e9; color: #2e7d32; }
  .badge.inativo, .badge.saida, .badge.danger { background: #ffebee; color: #c62828; }

  /* Event Sections */
  .pdf-event-section {
    margin-bottom: 30px;
    page-break-inside: avoid;
  }

  .pdf-event-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 15px;
    background: #f9f9f9;
    padding: 10px 15px;
    border-left: 5px solid var(--pdf-primary);
  }

  .pdf-event-header h3 {
    margin: 0;
    font-size: 18px;
    color: var(--pdf-primary);
  }

  .pdf-event-header span {
    font-size: 13px;
    color: #777;
    font-weight: 600;
  }

  .pdf-event-body {
    padding: 0 15px;
    font-size: 14px;
    line-height: 1.6;
  }

  .pdf-divider {
    border: 0;
    border-top: 1px dashed #ddd;
    margin: 30px 0;
  }

  /* Signatures */
  .pdf-signatures {
    margin-top: auto;
    display: flex;
    justify-content: space-around;
    padding: 60px 0 40px;
    page-break-inside: avoid;
  }

  .signature-box {
    text-align: center;
    width: 250px;
  }

  .signature-box .line {
    border-top: 1px solid #333;
    margin-bottom: 10px;
  }

  .signature-box .role {
    font-size: 12px;
    font-weight: 800;
    color: var(--pdf-primary);
    text-transform: uppercase;
  }

  .signature-box .name {
    font-size: 13px;
    color: #555;
    margin-top: 2px;
  }

  /* Footer */
  .pdf-footer {
    border-top: 1px solid #eee;
    padding-top: 15px;
    display: flex;
    justify-content: space-between;
    font-size: 10px;
    color: #aaa;
    font-weight: 600;
  }
}

/* UI Adjustments */
.btn svg {
  margin-right: 0;
}

.avatar svg {
  color: white;
}

/* Reset básico */
* { box-sizing: border-box; margin: 0; padding: 0; }
html, body { height: 100%; }
body {
  font-family: 'Segoe UI', Roboto, Helvetica, Arial, sans-serif;
  color: var(--text);
  background-color: var(--bg);
  line-height: 1.5;
}

/* Scroll customizado */
* {
  scrollbar-width: thin;
  scrollbar-color: var(--primary) transparent;
}
::-webkit-scrollbar { width: 8px; height: 8px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb {
  background: var(--primary);
  border-radius: 999px;
}

/* Loading */
#loading {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.4);
  display: none;
  place-items: center;
  flex-direction: column;
  gap: 12px;
  z-index: 9999;
  color: #fff;
}
#loading.active { display: flex; }
.spinner {
  width: 32px; height: 32px;
  border: 4px solid rgba(255, 255, 255, 0.3);
  border-top-color: #fff;
  border-radius: 50%;
  animation: spin 1s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* Toasts */
#toasts {
  position: fixed;
  top: 20px; right: 20px;
  display: flex; flex-direction: column;
  gap: 10px; z-index: 10000;
}
.toast {
  padding: 12px 20px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-left: 4px solid var(--primary);
  box-shadow: var(--shadow);
  border-radius: var(--radius);
  animation: slideIn 0.3s ease;
}
.toast.success { border-left-color: #2ecc71; }
.toast.error { border-left-color: #e74c3c; }
@keyframes slideIn {
  from { transform: translateX(100%); opacity: 0; }
  to { transform: translateX(0); opacity: 1; }
}

/* Layout SPA */
.app {
  display: flex;
  flex-direction: column;
  min-height: 100vh;
}

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

/* Topbar Institucional */
.topbar {
  height: 70px;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 30px;
  position: sticky;
  top: 0;
  z-index: 100;
  box-shadow: 0 2px 4px rgba(0,0,0,0.02);
}

.topbar-left, .topbar-right {
  display: flex;
  align-items: center;
  gap: 20px;
}

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

.logo {
  font-size: 24px;
  width: 40px;
  height: 40px;
  background: var(--primary);
  color: white;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 10px;
}

.title {
  font-size: 20px;
  font-weight: 700;
  color: var(--primary);
  letter-spacing: -0.5px;
}

.top-info {
  display: flex;
  gap: 15px;
}

.chip {
  background: var(--primary-light);
  color: var(--primary);
  padding: 6px 14px;
  border-radius: 20px;
  font-size: 13px;
  font-weight: 600;
}

.profile-pill {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 6px 6px 6px 14px;
  background: var(--bg);
  border-radius: 30px;
  border: 1px solid var(--border);
}

.profile-pill span {
  font-size: 14px;
  font-weight: 600;
}

.avatar {
  width: 32px;
  height: 32px;
  background: var(--primary);
  color: white;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
}

/* Área de Visualização */
.view {
  flex: 1;
  padding: 40px;
  max-width: 1400px;
  margin: 0 auto;
  width: 100%;
}

/* Grid de Módulos (Dashboard) */
.module-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
  gap: 20px;
}

.module-card {
  background: var(--surface);
  border-radius: var(--radius);
  padding: 40px 20px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
  cursor: pointer;
  transition: all 0.3s ease;
  border: 1px solid var(--border);
  box-shadow: var(--shadow);
  text-decoration: none;
  color: var(--text);
}

.module-card:hover {
  transform: translateY(-5px);
  box-shadow: var(--shadow-hover);
  border-color: var(--primary);
}

.module-icon-circle {
  width: 80px;
  height: 80px;
  border-radius: 50%;
  background: var(--primary-light);
  color: var(--primary);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 32px;
  margin-bottom: 20px;
  transition: all 0.3s ease;
}

.module-card:hover .module-icon-circle {
  background: var(--primary);
  color: white;
}

.module-card h3 {
  font-size: 18px;
  font-weight: 700;
  margin: 0;
}

/* Componentes Gerais */
.card {
  background: var(--surface);
  border-radius: var(--radius);
  padding: 25px;
  border: 1px solid var(--border);
  box-shadow: var(--shadow);
  margin-bottom: 25px;
}

.card-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 20px;
}

.btn {
  padding: 10px 20px;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text);
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s;
  display: inline-flex;
  align-items: center;
  gap: 8px;
}

.btn:hover {
  background: var(--bg);
}

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

.btn.primary:hover {
  filter: brightness(1.1);
}

.btn.danger {
  background: #e74c3c;
  color: white;
  border-color: #e74c3c;
}

.btn.ghost {
  background: transparent;
  border-color: transparent;
}

.icon-btn {
  padding: 8px;
  font-size: 20px;
}

/* Tabelas */
.table-container {
  overflow-x: auto;
  border-radius: var(--radius);
  border: 1px solid var(--border);
}

.table {
  width: 100%;
  border-collapse: collapse;
  background: var(--surface);
}

.table th, .table td {
  padding: 15px 20px;
  text-align: left;
  border-bottom: 1px solid var(--border);
}

.table th {
  background: var(--bg);
  font-weight: 700;
  color: var(--text);
  text-transform: uppercase;
  font-size: 12px;
  letter-spacing: 0.5px;
}

.table tr:last-child td {
  border-bottom: none;
}

.table tr:hover td {
  background: var(--primary-light);
}

/* Formulários */
.group {
  margin-bottom: 15px;
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.group label {
  font-size: 14px;
  font-weight: 600;
  color: var(--muted);
}

.input, .select {
  padding: 12px 15px;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: var(--bg);
  color: var(--text);
  font-size: 15px;
  width: 100%;
}

.input:focus, .select:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 3px var(--primary-light);
}

/* Modal */
.modal {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.7);
  display: none;
  place-items: center;
  z-index: 1000;
  padding: 20px;
  backdrop-filter: blur(4px);
}

.modal.show {
  display: flex;
  justify-content: center;
  align-items: center;
}

.modal-dialog {
  background: var(--surface);
  width: 100%;
  max-width: 600px;
  max-height: 90vh;
  border-radius: var(--radius);
  box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.5);
  display: flex;
  flex-direction: column;
  animation: modalIn 0.3s cubic-bezier(0.34, 1.56, 0.64, 1);
  border: 1px solid var(--border);
}

@keyframes modalIn {
  from { transform: translateY(30px) scale(0.95); opacity: 0; }
  to { transform: translateY(0) scale(1); opacity: 1; }
}

.modal-header {
  padding: 20px 25px;
  border-bottom: 1px solid var(--border);
  display: flex;
  justify-content: space-between;
  align-items: center;
  background: var(--surface);
  flex-shrink: 0;
}

.modal-body {
  padding: 25px;
  overflow-y: auto;
  flex: 1;
  max-height: calc(90vh - 140px);
}

.modal-footer {
  padding: 15px 25px;
  background: var(--bg);
  border-top: 1px solid var(--border);
  display: flex;
  justify-content: flex-end;
  gap: 12px;
  flex-shrink: 0;
}

/* Dashboard Stats */
/* Dashboard layout */
.dashboard-content {
  margin-top: 20px;
}

@media (max-width: 900px) {
  .dashboard-content {
    grid-template-columns: 1fr !important;
  }
}

.stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 20px;
  margin-bottom: 25px;
}

.stat-card {
  background: var(--surface);
  padding: 20px;
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  text-align: center;
  border-bottom: 4px solid var(--primary);
}

.stat-label {
  font-size: 14px;
  color: var(--muted);
  font-weight: 600;
  text-transform: uppercase;
}

.stat-value {
  font-size: 28px;
  font-weight: 800;
  color: var(--primary);
  margin-top: 5px;
}

/* Responsividade */
@media (max-width: 1024px) {
  .view { padding: 20px; }
  .topbar { padding: 0 20px; }
}

@media (max-width: 768px) {
  .top-info { display: none; }
  .module-grid { grid-template-columns: repeat(2, 1fr); }
  .topbar-right span { display: none; }
}

@media (max-width: 480px) {
  .module-grid { grid-template-columns: 1fr; }
  .topbar { padding: 0 15px; }
}

/* Área de Impressão */
.print-area { display: none; }
@media print {
  body { background: white; }
  #app, #toasts, .modal, #loading { display: none !important; }
  .print-area { display: block; }
}
