/* ============================================================
   QualiTracker Chat UI
   Brand colours: Deep Teal #0B6E5F | Dark Navy #1A3A4A | Quality Gold #C9A84C
   ============================================================ */

:root {
  --navy:        #1A3A4A;
  --navy-dark:   #122733;
  --teal:        #0B6E5F;
  --teal-dark:   #085A4D;
  --gold:        #C9A84C;
  --bg:          #F4F6F7;
  --mint:        #E6F4F1;
  --white:       #FFFFFF;
  --text:        #1C2833;
  --text-mid:    #666666;
  --text-light:  #9ca3af;
  --border:      #e3e8e9;
  --success:     #27AE60;
  --warning:     #E67E22;
  --error:       #E74C3C;
  --shadow-sm:   0 1px 4px rgba(0,0,0,.08);
  --shadow-md:   0 4px 16px rgba(0,0,0,.1);
  --radius-sm:   8px;
  --radius-md:   12px;
  --radius-lg:   18px;
  --radius-btn:  6px;
  --transition:  0.18s ease;
  --font-headline: 'Playfair Display', Georgia, serif;
  --font-ui:     'Poppins', Lato, sans-serif;
  --font-body:   'Inter', Arial, sans-serif;
}

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

html, body {
  height: 100%;
  font-family: var(--font-body), system-ui, -apple-system, sans-serif;
  font-size: 14px;
  line-height: 1.6;
  color: var(--text);
  background: var(--bg);
}

/* ----- Chat shell: shared header, chat main, footer stacked full-height.
   Same fixed-viewport / inner-scroll pattern as .lp-shell / .tp-shell
   (see platform-header.css) — the shell itself never scrolls, so the
   header and footer stay pinned on every viewport size; only
   .messages-area scrolls internally. ----- */
.chat-shell {
  height: 100vh;
  height: 100dvh;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

/* ===== CHAT MAIN ===== */
.chat-main {
  flex: 1;
  min-height: 0;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  background: var(--bg);
}

/* ----- Header ----- */
.chat-header {
  flex-shrink: 0;
  height: 60px;
  background: var(--white);
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  padding: 0 20px;
  gap: 12px;
  box-shadow: var(--shadow-sm);
}

.chat-header-info {
  display: flex;
  align-items: center;
  gap: 10px;
}

.chat-header-avatar {
  width: 36px;
  height: 36px;
  background: var(--teal);
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  color: #fff;
  font-size: 15px;
  flex-shrink: 0;
  overflow: hidden;
}

.chat-header-avatar img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.chat-header-name {
  font-family: var(--font-ui);
  font-size: 15px;
  font-weight: 600;
  color: var(--navy);
}

.back-to-topics {
  margin-left: auto;
  display: flex;
  align-items: center;
  gap: 6px;
  font-family: var(--font-ui);
  font-size: 12.5px;
  font-weight: 600;
  color: #fff;
  background: var(--navy);
  text-decoration: none;
  padding: 7px 14px;
  border-radius: var(--radius-btn);
  transition: background var(--transition);
  flex-shrink: 0;
}
.back-to-topics:hover { background: var(--navy-dark); }

.chat-header-status {
  font-size: 11px;
  color: var(--success);
  display: flex;
  align-items: center;
  gap: 5px;
}

.status-dot {
  width: 7px;
  height: 7px;
  background: var(--success);
  border-radius: 50%;
  display: inline-block;
  animation: pulse 2s infinite;
}

@keyframes pulse {
  0%, 100% { opacity: 1; }
  50%       { opacity: .4; }
}

/* ----- Messages area ----- */
.messages-area {
  flex: 1;
  overflow-y: auto;
  padding: 24px 28px;
  scroll-behavior: smooth;
}

.messages-area::-webkit-scrollbar { width: 6px; }
.messages-area::-webkit-scrollbar-track { background: transparent; }
.messages-area::-webkit-scrollbar-thumb { background: var(--border); border-radius: 3px; }

/* ----- Empty state ----- */
.empty-state {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  min-height: 65vh;
  text-align: center;
  padding: 32px 16px;
}

.empty-logo {
  width: 88px;
  height: 88px;
  margin-bottom: 24px;
  border-radius: 20px;
}

.empty-logo-placeholder {
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--mint);
  color: var(--teal);
  font-size: 36px;
}

.empty-title {
  font-family: var(--font-ui);
  font-size: 22px;
  font-weight: 600;
  color: var(--navy);
  margin-bottom: 10px;
}

.empty-subtitle {
  font-size: 14px;
  color: var(--text-mid);
  max-width: 440px;
  line-height: 1.7;
  margin-bottom: 28px;
}

.suggestion-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  justify-content: center;
}

.chip {
  padding: 9px 16px;
  background: var(--white);
  border: 1.5px solid var(--border);
  border-radius: 100px;
  font-family: var(--font-ui);
  font-size: 13px;
  font-weight: 500;
  color: var(--navy);
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 7px;
  transition: all var(--transition);
  box-shadow: var(--shadow-sm);
}

.chip:hover {
  border-color: var(--teal);
  background: var(--teal);
  color: #fff;
  box-shadow: var(--shadow-md);
  transform: translateY(-1px);
}

