:root {
  --primary: #1b4332;
  --primary-light: #2d6a4f;
  --primary-hover: #081c15;
  --accent: #52b788;
  --bg-page: #f4f7f5;
  --bg-card: #ffffff;
  --text-main: #1b1f24;
  --text-muted: #57606a;
  --emergency: #d90429;
  --emergency-light: #ffccd5;
  --border: #d0d7de;
  --radius-sm: 8px;
  --radius-md: 14px;
  --radius-lg: 20px;
  --shadow-sm: 0 1px 3px rgba(0,0,0,0.08);
  --shadow-md: 0 4px 12px rgba(0,0,0,0.1);
  --base-font-size: 16px;
}

/* Modo Fonte Grande (A+) */
body.font-large {
  --base-font-size: 19px;
}

/* Modo Alto Contraste (WCAG AAA) */
body.theme-contrast {
  --bg-page: #000000;
  --bg-card: #121212;
  --text-main: #ffffff;
  --text-muted: #ffff80;
  --primary: #ffff00;
  --primary-light: #ffff80;
  --border: #ffffff;
  --emergency: #ff3333;
}
body.theme-contrast .app-header {
  background: #000000;
  border-bottom: 2px solid #ffffff;
}
body.theme-contrast .brand-title,
body.theme-contrast .brand-subtitle {
  color: #ffff00;
}
body.theme-contrast .message-bubble {
  border: 2px solid #ffffff !important;
  background: #111111 !important;
  color: #ffffff !important;
}
body.theme-contrast .chip {
  background: #000000 !important;
  color: #ffff00 !important;
  border: 2px solid #ffff00 !important;
}

* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

body {
  font-family: 'Plus Jakarta Sans', system-ui, -apple-system, BlinkMacSystemFont, sans-serif;
  font-size: var(--base-font-size);
  color: var(--text-main);
  background-color: var(--bg-page);
  line-height: 1.55;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

.hidden {
  display: none !important;
}

/* BANNER DE EMERGÊNCIA TOPO */
.emergency-banner {
  background: linear-gradient(90deg, #990000, #d90429);
  color: #ffffff;
  padding: 8px 16px;
  font-size: 0.95rem;
  box-shadow: 0 2px 6px rgba(0,0,0,0.2);
  z-index: 100;
}
.banner-container {
  max-width: 900px;
  margin: 0 auto;
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 8px;
}
.banner-text {
  display: flex;
  align-items: center;
  gap: 8px;
}
.banner-actions {
  display: flex;
  gap: 8px;
}
.btn-hotline {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  background: #ffffff;
  color: #990000;
  text-decoration: none;
  font-weight: 700;
  padding: 6px 12px;
  border-radius: var(--radius-sm);
  font-size: 0.9rem;
  transition: transform 0.15s ease;
  min-height: 40px;
}
.btn-hotline.red {
  background: #ffe5ec;
  color: #990000;
}
.btn-hotline:hover {
  transform: scale(1.03);
}

/* CABEÇALHO */
.app-header {
  background: var(--primary);
  color: #ffffff;
  padding: 12px 16px;
  box-shadow: var(--shadow-sm);
}
.header-container {
  max-width: 900px;
  margin: 0 auto;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}
.branding {
  display: flex;
  align-items: center;
  gap: 10px;
}
.brand-logo {
  font-size: 2rem;
  background: rgba(255,255,255,0.15);
  width: 46px;
  height: 46px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: var(--radius-sm);
}
.brand-title {
  font-size: 1.35rem;
  font-weight: 800;
  letter-spacing: -0.5px;
}
.brand-subtitle {
  font-size: 0.8rem;
  opacity: 0.9;
}

/* TOOLBAR ACESSIBILIDADE */
.a11y-toolbar {
  display: flex;
  align-items: center;
  gap: 6px;
}
.a11y-btn {
  background: rgba(255,255,255,0.18);
  border: 1px solid rgba(255,255,255,0.3);
  color: #ffffff;
  padding: 6px 10px;
  border-radius: var(--radius-sm);
  font-size: 0.85rem;
  font-weight: 600;
  cursor: pointer;
  min-height: 42px;
  min-width: 42px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  transition: background 0.15s ease;
}
.a11y-btn:hover {
  background: rgba(255,255,255,0.3);
}

/* SUB HEADER */
.sub-header-container {
  max-width: 900px;
  margin: 8px auto 0;
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 8px;
  font-size: 0.85rem;
  border-top: 1px solid rgba(255,255,255,0.15);
  padding-top: 8px;
}
.location-selector {
  display: flex;
  align-items: center;
  gap: 10px;
}
.user-chip {
  background: rgba(255,255,255,0.2);
  padding: 4px 10px;
  border-radius: 20px;
  font-size: 0.8rem;
  display: inline-flex;
  align-items: center;
  gap: 8px;
}
.btn-logout {
  background: rgba(217, 4, 41, 0.85);
  color: #ffffff;
  border: none;
  padding: 2px 8px;
  border-radius: 4px;
  font-size: 0.72rem;
  font-weight: 700;
  cursor: pointer;
}
.btn-logout:hover {
  background: #d90429;
}
.select-field {
  background: #ffffff;
  color: #1b4332;
  border: none;
  font-weight: 600;
  padding: 4px 8px;
  border-radius: 6px;
  font-size: 0.85rem;
  cursor: pointer;
  min-height: 36px;
}
.server-status-badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  background: rgba(0,0,0,0.25);
  padding: 4px 10px;
  border-radius: 20px;
  font-size: 0.8rem;
}
.status-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: #70e000;
}
.status-dot.offline {
  background: #ffaa00;
}

