:root {
  --color-primary: #1E3C94;
  --color-container: #1E2D4E;
  --color-title: #5AA3FA;
  --color-subtitle: #B1C1DD;
  --color-label: #FFFFFF;
  --color-danger: #e74c3c;
  --color-success: #068F65;
  --border-radius: 10px;
  --shadow: 0 8px 20px rgba(0,0,0,0.25);
  --transition: all 0.25s ease;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  height: 100%;
  font-family: 'Roboto', system-ui, -apple-system, Segoe UI, Roboto, Arial, sans-serif;
  color: var(--color-label);
  background: linear-gradient(160deg, #11235A 0%, #0E1C47 60%, #0B1638 100%);
}

.hidden { display: none !important; }

/* Auth */
.auth-container {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 24px;
}

.login-box {
  width: 100%;
  max-width: 420px;
  background: #182444;
  border: 1px solid rgba(255,255,255,0.1);
  border-radius: var(--border-radius);
  padding: 28px;
  box-shadow: var(--shadow);
  text-align: center;
}
.login-box h2 {
  margin: 0 0 8px;
  color: var(--color-title);
}
.login-box p {
  margin: 0 0 18px;
  color: var(--color-subtitle);
}
.firebase-status {
  background: rgba(255,255,255,0.06);
  border: 1px solid rgba(255,255,255,0.08);
  border-radius: var(--border-radius);
  padding: 10px 12px;
  font-size: 14px;
  margin-bottom: 12px;
}
.login-btn {
  width: 100%;
  background: var(--color-title);
  color: #0f1b36;
  font-weight: 700;
  border: none;
  border-radius: 8px;
  padding: 12px 16px;
  cursor: pointer;
  transition: var(--transition);
}
.login-btn:disabled { opacity: 0.7; cursor: not-allowed; }
.login-btn:hover:not(:disabled) { filter: brightness(1.05); }
.hint { display: block; margin-top: 10px; color: #cfd6e6; opacity: 0.8; }

/* App */
.main-content { min-height: 100vh; padding: 20px; }
.container { max-width: 1100px; margin: 0 auto; }

.header {
  background: #15203E;
  border: 1px solid rgba(255,255,255,0.08);
  border-radius: var(--border-radius);
  padding: 12px 16px;
  display: flex; justify-content: space-between; align-items: center;
  box-shadow: var(--shadow);
}
.system-title { color: var(--color-title); margin: 0; }

.user-info { display: flex; align-items: center; gap: 12px; }
.user-avatar {
  width: 48px; height: 48px; border-radius: 50%;
  border: 2px solid var(--color-title); object-fit: cover;
}
.user-details { display: flex; flex-direction: column; gap: 6px; align-items: flex-end; }
.user-actions { display: flex; gap: 8px; }

.btn.secondary {
  background: transparent;
  border: 1px solid var(--color-title);
  color: var(--color-title);
  border-radius: 8px;
  padding: 6px 10px;
  cursor: pointer;
}
.logout-btn {
  background: var(--color-danger); color: white;
  border: none; border-radius: 8px; padding: 6px 10px; cursor: pointer;
}

.chat-container {
  margin-top: 18px;
  background: #162246;
  border: 1px solid rgba(255,255,255,0.08);
  border-radius: var(--border-radius);
  padding: 16px;
  height: 70vh;
  display: flex; flex-direction: column;
  box-shadow: var(--shadow);
}
.chat-messages {
  flex: 1; overflow-y: auto; display: flex; flex-direction: column; gap: 10px;
}
.message { max-width: 80%; padding: 10px 14px; border-radius: 16px; line-height: 1.5; }
.user-message { align-self: flex-end; background: #417ad9; color: white; }
.bot-message { align-self: flex-start; background: rgba(255,255,255,0.08); color: #e6edff; }

.input-container {
  display: flex; gap: 10px; margin-top: 12px;
}
#user-input {
  flex: 1; padding: 12px 14px; border-radius: 10px;
  border: 1px solid rgba(255,255,255,0.15);
  background: rgba(255,255,255,0.06); color: white; font-size: 16px;
}
.voice-btn, .send-btn {
  background: var(--color-title); border: none; color: #0f1b36;
  font-weight: 700; padding: 12px 16px; border-radius: 10px; cursor: pointer;
}
.voice-btn.listening { background: #e74c3c; color: white; animation: pulse 1.3s infinite; }
@keyframes pulse { 0%{opacity:1} 50%{opacity:.6} 100%{opacity:1} }

/* Alerts */
.alert-container { position: fixed; top: 20px; right: 20px; display: grid; gap: 10px; z-index: 9999; }
.alert { padding: 12px 14px; border-radius: 10px; border: 1px solid rgba(255,255,255,0.12); }
.alert-success { background: rgba(6,143,101,0.15); border-left: 4px solid var(--color-success); }
.alert-error { background: rgba(231,76,60,0.15); border-left: 4px solid var(--color-danger); }

/* Loading dots */
.loading-dots { display: inline-flex; gap: 4px; margin-left: 4px; }
.loading-dots span { width: 8px; height: 8px; border-radius: 50%; background: #6ba6ff; animation: b .9s infinite alternate; }
.loading-dots span:nth-child(2){ animation-delay:.15s }
.loading-dots span:nth-child(3){ animation-delay:.3s }
@keyframes b { from{ transform: translateY(0)} to{ transform: translateY(-7px)} }

@media (max-width: 768px) {
  .message { max-width: 92%; }
  .user-details { align-items: flex-start; }
  .header { gap: 10px; flex-direction: column; align-items: flex-start; }
}