/* -------------------------
   Modernized "Thesis Chatbot" UI - IMPROVED
------------------------- */

/* 1. Root Variables */
:root {
  /* Brand Colors */
  --primary: #74001c;      /* Deep maroon */
  --secondary: #e0a80f;    /* Gold */
  --accent: #b5003b;       /* Bright accent maroon */
  
  /* Additional Colors */
  --light-bg: #f8f9fa;     /* Light gray background */
  --dark-text: #212529;    /* Dark text color */
  --dark-grey: #4a4a4a;    /* Dark grey for text box */
  --white: #ffffff;
  
  /* Shadows & Transitions */
  --card-shadow: 0 4px 12px rgba(0, 0, 0, 0.08);
  --bubble-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
  --transition: all 0.3s ease;
}

/* 2. Global Body Style */
body {
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  margin: 0;
  padding: 0;
  line-height: 1.6;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  /* Subtle gradient background */
  background: linear-gradient(120deg, var(--primary) 0%, #9e1b34 100%);
  color: var(--secondary);
}

/* 3. Header */
header {
  text-align: center;
  padding: 20px;
  background: var(--white);
  color: var(--dark-text);
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.08);
}

header h1 {
  margin: 0.5rem 0;
  font-weight: 600;
  font-size: 2.2rem;
  letter-spacing: -0.5px;
  font-family: 'Poppins', sans-serif;
}

.logo {
  max-height: 80px;
  transition: var(--transition);
}

.logo:hover {
  transform: scale(1.03);
}

/* 4. Main Content Wrapper */
main {
  max-width: 800px;
  width: 100%;
  margin: 30px auto;
  padding: 20px;
  flex-grow: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
}

/* 5. Chat History Card */
.chat-history {
  width: 100%;
  max-width: 700px;
  background: var(--white);
  border-radius: 16px;
  box-shadow: var(--card-shadow);
  padding: 25px;
  margin-bottom: 1.5em;
  box-sizing: border-box;
  min-height: 400px;
}

.chat-history h2 {
  text-align: center;
  margin-top: 0;
  margin-bottom: 1.5rem;
  font-weight: 600;
  font-family: 'Poppins', sans-serif;
  font-size: 1.5rem;
  color: var(--dark-text);
  position: relative;
  padding-bottom: 10px;
}

.chat-history h2:after {
  content: '';
  position: absolute;
  bottom: 0;
  left: 50%;
  transform: translateX(-50%);
  width: 70px;
  height: 3px;
  background: linear-gradient(to right, var(--primary), var(--secondary));
  border-radius: 3px;
}

/* 6. No Conversation Text */
.chat-history p {
  color: #777;
  text-align: center;
  font-style: italic;
  font-size: 1.1rem;
  font-family: 'Inter', sans-serif;
}

/* 7. Message Bubbles */
.user-msg,
.bot-msg {
  position: relative;
  max-width: 85%;
  margin: 12px 0;
  padding: 14px 18px;
  border-radius: 16px;
  font-size: 16px;
  line-height: 1.6;
  background: #ececec;
  color: var(--dark-text);
  box-shadow: var(--bubble-shadow);
  animation: fadeIn 0.3s ease-in-out;
  white-space: pre-wrap;
  word-wrap: break-word;
  overflow-wrap: break-word;
  font-family: 'Inter', sans-serif;
}

/* User bubble on the right */
.user-msg {
  margin-left: auto;
  background: var(--secondary);
  color: var(--dark-text);
  display: flex;
  align-items: center;
}

.user-msg:before {
  content: '👤';
  font-size: 18px;
  margin-right: 8px;
}

/* Bot bubble on the left */
.bot-msg {
  margin-right: auto;
  background: var(--light-bg);
  color: var(--dark-text);
  display: flex;
  align-items: center;
}

.bot-msg .bot-text {
  flex: 1;
}

.bot-msg .bot-emoji {
  order: 2;
  margin-left: 8px;
  font-size: 18px;
}

