/* =========================================================
   CALCULADORA NEWS 2 — style.css
   ========================================================= */

/* ── Reset & Base ────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
  --color-bg:         #f1f5f9;
  --color-surface:    #ffffff;
  --color-header-bg:  #1e3a5f;
  --color-header-end: #1a5276;

  /* Cores de escore com excelente contraste WCAG */
  --color-score-0:    #166534;   /* verde escuro */
  --color-score-1:    #854d0e;   /* amarelo escuro */
  --color-score-2:    #c2410c;   /* laranja escuro */
  --color-score-3:    #991b1b;   /* vermelho escuro */

  --color-score-0-bg: #dcfce7;
  --color-score-1-bg: #fef9c3;
  --color-score-2-bg: #ffedd5;
  --color-score-3-bg: #fee2e2;

  --color-conduct-critical: #7f1d1d;
  --color-conduct-high:     #92400e;
  --color-conduct-medium:   #713f12;
  --color-conduct-watch:    #1e3a5f;

  --color-alert-bg:   #fef9c3;
  --color-alert-border: #facc15;
  --color-alert-text: #7c2d12;

  --color-text:       #0f172a; /* Slate 900 para máximo contraste */
  --color-text-muted: #475569; /* Slate 600 para unidades e legendas */
  --color-border:     #cbd5e1; /* Borda mais ativa para contraste */

  --radius-sm: 6px;
  --radius-md: 10px;
  --radius-lg: 16px;
  --radius-xl: 22px;

  --shadow-sm: 0 1px 3px rgba(0,0,0,0.06), 0 1px 2px rgba(0,0,0,0.04);
  --shadow-md: 0 4px 16px rgba(15,23,42,0.06), 0 1px 4px rgba(15,23,42,0.04);
  --shadow-lg: 0 10px 40px rgba(15,23,42,0.1), 0 4px 12px rgba(15,23,42,0.04);

  --transition: 0.18s cubic-bezier(0.4, 0, 0.2, 1);

  font-family: 'Inter', system-ui, -apple-system, sans-serif;
  font-size: 16px;
  color: var(--color-text);
  -webkit-font-smoothing: antialiased;
}

html { scroll-behavior: smooth; }

body {
  background: var(--color-bg);
  background-image:
    radial-gradient(ellipse at 20% 0%, rgba(30,58,95,0.05) 0%, transparent 60%),
    radial-gradient(ellipse at 80% 100%, rgba(30,58,95,0.03) 0%, transparent 60%);
  min-height: 100dvh;
}

/* ── App Wrapper ─────────────────────────────────────────── */
.app-wrapper {
  width: 100%;
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
}

/* ── Header ──────────────────────────────────────────────── */
.app-header {
  position: sticky;
  top: 0;
  z-index: 100;
  width: 100%;
  background: #002855; /* Fallback caso a imagem falhe */
  background-image: linear-gradient(rgba(0, 40, 85, 0.91), rgba(0, 25, 55, 0.96)), url('header-bg.png');
  background-size: cover;
  background-position: center;
  color: white;
  padding: 12px 16px 17px; /* Espaço para a barra absoluta no final */
  box-shadow: 0 4px 20px rgba(0,0,0,0.22);
}

