/* ============================================
   CHAT SCREEN
   Light translucent panel with glassmorphism,
   consistent with the menu drawer style.
   ============================================ */

.chat-screen {
  position: absolute;
  inset: 0;
  z-index: 8;
  background: rgba(247, 247, 245, 0.85);
  backdrop-filter: blur(24px) saturate(150%);
  -webkit-backdrop-filter: blur(24px) saturate(150%);
  border-radius: var(--frame-radius);
  display: flex;
  flex-direction: column;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.35s ease;
}

.chat-screen.active {
  opacity: 1;
  pointer-events: auto;
}

/* ---- Header ---- */

.chat-header {
  display: flex;
  align-items: center;
  justify-content: center;
  position: relative;
  padding: 58px 20px 14px;
  flex-shrink: 0;
  border-bottom: 1px solid rgba(0, 0, 0, 0.06);
}

.chat-back {
  position: absolute;
  left: 14px;
  top: 55px;
  width: 32px;
  height: 32px;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  border: none;
  background: none;
  border-radius: 8px;
  transition: background-color 0.15s ease;
  padding: 0;
  -webkit-tap-highlight-color: transparent;
}

.chat-back:hover {
  background: rgba(0, 0, 0, 0.05);
}

.chat-title {
  font-family: var(--font-sans);
  font-weight: 600;
  font-size: 17px;
  color: #1A1A1A;
}

/* ---- Messages area ---- */

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

/* ---- Message bubbles ---- */

.chat-msg {
  max-width: 82%;
  opacity: 0;
  transform: translateY(10px);
  animation: chat-msg-in 0.55s cubic-bezier(0.16, 1, 0.3, 1) forwards;
}

@keyframes chat-msg-in {
  to { opacity: 1; transform: translateY(0); }
}

/* ---- Typing indicator ---- */

.chat-typing-dots {
  display: flex;
  align-items: center;
  gap: 4px;
  padding: 10px 4px;
}

.chat-typing-dots span {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: #999;
  animation: chat-dot-bounce 1.2s ease-in-out infinite;
}

.chat-typing-dots span:nth-child(2) {
  animation-delay: 0.15s;
}

.chat-typing-dots span:nth-child(3) {
  animation-delay: 0.3s;
}

@keyframes chat-dot-bounce {
  0%, 60%, 100% { transform: translateY(0); opacity: 0.4; }
  30% { transform: translateY(-5px); opacity: 1; }
}

/* Collapsed previous messages */
.chat-msg.collapsed {
  opacity: 0.45;
  transform: none;
  animation: none;
  max-width: 100%;
}

.chat-msg.collapsed .chat-bubble {
  padding: 4px 12px;
  font-size: 12px;
  line-height: 1.4;
}

.chat-msg-user.collapsed .chat-bubble {
  background: rgba(0, 0, 0, 0.35);
  padding: 4px 12px;
}

/* ---- User bubble — right-aligned, dark ---- */

.chat-msg-user {
  align-self: flex-end;
}

.chat-msg-user .chat-bubble {
  background: #1A1A1A;
  color: #fff;
  border-radius: 16px 16px 4px 16px;
  padding: 12px 16px;
  font-family: var(--font-sans);
  font-size: 15px;
  line-height: 1.45;
}

/* ---- Bot bubble — left-aligned, with avatar ---- */

.chat-msg-bot {
  align-self: flex-start;
  display: flex;
  gap: 10px;
  align-items: flex-start;
}

.chat-avatar {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  background: #001e5f;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  margin-top: 1px;
  overflow: hidden;
}

.chat-avatar-img {
  width: 10px;
  height: auto;
  max-height: 18px;
  display: block;
  object-fit: contain;
  object-position: center center;
  pointer-events: none;
  /* léger ajustement optique pour centrer la forme « S » dans le cercle */
  transform: translateY(0.5px);
}

.chat-msg-bot .chat-bubble {
  background: transparent;
  color: #1A1A1A;
  padding: 2px 0;
  font-family: var(--font-sans);
  font-size: 15px;
  line-height: 1.5;
}

