/**
 * PsicoRisk Manager - Design System Local (Estilo Google Stitch)
 * Centraliza os design tokens corporativos e componentes visuais de alta fidelidade.
 * Execução 100% offline e independente, sem dependência obrigatória de CDNs externos.
 */

/* 1. Design Tokens (Variáveis Globais) */
:root {
  /* Cores Principais - Paleta Esmeralda Executiva */
  --prm-brand: #059669;
  --prm-brand-hover: #047857;
  --prm-brand-dark: #064e3b;
  --prm-brand-light: #ecfdf5;
  --prm-bg: #f8fafc;
  --prm-card-bg: #ffffff;
  --prm-text-main: #0f172a;
  --prm-text-muted: #64748b;
  --prm-border: #e2e8f0;
  --prm-border-light: #f1f5f9;

  /* Níveis de Risco */
  --prm-low-risk: #10b981;
  --prm-low-risk-bg: #d1fae5;
  --prm-low-risk-text: #065f46;
  
  --prm-mod-risk: #f59e0b;
  --prm-mod-risk-bg: #fef3c7;
  --prm-mod-risk-text: #92400e;
  
  --prm-high-risk: #ef4444;
  --prm-high-risk-bg: #fee2e2;
  --prm-high-risk-text: #991b1b;

  /* Layout, Raios e Sombras */
  --prm-radius-lg: 12px;
  --prm-radius-md: 8px;
  --prm-radius-sm: 4px;
  
  /* Sombras executivas suaves de múltiplos níveis */
  --prm-shadow-sm: 0 1px 2px 0 rgba(0, 0, 0, 0.05);
  --prm-shadow-md: 0 4px 6px -1px rgba(0, 0, 0, 0.04), 0 2px 4px -2px rgba(0, 0, 0, 0.04);
  --prm-shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.04), 0 4px 6px -4px rgba(0, 0, 0, 0.04);
  --prm-shadow-card: 0 1px 3px rgba(0,0,0,0.05), 0 4px 12px rgba(0,0,0,0.02);
  --prm-shadow-card-hover: 0 12px 20px -8px rgba(0, 0, 0, 0.08), 0 4px 12px -2px rgba(0, 0, 0, 0.03);

  /* Transição de Estado */
  --prm-transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
}

/* 2. Global Reset & Estética Geral */
body {
  font-family: Inter, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  background-color: var(--prm-bg);
  color: var(--prm-text-main);
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}

/* 3. Layout Grid e Containers */
.prm-container {
  width: 94vw;
  max-width: 1400px;
  margin: 1.5rem auto;
}

/* 4. Componentes - Topbar / Navbar Premium */
.prm-global-nav {
  display: block;
}

.prm-navbar {
  background-color: #ffffff;
  border-bottom: 1px solid var(--prm-border);
  box-shadow: var(--prm-shadow-sm);
  padding: 0.75rem 1.5rem;
  height: 64px; /* Altura consistente */
  display: flex;
  align-items: center;
}

.prm-navbar-inner {
  width: 100%;
  max-width: 1600px;
  margin: 0 auto;
}

.prm-brand {
  text-decoration: none;
}

.prm-brand-logo {
  height: 36px;
  width: auto;
  object-fit: contain;
}

.prm-brand-title {
  font-weight: 700;
  font-size: 1.125rem;
  color: var(--prm-text-main);
  letter-spacing: -0.02em;
}

.prm-unit-filter {
  width: 240px;
}

.prm-nav-links-wrapper {
  flex: 0 1 auto;
  min-width: 0;
  margin-left: auto; /* Push wrapper to the right safely */
  overflow-x: auto;
  scrollbar-width: none; /* Firefox */
  -ms-overflow-style: none;  /* IE and Edge */
  -webkit-overflow-scrolling: touch; /* Smooth scroll on iOS */
  display: flex;
}
.prm-nav-links-wrapper::-webkit-scrollbar {
  display: none; /* Safari and Chrome */
}

.prm-nav-links {
  display: flex;
  white-space: nowrap;
  gap: 0.25rem;
}

