/* #1 Variáveis de Tema (Design System Moderno) */
:root {
  --bg-body: #f8fafc;
  --bg-card: #ffffff;
  --bg-input: #ffffff;
  --bg-highlight: #eef2ff;
  --bg-hover: #f1f5f9;
  
  --text-main: #0f172a;
  --text-muted: #64748b;
  --text-inverse: #f8fafc;
  
  --border-light: #e2e8f0;
  --border-focus: #6366f1;
  
  --primary: #6366f1;
  --primary-hover: #4f46e5;
  --primary-light: #c7d2fe;
  --primary-dark: #3730a3;
  
  --success: #10b981;
  
  --shadow-sm: 0 1px 2px 0 rgb(0 0 0 / 0.05);
  --shadow-md: 0 4px 6px -1px rgb(0 0 0 / 0.1), 0 2px 4px -2px rgb(0 0 0 / 0.1);
  --shadow-lg: 0 10px 15px -3px rgb(0 0 0 / 0.1), 0 4px 6px -4px rgb(0 0 0 / 0.1);
  --radius-md: 12px;
  --radius-lg: 20px;
}

/* Suporte nativo a Dark Mode */
@media (prefers-color-scheme: dark) {
  :root {
    --bg-body: #0f172a;
    --bg-card: #1e293b;
    --bg-input: #0f172a;
    --bg-highlight: #312e81;
    --bg-hover: #334155;
    
    --text-main: #f8fafc;
    --text-muted: #94a3b8;
    
    --border-light: #334155;
    --border-focus: #818cf8;
    
    --primary: #818cf8;
    --primary-hover: #6366f1;
    --primary-light: #4338ca;
    --primary-dark: #e0e7ff;
    
    --success: #34d399;
  }
}

/* #2 Ajustes para WordPress e Reset Acessível */
.entry-title { display: none !important; }
.entry-content, .site-main, #primary { margin-top: 0 !important; padding-top: 0 !important; }

body {
  margin: 0;
  padding: 0;
  background: var(--bg-body);
  font-family: 'Inter', system-ui, -apple-system, sans-serif;
  color: var(--text-main);
  transition: background-color 0.3s ease, color 0.3s ease;
}

/* Foco Acessível (WCAG) - Navegação por teclado */
*:focus-visible {
  outline: 2px solid var(--primary);
  outline-offset: 2px;
}

/* #3 Container Principal */
.cj-app {
  max-width: 1100px;
  margin: 0 auto;
  padding: 24px 16px 40px;
  box-sizing: border-box;
}

/* #4 Hero / Título Principal */
.cj-hero {
  background: var(--bg-card);
  border-radius: var(--radius-lg);
  padding: 24px 32px;
  border: 1px solid var(--border-light);
  box-shadow: var(--shadow-sm);
  margin-bottom: 24px;
  position: relative;
}

/* Seletor de Idiomas Dropdown */
.cj-lang-dropdown {
  position: absolute;
  top: 16px;
  right: 24px;
  background: var(--bg-card);
  border: 1px solid var(--border-light);
  border-radius: 8px;
  cursor: pointer;
  z-index: 100;
  box-shadow: var(--shadow-sm);
  user-select: none;
  font-weight: 600;
  color: var(--text-main);
  transition: all 0.2s ease;
}

.cj-lang-dropdown:hover {
  border-color: var(--primary);
}

.cj-lang-current {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 6px 12px;
  font-size: 1rem;
}

.cj-lang-chevron {
  transition: transform 0.2s ease;
  color: var(--text-muted);
}

.cj-lang-menu {
  position: absolute;
  top: calc(100% + 4px);
  right: 0;
  background: var(--bg-card);
  border: 1px solid var(--border-light);
  border-radius: 8px;
  box-shadow: var(--shadow-md);
  display: flex;
  flex-direction: column;
  min-width: 100px;
  opacity: 0;
  visibility: hidden;
  transform: translateY(-10px);
  transition: all 0.2s ease;
}

.cj-lang-dropdown:hover .cj-lang-menu,
.cj-lang-dropdown:focus-within .cj-lang-menu {
  opacity: 1;
  visibility: visible;
  transform: translateY(0);
}

