/* ============================================
   Global Layout
============================================ */
html, body {
  margin: 0;
  padding: 0;
  min-height: 100svh;
  font-family: "Inter", Arial, sans-serif;
  background: #ffffff;
  color: #333;
  overflow-x: hidden;
  overflow-y: auto;
  scroll-behavior: smooth;
}

/* Custom Scrollbar Styling */
body::-webkit-scrollbar {
  width: 12px;
}

body::-webkit-scrollbar-track {
  background: #f1f1f1;
}

body::-webkit-scrollbar-thumb {
  background-color: #c1c1c1;
  border-radius: 10px;
  border: 3px solid #f1f1f1;
}

/* Firefox support for scrollbar */
html {
  scrollbar-width: thin;
  scrollbar-color: #c1c1c1 #f1f1f1;
}

#layout {
  display: flex;
  flex-direction: column;
  max-width: 780px;
  margin: 0 auto;
  padding: 0 16px;
  min-height: 100vh;
}

/* ============================================
   Instructions
============================================ */
#instructions {
  scroll-margin-top: 20px;
  background: #f7f7f8;
  padding: 16px 20px;
  margin-top: 20px;
  margin-bottom: 20px;
  border-radius: 12px;
  border: 1px solid #e5e5e5;
}

#instructions h2 {
  margin: 0 0 8px 0;
  font-size: 17px;
}

#instructions p {
  margin: 0;
  font-size: 15px;
  line-height: 1.4;
}

/* ============================================
   Message Container
============================================ */
#chat-container {
  flex: 1;
  overflow: visible;
  display: block;
}

.message {
  scroll-margin-top: 20px;
}

#messages {
  display: flex;
  flex-direction: column;
  gap: 28px;
  padding-top: 10px;
}

/* ============================================
   Messages
============================================ */

.message.assistant {
  align-self: flex-start;
  background: none;
  padding: 0;
  max-width: 85%;
  font-size: 16px;
  line-height: 1.6;
  color: #000;
}

.message.assistant p {
  margin: 0 0 16px 0;
}

.message.assistant p:last-child {
  margin-bottom: 0;
}

.message.assistant ul, .message.assistant ol {
  padding-left: 20px;
  margin-bottom: 16px;
}

.message.user {
  align-self: flex-end;
  max-width: 80%;
  background: #f4f4f4;
  padding: 10px 14px;
  border-radius: 16px;
  border-bottom-right-radius: 6px;
  font-size: 16px;
  line-height: 1.5;
  white-space: pre-wrap;
  margin: 0;
  scroll-margin-top: 20px;
}

/* ============================================
   Input Bar
============================================ */
#bottom-container {
  position: fixed;
  bottom: 0;
  left: 50%;
  transform: translateX(-50%);
  width: 100%;
  max-width: 780px;
  background: white;
  padding: 10px 16px;
  z-index: 100;
}

#chat-form {
  display: flex;
  align-items: center;
  gap: 10px;
  background: white;
}

#user-input {
  flex: 1;
  padding: 12px 14px;
  border-radius: 12px;
  border: 1px solid #d9d9e3;
  background: white;
  font-size: 16px;
  line-height: 1.4;
  outline: none;
}

#user-input:focus {
  border-color: #999;
  box-shadow: 0 0 0 2px rgba(0,0,0,0.05);
}

#chat-form button {
  width: 42px;
  height: 42px;
  border: none;
  border-radius: 50%;
  background: black;
  color: white;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  padding: 0;
}

#chat-form button:hover {
  opacity: 0.9;
}

/* Use SVG arrow inside the button for a bold, clean look */
#chat-form button svg {
  width: 16px;
  height: 16px;
  fill: white;
}

#bottom-spacer {
    height: 80px;
}
/* ============================================
   Status Text
============================================ */
#status {
  text-align: center;
  font-size: 13px;
  color: #666;
  margin-top: 8px;
  padding-bottom: 1px;
}

/* ============================================
   Responsive adjustments for mobile
============================================ */
@media (max-width: 480px) {
  #layout {
    padding: 0 8px;
  }

  #instructions {
    padding: 12px 14px;
    margin-top: 12px;
    margin-bottom: 12px;
  }

  #messages {
    gap: 16px;
    padding-top: 6px;
  }

  .message.user,
  .message.assistant {
    font-size: 15px;
  }

  #user-input {
    font-size: 16px;
    padding: 10px 12px;
  }

  #chat-form {
    padding: 6px 2px 8px 2px;
    gap: 8px;
  }

  #chat-form button {
    width: 36px;
    height: 36px;
  }

  #bottom-container {
    padding: 8px 6px 20px 6px;
    left: 0; /* Override the 50% */
    transform: none; /* Remove the translateX */
    width: 100%;
    box-sizing: border-box;
  }

  #bottom-spacer {
    height: 85vh !important;
  }

  #status {
    margin-top: 4px;
    font-size: 12px;
  }
}

/* 1. Remove extra space inside the User bubble */
.message.user p {
  margin: 0;
  display: inline; /* Keep text tight to the bubble */
}

/* 2. Fix the Assistant height */
.message.assistant {
  display: block;
  width: auto;      /* Change from 100% to auto so it doesn't force a full-width block */
  max-width: 85%;
}

/* 3. Handle paragraph spacing for Assistant only */
.message.assistant p {
  margin: 0 0 12px 0; /* Add space between paragraphs, but not at the very top */
}

.message.assistant p:last-child {
  margin-bottom: 0;   /* Remove margin from the last paragraph so the bottom is tight */
}

/* ============================================
Completion Overlay
============================================ */
#completion-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.45);
  z-index: 200;
  align-items: center;
  justify-content: center;
}

#completion-overlay.visible {
  display: flex;
}

#completion-box {
  background: #ffffff;
  border-radius: 16px;
  padding: 32px 28px;
  max-width: 400px;
  width: 90%;
  text-align: center;
  box-shadow: 0 8px 32px rgba(0, 0, 0, 0.18);
  font-family: "Inter", Arial, sans-serif;
}

#completion-box p {
  margin: 0 0 12px 0;
  font-size: 16px;
  line-height: 1.5;
  color: #333;
}

#completion-box p:last-child {
  margin-bottom: 0;
  font-size: 14px;
  color: #666;
}