/* TELA DE LOGIN */
.login-view {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px 16px;
}
.login-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  max-width: 460px;
  width: 100%;
  padding: 28px 24px;
  box-shadow: var(--shadow-md);
}
.login-header {
  text-align: center;
  margin-bottom: 20px;
}
.login-shield {
  font-size: 2.5rem;
  margin-bottom: 6px;
}
.login-header h2 {
  font-size: 1.35rem;
  font-weight: 800;
  color: var(--primary);
  margin-bottom: 4px;
}
.login-header p {
  font-size: 0.85rem;
  color: var(--text-muted);
}
.login-form {
  display: flex;
  flex-direction: column;
  gap: 14px;
  margin-bottom: 20px;
}
.form-group {
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.form-group label {
  font-size: 0.88rem;
  font-weight: 700;
  color: var(--text-main);
}
.input-field {
  background: #f8faf9;
  border: 2px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 12px 14px;
  font-size: 1rem;
  font-family: inherit;
  outline: none;
  min-height: 48px;
  transition: border-color 0.15s ease;
}
.input-field:focus {
  border-color: var(--accent);
  background: #ffffff;
}
.btn-primary-large {
  background: var(--primary);
  color: #ffffff;
  border: none;
  border-radius: var(--radius-sm);
  padding: 14px;
  font-size: 1.05rem;
  font-weight: 700;
  cursor: pointer;
  min-height: 52px;
  transition: background 0.15s ease;
  margin-top: 6px;
}
.btn-primary-large:hover {
  background: var(--primary-hover);
}
.login-alert {
  background: #ffebee;
  border: 1px solid #ef9a9a;
  color: #c62828;
  padding: 10px 12px;
  border-radius: var(--radius-sm);
  font-size: 0.88rem;
  font-weight: 600;
}
.login-credentials-guide {
  background: #f1f8f4;
  border: 1px solid #c8e6c9;
  border-radius: var(--radius-sm);
  padding: 12px;
  font-size: 0.82rem;
  color: #2e7d32;
}
.login-credentials-guide h4 {
  margin-bottom: 6px;
  font-size: 0.88rem;
}
.login-credentials-guide ul {
  list-style: none;
  margin-bottom: 8px;
}
.login-credentials-guide li {
  margin-bottom: 3px;
}
.login-credentials-guide code {
  background: #ffffff;
  border: 1px solid #a5d6a7;
  padding: 2px 6px;
  border-radius: 4px;
  font-weight: 700;
  color: #1b5e20;
}
.security-note {
  font-size: 0.76rem;
  color: #555;
  border-top: 1px dashed #c8e6c9;
  padding-top: 6px;
}

/* ÁREA DE CHAT */
.chat-main {
  flex: 1;
  display: flex;
  justify-content: center;
  padding: 12px 8px 140px;
}
.chat-container {
  width: 100%;
  max-width: 860px;
  display: flex;
  flex-direction: column;
  gap: 14px;
}

/* LISTA DE MENSAGENS */
.messages-list {
  display: flex;
  flex-direction: column;
  gap: 16px;
}
.message-bubble {
  max-width: 90%;
  padding: 14px 18px;
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-sm);
  animation: fadeIn 0.25s ease-out;
}
@keyframes fadeIn {
  from { opacity: 0; transform: translateY(6px); }
  to { opacity: 1; transform: translateY(0); }
}