.chat-msg-bot .chat-bubble strong {
  font-weight: 700;
}

/* ---- Success message (avatar Scout) ---- */

.chat-msg-success {
  align-self: flex-start;
  display: flex;
  gap: 10px;
  align-items: flex-start;
}

.chat-msg-success .chat-bubble {
  background: transparent;
  color: #1A1A1A;
  padding: 2px 0;
  font-family: var(--font-sans);
  font-size: 15px;
  line-height: 1.5;
}

.chat-msg-success .chat-bubble strong {
  font-weight: 700;
}

/* ---- User image message ---- */

.chat-image {
  max-width: 200px;
  border-radius: 12px;
  display: block;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
}

/* ---- Warning bubble (scam alert) — avatar reste Scout (#001e5f) ---- */

.chat-bubble-warning {
  color: #D94040 !important;
}

.chat-bubble-warning strong {
  font-weight: 700;
}

/* ---- Safe bubble (legitimate) — avatar reste Scout (#001e5f) ---- */

.chat-bubble-safe {
  color: #2E7D32 !important;
  font-size: 14px;
}

.chat-bubble-safe strong {
  font-weight: 700;
  font-size: 16px;
}

/* ---- Bot loading state ---- */

.chat-loading-bubble {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.chat-loading-text {
  font-size: 15px;
  color: #1A1A1A;
}

.chat-loading-sub {
  font-size: 12px;
  color: #888;
  animation: chat-loading-pulse 1.5s ease-in-out infinite;
}

@keyframes chat-loading-pulse {
  0%, 100% { opacity: 0.5; }
  50% { opacity: 1; }
}

/* ---- Quick reply options (glass cards) ---- */

.chat-options {
  display: flex;
  flex-direction: column;
  gap: 6px;
  padding: 8px 0;
  opacity: 0;
  animation: chat-msg-in 0.5s 0.1s cubic-bezier(0.16, 1, 0.3, 1) forwards;
}

.chat-option {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 18px;
  border: none;
  background: rgba(255, 255, 255, 0.65);
  backdrop-filter: blur(var(--glass-blur)) saturate(var(--glass-saturate));
  -webkit-backdrop-filter: blur(var(--glass-blur)) saturate(var(--glass-saturate));
  border-radius: 12px;
  cursor: pointer;
  text-align: left;
  color: #1A1A1A;
  font-family: var(--font-sans);
  border: 1px solid rgba(255, 255, 255, 0.7);
  border-top-color: rgba(255, 255, 255, 0.9);
  box-shadow:
    0 1px 3px rgba(0, 0, 0, 0.03),
    0 4px 12px rgba(0, 0, 0, 0.03);
  overflow: hidden;
  transition: background-color 0.2s ease, box-shadow 0.2s ease, transform 0.15s ease;
}

.chat-option::before {
  content: '';
  position: absolute;
  inset: 0;
  border-radius: inherit;
  background: linear-gradient(135deg, rgba(255, 255, 255, 0.25) 0%, rgba(255, 255, 255, 0.05) 40%, rgba(255, 255, 255, 0) 60%);
  opacity: 0.5;
  transition: opacity 0.2s ease;
  pointer-events: none;
}

.chat-option:hover {
  background: rgba(255, 255, 255, 0.88);
  box-shadow:
    0 2px 4px rgba(0, 0, 0, 0.04),
    0 6px 16px rgba(0, 0, 0, 0.05);
  transform: translateY(-1px);
}

.chat-option:hover::before {
  opacity: 1;
}

.chat-option:active {
  transform: translateY(0);
}

.chat-option-text {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.chat-option-label {
  font-size: 15px;
  font-weight: 600;
  color: #1A1A1A;
}

.chat-option-desc {
  font-size: 13px;
  font-weight: 400;
  color: #888;
}

.chat-option-chevron {
  font-size: 16px;
  color: #888;
  flex-shrink: 0;
}

.chat-option.selected {
  opacity: 0.45;
  pointer-events: none;
  transform: none;
}

/* ---- Input bar ---- */

.chat-input-bar {
  flex-shrink: 0;
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 12px 16px 28px;
  border-top: 1px solid rgba(0, 0, 0, 0.06);
}

.chat-input-plus {
  font-size: 20px;
  font-weight: 700;
  color: #888;
  flex-shrink: 0;
  width: 24px;
  text-align: center;
}

.chat-input-text {
  flex: 1;
  font-family: var(--font-sans);
  font-size: 15px;
  color: #888;
}

.chat-input-mic {
  flex-shrink: 0;
  line-height: 0;
  display: flex;
  align-items: center;
  justify-content: center;
}

.chat-input-mic-icon {
  display: block;
  width: 36px;
  height: 36px;
}

/* ---- Voice option (Describe vocally) — matches onboarding-alt-btn ---- */
.chat-option-voice {
  align-self: flex-start;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 10px 16px;
  border-radius: 24px;
  background: rgba(255, 255, 255, 0.7);
  border: 1px solid rgba(0, 0, 0, 0.1);
  font: 500 13px/1 var(--font-sans);
  color: #1A1A1A;
  cursor: pointer;
  box-shadow: none;
  transition: background-color 0.18s ease, border-color 0.18s ease;
  justify-content: flex-start;
  width: auto;
  min-height: 0;
}
.chat-option-voice::before { display: none; }
.chat-option-voice:hover {
  background: rgba(255, 255, 255, 0.95);
  border-color: rgba(0, 0, 0, 0.22);
  transform: none;
  box-shadow: none;
}
.chat-option-voice .chat-option-label {
  color: #1A1A1A;
  font-weight: 500;
  font-size: 13px;
}
.chat-option-voice-icon {
  width: 14px; height: 14px;
  display: inline-flex; align-items: center; justify-content: center;
  flex-shrink: 0;
}
.chat-option-voice-icon svg {
  width: 14px; height: 14px;
  stroke: currentColor; fill: none;
  stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round;
}

/* ---- Voice capture banner — matches onboarding-voice-recording ---- */
.chat-voice-capture {
  align-self: stretch;
  display: flex; align-items: center; gap: 12px;
  padding: 14px 16px;
  background: rgba(245, 10, 10, 0.06);
  border: 1px solid rgba(245, 10, 10, 0.2);
  border-radius: 14px;
  font: 500 14px/1 var(--font-sans);
  color: #1A1A1A;
  opacity: 0;
  animation: chat-voice-in 0.3s ease forwards;
}
@keyframes chat-voice-in { to { opacity: 1; } }
.chat-voice-dot {
  width: 10px; height: 10px; border-radius: 50%;
  background: #f50a0a;
  animation: chat-voice-pulse 1s ease-in-out infinite;
  flex-shrink: 0;
}
@keyframes chat-voice-pulse {
  0%, 100% { opacity: 1; transform: scale(1); }
  50%      { opacity: 0.4; transform: scale(0.75); }
}
.chat-voice-label { flex-shrink: 0; }
.chat-voice-wave {
  display: flex; align-items: center; gap: 3px; flex: 1;
}
.chat-voice-wave span {
  width: 2px; background: #1A1A1A; border-radius: 2px;
  animation: chat-voice-wave-bar 1.1s ease-in-out infinite;
}
.chat-voice-wave span:nth-child(1) { height: 10px; animation-delay: 0s; }
.chat-voice-wave span:nth-child(2) { height: 18px; animation-delay: 0.1s; }
.chat-voice-wave span:nth-child(3) { height: 24px; animation-delay: 0.2s; }
.chat-voice-wave span:nth-child(4) { height: 14px; animation-delay: 0.3s; }
.chat-voice-wave span:nth-child(5) { height: 20px; animation-delay: 0.4s; }
@keyframes chat-voice-wave-bar {
  0%, 100% { transform: scaleY(0.35); }
  50%      { transform: scaleY(1); }
}
