/* ─────────────────────────────────────────────
   PeçaRadar — Modais (IA + Preferências)
   Keyframes: definidos em base.css (fadeIn, slideUp, bounce)
───────────────────────────────────────────── */

/* ── AI Modal ── */

#aiModal {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(14, 15, 19, 0.88);
  z-index: 200;
  align-items: center;
  justify-content: center;
}

#aiModal.show { display: flex; }

.modal-box {
  background: var(--surface);
  border: 1px solid rgba(255, 107, 43, 0.25);
  border-radius: var(--r-2xl, 16px);
  width: 580px;
  max-width: 95%;
  padding: 26px;
  max-height: 80vh;
  overflow-y: auto;
}

.modal-title {
  font-family: 'Syne', sans-serif;
  font-size: 16px;
  font-weight: 700;
  margin-bottom: 16px;
  display: flex;
  align-items: center;
  gap: 8px;
  color: var(--text);
}

.modal-title span { color: var(--accent); }

#aiInput {
  width: 100%;
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: var(--r-lg, 10px);
  padding: 12px 14px;
  color: var(--text);
  font-family: inherit;
  font-size: 14px;
  margin-bottom: 10px;
  outline: none;
  resize: none;
  min-height: 90px;
  line-height: 1.5;
  transition: border-color var(--t, 0.15s ease);
}

#aiInput:focus       { border-color: var(--accent); }
#aiInput::placeholder { color: var(--muted); }

.modal-hint {
  font-size: 11.5px;
  color: var(--muted);
  margin-bottom: 12px;
}

.modal-hint kbd {
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: 4px;
  padding: 1px 5px;
  font-family: monospace;
  font-size: 11px;
}

.modal-actions {
  display: flex;
  gap: 8px;
  justify-content: flex-end;
}

/* ── Botões de modal (compartilhado entre AI e Monitor) ── */

.m-btn {
  padding: 9px 20px;
  border-radius: var(--r-md, 8px);
  font-family: inherit;
  font-size: 13px;
  border: 1px solid var(--border);
  background: transparent;
  color: var(--muted);
  cursor: pointer;
  transition: all var(--t, 0.15s ease);
}

.m-btn:hover      { color: var(--text); border-color: var(--border-h); }
.m-btn.send       { background: var(--accent); border-color: var(--accent); color: #fff; font-weight: 500; }
.m-btn.send:hover { background: var(--accent-h); border-color: var(--accent-h); }

/* ── AI Answer area ── */

#aiResult {
  margin-top: 18px;
  display: none;
}

.ai-label {
  font-size: 11px;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.8px;
  margin-bottom: 8px;
}

.ai-bubble {
  background: var(--surface2);
  /* border-radius apenas nos lados sem borda — evita cantos arredondados no lado esquerdo */
  border-radius: 0 var(--r-lg, 10px) var(--r-lg, 10px) 0;
  padding: 16px;
  font-size: 13.5px;
  color: var(--text);
  line-height: 1.7;
  border-left: 3px solid var(--accent);
}

/* ── Typing indicator ── */

.typing {
  display: flex;
  gap: 5px;
  align-items: center;
  padding: 4px 0;
}

.typing-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--accent);
  /* keyframe bounce definido em base.css */
  animation: bounce 0.9s infinite;
}

.typing-dot:nth-child(2) { animation-delay: 0.15s; }
.typing-dot:nth-child(3) { animation-delay: 0.30s; }

/* ══════════════════════════════════════════
   Preferences Modal
══════════════════════════════════════════ */

#prefsModal {
  /* display: none evita FOUC antes do JS inicializar */
  display: none;
  position: fixed;
  inset: 0;
  z-index: 300;
  align-items: center;
  justify-content: center;
}

/* Ativado pelo JS: prefsModal.classList.add('show') */
#prefsModal.show {
  display: flex;
  /* keyframe fadeIn definido em base.css */
  animation: fadeIn 0.25s ease;
}

.prefs-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(14, 15, 19, 0.92);
}