/* ----- Message bubbles ----- */
.bubble {
  display: flex;
  flex-direction: column;
  margin-bottom: 18px;
  max-width: 78%;
  animation: fadeUp .2s ease;
}

@keyframes fadeUp {
  from { opacity: 0; transform: translateY(6px); }
  to   { opacity: 1; transform: translateY(0); }
}

.bubble.user {
  align-self: flex-end;
  align-items: flex-end;
}

.bubble.bot,
.bubble.thinking {
  align-self: flex-start;
  align-items: flex-start;
}

.bubble-meta {
  font-size: 11px;
  color: var(--text-light);
  margin-bottom: 4px;
  padding: 0 4px;
}

.bubble-content {
  padding: 12px 16px;
  border-radius: var(--radius-lg);
  font-size: 14px;
  line-height: 1.65;
  word-break: break-word;
}

.bubble.user .bubble-content {
  background: var(--teal);
  color: #fff;
  border-radius: var(--radius-lg) var(--radius-lg) 4px var(--radius-lg);
}

.bubble.bot .bubble-content {
  background: var(--white);
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg) var(--radius-lg) var(--radius-lg) 4px;
  box-shadow: var(--shadow-sm);
}

/* Thinking indicator */
.bubble.thinking .bubble-content {
  background: var(--white);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg) var(--radius-lg) var(--radius-lg) 4px;
  padding: 14px 20px;
}

.thinking-dots {
  display: flex;
  gap: 5px;
  align-items: center;
}

.thinking-dots span {
  width: 8px;
  height: 8px;
  background: var(--teal);
  border-radius: 50%;
  animation: dotBounce 1.2s infinite ease-in-out both;
}

.thinking-dots span:nth-child(1) { animation-delay: 0s;    }
.thinking-dots span:nth-child(2) { animation-delay: .15s;  }
.thinking-dots span:nth-child(3) { animation-delay: .3s;   }

@keyframes dotBounce {
  0%, 80%, 100% { transform: scale(.6); opacity: .4; }
  40%           { transform: scale(1);  opacity: 1;   }
}

/* ----- Input area ----- */
.input-area {
  flex-shrink: 0;
  padding: 16px 28px 20px;
  background: var(--white);
  border-top: 1px solid var(--border);
}

.input-form { width: 100%; }

.input-wrap {
  display: flex;
  align-items: flex-end;
  gap: 10px;
  background: var(--mint);
  border: 1.5px solid var(--border);
  border-radius: var(--radius-md);
  padding: 10px 12px 10px 16px;
  transition: border-color var(--transition), box-shadow var(--transition);
}

.input-wrap:focus-within {
  border-color: var(--teal);
  box-shadow: 0 0 0 3px rgba(11,110,95,.12);
}

.message-textarea {
  flex: 1;
  border: none;
  background: transparent;
  resize: none;
  font-family: inherit;
  font-size: 14px;
  line-height: 1.5;
  color: var(--text);
  outline: none;
  max-height: 140px;
  overflow-y: auto;
}

.message-textarea::placeholder { color: var(--text-light); }

.send-btn {
  width: 36px;
  height: 36px;
  background: var(--teal);
  color: #fff;
  border: none;
  border-radius: var(--radius-btn);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  font-size: 14px;
  transition: background var(--transition), transform var(--transition);
}

.send-btn:hover   { background: var(--teal-dark); }
.send-btn:active  { transform: scale(.92); }
.send-btn:disabled { background: var(--text-light); cursor: not-allowed; }

.input-hint {
  margin-top: 7px;
  font-size: 11px;
  color: var(--text-light);
  text-align: right;
}

.input-hint kbd {
  background: var(--border);
  border-radius: 3px;
  padding: 1px 5px;
  font-family: inherit;
  font-size: 10px;
}

/* ===== CHAT FOOTER =====
   Navy, full width, pinned by .chat-shell (see above) — sits below
   .chat-main as a flex-shrink: 0 sibling. */
.cf-footer {
  flex-shrink: 0;
  background: var(--navy);
  color: #fff;
}

.cf-footer-inner {
  max-width: 1120px;
  margin: 0 auto;
  padding: 14px 24px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  flex-wrap: wrap;
}

.cf-footer-left {
  display: flex;
  align-items: center;
  gap: 14px;
}

.cf-footer-name {
  font-family: var(--font-ui);
  font-size: 13px;
  font-weight: 600;
  color: #fff;
}

.cf-footer-social {
  display: flex;
  gap: 12px;
}

.cf-footer-social a {
  color: rgba(255,255,255,.75);
  font-size: 14px;
  transition: color var(--transition);
}
.cf-footer-social a:hover { color: #fff; }

.cf-footer-right a {
  font-family: var(--font-ui);
  font-size: 12px;
  font-weight: 700;
  color: rgba(255,255,255,.85);
  text-decoration: none;
}
.cf-footer-right a:hover { color: #fff; text-decoration: underline; }

/* ===== RESPONSIVE ===== */
@media (max-width: 720px) {
  .messages-area { padding: 16px; }
  .input-area     { padding: 12px 16px 16px; }
  .bubble         { max-width: 92%; }
}

@media (max-width: 480px) {
  .cf-footer-inner { padding: 12px 16px; }
}
