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

body {
  font-family: 'Amazon Ember', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  background: #f9f9f9;
  color: #333;
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
}

.hidden { display: none !important; }

/* ---------- Login Section ---------- */
#login-section {
  background: #ffffff;
  border-radius: 16px;
  box-shadow: 0 4px 24px rgba(0,0,0,0.08), 0 0 0 1px rgba(245,166,35,0.15);
  padding: 2.5rem 2rem;
  width: 100%;
  max-width: 420px;
}

.login-logo {
  text-align: center;
  margin-bottom: 1.5rem;
}

.login-logo svg {
  width: 48px;
  height: 48px;
  fill: #f5a623;
}

.login-logo-text {
  font-size: 0.875rem;
  color: #888;
  margin-top: 0.5rem;
  letter-spacing: 0.5px;
}

#login-section h1 {
  font-size: 1.5rem;
  margin-bottom: 0.5rem;
  text-align: center;
  color: #222;
  font-weight: 700;
}

.login-subtitle {
  text-align: center;
  color: #888;
  font-size: 0.875rem;
  margin-bottom: 1.75rem;
}

#login-section label {
  display: block;
  font-size: 0.8125rem;
  font-weight: 600;
  margin-bottom: 0.375rem;
  color: #555;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

#login-section input {
  width: 100%;
  padding: 0.75rem 1rem;
  border: 1px solid #ddd;
  border-radius: 8px;
  font-size: 1rem;
  margin-bottom: 1.25rem;
  background: #fafafa;
  color: #222;
  transition: border-color 0.2s, box-shadow 0.2s;
}

#login-section input::placeholder { color: #aaa; }

#login-section input:focus {
  outline: none;
  border-color: #f5a623;
  box-shadow: 0 0 0 3px rgba(245,166,35,0.2);
}

#login-btn {
  width: 100%;
  padding: 0.875rem;
  background: linear-gradient(180deg, #f5a623 0%, #e89b1c 100%);
  color: #fff;
  border: none;
  border-radius: 8px;
  font-size: 1rem;
  font-weight: 700;
  cursor: pointer;
  transition: background 0.2s, transform 0.1s;
  letter-spacing: 0.3px;
}

#login-btn:hover { background: linear-gradient(180deg, #f7b84d 0%, #f5a623 100%); }
#login-btn:active { transform: scale(0.98); }
#login-btn:disabled { background: #ddd; color: #999; cursor: not-allowed; transform: none; }

#login-error {
  color: #e74c3c;
  font-size: 0.875rem;
  margin-top: 0.75rem;
  text-align: center;
  min-height: 1.25rem;
}

/* ---------- Chat Section ---------- */
#chat-section {
  display: none;
  flex-direction: column;
  width: 100%;
  max-width: 900px;
  height: 92vh;
  background: #ffffff;
  border-radius: 16px;
  box-shadow: 0 4px 24px rgba(0,0,0,0.08), 0 0 0 1px rgba(245,166,35,0.1);
  overflow: hidden;
}

/* Header */
.chat-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0.875rem 1.5rem;
  border-bottom: 2px solid #f5a623;
  background: #fff;
  flex-shrink: 0;
}

.chat-header h2 {
  font-size: 1.125rem;
  font-weight: 700;
  color: #222;
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.chat-header h2 .aws-icon {
  color: #f5a623;
  font-size: 1.25rem;
}

.chat-header-controls {
  display: flex;
  align-items: center;
  gap: 0.75rem;
}

#model-selector {
  padding: 0.5rem 0.75rem;
  border: 1px solid #ddd;
  border-radius: 8px;
  font-size: 0.8125rem;
  background: #fafafa;
  color: #333;
  cursor: pointer;
  transition: border-color 0.2s;
}

#model-selector:focus {
  outline: none;
  border-color: #f5a623;
  box-shadow: 0 0 0 3px rgba(245,166,35,0.2);
}