.bot-message {
  align-self: flex-start;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-left: 5px solid var(--accent);
}
.bot-message.emergency-alert {
  border-left: 5px solid var(--emergency);
  background: #fffafa;
}
.user-message {
  align-self: flex-end;
  background: var(--primary);
  color: #ffffff;
  border-bottom-right-radius: 4px;
}

.bubble-header {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 8px;
  font-size: 0.85rem;
}
.bot-avatar {
  font-size: 1.2rem;
}
.sender-name {
  font-weight: 700;
  color: var(--primary);
}
body.theme-contrast .sender-name {
  color: #ffff00;
}
.source-tag {
  background: #e8f5e9;
  color: #2e7d32;
  font-size: 0.72rem;
  padding: 2px 6px;
  border-radius: 4px;
  font-weight: 600;
}
.btn-speaker {
  margin-left: auto;
  background: #eef2f5;
  border: 1px solid var(--border);
  color: #333;
  padding: 4px 8px;
  border-radius: 6px;
  font-size: 0.8rem;
  cursor: pointer;
  min-height: 36px;
  display: inline-flex;
  align-items: center;
  gap: 4px;
}
.btn-speaker:hover {
  background: #dde3e8;
}

.bubble-content p {
  margin-bottom: 8px;
}
.bubble-content p:last-child {
  margin-bottom: 0;
}
.voice-hint {
  font-size: 0.9rem;
  color: #2d6a4f;
  background: #e8f5e9;
  padding: 6px 10px;
  border-radius: 6px;
  margin-top: 6px;
}

/* FEEDBACK BUTTONS */
.bubble-feedback {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-top: 12px;
  padding-top: 8px;
  border-top: 1px solid rgba(0,0,0,0.06);
  font-size: 0.8rem;
  color: var(--text-muted);
}
.btn-feedback {
  background: transparent;
  border: 1px solid var(--border);
  border-radius: 4px;
  padding: 2px 8px;
  cursor: pointer;
  min-height: 32px;
}
.btn-feedback:hover {
  background: #f0f0f0;
}

/* CHIPS DE TÓPICOS RÁPIDOS */
.quick-topics-wrapper {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 12px;
}
.quick-topics-label {
  font-size: 0.85rem;
  font-weight: 700;
  color: var(--text-muted);
  margin-bottom: 8px;
}
.chips-container {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}
.chip {
  background: #f0f4f2;
  border: 1px solid #d0dcd5;
  color: #1b4332;
  padding: 8px 14px;
  border-radius: 24px;
  font-size: 0.88rem;
  font-weight: 600;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  min-height: 48px;
  transition: all 0.15s ease;
}
.chip:hover {
  background: #e0ece5;
  border-color: #2d6a4f;
  transform: translateY(-1px);
}
.chip.alert {
  background: #fff0f3;
  border-color: #ffccd5;
  color: #a4161a;
}
.chip.danger {
  background: #fff5eb;
  border-color: #ffd8a8;
  color: #d9480f;
}
.chip.bio {
  background: #e6fcf5;
  border-color: #96f2d7;
  color: #0ca678;
}

/* PAINEL DE ENTRADA FIXO NO RODAPÉ */
.input-panel {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  background: var(--bg-card);
  border-top: 1px solid var(--border);
  padding: 10px 16px 14px;
  box-shadow: 0 -4px 16px rgba(0,0,0,0.08);
  z-index: 90;
}
.voice-toolbar {
  max-width: 860px;
  margin: 0 auto 8px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-size: 0.82rem;
  color: var(--text-muted);
}
.toggle-voice-label {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  cursor: pointer;
}
.voice-selector-wrapper {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  background: #f1f5f3;
  padding: 3px 8px;
  border-radius: 16px;
  border: 1px solid var(--border);
}
.lbl-voice {
  font-size: 0.78rem;
  font-weight: 600;
  color: var(--text-muted);
}
.select-voice-inline {
  border: none;
  background: transparent;
  font-size: 0.78rem;
  font-weight: 600;
  color: var(--text-main);
  cursor: pointer;
  max-width: 180px;
  outline: none;
}
.speech-recording {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  color: var(--emergency);
  font-weight: 700;
}
.mic-wave {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: var(--emergency);
  animation: pulse 1s infinite;
}
@keyframes pulse {
  0% { transform: scale(1); opacity: 1; }
  50% { transform: scale(1.6); opacity: 0.5; }
  100% { transform: scale(1); opacity: 1; }
}