.prm-nav-link {
  font-size: 0.875rem;
  font-weight: 500;
  color: var(--prm-text-muted);
  text-decoration: none;
  padding: 0.5rem 1rem;
  border-radius: 9999px; /* Formato pílula */
  transition: var(--prm-transition);
  display: inline-block;
}

.prm-nav-link:hover {
  color: var(--prm-brand-dark);
  background-color: var(--prm-border-light);
  text-decoration: none;
}

.prm-nav-link.active {
  color: var(--prm-brand-dark);
  font-weight: 600;
  background-color: var(--prm-brand-light);
}

@media print {
  .no-print,
  .prm-global-nav,
  .prm-navbar {
    display: none !important;
  }
}

/* 5. Componentes - Cards Premium Stitch */
.prm-card {
  background: var(--prm-card-bg);
  border-radius: var(--prm-radius-lg);
  border: 1px solid var(--prm-border-light);
  box-shadow: var(--prm-shadow-card);
  transition: var(--prm-transition);
  padding: 1.5rem;
}

.prm-card:hover {
  box-shadow: var(--prm-shadow-card-hover);
  transform: translateY(-2px);
}

/* 6. Zona de Upload / Importação Minimalista */
.prm-upload-zone {
  border: 2px dashed var(--prm-border);
  border-radius: var(--prm-radius-lg);
  background: #ffffff;
  padding: 2rem;
  text-align: center;
  transition: var(--prm-transition);
}

.prm-upload-zone:hover {
  border-color: var(--prm-brand);
  background: var(--prm-brand-light);
}

/* 7. KPIs Executivos */
.prm-kpi-card {
  background: #ffffff;
  border-radius: var(--prm-radius-lg);
  border: 1px solid var(--prm-border-light);
  padding: 1.25rem 1.5rem;
  box-shadow: var(--prm-shadow-card);
  transition: var(--prm-transition);
  display: flex;
  flex-direction: column;
  justify-content: space-between;
}

.prm-kpi-card:hover {
  transform: translateY(-2px);
  box-shadow: var(--prm-shadow-card-hover);
}

.prm-kpi-value {
  font-size: 1.75rem;
  font-weight: 700;
  color: var(--prm-text-main);
  letter-spacing: -0.02em;
  margin-top: 0.25rem;
}

.prm-kpi-label {
  font-size: 0.75rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--prm-text-muted);
}

/* 8. Badges e Níveis de Risco */
.prm-badge {
  font-size: 0.75rem;
  font-weight: 600;
  padding: 0.25rem 0.75rem;
  border-radius: 9999px;
  display: inline-flex;
  align-items: center;
}

.prm-badge.risk-low {
  background-color: var(--prm-low-risk-bg);
  color: var(--prm-low-risk-text);
  border: 1px solid rgba(16, 185, 129, 0.2);
}

.prm-badge.risk-moderate {
  background-color: var(--prm-mod-risk-bg);
  color: var(--prm-mod-risk-text);
  border: 1px solid rgba(245, 158, 11, 0.2);
}

.prm-badge.risk-high {
  background-color: var(--prm-high-risk-bg);
  color: var(--prm-high-risk-text);
  border: 1px solid rgba(239, 68, 68, 0.2);
}

/* 9. Botões Customizados */
.prm-btn {
  font-size: 0.875rem;
  font-weight: 600;
  padding: 0.5rem 1.25rem;
  border-radius: var(--prm-radius-md);
  transition: var(--prm-transition);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
}

.prm-btn-primary {
  background-color: var(--prm-brand);
  color: #ffffff !important;
  border: 1px solid transparent;
}

.prm-btn-primary:hover:not(:disabled) {
  background-color: var(--prm-brand-hover);
}

.prm-btn-primary:disabled {
  background-color: var(--prm-text-muted);
  opacity: 0.6;
  cursor: not-allowed;
}

.prm-btn-outline-warning {
  border: 1px solid var(--prm-mod-risk);
  color: var(--prm-mod-risk-text) !important;
  background-color: transparent;
}

