/* === Layout === */

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

main.container-fluid {
  padding-top: 0;
  padding-bottom: 0;
  height: calc(100vh - 4rem);
  overflow: hidden;
}

.chat-container {
  display: flex;
  flex-direction: column;
  height: 100%;
  position: relative;
  padding: 0;
  overflow: hidden;
}

/* === Messages === */

.messages {
  flex: 1;
  overflow-y: auto;
  padding: 1rem 0;
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
}

.message {
  padding: 0.75rem 1rem;
  border-radius: var(--pico-border-radius);
  max-width: 85%;
}

.message-user {
  background: var(--pico-primary-background);
  align-self: flex-end;
}

.message-assistant {
  background: var(--pico-card-background-color);
  align-self: flex-start;
}

.message-role {
  font-size: 0.75rem;
  font-weight: 600;
  opacity: 0.6;
  margin-bottom: 0.25rem;
}

.message-content {
  line-height: 1.6;
  word-wrap: break-word;
  overflow-wrap: break-word;
}

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

.message-content pre {
  margin: 0.5rem 0;
  overflow-x: auto;
}

.message-content pre code {
  font-size: 0.85rem;
  border-radius: var(--pico-border-radius);
}

.message-content code:not(pre code) {
  padding: 0.125rem 0.375rem;
  font-size: 0.875em;
}

/* === File links in messages === */

.message-files {
  margin-top: 0.5rem;
  display: flex;
  flex-wrap: wrap;
  gap: 0.375rem;
}

.file-link {
  display: inline-block;
  padding: 0.25rem 0.5rem;
  font-size: 0.8rem;
  border: 1px solid var(--pico-muted-border-color);
  border-radius: var(--pico-border-radius);
}

/* === Status bar === */

.status-bar {
  padding: 0.375rem 0.5rem;
  font-size: 0.8rem;
  opacity: 0.7;
  display: flex;
  align-items: center;
  gap: 0.375rem;
  flex-shrink: 0;
}

.connection-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  display: inline-block;
  flex-shrink: 0;
}

.connection-dot.connected {
  background-color: #22c55e;
}

.connection-dot.disconnected {
  background-color: #ef4444;
}

/* === Input area === */

.input-area {
  padding: 0.75rem 0;
  display: flex;
  gap: 0.5rem;
  align-items: flex-end;
  flex-shrink: 0;
  background: var(--pico-background-color);
  border-top: 1px solid var(--pico-muted-border-color);
}

.input-area textarea {
  flex: 1;
  resize: vertical;
  max-height: 200px;
  min-height: 2.5rem;
  margin-bottom: 0;
}

.input-buttons {
  display: flex;
  gap: 0.375rem;
  flex-shrink: 0;
}

.input-buttons button {
  margin-bottom: 0;
  padding: 0.5rem 0.75rem;
  white-space: nowrap;
}

/* === Streaming cursor === */

.streaming-cursor {
  display: inline-block;
  width: 2px;
  height: 1em;
  background: var(--pico-primary);
  margin-left: 2px;
  vertical-align: text-bottom;
  animation: blink 0.8s step-end infinite;
}

@keyframes blink {
  50% { opacity: 0; }
}

/* === Drop zone === */

.drop-zone {
  position: absolute;
  inset: 0;
  z-index: 100;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(0, 0, 0, 0.7);
  border: 3px dashed var(--pico-primary);
  border-radius: var(--pico-border-radius);
  pointer-events: none;
}

.drop-zone p {
  font-size: 1.25rem;
  color: var(--pico-primary);
  margin: 0;
}

/* === Login === */

.login-wrapper {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 80vh;
}

.login-wrapper article {
  width: 100%;
  max-width: 400px;
}

/* === Responsive === */

@media (max-width: 768px) {
  .chat-container {
    height: calc(100vh - 3.5rem);
  }

  .message {
    max-width: 95%;
    padding: 0.5rem 0.75rem;
  }

  .input-area {
    flex-wrap: wrap;
  }

  .input-area textarea {
    width: 100%;
  }

  .input-buttons {
    width: 100%;
    justify-content: flex-end;
  }

  .input-buttons button {
    padding: 0.375rem 0.5rem;
    font-size: 0.875rem;
  }
}
