/* Base styles */
* {
  box-sizing: border-box;
}
body {
  margin: 0;
  font-family: Arial, sans-serif;
  background-color: #f0f4f8;
  color: #1e293b;
  line-height: 1.5;
}
.container {
  max-width: 900px;
  margin: 0 auto;
  padding: 20px;
  display: flex;
  flex-direction: column;
  min-height: 100vh;
}
.header {
  text-align: center;
  margin-bottom: 16px;
}
.header h1 {
  margin: 0;
  font-size: 32px;
}
.header p {
  margin: 4px 0 0;
  color: #475569;
}
.header nav a {
  margin-right: 8px;
  text-decoration: none;
  color: #1d4ed8;
}
.header nav a:hover {
  text-decoration: underline;
}
.chat-wrapper {
  display: flex;
  flex-direction: column;
  flex: 1;
  margin-bottom: 12px;
}
.chat-area {
  flex: 1;
  border: 1px solid #cbd5e1;
  border-radius: 8px;
  background: #ffffff;
  padding: 12px;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
}
.research-panel {
  margin-top: 8px;
  border: 1px dashed #94a3b8;
  border-radius: 8px;
  background: #f8fafc;
  padding: 8px;
  height: 120px;
  overflow-y: auto;
  font-size: 14px;
  color: #334155;
}
.input-area {
  background: #e2e8f0;
  border-radius: 8px;
  padding: 8px;
}
.controls {
  display: flex;
  gap: 8px;
  align-items: center;
}
#messageInput {
  flex: 1;
  padding: 10px;
  border: 1px solid #cbd5e1;
  border-radius: 6px;
  font-size: 16px;
}
button {
  padding: 10px 16px;
  background: #2563eb;
  color: #fff;
  border: none;
  border-radius: 6px;
  font-size: 16px;
  cursor: pointer;
}
button:hover {
  background: #1e40af;
}
#micBtn {
  font-size: 20px;
  width: 40px;
  height: 40px;
  padding: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 50%;
  background: #0ea5e9;
  color: #fff;
}
#micBtn.listening {
  background: #dc2626;
}
.message {
  margin-bottom: 10px;
  max-width: 80%;
  padding: 8px 12px;
  border-radius: 12px;
  position: relative;
  word-break: break-word;
}
.message.user {
  align-self: flex-end;
  background: #dbeafe;
  color: #1e3a8a;
}
.message.bot {
  align-self: flex-start;
  background: #fef9c3;
  color: #713f12;
}
.message .meta {
  font-size: 12px;
  color: #64748b;
  margin-top: 2px;
}
.status-bar {
  margin-top: 4px;
  font-size: 12px;
  color: #64748b;
}

/* Admin page */
#unknownList .unknown-item {
  border: 1px solid #cbd5e1;
  border-radius: 6px;
  padding: 10px;
  margin-bottom: 12px;
  background: #ffffff;
}
#unknownList .unknown-item h4 {
  margin: 0 0 4px;
  font-size: 16px;
}
#unknownList .unknown-item textarea {
  width: 100%;
  height: 80px;
  margin: 4px 0;
  padding: 6px;
  border: 1px solid #cbd5e1;
  border-radius: 4px;
  resize: vertical;
}
#unknownList .unknown-item input[type="text"] {
  width: 100%;
  margin: 4px 0;
  padding: 6px;
  border: 1px solid #cbd5e1;
  border-radius: 4px;
}
#unknownList .unknown-item select {
  width: 100%;
  margin: 4px 0;
  padding: 6px;
  border: 1px solid #cbd5e1;
  border-radius: 4px;
}
#unknownList .unknown-item button {
  margin-top: 6px;
}
.top-tools {
  max-width: 900px;
  margin: 0 auto 12px;
  display: flex;
  gap: 12px;
  flex-wrap: wrap;
  justify-content: center;
  background: #e2e8f0;
  padding: 10px;
  border-radius: 10px;
}

.top-tools label {
  font-size: 14px;
  color: #334155;
}

.top-tools select,
#voiceLang,
#answerLang {
  margin-left: 6px;
  padding: 8px;
  border: 1px solid #cbd5e1;
  border-radius: 6px;
  background: #fff;
  color: #1e293b;
}

.message-wrap {
  display: flex;
  flex-direction: column;
  margin-bottom: 10px;
}

.message-wrap.user {
  align-items: flex-end;
}

.message-wrap.bot {
  align-items: flex-start;
}

.answer-actions {
  display: flex;
  gap: 6px;
  margin-top: 4px;
}

.answer-actions button,
.answer-actions select {
  font-size: 12px;
  padding: 5px 8px;
  border-radius: 6px;
  border: 1px solid #cbd5e1;
}

.answer-actions button {
  background: #2563eb;
  color: #fff;
}

/* ===== FIXED CHAT LAYOUT V2 ===== */

html, body {
  height: 100%;
  overflow: hidden;
}

body {
  display: flex;
  flex-direction: column;
}

.app,
.container,
.wrapper,
.main-wrap {
  height: 100vh;
  display: flex;
  flex-direction: column;
}

.chat-container,
#chatBox,
.chat-box,
#messages {
  flex: 1;
  overflow-y: auto !important;
  min-height: 0;
  scroll-behavior: smooth;
}

.controls,
.input-area,
.chat-input,
.input-row,
footer {
  flex-shrink: 0;
}

.research-box,
.research-panel,
#researchBox,
#research {
  max-height: 160px;
  overflow-y: auto;
}

/* ===== END FIXED CHAT LAYOUT V2 ===== */

/* ===== FINAL FIXED LAPTOP CHAT LAYOUT ===== */

html, body {
  height: 100%;
  margin: 0;
  overflow: hidden !important;
}

body {
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
  background: #eef3f9;
}