.cj-lang-dropdown:hover .cj-lang-chevron,
.cj-lang-dropdown:focus-within .cj-lang-chevron {
  transform: rotate(180deg);
}

.cj-lang-option {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 10px 12px;
  text-decoration: none;
  color: var(--text-main);
  font-size: 1rem;
  transition: background 0.2s ease;
}

.cj-lang-option:first-child { border-radius: 8px 8px 0 0; }
.cj-lang-option:last-child { border-radius: 0 0 8px 8px; }

.cj-lang-option:hover {
  background: var(--bg-hover);
  color: var(--primary);
}

.cj-hero-header {
  display: flex;
  align-items: center;
  gap: 16px;
  margin-bottom: 8px;
}

.cj-logo {
  width: 56px;
  height: 56px;
  border-radius: 14px;
  object-fit: cover;
  box-shadow: 0 4px 10px rgba(99, 102, 241, 0.25);
  flex-shrink: 0;
}

.cj-hero-title {
  font-size: clamp(1.4rem, 3.5vw, 2.1rem);
  margin: 0;
  font-weight: 800;
  letter-spacing: -0.02em;
  color: var(--text-main);
}

.cj-hero-subtitle {
  margin: 0;
  font-size: 1rem;
  color: var(--text-muted);
  max-width: 700px;
  line-height: 1.5;
}

.cj-hero-highlights {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin-top: 16px;
}

.cj-chip {
  font-size: 0.8rem;
  padding: 6px 12px;
  border-radius: 999px;
  background: var(--bg-highlight);
  color: var(--primary);
  font-weight: 600;
}

/* #5 Grid de Layout (Cards) */
.cj-calculator-layout {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 24px;
  align-items: start;
}

.cj-chart-card {
  grid-column: 1 / -1;
}

.cj-chart-wrapper {
  width: 100%;
  position: relative;
  height: 400px; /* Altura padrão desktop */
}

.cj-card {
  background: var(--bg-card);
  border-radius: var(--radius-lg);
  padding: 24px;
  border: 1px solid var(--border-light);
  box-shadow: var(--shadow-md);
  transition: transform 0.2s ease, box-shadow 0.2s ease;
}

.cj-card:hover {
  box-shadow: var(--shadow-lg);
}

.cj-section-title {
  font-size: 1.25rem;
  margin: 0 0 4px 0;
  font-weight: 700;
  color: var(--text-main);
}

.cj-section-subtitle {
  margin: 0 0 20px 0;
  font-size: 0.9rem;
  color: var(--text-muted);
}

/* #6 Formulários Modernos */
.cj-form { display: flex; flex-direction: column; gap: 16px; }
.cj-field-row { display: grid; grid-template-columns: 1.5fr 1fr; gap: 16px; }
.cj-field-group { display: flex; flex-direction: column; gap: 6px; }

.cj-label {
  font-size: 0.875rem;
  font-weight: 600;
  color: var(--text-main);
}

.cj-input, .cj-select {
  width: 100%;
  border-radius: var(--radius-md);
  border: 1px solid var(--border-light);
  padding: 12px 14px;
  font-size: 1rem;
  background: var(--bg-input);
  color: var(--text-main);
  transition: all 0.2s ease;
  box-sizing: border-box;
}

.cj-input::placeholder { color: var(--text-muted); opacity: 0.6; }
.cj-input:focus, .cj-select:focus {
  border-color: var(--border-focus);
  box-shadow: 0 0 0 3px rgba(99, 102, 241, 0.15);
  outline: none;
}

/* Correção Autocomplete (fundo branco no Chrome/Edge) */
.cj-input:-webkit-autofill,
.cj-input:-webkit-autofill:hover, 
.cj-input:-webkit-autofill:focus, 
.cj-input:-webkit-autofill:active {
    -webkit-box-shadow: 0 0 0 30px var(--bg-input) inset !important;
    -webkit-text-fill-color: var(--text-main) !important;
    transition: background-color 5000s ease-in-out 0s;
}