#sign-out-btn {
  padding: 0.5rem 1rem;
  background: transparent;
  color: #888;
  border: 1px solid #ddd;
  border-radius: 8px;
  font-size: 0.8125rem;
  cursor: pointer;
  transition: all 0.2s;
}

#sign-out-btn:hover {
  background: #fef2f2;
  color: #e74c3c;
  border-color: #e74c3c;
}

/* Messages Area */
#messages {
  flex: 1;
  overflow-y: auto;
  padding: 1.5rem;
  display: flex;
  flex-direction: column;
  gap: 1rem;
  background: #f9f9f9;
}

#messages::-webkit-scrollbar { width: 6px; }
#messages::-webkit-scrollbar-track { background: transparent; }
#messages::-webkit-scrollbar-thumb { background: #ddd; border-radius: 3px; }
#messages::-webkit-scrollbar-thumb:hover { background: #bbb; }

.message {
  max-width: 78%;
  padding: 0.875rem 1.125rem;
  border-radius: 16px;
  font-size: 0.9375rem;
  line-height: 1.6;
  word-wrap: break-word;
  white-space: pre-wrap;
}

.message.user {
  align-self: flex-end;
  background: linear-gradient(135deg, #f5a623 0%, #e89b1c 100%);
  color: #fff;
  border-bottom-right-radius: 4px;
  font-weight: 500;
}

.message.assistant {
  align-self: flex-start;
  background: #ffffff;
  color: #333;
  border: 1px solid #eee;
  border-bottom-left-radius: 4px;
  box-shadow: 0 1px 4px rgba(0,0,0,0.04);
}

.message.thinking {
  align-self: flex-start;
  background: #ffffff;
  color: #aaa;
  font-style: italic;
  border: 1px solid #eee;
  border-bottom-left-radius: 4px;
}

.message.error {
  align-self: center;
  background: #fef2f2;
  color: #e74c3c;
  border: 1px solid #fecaca;
  font-size: 0.875rem;
  max-width: 90%;
  display: flex;
  align-items: center;
  gap: 0.75rem;
  flex-wrap: wrap;
  border-radius: 12px;
}

.retry-btn {
  padding: 0.375rem 0.875rem;
  background: #fef2f2;
  color: #e74c3c;
  border: 1px solid #fecaca;
  border-radius: 6px;
  font-size: 0.8125rem;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s;
  white-space: nowrap;
}

.retry-btn:hover { background: #fee2e2; }
.retry-btn:focus-visible { outline: 2px solid #e74c3c; outline-offset: 2px; }

/* Input Area */
.chat-input-area {
  display: flex;
  gap: 0.625rem;
  padding: 1rem 1.5rem;
  border-top: 1px solid #eee;
  background: #fff;
  flex-shrink: 0;
}

#chat-input {
  flex: 1;
  padding: 0.75rem 1rem;
  border: 1px solid #ddd;
  border-radius: 10px;
  font-size: 1rem;
  font-family: inherit;
  resize: none;
  background: #fafafa;
  color: #222;
  transition: border-color 0.2s, box-shadow 0.2s;
}

#chat-input::placeholder { color: #aaa; }

#chat-input:focus {
  outline: none;
  border-color: #f5a623;
  box-shadow: 0 0 0 3px rgba(245,166,35,0.2);
}

#send-btn {
  padding: 0.75rem 1.5rem;
  background: linear-gradient(180deg, #f5a623 0%, #e89b1c 100%);
  color: #fff;
  border: none;
  border-radius: 10px;
  font-size: 1rem;
  font-weight: 700;
  cursor: pointer;
  transition: background 0.2s, transform 0.1s;
  white-space: nowrap;
}

#send-btn:hover { background: linear-gradient(180deg, #f7b84d 0%, #f5a623 100%); }
#send-btn:active { transform: scale(0.97); }
#send-btn:disabled { background: #ddd; color: #999; cursor: not-allowed; transform: none; }