/* Main app wrapper */
body > *:first-child,
.app,
.container,
.wrapper,
.main,
.main-wrap {
  height: 100dvh !important;
  max-height: 100dvh !important;
  display: flex !important;
  flex-direction: column !important;
  overflow: hidden !important;
}

/* Header fixed area */
h1,
.header,
.top-header,
.language-bar,
.controls {
  flex-shrink: 0 !important;
}

/* Chat middle scroll area */
#chatBox,
#messages,
.chat-box,
.chat-container,
.messages {
  flex: 1 1 auto !important;
  min-height: 0 !important;
  overflow-y: auto !important;
  overflow-x: hidden !important;
  scroll-behavior: smooth;
  padding-bottom: 16px !important;
}

/* Research panel should not push footer out */
#researchBox,
#research,
.research-box,
.research-panel {
  flex-shrink: 0 !important;
  max-height: 130px !important;
  overflow-y: auto !important;
}

/* Footer/input fixed */
.input-area,
.chat-input,
.input-row,
.footer,
footer {
  flex-shrink: 0 !important;
  position: sticky !important;
  bottom: 0 !important;
  z-index: 50 !important;
  background: #e8eef7 !important;
}

/* Auto expanding textarea */
#messageInput,
#userInput,
textarea.message-input,
textarea.chat-message-input {
  min-height: 46px !important;
  max-height: 150px !important;
  overflow-y: auto !important;
  resize: none !important;
  line-height: 1.45 !important;
  border-radius: 10px !important;
}

/* Mic button new shape */
#micBtn,
.mic-btn,
.voice-btn,
button[aria-label="mic"],
button[aria-label="voice"] {
  width: 46px !important;
  height: 46px !important;
  min-width: 46px !important;
  border-radius: 14px !important;
  background: linear-gradient(135deg, #0ea5e9, #2563eb) !important;
  color: white !important;
  border: 0 !important;
  box-shadow: 0 6px 14px rgba(37, 99, 235, 0.25) !important;
  display: inline-flex !important;
  align-items: center !important;
  justify-content: center !important;
  font-size: 20px !important;
}

/* Mobile/laptop fit */
@media (min-width: 900px) {
  #chatBox,
  #messages,
  .chat-box,
  .chat-container,
  .messages {
    max-height: calc(100dvh - 330px) !important;
  }
}

@media (max-width: 899px) {
  #chatBox,
  #messages,
  .chat-box,
  .chat-container,
  .messages {
    max-height: calc(100dvh - 300px) !important;
  }
}

/* ===== END FINAL FIXED LAPTOP CHAT LAYOUT ===== */

/* ===== CHATGPT STYLE FIXED LAYOUT FINAL ===== */

:root {
  --top-height: 238px;
  --research-height: 112px;
  --footer-height: 92px;
}

html,
body {
  width: 100%;
  height: 100%;
  margin: 0 !important;
  overflow: hidden !important;
  background: #eef3f9 !important;
}

/* Full page app lock */
body {
  height: 100dvh !important;
  max-height: 100dvh !important;
}

/* Header area: title + language controls */
body > h1,
body > .title,
body > .app-title,
body > header,
.header,
.top-header {
  flex-shrink: 0 !important;
}

/* Main chat white box */
#chatBox,
#messages,
.chat-box,
.chat-container,
.messages {
  height: calc(100dvh - var(--top-height) - var(--research-height) - var(--footer-height)) !important;
  max-height: calc(100dvh - var(--top-height) - var(--research-height) - var(--footer-height)) !important;
  min-height: 280px !important;
  overflow-y: auto !important;
  overflow-x: hidden !important;
  padding: 18px 22px 30px 22px !important;
  box-sizing: border-box !important;
  scroll-behavior: smooth !important;
}

/* Stop chat messages from expanding page */
.message,
.msg,
.bot-message,
.user-message,
.bubble {
  max-width: 78% !important;
  overflow-wrap: anywhere !important;
  word-break: break-word !important;
}

/* Research panel fixed height */
#researchBox,
#research,
.research-box,
.research-panel {
  height: var(--research-height) !important;
  max-height: var(--research-height) !important;
  overflow-y: auto !important;
  overflow-x: hidden !important;
  flex-shrink: 0 !important;
  box-sizing: border-box !important;
  margin-top: 8px !important;
}

/* Footer/input fixed style */
.input-area,
.chat-input,
.input-row,
.footer,
footer {
  height: auto !important;
  min-height: var(--footer-height) !important;
  max-height: 190px !important;
  flex-shrink: 0 !important;
  background: #e7edf6 !important;
  z-index: 50 !important;
  box-sizing: border-box !important;
}

/* The typing box itself expands, not the whole screen */
#messageInput,
#userInput,
textarea,
input[type="text"] {
  min-height: 46px !important;
  max-height: 138px !important;
  overflow-y: auto !important;
  resize: none !important;
  line-height: 1.45 !important;
  box-sizing: border-box !important;
  border-radius: 12px !important;
}

/* Mic button new design */
#micBtn,
.mic-btn,
.voice-btn,
button[aria-label="mic"],
button[aria-label="voice"] {
  width: 52px !important;
  height: 52px !important;
  min-width: 52px !important;
  border-radius: 16px !important;
  border: 0 !important;
  background: linear-gradient(145deg, #0ea5e9, #1d4ed8) !important;
  color: #fff !important;
  display: inline-flex !important;
  align-items: center !important;
  justify-content: center !important;
  box-shadow: 0 7px 18px rgba(29, 78, 216, 0.28) !important;
}

/* Laptop fit */
@media (min-width: 900px) {
  body {
    padding-bottom: 0 !important;
  }
}

/* ===== END CHATGPT STYLE FIXED LAYOUT FINAL ===== */