/* Select Estilizado */
.cj-select-wrapper { position: relative; width: 100%; }
.cj-select {
  appearance: none;
  -webkit-appearance: none;
  padding-right: 36px;
  cursor: pointer;
}
.cj-select-arrow {
  position: absolute; right: 14px; top: 50%;
  transform: translateY(-50%); pointer-events: none;
  width: 0; height: 0;
  border-left: 5px solid transparent;
  border-right: 5px solid transparent;
  border-top: 6px solid var(--text-muted);
}

/* Input Groups Avançados */
.cj-input-group {
  display: flex;
  align-items: stretch;
  border-radius: var(--radius-md);
  border: 1px solid var(--border-light);
  background: var(--bg-input);
  overflow: hidden;
  transition: all 0.2s ease;
}

.cj-input-group:focus-within {
  border-color: var(--border-focus);
  box-shadow: 0 0 0 3px rgba(99, 102, 241, 0.15);
}

.cj-input-group.cj-input-error {
  border-color: #dc2626 !important;
  background-color: #fef2f2 !important;
  box-shadow: 0 0 0 3px rgba(220, 38, 38, 0.15) !important;
  animation: shake-error 0.3s ease-in-out;
}

.cj-input-prefix {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0 14px;
  background: var(--bg-hover);
  color: var(--text-muted);
  font-weight: 600;
  border-right: 1px solid var(--border-light);
  font-size: 0.9rem;
}

.cj-input-grouped {
  border: none !important;
  box-shadow: none !important;
  border-radius: 0 !important;
  flex: 1;
  min-width: 0;
  background: transparent !important;
}
.cj-input-grouped:focus {
  outline: none !important;
}

.cj-select-addon {
  position: relative;
  border-left: 1px solid var(--border-light);
  background: var(--bg-input);
  display: flex;
  align-items: center;
}

.cj-select-bare {
  border: none !important;
  box-shadow: none !important;
  background: transparent !important;
  color: var(--primary) !important;
  font-weight: 600 !important;
  padding: 0 36px 0 14px !important;
  height: 100%;
}
.cj-select-bare:focus {
  outline: none !important;
}

.cj-select-addon .cj-select-arrow {
  border-top-color: var(--primary);
  right: 14px;
}

/* #7 Botões (Interativos e Acessíveis) */
.cj-buttons-row {
  display: flex; gap: 12px; margin-top: 8px;
}

.cj-btn {
  border-radius: var(--radius-md);
  padding: 12px 20px;
  font-size: 1rem;
  font-weight: 600;
  border: none;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  transition: all 0.2s ease;
}

.cj-btn-primary {
  flex: 2;
  background: var(--primary);
  color: #ffffff; /* Fixo para contraste */
}

.cj-btn-primary:hover {
  background: var(--primary-hover);
  transform: translateY(-2px);
}

.cj-btn-secondary {
  flex: 1;
  background: var(--bg-body);
  color: var(--text-main);
  border: 1px solid var(--border-light);
}

.cj-btn-secondary:hover {
  background: var(--bg-hover);
}

/* #8 Resultados */
.cj-results-grid {
  display: grid;
  grid-template-columns: repeat(1, 1fr);
  gap: 12px;
  margin-bottom: 20px;
}