/* Faixa horizontal brilhante azul-celeste em gradiente */
.app-header::after {
  content: '';
  position: absolute;
  bottom: 0;
  left: 0;
  width: 100%;
  height: 5px;
  background: linear-gradient(90deg, #1d4ed8 0%, #3b82f6 50%, #60a5fa 100%);
  box-shadow: 0 -1px 10px rgba(59,130,246,0.4);
}

.header-content {
  max-width: 1024px;
  margin: 0 auto;
  width: 100%;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 15px;
}

.header-logo-left {
  display: flex;
  align-items: center;
  justify-content: flex-start;
  flex: 1;
}

.header-logo-right {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  flex: 1;
}

.header-logo {
  height: 48px;
  width: auto;
  display: block;
  filter: drop-shadow(0 2px 8px rgba(255,255,255,0.18)) drop-shadow(0 1px 3px rgba(0,0,0,0.25));
  transition: transform var(--transition);
}

.header-logo:hover {
  transform: scale(1.03);
}

.header-text {
  flex: 2;
  display: flex;
  justify-content: center;
  align-items: center;
  text-align: center;
}

.header-title {
  font-size: 1.4rem;
  font-weight: 900;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: #ffffff;
  line-height: 1.2;
  text-shadow: 0 2px 8px rgba(0,0,0,0.45);
}

/* ── Main Content ────────────────────────────────────────── */
.main-content {
  flex: 1;
  width: 100%;
  max-width: 1024px;
  margin: 0 auto;
  padding: 14px 12px 20px;
  display: flex;
  flex-direction: column;
  gap: 12px;
}

/* ── Grid/Column Layout ──────────────────────────────────── */
.app-grid-layout {
  display: flex;
  flex-direction: column;
  gap: 12px;
  width: 100%;
}

.layout-left {
  width: 100%;
}

.layout-right {
  width: 100%;
  display: flex;
  flex-direction: column;
  gap: 12px;
}

/* Layout lado a lado em telas maiores */
@media (min-width: 820px) {
  .app-grid-layout {
    display: grid;
    grid-template-columns: 58% 40%;
    gap: 2%;
    align-items: start;
  }
  
  .layout-right {
    position: sticky;
    top: 60px; /* Fica fixo abaixo do header sticky */
    max-height: calc(100vh - 85px);
    overflow-y: auto;
    padding-right: 2px;
  }
  
  .layout-right::-webkit-scrollbar {
    width: 4px;
  }
  .layout-right::-webkit-scrollbar-thumb {
    background: #cbd5e1;
    border-radius: 4px;
  }
}

/* ── Alert Banner — Parâmetro 3 (Transição Suave) ────────── */
.alert-param3 {
  background: var(--color-alert-bg);
  border: 2px solid var(--color-alert-border);
  border-radius: var(--radius-lg);
  box-shadow: 0 4px 16px rgba(250,204,21,0.25);
  overflow: hidden;
  transition: max-height 0.4s cubic-bezier(0.4, 0, 0.2, 1),
              opacity 0.3s ease,
              padding 0.4s cubic-bezier(0.4, 0, 0.2, 1),
              margin-bottom 0.4s cubic-bezier(0.4, 0, 0.2, 1),
              border-color 0.3s ease;
  max-height: 150px; /* Limite de altura seguro para o conteúdo */
  opacity: 1;
  padding: 12px 14px;
  margin-bottom: 12px;
}

/* Estado recolhido do banner (ocultação suave) */
.alert-param3.collapsed {
  max-height: 0 !important;
  opacity: 0 !important;
  padding-top: 0 !important;
  padding-bottom: 0 !important;
  margin-bottom: 0 !important;
  border-color: transparent !important;
  box-shadow: none !important;
  pointer-events: none;
}

.alert-param3-inner {
  display: flex;
  align-items: flex-start;
  gap: 10px;
}

.alert-icon {
  font-size: 1.3rem;
  flex-shrink: 0;
  line-height: 1;
  margin-top: 1px;
}

.alert-text {
  display: flex;
  flex-direction: column;
  gap: 2px;
  color: var(--color-alert-text);
}

.alert-text strong {
  font-size: 0.88rem;
  font-weight: 800;
  letter-spacing: 0.01em;
}

.alert-text span {
  font-size: 0.8rem;
  font-weight: 600;
  line-height: 1.3;
}

/* ── Parameters Section ──────────────────────────────────── */
.params-section {
  background: var(--color-surface);
  border-radius: var(--radius-xl);
  box-shadow: var(--shadow-md);
  overflow: hidden;
  border: 1.5px solid var(--color-border);
}

.params-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 14px;
  background: #f8fafc;
  border-bottom: 1.5px solid var(--color-border);
}

.params-title {
  font-size: 0.88rem;
  font-weight: 700;
  color: var(--color-header-bg);
  letter-spacing: -0.01em;
}

.btn-clear-link {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  background: transparent;
  border: none;
  color: #e11d48;
  font-family: inherit;
  font-size: 0.78rem;
  font-weight: 700;
  cursor: pointer;
  padding: 4px 8px;
  border-radius: var(--radius-sm);
  transition: background var(--transition), color var(--transition);
}

.btn-clear-link:hover {
  background: #ffe4e6;
  color: #be123c;
}

.btn-clear-link:active {
  transform: scale(0.97);
}

.table-wrapper { overflow-x: auto; }

