/* ── Reset & Base ─────────────────────────────────── */
*, *::before, *::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

html, body {
  height: 100%;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  background: #f5f5f5;
  color: #1a1a1a;
}

/* ── Screen-reader-only utility ──────────────────── */
.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  border: 0;
}

/* ── Login form ──────────────────────────────────── */
.login-container {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 100vh;
  padding: 20px;
}

.login-container[hidden] {
  display: none;
}

.login-card {
  width: 100%;
  max-width: 380px;
  background: #fff;
  border-radius: 12px;
  box-shadow: 0 4px 24px rgba(0, 0, 0, 0.1);
  padding: 40px 32px;
  text-align: center;
}

.login-card h1 {
  font-size: 1.5rem;
  color: #232f3e;
  margin-bottom: 24px;
}

.login-field {
  text-align: left;
  margin-bottom: 16px;
}

.login-field label {
  display: block;
  font-size: 0.85rem;
  font-weight: 600;
  color: #333;
  margin-bottom: 4px;
}

.login-field input {
  width: 100%;
  padding: 10px 12px;
  font-size: 0.95rem;
  border: 1px solid #ccc;
  border-radius: 6px;
  outline: none;
  transition: border-color 0.15s;
}

.login-field input:focus {
  border-color: #0073bb;
}

.login-error {
  background: #fff0f0;
  color: #d13212;
  border: 1px solid #fcc;
  border-radius: 6px;
  padding: 8px 12px;
  font-size: 0.85rem;
  margin-bottom: 16px;
  text-align: left;
}

.login-error[hidden] {
  display: none;
}

.login-button {
  width: 100%;
  padding: 12px;
  font-size: 1rem;
  font-weight: 600;
  color: #fff;
  background: #0073bb;
  border: none;
  border-radius: 8px;
  cursor: pointer;
  transition: background 0.15s;
}

.login-button:hover {
  background: #005a8e;
}

.login-button:disabled {
  background: #aaa;
  cursor: not-allowed;
}

/* ── App layout ──────────────────────────────────── */
.app-container {
  display: flex;
  flex-direction: column;
  height: 100vh;
  max-width: 800px;
  margin: 0 auto;
  background: #fff;
  box-shadow: 0 0 12px rgba(0, 0, 0, 0.08);
}

.app-container[hidden] {
  display: none;
}

/* ── Header ──────────────────────────────────────── */
.app-header {
  padding: 16px 20px;
  background: #232f3e;
  color: #fff;
  text-align: center;
  flex-shrink: 0;
}

.app-header h1 {
  font-size: 1.25rem;
  font-weight: 600;
}

/* ── Conversation area ───────────────────────────── */
.conversation-area {
  flex: 1;
  overflow-y: auto;
  padding: 20px;
  display: flex;
  flex-direction: column;
  gap: 12px;
}

/* ── Message bubbles ─────────────────────────────── */
.message {
  max-width: 75%;
  padding: 10px 14px;
  border-radius: 12px;
  line-height: 1.5;
  font-size: 0.95rem;
  word-wrap: break-word;
}

.message--user {
  align-self: flex-end;
  background: #0073bb;
  color: #fff;
  border-bottom-right-radius: 4px;
}

.message--assistant {
  align-self: flex-start;
  background: #e8e8e8;
  color: #1a1a1a;
  border-bottom-left-radius: 4px;
}

/* ── Error messages ──────────────────────────────── */
.message--error {
  align-self: center;
  background: #fff0f0;
  color: #d13212;
  border: 1px solid #fcc;
  border-radius: 8px;
  font-size: 0.9rem;
  text-align: center;
}

/* ── Validation message ──────────────────────────── */
.validation-message {
  color: #d13212;
  font-size: 0.8rem;
  padding: 4px 20px 0;
  flex-shrink: 0;
}

/* ── Loading indicator ───────────────────────────── */
.loading-indicator {
  display: flex;
  gap: 6px;
  padding: 8px 20px;
  align-self: flex-start;
  flex-shrink: 0;
}

.loading-indicator[hidden] {
  display: none;
}

.dot {
  width: 8px;
  height: 8px;
  background: #888;
  border-radius: 50%;
  animation: bounce 1.2s infinite ease-in-out;
}

.dot:nth-child(2) {
  animation-delay: 0.2s;
}

.dot:nth-child(3) {
  animation-delay: 0.4s;
}

@keyframes bounce {
  0%, 80%, 100% { transform: translateY(0); }
  40% { transform: translateY(-8px); }
}

/* ── Input form ──────────────────────────────────── */
.input-form {
  display: flex;
  gap: 8px;
  padding: 12px 20px;
  border-top: 1px solid #e0e0e0;
  background: #fafafa;
  flex-shrink: 0;
}

.prompt-input {
  flex: 1;
  padding: 10px 14px;
  font-size: 0.95rem;
  border: 1px solid #ccc;
  border-radius: 8px;
  outline: none;
  transition: border-color 0.15s;
}

.prompt-input:focus {
  border-color: #0073bb;
}

.send-button {
  padding: 10px 20px;
  font-size: 0.95rem;
  font-weight: 600;
  color: #fff;
  background: #0073bb;
  border: none;
  border-radius: 8px;
  cursor: pointer;
  transition: background 0.15s;
}

.send-button:hover {
  background: #005a8e;
}

.send-button:disabled {
  background: #aaa;
  cursor: not-allowed;
}

/* ── Responsive tweaks ───────────────────────────── */
@media (max-width: 600px) {
  .message {
    max-width: 90%;
  }

  .app-header h1 {
    font-size: 1.1rem;
  }
}

/* ── Model selector (Assignment 2) ───────────────── */
.app-header {
  display: flex;
  flex-direction: column;
  gap: 8px;
  align-items: center;
}

.model-selector-wrap {
  width: 100%;
  max-width: 400px;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
}

.model-selector-label {
  font-size: 0.85rem;
  font-weight: 600;
  color: #fff;
  white-space: nowrap;
}

.model-selector {
  width: 100%;
  padding: 6px 10px;
  font-size: 0.85rem;
  border-radius: 6px;
  border: 1px solid rgba(255, 255, 255, 0.3);
  background: rgba(255, 255, 255, 0.1);
  color: #fff;
  cursor: pointer;
  outline: none;
}

.model-selector option {
  background: #fff;
  color: #1a1a1a;
}

.model-selector:focus {
  border-color: #ff9900;
}

/* ── Metrics panel (Assignment 2) ────────────────── */
.metrics-panel {
  align-self: flex-start;
  max-width: 85%;
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  padding: 6px 10px;
  margin-top: -6px;
  background: #f7f7f9;
  border: 1px solid #e0e0e0;
  border-radius: 6px;
  font-size: 0.75rem;
  color: #555;
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
}

.metrics-panel .metric {
  display: inline-flex;
  gap: 4px;
  align-items: center;
  white-space: nowrap;
}

.metrics-panel .metric-label {
  color: #888;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.03em;
  font-size: 0.7rem;
}