.prefs-box {
  position: relative;
  background: var(--surface);
  border: 1px solid rgba(255, 107, 43, 0.25);
  border-radius: var(--r-2xl, 16px);
  width: 560px;
  max-width: 95%;
  max-height: 90vh;
  overflow-y: auto;
  padding: 28px;
  /* keyframe slideUp definido em base.css */
  animation: slideUp 0.3s ease;
}

.prefs-header { margin-bottom: 22px; }

.prefs-title {
  font-family: 'Syne', sans-serif;
  font-size: 20px;
  font-weight: 700;
  color: var(--text);
  margin-bottom: 6px;
}

.prefs-title span { color: var(--accent); }

.prefs-sub {
  font-size: 13px;
  color: var(--muted);
  line-height: 1.5;
}

.prefs-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
  gap: 10px;
  margin-bottom: 22px;
}

.pref-chip {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  padding: 14px 10px;
  border-radius: var(--r-xl, 12px);
  border: 1px solid var(--border);
  background: var(--surface2);
  color: var(--muted);
  font-family: inherit;
  cursor: pointer;
  transition: all var(--t, 0.15s ease);
}

.pref-chip:hover    { border-color: var(--accent); color: var(--text); }
.pref-chip.selected { border-color: var(--accent); background: var(--tag-bg); color: var(--accent); }

.pref-icon  { font-size: 22px; }
.pref-label { font-size: 11.5px; text-align: center; line-height: 1.3; }

.prefs-footer {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
  padding-top: 16px;
  border-top: 1px solid var(--border);
}

.prefs-hint { font-size: 12px; color: var(--muted); }

.prefs-skip {
  background: transparent;
  border: 1px solid var(--border);
  border-radius: var(--r-md, 8px);
  padding: 9px 16px;
  color: var(--muted);
  font-family: inherit;
  font-size: 13px;
  cursor: pointer;
  transition: all var(--t, 0.15s ease);
}

.prefs-skip:hover { color: var(--text); border-color: var(--border-h); }

.prefs-save {
  background: var(--accent);
  border: none;
  border-radius: var(--r-md, 8px);
  padding: 9px 20px;
  color: #fff;
  font-family: inherit;
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  transition: all var(--t, 0.15s ease);
}

.prefs-save:hover { background: var(--accent-h); }

/* Badge de personalização no topbar */
.prefs-badge {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 6px 12px;
  border-radius: 20px;
  background: var(--tag-bg);
  border: 1px solid rgba(255, 107, 43, 0.3);
  font-size: 12px;
  color: var(--accent);
  cursor: pointer;
  transition: all var(--t, 0.15s ease);
  white-space: nowrap;
}

.prefs-badge:hover { background: rgba(255, 107, 43, 0.2); }

/* ── Responsividade ── */

@media (max-width: 600px) {
  .modal-box,
  .prefs-box {
    padding: 20px 16px;
    border-radius: var(--r-xl, 12px);
    max-height: 95vh;
  }

  .modal-title,
  .prefs-title { font-size: 18px; }

  #aiInput { min-height: 120px; font-size: 15px; }

  /*
    Ordem DOM mantida (Cancelar antes de Enviar) para acessibilidade via Tab.
    Usamos order para inverter visualmente sem quebrar foco do teclado.
  */
  .modal-actions {
    flex-direction: column;
    gap: 12px;
    align-items: stretch;
  }

  .modal-actions .m-btn:last-child { order: -1; } /* Enviar sobe visualmente */

  .prefs-footer {
    flex-direction: column;
    gap: 12px;
    align-items: stretch;
  }

  .prefs-footer .prefs-save { order: -1; } /* Salvar sobe visualmente */

  .m-btn,
  .prefs-save,
  .prefs-skip {
    width: 100%;
    padding: 12px;
    font-size: 15px;
    justify-content: center;
    display: flex;
  }

  .prefs-grid {
    grid-template-columns: 1fr 1fr;
    gap: 8px;
  }

  .pref-chip { padding: 12px 8px; }
}