/* 8. Additional styling for <pre> inside bot messages */
.bot-msg pre {
  background: #f1f3f5;
  padding: 12px;
  border-radius: 8px;
  margin: 0.5em 0 0 0;
  max-width: 100%;
  overflow-x: auto;
  font-family: "JetBrains Mono", "Fira Code", monospace;
  font-size: 14px;
}

/* Code styling */
.bot-msg code {
  font-family: "JetBrains Mono", "Fira Code", monospace;
  background: #f1f3f5;
  padding: 2px 5px;
  border-radius: 4px;
  font-size: 14px;
}

/* 9. Chat Form / Textarea */
.large-search-bar {
  display: block;
  width: 100%;
  padding: 15px;
  font-size: 16px;
  border: none;
  border-radius: 12px;
  margin-bottom: 12px;
  box-sizing: border-box;
  background-color: var(--dark-grey);
  color: var(--white);
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.1);
  transition: box-shadow 0.3s ease;
  font-family: 'Inter', sans-serif;
}

.large-search-bar:focus {
  outline: none;
  box-shadow: 0 3px 15px rgba(224, 168, 15, 0.25);
  border: 2px solid var(--secondary);
}

/* 10. Form Button (Ask) */
form button {
  padding: 12px 24px;
  background-color: var(--secondary);
  border: none;
  border-radius: 12px;
  color: var(--dark-text);
  font-weight: 600;
  font-size: 16px;
  cursor: pointer;
  transition: var(--transition);
  font-family: 'Poppins', sans-serif;
}

form button:hover {
  background-color: #c8a000;
  transform: translateY(-2px);
  box-shadow: 0 3px 8px rgba(224, 168, 15, 0.3);
}

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

/* 11. Home Box (Button Only) */
.home-box {
  margin: 0 auto 1em;
  display: flex;
  justify-content: center;
  width: 100%;
  max-width: 700px;
}

.home-box a {
  display: block;
  width: 100%;
  padding: 12px 0;
  background-color: #600000; /* Dark red */
  color: var(--white);
  text-align: center;
  text-decoration: none;
  font-weight: 600;
  border-radius: 12px;
  transition: var(--transition);
  box-shadow: 0 3px 6px rgba(0,0,0,0.1);
  font-family: 'Poppins', sans-serif;
  font-size: 16px;
}

.home-box a:hover {
  background-color: #a31c23;
  transform: translateY(-2px);
  box-shadow: 0 5px 15px rgba(0,0,0,0.15);
}

/* 12. Footer */
footer {
  text-align: center;
  padding: 20px;
  margin-top: auto;
  color: var(--white);
  font-family: 'Inter', sans-serif;
}

/* 13. Media Queries for Mobile */
@media (max-width: 600px) {
  .chat-history,
  .home-box {
    padding: 16px;
  }
  
  .user-msg,
  .bot-msg {
    max-width: 100%;
  }
}

/* Layout + defaults */
body { font-family: 'Open Sans', sans-serif; color: #111; }
main { display: flex; flex-direction: column; align-items: center; gap: 16px; }
.ask { margin-top: 8px; }

/* Bubbles */
.bubble { max-width: 900px; width: 90%; padding: 14px 16px; border-radius: 16px;
          box-shadow: 0 6px 18px rgba(0,0,0,.08); line-height: 1.55;
          overflow-wrap: anywhere; }
.bubble.user { background: #fef3c7; color: #1f2937; border: 1px solid #fde68a; }
.bubble.bot  { background: #1f2937; color: #f9fafb; border: 1px solid #111827; }

/* Preserve line breaks but keep normal font */
.bubble pre {
  white-space: pre-wrap;      /* wrap long lines */
  font-family: inherit;       /* not monospace */
  margin: 8px 0 0;
}

/* Inputs */
textarea { width: 320px; min-height: 56px; resize: vertical; padding: 8px; }

/* Error box (make sure this style doesn't bleed into answers) */
.error { background: #fee2e2; color: #991b1b; border: 1px solid #fecaca;
         padding: 10px 12px; border-radius: 12px; max-width: 900px; width: 90%; }

