/* === RoyCo Cloud Advisory — Succession Theme === */

:root {
  --navy: #0a0e1a;
  --charcoal: #141824;
  --dark-surface: #1a1f2e;
  --card-bg: #1e2333;
  --gold: #c9a84c;
  --gold-light: #d4b96a;
  --gold-dim: #8a7234;
  --text-primary: #e8e6e1;
  --text-secondary: #9a978f;
  --text-muted: #5a5850;
  --user-bubble: #252a3a;
  --assistant-border: #c9a84c;
  --error: #c44b4b;
  --font-serif: 'Playfair Display', Georgia, 'Times New Roman', serif;
  --font-sans: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
}

* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

html, body {
  height: 100%;
  background: var(--navy);
  color: var(--text-primary);
  font-family: var(--font-sans);
  -webkit-font-smoothing: antialiased;
}

.page {
  display: none;
  height: 100%;
}
.page.active {
  display: flex;
}

/* === LOGIN PAGE === */

#login-page {
  align-items: center;
  justify-content: center;
  background: linear-gradient(135deg, var(--navy) 0%, #0d1220 50%, #111827 100%);
}

.login-container {
  text-align: center;
  max-width: 420px;
  width: 100%;
  padding: 0 24px;
}

.login-brand {
  margin-bottom: 40px;
}

.logo-mark {
  width: 64px;
  height: 64px;
  border: 2px solid var(--gold);
  color: var(--gold);
  font-family: var(--font-serif);
  font-size: 32px;
  font-weight: 700;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  margin-bottom: 20px;
}

.login-brand h1 {
  font-family: var(--font-serif);
  font-size: 28px;
  font-weight: 600;
  color: var(--text-primary);
  letter-spacing: 0.5px;
}

.tagline {
  color: var(--gold-dim);
  font-size: 14px;
  font-style: italic;
  margin-top: 8px;
  font-family: var(--font-serif);
}

.login-card {
  background: var(--card-bg);
  border: 1px solid rgba(201, 168, 76, 0.15);
  border-radius: 8px;
  padding: 32px;
  margin-bottom: 20px;
}

.login-card h2 {
  font-family: var(--font-serif);
  font-size: 20px;
  color: var(--gold);
  margin-bottom: 24px;
  font-weight: 600;
}

.error-message {
  background: rgba(196, 75, 75, 0.15);
  border: 1px solid var(--error);
  color: var(--error);
  padding: 10px 14px;
  border-radius: 4px;
  font-size: 13px;
  margin-bottom: 16px;
  text-align: left;
}

.input-group {
  margin-bottom: 18px;
  text-align: left;
}

.input-group label {
  display: block;
  font-size: 12px;
  font-weight: 500;
  color: var(--text-secondary);
  margin-bottom: 6px;
  text-transform: uppercase;
  letter-spacing: 1px;
}

.input-group input {
  width: 100%;
  padding: 12px 14px;
  background: var(--dark-surface);
  border: 1px solid rgba(201, 168, 76, 0.2);
  border-radius: 4px;
  color: var(--text-primary);
  font-size: 15px;
  font-family: var(--font-sans);
  transition: border-color 0.2s;
}

.input-group input:focus {
  outline: none;
  border-color: var(--gold);
}

.input-group input::placeholder {
  color: var(--text-muted);
}

.btn-gold {
  width: 100%;
  padding: 13px;
  background: var(--gold);
  color: var(--navy);
  border: none;
  border-radius: 4px;
  font-size: 14px;
  font-weight: 600;
  font-family: var(--font-sans);
  text-transform: uppercase;
  letter-spacing: 1.5px;
  cursor: pointer;
  transition: background 0.2s;
  margin-top: 6px;
}

.btn-gold:hover {
  background: var(--gold-light);
}

.btn-gold:disabled {
  background: var(--gold-dim);
  cursor: not-allowed;
}

.login-footer {
  color: var(--text-muted);
  font-size: 12px;
  font-style: italic;
}

/* === CHAT PAGE === */

#chat-page {
  flex-direction: column;
  background: var(--navy);
}

.chat-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 24px;
  background: var(--charcoal);
  border-bottom: 1px solid rgba(201, 168, 76, 0.15);
  flex-shrink: 0;
}

.header-left {
  display: flex;
  align-items: center;
  gap: 14px;
}

.header-avatar {
  width: 42px;
  height: 42px;
  border-radius: 50%;
  border: 2px solid var(--gold);
  overflow: hidden;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--dark-surface);
}

.header-avatar img {
  width: 100%;
  height: 100%;
}

.header-title h1 {
  font-family: var(--font-serif);
  font-size: 18px;
  font-weight: 600;
  color: var(--text-primary);
}

.header-title p {
  font-size: 12px;
  color: var(--gold-dim);
  font-style: italic;
}

.header-right {
  display: flex;
  gap: 8px;
}

.icon-btn {
  background: none;
  border: 1px solid rgba(201, 168, 76, 0.2);
  color: var(--gold-dim);
  width: 38px;
  height: 38px;
  border-radius: 4px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.2s;
}

.icon-btn:hover {
  border-color: var(--gold);
  color: var(--gold);
}

