/* ── Chat Hero Section ── */

.chat-hero-section {
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  min-height: calc(100vh - 80px);
  padding: 48px 24px 40px;
}

/* ── IDLE HERO ── */
.idle-hero {
  display: flex; flex-direction: column; align-items: center;
  width: 100%; max-width: 860px;
  transition: opacity .35s, transform .35s;
}
.idle-hero.hidden { opacity: 0; pointer-events: none; transform: translateY(-20px); position: absolute; }

.chat-logo-mark {
  width: 68px; height: 68px; border-radius: 20px;
  background: linear-gradient(135deg, #8B4513, #D2691E);
  display: flex; align-items: center; justify-content: center;
  font-size: 1.15rem; font-weight: 700; color: #fff;
  box-shadow: 0 8px 32px rgba(139,69,19,.3);
  margin-bottom: 28px;
  animation: chatFadeDown .5s ease both;
}

.chat-headline {
  font-size: clamp(3.2rem, 7.5vw, 5.4rem); font-weight: 700;
  text-align: center; line-height: 1.1; letter-spacing: -.03em;
  animation: chatFadeDown .5s .05s ease both;
  color: #1A1A1A;
}
.chat-headline span {
  background: linear-gradient(135deg, #8B4513 10%, #D2691E 90%);
  -webkit-background-clip: text; -webkit-text-fill-color: transparent; background-clip: text;
}

.chat-subline {
  margin: 18px 0 48px; font-size: 1.2rem; color: #888888;
  text-align: center; animation: chatFadeDown .5s .1s ease both;
}
.chat-subline .underlined {
  position: relative; display: inline-block;
  color: #1A1A1A; font-weight: 500;
}
.chat-subline .underlined::after {
  content: ''; position: absolute; left: 0; bottom: -3px;
  width: 100%; height: 2px;
  background: linear-gradient(90deg, #8B4513, #D2691E);
  border-radius: 1px;
}

/* ── Input wrap (shared idle + chat) ── */
.chat-input-wrap {
  width: 100%; background: #fff;
  border: 1.5px solid rgba(0,0,0,0.1); border-radius: 22px;
  box-shadow: 0 2px 4px rgba(0,0,0,.04), 0 12px 40px rgba(0,0,0,.08);
  display: flex; align-items: flex-end; gap: 10px;
  padding: 18px 16px 18px 24px;
  transition: box-shadow .25s, border-color .25s;
  animation: chatFadeUp .5s .15s ease both;
}
.chat-input-wrap:focus-within {
  border-color: rgba(139,69,19,.4);
  box-shadow: 0 2px 4px rgba(0,0,0,.05), 0 16px 48px rgba(0,0,0,.1), 0 0 0 4px rgba(210,105,30,.08);
}

textarea.chat-main-input {
  flex: 1; font-family: 'Poppins', sans-serif; font-size: 1.05rem; color: #1A1A1A;
  background: transparent; border: none; outline: none; resize: none;
  line-height: 1.6; min-height: 32px; max-height: 180px; overflow-y: auto;
}
textarea.chat-main-input::placeholder { color: #888888; }

.chat-input-actions { display: flex; align-items: center; gap: 8px; flex-shrink: 0; }

.chat-icon-btn {
  width: 44px; height: 44px; border-radius: 12px; border: none;
  background: transparent; cursor: pointer;
  display: flex; align-items: center; justify-content: center;
  color: #888888; transition: background .16s, color .16s;
}
.chat-icon-btn:hover { background: rgba(210,105,30,0.09); color: #D2691E; }

.chat-send-btn {
  width: 44px; height: 44px; border-radius: 12px; border: none;
  background: linear-gradient(135deg, #8B4513, #D2691E);
  cursor: pointer; display: flex; align-items: center; justify-content: center;
  box-shadow: 0 4px 14px rgba(139,69,19,.35);
  transition: transform .15s, box-shadow .15s, opacity .15s; flex-shrink: 0;
}
.chat-send-btn:hover { transform: translateY(-1px); box-shadow: 0 6px 20px rgba(139,69,19,.45); }
.chat-send-btn:active { transform: none; }
.chat-send-btn:disabled { opacity: .4; cursor: default; transform: none; box-shadow: none; }
.chat-send-btn svg { width: 20px; height: 20px; fill: #fff; }

/* Chips */
.chat-chips {
  display: flex; flex-wrap: wrap; gap: 10px; justify-content: center;
  margin-top: 24px; animation: chatFadeUp .5s .22s ease both;
}
.chat-chip {
  font-family: 'Poppins', sans-serif; font-size: .9rem; font-weight: 500;
  color: #8B4513; background: #fff;
  border: 1.5px solid rgba(139,69,19,.18); border-radius: 28px;
  padding: 10px 20px; cursor: pointer;
  display: flex; align-items: center; gap: 7px; white-space: nowrap;
  transition: background .18s, border-color .18s, transform .12s, box-shadow .18s;
}
.chat-chip:hover { background: rgba(139,69,19,.06); border-color: rgba(139,69,19,.3); transform: translateY(-1px); box-shadow: 0 4px 14px rgba(0,0,0,.08); }
.chat-chip:active { transform: none; }

/* Footer note */
.chat-footer-note {
  font-size: .8rem; color: #888888; display: flex; justify-content: center; opacity: .8;
  margin-top: 28px;
}
.chat-footer-note span + span::before { content: ' \00b7  '; }

/* ── CHAT VIEW ── */
.chat-view {
  display: none; flex-direction: column;
  width: 100%; max-width: 860px;
  height: calc(100vh - 160px); max-height: 860px;
}
.chat-view.active { display: flex; }

.chat-topbar {
  display: flex; align-items: center; justify-content: space-between;
  padding: 0 4px 18px; animation: chatFadeDown .3s ease both;
}
.chat-brand { display: flex; align-items: center; gap: 12px; font-size: 1rem; font-weight: 600; }
.chat-mini-logo {
  width: 34px; height: 34px; border-radius: 10px;
  background: linear-gradient(135deg, #8B4513, #D2691E);
  display: flex; align-items: center; justify-content: center;
  font-size: .7rem; font-weight: 700; color: #fff;
}
.chat-online-badge {
  font-size: .8rem; font-weight: 400; color: #888888;
  display: flex; align-items: center; gap: 6px;
}
.chat-online-badge::before {
  content: ''; width: 8px; height: 8px; border-radius: 50%;
  background: #4ADE80; box-shadow: 0 0 0 2px rgba(74,222,128,.25);
  animation: chatPulse 2s infinite;
}
@keyframes chatPulse { 0%,100%{opacity:1} 50%{opacity:.5} }

.chat-reset-btn {
  font-family: 'Poppins', sans-serif; font-size: 1rem; color: #888888;
  background: none; border: 1px solid rgba(0,0,0,0.1); border-radius: 50%;
  width: 38px; height: 38px; padding: 0;
  display: flex; align-items: center; justify-content: center;
  cursor: pointer; transition: border-color .16s, color .16s, background .16s;
}
.chat-reset-btn:hover { border-color: #D2691E; color: #D2691E; background: rgba(210,105,30,.06); }

/* Messages */
.chat-messages {
  flex: 1; overflow-y: auto;
  display: flex; flex-direction: column; gap: 20px;
  padding: 4px 0 20px; scroll-behavior: smooth;
}
.chat-messages::-webkit-scrollbar { width: 5px; }
.chat-messages::-webkit-scrollbar-thumb { background: rgba(0,0,0,0.1); border-radius: 3px; }

.msg-row {
  display: flex; gap: 14px; align-items: flex-start;
  animation: chatMsgIn .35s cubic-bezier(.34,1.2,.64,1) both;
}
.msg-row.user { flex-direction: row-reverse; }
@keyframes chatMsgIn {
  from { opacity: 0; transform: translateY(12px) scale(.97); }
  to   { opacity: 1; transform: translateY(0) scale(1); }
}

.msg-avatar {
  width: 40px; height: 40px; border-radius: 50%;
  background: linear-gradient(135deg, #D2691E, #8B4513);
  display: flex; align-items: center; justify-content: center;
  font-size: .7rem; font-weight: 700; color: #fff; flex-shrink: 0; margin-top: 2px;
}
.msg-row.user .msg-avatar { background: linear-gradient(135deg, #C4A882, #A07860); }

.msg-bubble {
  max-width: 80%; padding: 14px 20px; border-radius: 20px;
  font-size: .97rem; line-height: 1.65;
}
.msg-row.bot .msg-bubble {
  background: #F3F3F3; border: 1px solid rgba(0,0,0,.07);
  border-top-left-radius: 4px; color: #1A1A1A;
}
.msg-row.user .msg-bubble {
  background: #8B4513; border-top-right-radius: 4px; color: #fff;
}

/* Typing dots */
.typing-dots { display: flex; gap: 5px; align-items: center; padding: 4px 0; }
.typing-dots span {
  width: 8px; height: 8px; border-radius: 50%; background: #D2691E;
  animation: chatBounce 1.1s infinite;
}
.typing-dots span:nth-child(2) { animation-delay: .18s; }
.typing-dots span:nth-child(3) { animation-delay: .36s; }
@keyframes chatBounce { 0%,60%,100%{transform:translateY(0)} 30%{transform:translateY(-8px)} }

/* Chat bottom */
.chat-bottom { padding-top: 12px; display: flex; flex-direction: column; gap: 12px; animation: chatFadeUp .3s ease both; }
.chat-bottom .chat-chips { margin-top: 0; animation: none; }
.chat-bottom .chat-chip { font-size: .82rem; padding: 8px 16px; }

/* Recording state — red ring */
.chat-input-wrap.recording {
  border-color: rgba(229,62,62,.5);
  box-shadow: 0 0 0 4px rgba(229,62,62,.08);
}
.chat-icon-btn.rec-active { color: #E53E3E; background: rgba(229,62,62,.1); }

/* Recording UI inside input */
.chat-rec-ui {
  flex: 1; display: none; align-items: center; gap: 12px;
}
.chat-rec-ui.active { display: flex; }
.chat-rec-timer { font-size: .95rem; font-weight: 600; color: #E53E3E; min-width: 36px; }
.chat-rec-bars {
  flex: 1; display: flex; align-items: center; gap: 2px; height: 28px; overflow: hidden;
}
.chat-rec-bar {
  width: 3px; border-radius: 2px; background: #E53E3E; opacity: .7;
  animation: chatRecBar .6s ease-in-out infinite alternate;
  transform-origin: bottom;
}
@keyframes chatRecBar { from { transform: scaleY(.2); } to { transform: scaleY(1); } }

/* ── Audio bubble ── */
.chat-audio-bubble {
  display: flex; align-items: center; gap: 12px;
  padding: 12px 16px; border-radius: 20px;
  min-width: 240px; max-width: 340px; cursor: pointer;
}
.msg-row.user .chat-audio-bubble {
  background: #8B4513; border-top-right-radius: 4px;
}
.msg-row.bot .chat-audio-bubble {
  background: #F3F3F3; border: 1px solid rgba(0,0,0,.07);
  border-top-left-radius: 4px;
}

.chat-ab-play {
  width: 38px; height: 38px; border-radius: 50%; border: none;
  display: flex; align-items: center; justify-content: center;
  cursor: pointer; flex-shrink: 0; transition: transform .12s;
}
.chat-ab-play:active { transform: scale(.9); }
.msg-row.user .chat-ab-play { background: rgba(255,255,255,.2); }
.msg-row.bot .chat-ab-play { background: #8B4513; }
.chat-ab-play svg { width: 15px; height: 15px; fill: #fff; }

.chat-ab-body { flex: 1; display: flex; flex-direction: column; gap: 4px; min-width: 0; }
.chat-ab-waveform {
  display: flex; align-items: center; gap: 2.5px; height: 30px;
}
.chat-ab-bar {
  width: 3px; border-radius: 2px; flex-shrink: 0;
  transition: background .15s;
}
.msg-row.user .chat-ab-bar         { background: rgba(255,255,255,.35); }
.msg-row.user .chat-ab-bar.played  { background: rgba(255,255,255,.9); }
.msg-row.bot .chat-ab-bar          { background: #C0A090; }
.msg-row.bot .chat-ab-bar.played   { background: #8B4513; }

.chat-ab-meta { display: flex; align-items: center; justify-content: space-between; }
.chat-ab-time { font-size: .75rem; font-weight: 500; }
.msg-row.user .chat-ab-time { color: rgba(255,255,255,.65); }
.msg-row.bot  .chat-ab-time { color: #888888; }
.chat-ab-label { font-size: .72rem; font-style: italic; }
.msg-row.user .chat-ab-label { color: rgba(255,255,255,.5); }
.msg-row.bot  .chat-ab-label { color: #888888; }

/* Animations */
@keyframes chatFadeDown { from{opacity:0;transform:translateY(-12px)} to{opacity:1;transform:translateY(0)} }
@keyframes chatFadeUp   { from{opacity:0;transform:translateY(16px)}  to{opacity:1;transform:translateY(0)} }

/* ── Mobile overrides ── */
@media (max-width: 600px) {

  /* Hide navbar, show on scroll */
  body.chat-page .navbar {
    transform: translateY(-100%);
    transition: transform .3s ease;
  }
  body.chat-page .navbar.nav-visible {
    transform: translateY(0);
  }

  /* Idle hero */
  .chat-hero-section {
    padding: 16px 14px 20px;
    min-height: 100vh; min-height: 100dvh;
  }
  .chat-headline { font-size: 1.9rem; }
  .chat-subline { font-size: .95rem; margin-bottom: 28px; }
  .chat-logo-mark { width: 52px; height: 52px; font-size: .9rem; margin-bottom: 20px; }
  .chat-input-wrap { padding: 14px 12px 14px 18px; }
  textarea.chat-main-input { font-size: .95rem; }

  /* Chat active: fixed to viewport, immune to keyboard scroll */
  .chat-hero-section.chat-active {
    position: fixed;
    top: 0; left: 0; right: 0;
    justify-content: flex-start;
    padding: 8px 14px 0;
    min-height: auto;
    height: calc(var(--vh, 1vh) * 100);
    z-index: 100;
    background: #F8F8F8;
  }

  .chat-view {
    flex: 1; height: 0;
    min-height: 0;
    max-height: none;
  }

  .chat-messages {
    flex: 1;
    min-height: 0;
    overflow-y: auto;
  }

  .chat-bottom { flex-shrink: 0; }

  /* Chips — horizontal scroll */
  .chat-chips {
    flex-wrap: nowrap; overflow-x: auto; justify-content: flex-start;
    gap: 8px; padding: 2px 0;
    max-width: 100%;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: none;
  }
  .idle-hero .chat-chips { width: 100%; }
  .chat-chip { font-size: .78rem; padding: 7px 14px; flex-shrink: 0; }
  .chat-chips::-webkit-scrollbar { display: none; }

  /* Topbar compact */
  .chat-topbar { padding: 0 4px 8px; flex-shrink: 0; }
  .chat-reset-btn { width: 34px; height: 34px; padding: 0; font-size: 1.1rem;
    display: flex; align-items: center; justify-content: center; border-radius: 50%; }

  /* Footer note smaller */
  .chat-bottom .chat-footer-note { margin-top: 8px; }
}
