/* ============================================================
   Web Research Assistant - stylesheet
   Simple black and white chat theme, like a plain chat app:
   white background, black text, thin light borders, nothing fancy.
   ============================================================ */

* {
  box-sizing: border-box;
}

html {
  height: 100%;
}

body {
  margin: 0;
  background-color: #ffffff;
  color: #000000;
  font-family: Arial, Helvetica, sans-serif;
  font-size: 15px;
  line-height: 1.55;
}

.hidden {
  display: none;
}

/* the page: short header, chat in the middle (grows and scrolls),
   one input box at the bottom, small footer */
.page {
  max-width: 860px;
  margin: 0 auto;
  height: 100vh;
  display: flex;
  flex-direction: column;
}

/* ---------- header ---------- */

header {
  border-bottom: 1px solid #dddddd;
  padding: 10px 16px;
  background-color: #ffffff;
}

.header-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
}

h1 {
  margin: 0;
  font-size: 18px;
}

.header-buttons {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
}

.header-buttons button {
  font-size: 13px;
  padding: 6px 10px;
  font-weight: normal;
}

/* ---------- chat area (scrolls) ---------- */

#chat-area {
  flex: 1;
  overflow-y: auto;
  padding: 18px 16px;
}

#messages {
  max-width: 740px;
}

/* ---------- messages ---------- */

.msg {
  margin-bottom: 18px;
  display: flex;
}

.msg.user {
  justify-content: flex-end;
}

.msg .bubble {
  max-width: 86%;
  overflow-wrap: break-word;
  padding: 4px 6px;
}

/* the user's words: light gray bubble on the right */
.msg.user .bubble {
  background-color: #f2f2f2;
  border-radius: 12px;
  padding: 9px 14px;
  max-width: 78%;
}

/* the assistant's answers: plain text on the left */
.msg.assistant .bubble {
  background-color: transparent;
}

.msg .who {
  display: block;
  font-size: 11px;
  font-weight: bold;
  text-transform: uppercase;
  letter-spacing: 1px;
  margin-bottom: 4px;
  color: #555555;
}

.msg.user .who {
  display: none;
}

.msg .bubble p {
  margin: 6px 0;
}

.msg .hint {
  margin: 8px 0 0 0;
}

/* the suggestion buttons under the welcome message */
.chips {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin: 10px 0;
}

button.chip {
  border: 1px solid #000000;
  border-radius: 16px;
  background-color: #ffffff;
  color: #000000;
  font-weight: normal;
  font-size: 13px;
  padding: 6px 12px;
  cursor: pointer;
}

button.chip:hover {
  background-color: #000000;
  color: #ffffff;
}

code {
  font-family: "Courier New", Courier, monospace;
  font-size: 13px;
  background-color: #efefef;
  border: 1px solid #cccccc;
  padding: 0 3px;
}

/* ---------- markdown answers ---------- */

/* the AI answers in Markdown; this makes them look like in a chat app */
.md {
  overflow-wrap: break-word;
}

.md h1, .md h2, .md h3, .md h4, .md h5, .md h6 {
  margin: 14px 0 4px 0;
  line-height: 1.3;
}
.md h1 { font-size: 19px; }
.md h2 { font-size: 17px; }
.md h3 { font-size: 15px; }
.md h4, .md h5, .md h6 { font-size: 14px; }

.md p {
  margin: 6px 0;
}

.md ul, .md ol {
  margin: 6px 0;
  padding-left: 22px;
}

.md li {
  margin: 3px 0;
}

.md blockquote {
  margin: 6px 0;
  padding: 4px 10px;
  border-left: 3px solid #000000;
  background-color: #f7f7f7;
}

.md pre {
  background-color: #f5f5f5;
  border: 1px solid #dddddd;
  border-radius: 6px;
  padding: 10px;
  margin: 8px 0;
  overflow-x: auto;
}

.md pre code {
  background-color: transparent;
  border: none;
  padding: 0;
  font-size: 13px;
}

.md table {
  border-collapse: collapse;
  margin: 8px 0;
  max-width: 100%;
  display: block;
  overflow-x: auto;
}

.md th, .md td {
  border: 1px solid #bbbbbb;
  padding: 5px 9px;
  font-size: 14px;
  text-align: left;
}

.md th {
  background-color: #efefef;
}

.md hr {
  border: none;
  border-top: 1px solid #dddddd;
  margin: 10px 0;
}

/* the blinking line while the answer is being streamed */
.cursor {
  display: inline-block;
  animation: blink 1s steps(2, start) infinite;
  font-weight: bold;
}

@keyframes blink {
  to { visibility: hidden; }
}

/* ---------- history panel ---------- */

.history-panel {
  border: 1px solid #000000;
  border-radius: 8px;
  padding: 12px;
  margin-bottom: 10px;
  background-color: #ffffff;
  max-height: 260px;
  overflow-y: auto;
}

.history-item {
  border: 1px solid #dddddd;
  border-radius: 6px;
  padding: 7px 10px;
  margin-bottom: 6px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 8px;
  cursor: pointer;
}

.history-item:hover {
  background-color: #f2f2f2;
}