/* === CHAT MESSAGES === */

.chat-messages {
  flex: 1;
  overflow-y: auto;
  padding: 24px;
  display: flex;
  flex-direction: column;
  gap: 20px;
}

.message {
  display: flex;
  gap: 12px;
  max-width: 85%;
  animation: fadeIn 0.3s ease;
}

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

.message.user {
  align-self: flex-end;
  flex-direction: row-reverse;
}

.message-avatar {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  flex-shrink: 0;
  overflow: hidden;
  display: flex;
  align-items: center;
  justify-content: center;
}

.message.assistant .message-avatar {
  border: 1.5px solid var(--gold-dim);
  background: var(--dark-surface);
}

.message.assistant .message-avatar img {
  width: 100%;
  height: 100%;
}

.message.user .message-avatar {
  background: var(--user-bubble);
  color: var(--text-secondary);
  font-size: 14px;
  font-weight: 500;
  border: 1px solid rgba(255,255,255,0.1);
}

.message-bubble {
  padding: 14px 18px;
  border-radius: 12px;
  font-size: 14px;
  line-height: 1.6;
}

.message.assistant .message-bubble {
  background: var(--dark-surface);
  border-left: 3px solid var(--gold);
  color: var(--text-primary);
}

.message.user .message-bubble {
  background: var(--user-bubble);
  color: var(--text-primary);
  border: 1px solid rgba(255,255,255,0.06);
}

.message-bubble p {
  margin-bottom: 8px;
}

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

.message-bubble code {
  background: rgba(201, 168, 76, 0.1);
  padding: 2px 6px;
  border-radius: 3px;
  font-size: 13px;
  color: var(--gold-light);
}

.message-bubble pre {
  background: #0d1117;
  padding: 14px;
  border-radius: 6px;
  overflow-x: auto;
  margin: 8px 0;
  border: 1px solid rgba(201, 168, 76, 0.1);
}

.message-bubble pre code {
  background: none;
  padding: 0;
  color: var(--text-primary);
  font-size: 13px;
}

.message-bubble ul, .message-bubble ol {
  padding-left: 20px;
  margin: 8px 0;
}

.message-bubble li {
  margin-bottom: 4px;
}

.message-bubble strong {
  color: var(--gold-light);
}

/* Typing indicator */
.typing-indicator {
  display: flex;
  gap: 4px;
  padding: 4px 0;
}

.typing-indicator span {
  width: 7px;
  height: 7px;
  background: var(--gold-dim);
  border-radius: 50%;
  animation: typing 1.4s infinite;
}

.typing-indicator span:nth-child(2) { animation-delay: 0.2s; }
.typing-indicator span:nth-child(3) { animation-delay: 0.4s; }

@keyframes typing {
  0%, 60%, 100% { opacity: 0.3; transform: scale(0.8); }
  30% { opacity: 1; transform: scale(1); }
}

/* === CHAT INPUT === */

.chat-input-container {
  padding: 16px 24px 12px;
  background: var(--charcoal);
  border-top: 1px solid rgba(201, 168, 76, 0.1);
  flex-shrink: 0;
}

#chat-form {
  max-width: 800px;
  margin: 0 auto;
}

.input-wrapper {
  display: flex;
  gap: 10px;
  align-items: flex-end;
  background: var(--dark-surface);
  border: 1px solid rgba(201, 168, 76, 0.2);
  border-radius: 8px;
  padding: 8px 12px;
  transition: border-color 0.2s;
}

.input-wrapper:focus-within {
  border-color: var(--gold);
}

#chat-input {
  flex: 1;
  background: none;
  border: none;
  color: var(--text-primary);
  font-size: 14px;
  font-family: var(--font-sans);
  resize: none;
  max-height: 120px;
  line-height: 1.5;
  padding: 4px 0;
}

#chat-input:focus {
  outline: none;
}

#chat-input::placeholder {
  color: var(--text-muted);
}

.btn-send {
  background: var(--gold);
  color: var(--navy);
  border: none;
  width: 36px;
  height: 36px;
  border-radius: 6px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  transition: background 0.2s;
}

.btn-send:hover {
  background: var(--gold-light);
}

.btn-send:disabled {
  background: var(--gold-dim);
  cursor: not-allowed;
}

.input-disclaimer {
  text-align: center;
  font-size: 11px;
  color: var(--text-muted);
  margin-top: 8px;
}

/* === SCROLLBAR === */

::-webkit-scrollbar {
  width: 6px;
}

::-webkit-scrollbar-track {
  background: transparent;
}

::-webkit-scrollbar-thumb {
  background: rgba(201, 168, 76, 0.2);
  border-radius: 3px;
}

::-webkit-scrollbar-thumb:hover {
  background: rgba(201, 168, 76, 0.4);
}

/* === RESPONSIVE === */

@media (max-width: 640px) {
  .chat-header {
    padding: 10px 16px;
  }

  .header-title h1 {
    font-size: 15px;
  }

  .chat-messages {
    padding: 16px;
  }

  .message {
    max-width: 95%;
  }

  .chat-input-container {
    padding: 12px 16px 8px;
  }
}