.prm-btn-outline-warning:hover {
  background-color: var(--prm-mod-risk-bg);
}

.prm-btn-warning {
  background-color: var(--prm-mod-risk);
  color: var(--prm-mod-risk-text) !important;
  border: 1px solid transparent;
}

.prm-btn-warning:hover {
  background-color: #d97706;
}

/* 10. Wrappers de Barras de Progresso de Categoria */
.prm-progress-wrapper {
  background: var(--prm-bg);
  border-radius: 9999px;
  height: 0.625rem;
  overflow: hidden;
  position: relative;
  width: 100%;
}

.prm-progress-bar {
  height: 100%;
  border-radius: 9999px;
  transition: width 0.4s ease;
}

/* 11. Tabela Executiva Clean */
.prm-table-wrapper {
  border-radius: var(--prm-radius-lg);
  overflow: hidden;
  border: 1px solid var(--prm-border-light);
  background: #ffffff;
}

.prm-table {
  width: 100%;
  margin-bottom: 0;
  border-collapse: collapse;
}

.prm-table th {
  background-color: #f8fafc;
  color: var(--prm-text-muted);
  font-size: 0.75rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  padding: 0.75rem 1rem;
  border-bottom: 1px solid var(--prm-border-light);
}

.prm-table td {
  padding: 0.875rem 1rem;
  font-size: 0.875rem;
  border-bottom: 1px solid var(--prm-border-light);
  color: var(--prm-text-main);
  transition: var(--prm-transition);
}

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

.prm-table tr:hover td {
  background-color: var(--prm-bg);
}

/* 12. Sobrescrita de Barras de Progresso e Elementos Dinâmicos */
.prm-card .progress {
  background-color: var(--prm-bg) !important;
  border-radius: 9999px !important;
  height: 8px !important;
  box-shadow: inset 0 1px 2px rgba(0,0,0,0.02) !important;
  overflow: hidden !important;
  border: none !important;
}

.prm-card .progress-bar {
  border-radius: 9999px !important;
  transition: width 0.6s cubic-bezier(0.4, 0, 0.2, 1) !important;
}

.prm-card .progress-bar.bg-success {
  background-color: var(--prm-low-risk) !important;
}

.prm-card .progress-bar.bg-warning {
  background-color: var(--prm-mod-risk) !important;
}

.prm-card .progress-bar.bg-danger {
  background-color: var(--prm-high-risk) !important;
}

/* Custom Scrollbar for premium tables and scrollareas */
::-webkit-scrollbar {
  width: 6px;
  height: 6px;
}

::-webkit-scrollbar-track {
  background: var(--prm-bg);
}

::-webkit-scrollbar-thumb {
  background: #cbd5e1;
  border-radius: 9999px;
}

::-webkit-scrollbar-thumb:hover {
  background: #94a3b8;
}

/* 13. Global Navigation Navbar */
.prm-navbar {
  background: #ffffff;
  border-bottom: 2px solid var(--prm-brand);
  padding: 0.75rem 2rem;
}

.prm-brand-title {
  font-family: Inter, sans-serif;
  font-size: 1.1rem;
  font-weight: 700;
  color: var(--prm-brand-dark) !important;
  letter-spacing: -0.02em;
  white-space: nowrap;
}

.prm-nav-links-wrapper {
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  scrollbar-width: none;
}

.prm-nav-links-wrapper::-webkit-scrollbar {
  display: none;
}

.prm-nav-links-inner {
  padding-bottom: 2px;
}

.prm-nav-link {
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--prm-text-muted);
  text-decoration: none;
  padding: 0.5rem 0.85rem;
  border-radius: var(--prm-radius-md);
  transition: var(--prm-transition);
  white-space: nowrap;
  display: flex;
  align-items: center;
  gap: 0.4rem;
}

.prm-nav-link:hover {
  color: var(--prm-text-main);
  background: var(--prm-bg);
}

.prm-nav-link.active {
  color: var(--prm-brand);
  background: var(--prm-brand-light);
}

/* Esconder elementos na impressão */
@media print {
  .no-print {
    display: none !important;
  }
}