.chat-input-form {
  max-width: 860px;
  margin: 0 auto;
  display: flex;
  align-items: center;
  gap: 8px;
}
.btn-voice {
  background: #2d6a4f;
  color: #ffffff;
  border: none;
  border-radius: 50%;
  width: 52px;
  height: 52px;
  font-size: 1.4rem;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: var(--shadow-sm);
  transition: transform 0.15s ease, background 0.15s ease;
  flex-shrink: 0;
}
.btn-voice:hover {
  background: #1b4332;
  transform: scale(1.05);
}
.btn-voice.recording {
  background: var(--emergency);
  animation: pulse 1.2s infinite;
}

.input-chat {
  flex: 1;
  background: #f8faf9;
  border: 2px solid var(--border);
  padding: 12px 16px;
  font-size: 1rem;
  font-family: inherit;
  border-radius: 26px;
  outline: none;
  min-height: 52px;
  transition: border-color 0.15s ease;
}
.input-chat:focus {
  border-color: var(--accent);
  background: #ffffff;
}

.btn-send {
  background: var(--primary);
  color: #ffffff;
  border: none;
  border-radius: 26px;
  padding: 0 20px;
  height: 52px;
  font-weight: 700;
  font-size: 0.95rem;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  flex-shrink: 0;
  transition: background 0.15s ease;
}
.btn-send:hover {
  background: var(--primary-hover);
}

/* MODAL DE MONITORAMENTO */
.modal-backdrop {
  position: fixed;
  top: 0; left: 0; right: 0; bottom: 0;
  background: rgba(0,0,0,0.6);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 16px;
  z-index: 200;
}
.modal-card {
  background: var(--bg-card);
  border-radius: var(--radius-md);
  max-width: 600px;
  width: 100%;
  max-height: 90vh;
  overflow-y: auto;
  padding: 20px;
  box-shadow: var(--shadow-md);
}
.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 12px;
}
.btn-close-modal {
  background: transparent;
  border: none;
  font-size: 1.3rem;
  cursor: pointer;
  padding: 4px 8px;
}
.dash-subtitle {
  font-size: 0.85rem;
  color: var(--text-muted);
  margin-bottom: 16px;
}
.stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(120px, 1fr));
  gap: 12px;
  margin-bottom: 20px;
}
.stat-card {
  background: #f4f8f6;
  border: 1px solid #dce8e2;
  border-radius: var(--radius-sm);
  padding: 12px;
  text-align: center;
}
.stat-value {
  font-size: 1.6rem;
  font-weight: 800;
  color: var(--primary);
}
.stat-label {
  font-size: 0.78rem;
  color: var(--text-muted);
  margin-top: 4px;
}
.section-title {
  font-size: 1rem;
  margin-bottom: 10px;
  color: var(--primary);
}
.themes-list {
  list-style: none;
  margin-bottom: 20px;
}
.themes-list li {
  display: flex;
  justify-content: space-between;
  padding: 6px 0;
  border-bottom: 1px solid #eee;
  font-size: 0.88rem;
}

/* LISTA DE DÚVIDAS NÃO ATENDIDAS (CURADORIA) */
.unanswered-list {
  list-style: none;
  background: #fff8e1;
  border: 1px solid #ffe082;
  border-radius: var(--radius-sm);
  padding: 10px;
  max-height: 180px;
  overflow-y: auto;
  margin-bottom: 20px;
}
.unanswered-list li {
  padding: 6px 0;
  border-bottom: 1px dashed #ffd54f;
  font-size: 0.85rem;
  color: #5d4037;
}
.unanswered-list li:last-child {
  border-bottom: none;
}
.unanswered-tag {
  background: #ffecb3;
  color: #8d6e63;
  padding: 2px 6px;
  border-radius: 4px;
  font-size: 0.75rem;
  font-weight: 700;
  margin-right: 6px;
}

.server-config-info {
  background: #f8faf9;
  border: 1px solid var(--border);
  padding: 12px;
  border-radius: 8px;
  font-size: 0.85rem;
}

/* RESPONSIVIDADE MOBILE */
@media (max-width: 640px) {
  .header-container {
    flex-direction: column;
    align-items: flex-start;
  }
  .a11y-toolbar {
    width: 100%;
    justify-content: flex-end;
  }
  .btn-send {
    padding: 0 14px;
  }
  .btn-send span {
    display: none;
  }
}