.params-table {
  width: 100%;
  border-collapse: collapse;
}

.params-table thead th {
  background: #f8fafc;
  padding: 8px 14px;
  font-size: 0.68rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--color-text-muted);
  border-bottom: 1.5px solid var(--color-border);
  white-space: nowrap;
}

.col-param  { width: 44%; text-align: left; }
.col-value  { width: 38%; text-align: center; }
.col-score  { width: 18%; text-align: center; }

.param-row {
  transition: background var(--transition);
  border-bottom: 1.5px solid var(--color-border);
}

.param-row:last-child { border-bottom: none; }
.param-row:hover { background: #f8fafc; }

.param-label {
  padding: 10px 14px;
  vertical-align: middle;
}

.param-name {
  display: inline-flex;
  align-items: center;
  flex-wrap: wrap;
  font-size: 0.88rem;
  font-weight: 600;
  color: var(--color-text);
  cursor: pointer;
  line-height: 1.3;
}

.param-unit {
  font-size: 0.72rem;
  font-weight: 600;
  color: var(--color-text-muted);
  margin-left: 5px;
  letter-spacing: 0.01em;
}

.param-input-cell {
  padding: 8px 10px;
  vertical-align: middle;
  text-align: center;
}

.param-score-cell {
  padding: 8px 12px;
  vertical-align: middle;
  text-align: center;
}

/* ── Inputs ──────────────────────────────────────────────── */
.param-input, .param-select {
  width: 100%;
  padding: 10px 12px;
  border: 1.5px solid var(--color-border);
  border-radius: var(--radius-md);
  font-family: inherit;
  font-size: 0.92rem;
  font-weight: 600;
  color: var(--color-text);
  background: #ffffff; /* Fundo branco para melhor destaque */
  transition: border-color var(--transition), box-shadow var(--transition), background var(--transition);
  outline: none;
  text-align: center;
  -moz-appearance: textfield;
}

.param-input::-webkit-outer-spin-button,
.param-input::-webkit-inner-spin-button { -webkit-appearance: none; margin: 0; }

.param-input:hover, .param-select:hover {
  border-color: #94a3b8;
  background: #f8fafc;
}

.param-input:focus, .param-select:focus {
  border-color: var(--color-header-bg);
  background: #ffffff;
  box-shadow: 0 0 0 3px rgba(30,58,95,0.18);
}

.param-input::placeholder { color: #64748b; font-weight: 500; }

.param-select {
  cursor: pointer;
  text-align-last: center;
  -webkit-appearance: none;
  appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='none' stroke='%23475569' stroke-width='2.5' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpolyline points='6 9 12 15 18 9'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 12px center;
  padding-right: 32px;
}

.param-select:has(option[value=""]:checked) {
  color: #64748b;
}

/* ── Toggle Buttons ──────────────────────────────────────── */
.toggle-group {
  display: flex;
  border-radius: var(--radius-md);
  overflow: hidden;
  border: 1.5px solid var(--color-border);
  background: #f1f5f9;
}

.toggle-btn {
  flex: 1;
  padding: 10.5px 6px; /* Ajuste para simetria vertical com inputs */
  font-family: inherit;
  font-size: 0.7rem;
  font-weight: 700;
  letter-spacing: 0.02em;
  text-transform: uppercase;
  border: none;
  background: transparent;
  color: var(--color-text-muted);
  cursor: pointer;
  transition: background var(--transition), color var(--transition);
  white-space: nowrap;
}

.toggle-btn + .toggle-btn {
  border-left: 1.5px solid var(--color-border);
}

.toggle-btn.active {
  background: var(--color-header-bg);
  color: white;
  box-shadow: inset 0 1px 3px rgba(0,0,0,0.15);
}

.toggle-btn:hover:not(.active) {
  background: #e2e8f0;
  color: var(--color-text);
}

/* ── Score Badge ─────────────────────────────────────────── */
.score-badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 36px;
  height: 36px;
  border-radius: var(--radius-md);
  font-size: 1rem;
  font-weight: 850;
  letter-spacing: -0.02em;
  transition: background var(--transition), color var(--transition), transform var(--transition);
  padding: 0 6px;
}

.score-badge.empty {
  background: #f1f5f9;
  color: #64748b;
  font-size: 0.9rem;
  font-weight: 500;
}

.score-badge.special {
  background: #f1f5f9;
  color: #64748b;
  font-size: 0.9rem;
  font-weight: 500;
}

.score-badge.s0 { background: var(--color-score-0-bg); color: var(--color-score-0); border: 1.5px solid #bbf7d0; }
.score-badge.s1 { background: var(--color-score-1-bg); color: var(--color-score-1); border: 1.5px solid #fef08a; }
.score-badge.s2 { background: var(--color-score-2-bg); color: var(--color-score-2); border: 1.5px solid #fed7aa; }
.score-badge.s3 { background: var(--color-score-3-bg); color: var(--color-score-3); border: 1.5px solid #fecaca; animation: pulseBadge 1.8s ease-in-out infinite; }

@keyframes pulseBadge {
  0%, 100% { box-shadow: 0 0 0 0 rgba(153,27,27,0); }
  50%       { box-shadow: 0 0 0 5px rgba(153,27,27,0.15); }
}

/* ── Row highlight when score = 3 ────────────────────────── */
.param-row.critical-row { background: #fff5f5; }

/* ── Total Section ───────────────────────────────────────── */
.total-card {
  background: var(--color-surface);
  border-radius: var(--radius-xl);
  box-shadow: var(--shadow-md);
  border: 2.5px solid var(--color-border);
  padding: 20px;
  text-align: center;
  transition: all var(--transition);
}

.total-card.risk-safe {
  background: #f0fdf4;
  border-color: #bbf7d0;
  box-shadow: 0 4px 20px rgba(22,163,74,0.08);
}
.total-card.risk-safe .total-value { color: #166534; }

.total-card.risk-medium {
  background: #fffbeb;
  border-color: #fef08a;
  box-shadow: 0 4px 20px rgba(202,138,4,0.12);
}
.total-card.risk-medium .total-value { color: #854d0e; }

.total-card.risk-high {
  background: #fef2f2;
  border-color: #fecaca;
  box-shadow: 0 4px 24px rgba(220,38,38,0.18);
}
.total-card.risk-high .total-value { color: #991b1b; }

.total-label {
  font-size: 0.72rem;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 0.12em;
  color: var(--color-text-muted);
  margin-bottom: 8px;
  transition: color var(--transition);
}

.total-value {
  font-size: 4rem;
  font-weight: 900;
  letter-spacing: -0.04em;
  line-height: 1;
  transition: color var(--transition), transform var(--transition);
}

.total-value.empty { color: #cbd5e1; font-size: 2.5rem; font-weight: 300; }
.total-value.risk-safe     { color: #15803d; }
.total-value.risk-medium   { color: #d97706; }
.total-value.risk-high     { color: #b91c1c; }

.total-risk {
  margin-top: 8px;
  font-size: 0.78rem;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  padding: 4px 14px;
  border-radius: 100px;
  display: inline-block;
}

.total-risk[hidden] { display: none; }

.risk-label-safe     { background: #dcfce7; color: #15803d; border: 1px solid #bbf7d0; }
.risk-label-moderate { background: #fef9c3; color: #a16207; border: 1px solid #fef08a; }
.risk-label-high     { background: #fee2e2; color: #b91c1c; border: 1px solid #fecaca; }

/* ── Condutas ────────────────────────────────────────────── */
.condutas-section {
  background: var(--color-surface);
  border-radius: var(--radius-xl);
  box-shadow: var(--shadow-md);
  overflow: hidden;
  border: 1.5px solid var(--color-border);
  animation: fadeIn 0.3s ease both;
}

.condutas-section[hidden] { display: none; }

@keyframes fadeIn {
  from { opacity: 0; transform: translateY(6px); }
  to   { opacity: 1; transform: translateY(0); }
}

.condutas-header {
  padding: 12px 16px;
  font-size: 0.72rem;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 0.12em;
  color: white;
  background: linear-gradient(135deg, #1e3a5f, #154360);
  display: flex;
  align-items: center;
  gap: 8px;
}

.condutas-icon { font-size: 1rem; }

.condutas-list {
  list-style: none;
  padding: 0;
}

.conduta-item {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  padding: 12px 16px;
  border-bottom: 1px solid rgba(0,0,0,0.06);
  font-size: 0.88rem;
  font-weight: 600;
  line-height: 1.4;
  animation: slideIn 0.25s ease both;
  transition: background var(--transition);
}

.conduta-item:last-child { border-bottom: none; }

@keyframes slideIn {
  from { opacity: 0; transform: translateX(-8px); }
  to   { opacity: 1; transform: translateX(0); }
}

.conduta-item.level-critical {
  color: var(--color-conduct-critical);
  background: linear-gradient(90deg, #fff5f5, #ffffff);
}
.conduta-item.level-high {
  color: var(--color-conduct-high);
  background: linear-gradient(90deg, #fff7ed, #ffffff);
}
.conduta-item.level-medium {
  color: var(--color-conduct-medium);
  background: linear-gradient(90deg, #fefce8, #ffffff);
}
.conduta-item.level-watch {
  color: var(--color-conduct-watch);
  background: linear-gradient(90deg, #eff6ff, #ffffff);
}

.conduta-bullet {
  flex-shrink: 0;
  width: 22px;
  height: 22px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.7rem;
  font-weight: 800;
  margin-top: 1px;
}

.level-critical .conduta-bullet { background: #fee2e2; color: #dc2626; }
.level-high     .conduta-bullet { background: #ffedd5; color: #ea580c; }
.level-medium   .conduta-bullet { background: #fef9c3; color: #ca8a04; }
.level-watch    .conduta-bullet { background: #dbeafe; color: #2563eb; }

/* ── Disclaimer Box (Melhoria Estruturada WCAG) ────────────── */
.disclaimer-card {
  background: #f8fafc;
  border: 1.5px solid var(--color-border);
  border-radius: var(--radius-md);
  padding: 12px 14px;
  box-shadow: var(--shadow-sm);
}

.disclaimer-header {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 0.8rem;
  font-weight: 750;
  color: var(--color-text-muted);
  margin-bottom: 4px;
}

.disclaimer-icon {
  font-size: 1rem;
}

.disclaimer-text {
  font-size: 0.75rem;
  line-height: 1.5;
  color: var(--color-text-muted);
}

/* ── Footer ──────────────────────────────────────────────── */
.app-footer {
  background: #0f172a;
  color: #94a3b8;
  padding: 14px 16px;
  font-size: 0.7rem;
  letter-spacing: 0.02em;
  width: 100%;
}

.app-footer p {
  max-width: 1024px;
  margin: 0 auto;
  text-align: center;
  width: 100%;
}

/* ── Responsive ──────────────────────────────────────────── */
@media (max-width: 480px) {
  .header-title   { font-size: 0.88rem; letter-spacing: 0.02em; }
  .header-logo    { height: 26px; }
  .header-content { gap: 6px; }

  .main-content { padding: 10px 8px 16px; gap: 10px; }

  .param-label  { padding: 8px 8px; }
  .param-name   { font-size: 0.82rem; }
  .param-unit   { font-size: 0.68rem; margin-left: 3px; }
  .param-input-cell { padding: 6px 4px; }
  .param-score-cell { padding: 6px 6px; }

  .params-table thead th { padding: 6px 8px; font-size: 0.62rem; }

  .col-param { width: 44%; }
  .col-value { width: 38%; }
  .col-score { width: 18%; }

  .toggle-btn { font-size: 0.65rem; padding: 9px 4px; }
  .param-input, .param-select { padding: 8.5px 8px; font-size: 0.88rem; }

  .total-value { font-size: 3.2rem; }

  .conduta-item { padding: 10px 12px; font-size: 0.82rem; }
}

@media (max-width: 360px) {
  .param-name { font-size: 0.78rem; }
  .total-value { font-size: 2.8rem; }
  .toggle-btn { font-size: 0.6rem; }
}

/* ── Score row highlight animation ──────────────────────── */
.score-badge {
  position: relative;
  overflow: hidden;
}

.score-badge::after {
  content: '';
  position: absolute;
  inset: 0;
  background: white;
  border-radius: inherit;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.15s;
}

.score-badge.just-updated::after {
  animation: flashBadge 0.4s ease-out forwards;
}

@keyframes flashBadge {
  0%   { opacity: 0.6; }
  100% { opacity: 0; }
}

/* ── Scrollbar ───────────────────────────────────────────── */
::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: #cbd5e1; border-radius: 10px; }
::-webkit-scrollbar-thumb:hover { background: #94a3b8; }