.cj-result-item {
  background: var(--bg-body);
  border-radius: var(--radius-md);
  padding: 16px;
  border: 1px solid var(--border-light);
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.cj-result-label {
  font-size: 0.875rem;
  color: var(--text-muted);
  font-weight: 500;
}

.cj-result-value {
  font-size: 1.5rem;
  font-weight: 800;
  color: var(--text-main);
}

.cj-result-positive { color: var(--success); }

/* Erros de Validação Premium */
@keyframes shake-error {
  0%, 100% { transform: translateX(0); }
  25% { transform: translateX(-4px); }
  75% { transform: translateX(4px); }
}

@keyframes fade-in-error {
  from { opacity: 0; transform: translateY(-4px); }
  to { opacity: 1; transform: translateY(0); }
}

.cj-input-error {
  border-color: #dc2626 !important;
  background-color: #fef2f2 !important;
  color: #991b1b !important;
  box-shadow: 0 0 0 3px rgba(220, 38, 38, 0.15) !important;
  animation: shake-error 0.3s ease-in-out;
}

.cj-error-msg {
  color: #dc2626;
  font-size: 0.8rem;
  font-weight: 600;
  margin-top: 6px;
  display: flex;
  align-items: center;
  gap: 6px;
  animation: fade-in-error 0.3s ease-out;
}

/* Erro no Dark Mode */
@media (prefers-color-scheme: dark) {
  .cj-input-group.cj-input-error, .cj-input-error {
    background-color: #450a0a !important;
    border-color: #ef4444 !important;
    color: #fca5a5 !important;
    box-shadow: 0 0 0 3px rgba(239, 68, 68, 0.2) !important;
  }
  .cj-error-msg {
    color: #ef4444;
  }
}

/* Linha de Compartilhamento */
.cj-share-row {
  display: flex; gap: 12px; margin-bottom: 20px;
}
.cj-btn-share {
  font-size: 0.9rem; padding: 10px; flex: 1;
}

/* #10 Artigo Educativo */
.cj-article-card {
  grid-column: 1 / -1;
}

.cj-quote {
  border-left: 4px solid var(--primary);
  background: var(--bg-highlight);
  padding: 16px 24px;
  margin: 24px 0;
  border-radius: 0 var(--radius-md) var(--radius-md) 0;
  color: var(--text-main);
}

.cj-quote p {
  margin: 0 0 8px 0;
  font-size: 1.1rem;
  font-style: italic;
  line-height: 1.5;
  font-weight: 500;
}

.cj-quote cite {
  font-size: 0.9rem;
  color: var(--primary);
  font-weight: 700;
}

.cj-article-content p {
  line-height: 1.7;
  margin-bottom: 16px;
  color: var(--text-muted);
}

.cj-article-content h3 {
  font-size: 1.15rem;
  color: var(--text-main);
  margin: 24px 0 12px 0;
}

.cj-article-content ul {
  list-style: none;
  padding: 0;
  margin: 0 0 24px 0;
}

.cj-article-content li {
  position: relative;
  padding-left: 24px;
  margin-bottom: 12px;
  line-height: 1.6;
  color: var(--text-muted);
}

.cj-article-content li::before {
  content: "✓";
  position: absolute;
  left: 0;
  top: 0;
  color: var(--success);
  font-weight: bold;
}

.cj-article-content strong {
  color: var(--text-main);
}

/* #11 FAQ SEO */
.cj-faq-container {
  display: flex;
  flex-direction: column;
}

.cj-faq-item {
  border-bottom: 1px solid var(--border-light);
  padding: 24px 0;
}

.cj-faq-item:last-child {
  border-bottom: none;
  padding-bottom: 8px;
}

.cj-faq-question {
  font-size: 1.15rem;
  font-weight: 700;
  color: var(--text-main);
  margin: 0 0 12px 0;
}

.cj-faq-answer {
  color: var(--text-muted);
  line-height: 1.7;
  margin: 0;
}

/* #12 Responsividade */
@media (max-width: 860px) {
  .cj-calculator-layout { grid-template-columns: 1fr; gap: 16px; }
  .cj-hero-title { font-size: 1.5rem; }
}

@media (max-width: 480px) {
  .cj-app { padding: 16px 12px 24px; }
  .cj-card { padding: 16px; }
  .cj-field-row { grid-template-columns: 1fr; gap: 12px; }
  .cj-buttons-row, .cj-share-row { flex-direction: column; }
  .cj-btn { width: 100%; padding: 14px 20px; }
  .cj-result-value { font-size: 1.35rem; }
  .cj-chart-wrapper { height: 280px; } /* Ajuste de altura do gráfico no mobile */
  .cj-hero-header { gap: 12px; }
  .cj-logo { width: 44px; height: 44px; border-radius: 10px; }
}

/* #13 Footer */
.cj-footer {
  text-align: center;
  padding: 32px 16px;
  margin-top: 40px;
  border-top: 1px solid var(--border-light);
  color: var(--text-muted);
}
.cj-footer-links {
  display: flex;
  justify-content: center;
  gap: 24px;
  margin-bottom: 16px;
  flex-wrap: wrap;
}
.cj-footer-links a {
  color: var(--primary);
  text-decoration: none;
  font-weight: 500;
  transition: color 0.2s;
}
.cj-footer-links a:hover {
  color: var(--primary-hover);
  text-decoration: underline;
}