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

body {
  font-family: 'Segoe UI', system-ui, -apple-system, sans-serif;
  background: #f0f2f5;
  color: #1a1a2e;
  font-size: 14px;
  min-height: 100vh;
}

/* ===== Login ===== */
.login-page {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  background: linear-gradient(135deg, #1a1a2e 0%, #16213e 50%, #0f3460 100%);
}

.login-card {
  background: #fff;
  border-radius: 16px;
  padding: 48px 40px;
  width: 100%;
  max-width: 400px;
  box-shadow: 0 20px 60px rgba(0,0,0,0.3);
}

.login-logo {
  text-align: center;
  margin-bottom: 32px;
}

.login-logo-icon {
  font-size: 48px;
  display: block;
  margin-bottom: 8px;
}

.login-logo h1 {
  font-size: 28px;
  font-weight: 700;
  color: #1a1a2e;
  letter-spacing: 2px;
}

.login-logo p {
  color: #666;
  font-size: 13px;
  margin-top: 4px;
}

.login-form { display: flex; flex-direction: column; gap: 16px; }

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

.field label {
  font-weight: 600;
  font-size: 13px;
  color: #444;
}

.field input {
  padding: 12px 16px;
  border: 1.5px solid #e0e0e0;
  border-radius: 8px;
  font-size: 14px;
  transition: border-color 0.2s;
  outline: none;
}

.field input:focus { border-color: #0f3460; }

/* ===== Buttons ===== */
.btn-primary {
  background: #0f3460;
  color: #fff;
  border: none;
  border-radius: 8px;
  padding: 14px;
  font-size: 15px;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.2s;
  margin-top: 8px;
}
.btn-primary:hover:not(:disabled) { background: #16213e; }
.btn-primary:disabled { opacity: 0.6; cursor: not-allowed; }

.btn-ghost {
  background: transparent;
  border: 1.5px solid rgba(255,255,255,0.3);
  color: #fff;
  border-radius: 6px;
  padding: 6px 14px;
  font-size: 13px;
  cursor: pointer;
  transition: all 0.2s;
}
.btn-ghost:hover { background: rgba(255,255,255,0.1); }
.btn-ghost.active { background: rgba(255,255,255,0.15); border-color: rgba(255,255,255,0.6); }

/* ===== Error ===== */
.error-msg {
  background: #fff0f0;
  border: 1px solid #ffcccc;
  color: #c0392b;
  border-radius: 8px;
  padding: 10px 14px;
  font-size: 13px;
}
.error-msg.centered { text-align: center; margin-top: 12px; }

/* ===== App Layout ===== */
.app-layout { display: flex; flex-direction: column; height: 100vh; overflow: hidden; }

.app-header {
  background: #1a1a2e;
  color: #fff;
  padding: 0 24px;
  height: 56px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-shrink: 0;
  box-shadow: 0 2px 8px rgba(0,0,0,0.3);
}

.header-brand { display: flex; align-items: center; gap: 10px; }
.header-icon { font-size: 20px; }
.header-title { font-size: 18px; font-weight: 700; letter-spacing: 1px; }
.header-sub { font-size: 12px; color: #8899bb; margin-left: 4px; }

.header-actions { display: flex; align-items: center; gap: 10px; }
.header-user { font-size: 13px; color: #aabbdd; padding: 0 8px; }

/* ===== Content Area ===== */
.content-area {
  display: flex;
  flex: 1;
  overflow: hidden;
}

.main-content {
  flex: 1;
  overflow-y: auto;
  padding: 24px;
}

/* ===== Upload ===== */
.upload-wrapper {
  max-width: 600px;
  margin: 80px auto 0;
}

.upload-zone {
  border: 2.5px dashed #c0cce0;
  border-radius: 16px;
  background: #fff;
  padding: 60px 40px;
  text-align: center;
  cursor: pointer;
  transition: all 0.2s;
}

.upload-zone:hover, .upload-zone.dragging {
  border-color: #0f3460;
  background: #f0f4ff;
}

.upload-zone.loading { opacity: 0.7; cursor: wait; }
.upload-icon { font-size: 48px; margin-bottom: 16px; }
.upload-zone p { color: #444; line-height: 1.6; }
.upload-hint { font-size: 12px; color: #999; margin-top: 6px; }

/* ===== Document View ===== */
.document-view { display: flex; flex-direction: column; gap: 20px; max-width: 1200px; }

/* Filiado */
.filiado-card {
  background: #1a1a2e;
  color: #fff;
  border-radius: 12px;
  padding: 20px 24px;
}

.filiado-top {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 20px;
  flex-wrap: wrap;
}

.filiado-info h2 { font-size: 20px; font-weight: 700; margin-bottom: 8px; }

.filiado-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 16px;
  font-size: 13px;
  color: #aabbdd;
}

.filiado-periodo {
  display: flex;
  gap: 20px;
  flex-shrink: 0;
}

.periodo-box {
  display: flex;
  flex-direction: column;
  align-items: center;
  background: rgba(255,255,255,0.08);
  border-radius: 8px;
  padding: 10px 18px;
}

.periodo-label { font-size: 11px; color: #8899bb; text-transform: uppercase; letter-spacing: 0.5px; }
.periodo-valor { font-size: 15px; font-weight: 600; margin-top: 4px; }
.total-geral { color: #5ee7c8; }

.filiado-doc-info {
  display: flex;
  gap: 24px;
  margin-top: 14px;
  padding-top: 14px;
  border-top: 1px solid rgba(255,255,255,0.1);
  font-size: 12px;
  color: #8899bb;
  flex-wrap: wrap;
}

/* Benefício card */
.beneficio-card {
  background: #fff;
  border-radius: 12px;
  overflow: hidden;
  box-shadow: 0 2px 8px rgba(0,0,0,0.08);
}

.beneficio-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  padding: 18px 20px 14px;
  border-bottom: 1px solid #f0f0f0;
  flex-wrap: wrap;
  gap: 12px;
}

.beneficio-header-left { display: flex; flex-direction: column; gap: 4px; }

.especie-badge {
  font-size: 11px;
  font-weight: 600;
  color: #0f3460;
  background: #e8eef8;
  border-radius: 4px;
  padding: 2px 8px;
  display: inline-block;
  width: fit-content;
}

.beneficio-header-left h3 { font-size: 16px; font-weight: 700; color: #1a1a2e; }
.nb-label { font-size: 12px; color: #888; }

.beneficio-header-right { display: flex; gap: 16px; flex-wrap: wrap; }

.meta-item { display: flex; flex-direction: column; align-items: center; }
.meta-label { font-size: 11px; color: #999; text-transform: uppercase; letter-spacing: 0.5px; }
.meta-value { font-size: 14px; font-weight: 600; margin-top: 2px; }
.meta-value.highlight { color: #0f3460; }

.beneficio-aps {
  padding: 8px 20px;
  font-size: 12px;
  color: #666;
  background: #fafafa;
  border-bottom: 1px solid #f0f0f0;
}

.resumo-bar {
  display: flex;
  gap: 0;
  border-bottom: 1px solid #f0f0f0;
}

.resumo-item {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 12px 8px;
  border-right: 1px solid #f0f0f0;
}
.resumo-item:last-child { border-right: none; }
.resumo-item span { font-size: 11px; color: #888; }
.resumo-item strong { font-size: 15px; font-weight: 700; margin-top: 2px; }
.valor-pago { color: #27ae60; }

/* Table */
.table-wrapper { overflow-x: auto; }

.creditos-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
}

.creditos-table thead tr {
  background: #f5f7fa;
}

.creditos-table th {
  padding: 10px 12px;
  text-align: left;
  font-weight: 600;
  color: #555;
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 0.4px;
  white-space: nowrap;
  border-bottom: 2px solid #e8eef8;
}

.creditos-table td {
  padding: 10px 12px;
  border-bottom: 1px solid #f0f2f5;
  vertical-align: middle;
}

.credito-row.even td { background: #fafbfd; }
.credito-row:hover td { background: #f0f4ff; }

.credito-row .periodo { font-size: 12px; }
.credito-row .text-muted { color: #999; }

.credito-row .valor { font-weight: 600; font-family: monospace; white-space: nowrap; }

/* Rubricas */
.rubrica-row td { background: #fffbf0 !important; font-size: 12px; }
.rubrica-code { color: #888; font-weight: 600; }
.rubrica-desc { color: #555; font-style: italic; }
.rubrica-valor { font-weight: 600; font-family: monospace; color: #b07000; }

.btn-expand {
  background: #e8eef8;
  border: none;
  border-radius: 4px;
  padding: 3px 8px;
  font-size: 11px;
  cursor: pointer;
  color: #0f3460;
  font-weight: 600;
  transition: background 0.2s;
  white-space: nowrap;
}
.btn-expand:hover { background: #d0dcf0; }

/* ===== Badges ===== */
.badge {
  display: inline-block;
  padding: 3px 10px;
  border-radius: 20px;
  font-size: 11px;
  font-weight: 600;
}
.badge-pago { background: #d4edda; color: #1a7a35; }
.badge-pendente { background: #fff3cd; color: #856404; }
.badge-outro { background: #e2e3e5; color: #383d41; }

/* ===== Chat Panel ===== */
.content-area.with-chat .main-content { flex: 1; min-width: 0; }

.chat-panel {
  width: 380px;
  flex-shrink: 0;
  background: #fff;
  border-left: 1px solid #e0e6f0;
  display: flex;
  flex-direction: column;
  height: 100%;
}

.chat-header {
  background: #1a1a2e;
  color: #fff;
  padding: 14px 18px;
  font-weight: 600;
  font-size: 14px;
  display: flex;
  align-items: center;
  gap: 8px;
  flex-shrink: 0;
}

.chat-messages {
  flex: 1;
  overflow-y: auto;
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.chat-msg { display: flex; }
.chat-msg.user { justify-content: flex-end; }
.chat-msg.assistant { justify-content: flex-start; }

.chat-bubble {
  max-width: 85%;
  padding: 10px 14px;
  border-radius: 12px;
  font-size: 13px;
  line-height: 1.5;
}

.chat-msg.user .chat-bubble {
  background: #0f3460;
  color: #fff;
  border-bottom-right-radius: 4px;
}

.chat-msg.assistant .chat-bubble {
  background: #f0f2f8;
  color: #1a1a2e;
  border-bottom-left-radius: 4px;
}

/* Typing indicator */
.chat-bubble.typing {
  display: flex;
  align-items: center;
  gap: 5px;
  padding: 14px 16px;
}

.chat-bubble.typing span {
  display: inline-block;
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: #888;
  animation: bounce 1.2s infinite;
}
.chat-bubble.typing span:nth-child(2) { animation-delay: 0.2s; }
.chat-bubble.typing span:nth-child(3) { animation-delay: 0.4s; }

@keyframes bounce {
  0%, 60%, 100% { transform: translateY(0); opacity: 0.5; }
  30% { transform: translateY(-6px); opacity: 1; }
}

.chat-input-area {
  display: flex;
  gap: 8px;
  padding: 12px;
  border-top: 1px solid #e0e6f0;
  flex-shrink: 0;
}

.chat-input-area textarea {
  flex: 1;
  border: 1.5px solid #e0e6f0;
  border-radius: 8px;
  padding: 10px 12px;
  font-size: 13px;
  resize: none;
  outline: none;
  font-family: inherit;
  transition: border-color 0.2s;
}
.chat-input-area textarea:focus { border-color: #0f3460; }

.btn-send {
  background: #0f3460;
  color: #fff;
  border: none;
  border-radius: 8px;
  width: 44px;
  font-size: 18px;
  cursor: pointer;
  transition: background 0.2s;
  flex-shrink: 0;
}
.btn-send:hover:not(:disabled) { background: #16213e; }
.btn-send:disabled { opacity: 0.4; cursor: not-allowed; }

/* ===== Descobertas do Agente ===== */
.descobertas-card {
  background: #fff;
  border-radius: 12px;
  overflow: hidden;
  box-shadow: 0 2px 8px rgba(0,0,0,0.08);
}

.descobertas-header {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 14px 20px;
  background: #1a1a2e;
  color: #fff;
  font-weight: 700;
  font-size: 14px;
  letter-spacing: 0.3px;
}

.descobertas-header-icon { font-size: 18px; }

.descobertas-lista {
  display: flex;
  flex-direction: column;
}

.descoberta-item {
  display: flex;
  gap: 16px;
  align-items: flex-start;
  padding: 16px 20px;
  border-bottom: 1px solid #f0f2f5;
}
.descoberta-item:last-child { border-bottom: none; }

.descoberta-icone {
  font-size: 22px;
  flex-shrink: 0;
  margin-top: 2px;
}

.descoberta-corpo {
  display: flex;
  flex-direction: column;
  gap: 8px;
  flex: 1;
}

.descoberta-titulo {
  font-weight: 700;
  font-size: 13px;
  color: #1a1a2e;
}

.descoberta-conteudo { font-size: 13px; color: #444; }

.descoberta-nb-lista {
  list-style: none;
  display: flex;
  flex-direction: column;
  gap: 6px;
  margin-top: 2px;
}

.descoberta-nb-lista li {
  display: flex;
  align-items: center;
  gap: 10px;
}

.descoberta-nb-desc { color: #333; }

/* ===== Atrasados ===== */
.descoberta-ok { color: #27ae60; font-weight: 500; }

.atrasados-lista { display: flex; flex-direction: column; gap: 12px; margin-top: 4px; }

.atrasado-item {
  border: 1px solid #ffe0b2;
  border-left: 4px solid #f39c12;
  border-radius: 8px;
  overflow: hidden;
}

.atrasado-header {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 12px;
  background: #fff8f0;
  flex-wrap: wrap;
}

.atrasado-nb { font-size: 12px; color: #555; font-weight: 600; }

.atrasado-atraso-badge {
  margin-left: auto;
  background: #f39c12;
  color: #fff;
  font-size: 11px;
  font-weight: 700;
  border-radius: 20px;
  padding: 2px 10px;
}

.atrasado-detalhe {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 4px 24px;
  padding: 10px 12px;
}

.atrasado-linha {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 12px;
}

.atrasado-label { color: #888; white-space: nowrap; }

.btn-ir-credito {
  margin-left: auto;
  background: none;
  border: 1.5px solid #0f3460;
  color: #0f3460;
  border-radius: 5px;
  padding: 2px 10px;
  font-size: 11px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.15s;
  white-space: nowrap;
}
.btn-ir-credito:hover {
  background: #0f3460;
  color: #fff;
}

.btn-ir-descobertas {
  background: linear-gradient(135deg, #0f3460, #16213e);
  color: #fff;
  border: none;
  border-radius: 20px;
  padding: 5px 14px;
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
  letter-spacing: 0.3px;
  transition: opacity 0.15s, transform 0.1s;
  white-space: nowrap;
  box-shadow: 0 2px 6px rgba(15,52,96,0.25);
}
.btn-ir-descobertas:hover {
  opacity: 0.85;
  transform: translateY(-1px);
}

/* Flash no lançamento ao navegar pela descoberta */
@keyframes credito-flash {
  0%   { background-color: inherit; }
  15%  { background-color: #fff176; }
  85%  { background-color: #fff176; }
  100% { background-color: inherit; }
}

.credito-flash td {
  animation: credito-flash 1.4s ease-out forwards;
}

/* ===== Variações ===== */
.variacoes-lista { display: flex; flex-direction: column; gap: 12px; margin-top: 4px; }

.variacao-item {
  border-radius: 8px;
  overflow: hidden;
  border: 1px solid #e0e0e0;
}

.variacao-alta { border-left: 4px solid #27ae60; }
.variacao-baixa { border-left: 4px solid #e74c3c; }

.variacao-header {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 12px;
  flex-wrap: wrap;
}

.variacao-alta .variacao-header { background: #f0faf4; }
.variacao-baixa .variacao-header { background: #fdf0f0; }

.variacao-badge {
  font-size: 11px;
  font-weight: 700;
  border-radius: 20px;
  padding: 2px 10px;
}
.badge-aumento { background: #27ae60; color: #fff; }
.badge-reducao { background: #e74c3c; color: #fff; }

.variacao-detalhe { padding: 12px; }

.variacao-fluxo {
  display: flex;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
}

.variacao-bloco {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
  min-width: 100px;
}

.variacao-comp-label {
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: 0.4px;
  color: #999;
}

.variacao-bloco strong { font-size: 14px; color: #1a1a2e; }

.variacao-valor-antigo { font-size: 13px; color: #777; font-family: monospace; }
.variacao-valor-novo   { font-size: 13px; font-family: monospace; font-weight: 600; }
.variacao-seta { font-size: 20px; color: #aaa; flex-shrink: 0; }

.variacao-diff { border-left: 1px solid #eee; padding-left: 12px; margin-left: 4px; }

.valor-subiu { color: #27ae60; }
.valor-caiu  { color: #e74c3c; }

.variacao-reajuste-nota {
  margin-top: 10px;
  padding: 8px 12px;
  background: #e8f5e9;
  border-radius: 6px;
  font-size: 12px;
  color: #2e7d32;
  font-weight: 500;
}

/* ===== Competências faltantes ===== */
.faltantes-lista { display: flex; flex-direction: column; gap: 12px; margin-top: 4px; }

.faltante-item {
  border: 1px solid #e8d5f5;
  border-left: 4px solid #8e44ad;
  border-radius: 8px;
  overflow: hidden;
}

.faltante-header {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 12px;
  background: #f9f0ff;
  flex-wrap: wrap;
}

.faltante-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  padding: 10px 12px;
}

.faltante-chip {
  background: #8e44ad;
  color: #fff;
  font-size: 12px;
  font-weight: 600;
  border-radius: 20px;
  padding: 3px 12px;
}

/* ===== Scrollbar ===== */
::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: #c0cce0; border-radius: 3px; }
::-webkit-scrollbar-thumb:hover { background: #a0b0c8; }