.history-item .h-title {
  font-weight: bold;
  font-size: 13px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.history-item .h-meta {
  font-size: 11px;
  color: #666666;
}

.history-item button {
  font-size: 11px;
  font-weight: normal;
  padding: 3px 8px;
  flex-shrink: 0;
}

.history-empty {
  font-size: 13px;
  color: #666666;
  margin: 4px 0;
}

/* ---------- result cards inside chat ---------- */

.card {
  border: 1px solid #dddddd;
  border-radius: 8px;
  padding: 12px 14px;
  margin-top: 6px;
  background-color: #ffffff;
}

.card h3 {
  margin: 0 0 4px 0;
  font-size: 16px;
}

.card .meta {
  font-size: 13px;
  margin: 0 0 8px 0;
}

.card h4 {
  margin: 10px 0 4px 0;
  font-size: 14px;
}

.card p {
  margin: 4px 0;
}

.card ul {
  margin: 4px 0;
  padding-left: 20px;
}

.card ul li {
  margin: 3px 0;
}

.card .source {
  font-size: 12px;
}

.card .warn {
  border: 1px solid #000000;
  padding: 4px 8px;
  margin: 4px 0;
  font-size: 13px;
}

details {
  margin: 8px 0;
}

details summary {
  cursor: pointer;
  font-weight: bold;
  font-size: 13px;
}

.card-actions {
  border-top: 1px solid #dddddd;
  margin-top: 10px;
  padding-top: 8px;
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

.shot-img {
  max-width: 100%;
  border: 1px solid #dddddd;
  margin-top: 6px;
  display: block;
}

/* ---------- the chat box (bottom of the screen) ---------- */

.chat-box {
  border-top: 1px solid #dddddd;
  padding: 10px 16px 12px 16px;
  background-color: #ffffff;
}

/* the small AI settings panel (hidden until the button is pressed) */
.settings {
  border: 1px solid #000000;
  border-radius: 8px;
  padding: 12px;
  margin-bottom: 10px;
  background-color: #ffffff;
}

.settings-title {
  margin: 0 0 8px 0;
  font-weight: bold;
  font-size: 14px;
}

.settings-fields input {
  width: 100%;
  margin-bottom: 8px;
}

.settings-buttons {
  display: flex;
  gap: 8px;
  margin-bottom: 8px;
  flex-wrap: wrap;
}

.small-check {
  font-size: 12px;
  display: flex;
  align-items: center;
  gap: 6px;
  margin-bottom: 6px;
  cursor: pointer;
}

/* black checkboxes, so the page stays strictly black and white */
input[type="checkbox"] {
  accent-color: #000000;
}

/* the model selector row */
.model-row {
  display: flex;
  gap: 8px;
  margin-bottom: 8px;
  flex-wrap: wrap;
  align-items: center;
}

.model-row select {
  max-width: 300px;
  min-width: 180px;
}

#ai-model-manual {
  flex: 1;
  min-width: 160px;
}

.web-check {
  flex-shrink: 0;
  margin-bottom: 0;
}

/* the one input row */
.input-row {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

#chat-input {
  flex: 1;
  min-width: 140px;
}

/* ---------- inputs, buttons ---------- */

input[type="text"],
input[type="password"],
select {
  border: 1px solid #bbbbbb;
  border-radius: 8px;
  background-color: #ffffff;
  color: #000000;
  font-family: Arial, Helvetica, sans-serif;
  font-size: 14px;
  padding: 8px 10px;
}

input[type="text"]:focus,
input[type="password"]:focus,
select:focus {
  outline: 2px solid #000000;
  outline-offset: 0;
  border-color: #000000;
}

button {
  border: 1px solid #000000;
  border-radius: 8px;
  background-color: #ffffff;
  color: #000000;
  font-family: Arial, Helvetica, sans-serif;
  font-size: 14px;
  font-weight: bold;
  padding: 8px 14px;
  cursor: pointer;
}

button:hover {
  background-color: #000000;
  color: #ffffff;
}

button:disabled {
  border-color: #999999;
  color: #999999;
  background-color: #ffffff;
  cursor: default;
}

button:disabled:hover {
  background-color: #ffffff;
  color: #999999;
}

/* the send button stands out: black by default */
#btn-send {
  background-color: #000000;
  color: #ffffff;
}

#btn-send:hover {
  background-color: #ffffff;
  color: #000000;
}

.hint {
  font-size: 12px;
  color: #555555;
  margin: 0;
}

.hint.center {
  text-align: center;
  margin-top: 6px;
}

/* ---------- footer ---------- */

footer {
  border-top: 1px solid #dddddd;
  padding: 8px 16px;
}

footer p {
  margin: 0;
  font-size: 11px;
  color: #666666;
  text-align: center;
}

footer .footer-title {
  margin-top: 2px;
}

/* ---------- small screens ---------- */

@media (max-width: 560px) {
  .msg .bubble {
    max-width: 96%;
  }

  .msg.user .bubble {
    max-width: 90%;
  }

  .model-row select {
    max-width: none;
    flex: 1;
  }

  #btn-send {
    flex: 1;
  }
}
