/* Typography & Design Tokens */
@import url('https://fonts.googleapis.com/css2?family=Plus+Jakarta+Sans:wght@300;400;500;600;700&family=Space+Grotesk:wght@400;500;700&display=swap');

:root {
  --bg-deep: #0b0b0e;
  --bg-surface: #13131a;
  --bg-panel: #1a1a24;
  --border-color: rgba(255, 255, 255, 0.08);
  
  --text-primary: #f3f4f6;
  --text-secondary: #9ca3af;
  --text-muted: #6b7280;
  
  --gemini-gradient: linear-gradient(135deg, #4285f4 0%, #9b51e0 50%, #e91e63 100%);
  --claude-accent: #cc7d44;
  --success: #10b981;
  --error: #ef4444;
}

* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
  font-family: 'Plus Jakarta Sans', sans-serif;
}

body {
  background-color: var(--bg-deep);
  color: var(--text-primary);
  height: 100vh;
  overflow: hidden;
}

.hidden { display: none !important; }

/* Advanced Auth Layout */
.auth-container {
  display: flex;
  align-items: center;
  justify-content: center;
  height: 100vh;
  background: radial-gradient(circle at center, #1b1b29 0%, var(--bg-deep) 70%);
  z-index: 1000;
  position: relative;
}

.auth-card {
  background: rgba(19, 19, 26, 0.75);
  backdrop-filter: blur(20px);
  border: 1px solid var(--border-color);
  padding: 3rem;
  border-radius: 24px;
  width: 480px;
  text-align: center;
  box-shadow: 0 20px 50px rgba(0, 0, 0, 0.5);
}

.auth-logo {
  font-family: 'Space Grotesk', sans-serif;
  font-size: 2.5rem;
  font-weight: 700;
  margin-bottom: 1rem;
}

.gradient-text-gemini {
  background: var(--gemini-gradient);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
}

.text-claude { color: var(--claude-accent); }

.auth-card h2 {
  font-size: 1.5rem;
  font-weight: 600;
  margin-bottom: 0.5rem;
}

.auth-card p {
  color: var(--text-secondary);
  font-size: 0.9rem;
  margin-bottom: 2rem;
}

.pin-input-group {
  display: flex;
  gap: 0.75rem;
  justify-content: center;
  margin-bottom: 1.5rem;
}

.pin-box {
  width: 50px;
  height: 60px;
  background: var(--bg-panel);
  border: 2px solid transparent;
  border-radius: 12px;
  text-align: center;
  font-size: 1.5rem;
  color: white;
  font-weight: 700;
  transition: all 0.25s cubic-bezier(0.4, 0, 0.2, 1);
}

.pin-box:focus {
  outline: none;
  border-color: #9b51e0;
  box-shadow: 0 0 15px rgba(155, 81, 224, 0.3);
  transform: scale(1.05);
}

.auth-status {
  height: 20px;
  font-size: 0.85rem;
  font-weight: 500;
}

/* App View Layout */
.app-container {
  display: flex;
  height: 100vh;
  width: 100vw;
}

/* Sidebar Construction */
.sidebar {
  width: 340px;
  background-color: var(--bg-surface);
  border-right: 1px solid var(--border-color);
  display: flex;
  flex-direction: column;
}

.sidebar-header {
  padding: 1.25rem;
  border-bottom: 1px solid var(--border-color);
}

.app-branding {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  font-family: 'Space Grotesk', sans-serif;
  font-size: 1.25rem;
  font-weight: 700;
  margin-bottom: 1rem;
}

.brand-icon {
  background: var(--gemini-gradient);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
}

.user-profile-badge {
  background: var(--bg-panel);
  padding: 0.65rem 0.85rem;
  border-radius: 14px;
  border: 1px solid rgba(255,255,255,0.04);
}

.profile-label {
  font-size: 0.7rem;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  display: block;
  margin-bottom: 0.25rem;
}

.name-edit-wrapper {
  display: flex;
  gap: 0.5rem;
}

.name-edit-wrapper input {
  background: transparent;
  border: none;
  color: var(--text-primary);
  font-size: 0.9rem;
  font-weight: 600;
  width: 100%;
}

.name-edit-wrapper input:focus {
  outline: none;
  border-bottom: 1px solid var(--claude-accent);
}

#save-username-btn {
  background: transparent;
  border: none;
  color: var(--success);
  cursor: pointer;
  padding: 0 0.25rem;
}

/* AI Sessions Sidebar Explorer */
.ai-sessions-ecosystem {
  padding: 1.25rem;
  border-bottom: 1px solid var(--border-color);
  display: flex;
  flex-direction: column;
  height: 40%;
}

.new-chat-btn {
  background: rgba(255, 255, 255, 0.03);
  border: 1px solid var(--border-color);
  color: var(--text-primary);
  padding: 0.75rem;
  border-radius: 14px;
  font-weight: 600;
  font-size: 0.9rem;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  cursor: pointer;
  transition: all 0.2s;
  width: 100%;
}

.new-chat-btn:hover {
  background: rgba(255, 255, 255, 0.07);
  border-color: var(--text-secondary);
}

.sessions-history-list {
  flex: 1;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
  margin-top: 0.5rem;
  padding-right: 0.25rem;
}

.session-history-item {
  padding: 0.65rem 0.85rem;
  border-radius: 10px;
  font-size: 0.88rem;
  color: var(--text-secondary);
  cursor: pointer;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  display: flex;
  align-items: center;
  gap: 0.65rem;
  transition: all 0.2s;
  border: 1px solid transparent;
}

.session-history-item:hover {
  background: rgba(255, 255, 255, 0.04);
  color: white;
}

.session-history-item.active {
  background: rgba(204, 125, 68, 0.12);
  color: var(--claude-accent);
  border-color: rgba(204, 125, 68, 0.25);
  font-weight: 500;
}

/* Public Chat Interface Container */
.public-chat-container {
  flex: 1;
  display: flex;
  flex-direction: column;
  padding: 1.25rem;
  overflow: hidden;
}

.section-title {
  font-size: 0.75rem;
  font-weight: 700;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  margin-bottom: 0.75rem;
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.chat-messages {
  flex: 1;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
  padding-right: 0.25rem;
  margin-bottom: 0.75rem;
}

.sessions-history-list::-webkit-scrollbar,
.chat-messages::-webkit-scrollbar,
.ai-canvas::-webkit-scrollbar {
  width: 5px;
}
.sessions-history-list::-webkit-scrollbar-thumb,
.chat-messages::-webkit-scrollbar-thumb,
.ai-canvas::-webkit-scrollbar-thumb {
  background: rgba(255,255,255,0.06);
  border-radius: 10px;
}

.public-msg {
  background: var(--bg-panel);
  padding: 0.65rem 0.85rem;
  border-radius: 12px;
  border-bottom-left-radius: 2px;
  animation: slideUp 0.15s ease-out;
}

.msg-header {
  display: flex;
  justify-content: space-between;
  font-size: 0.72rem;
  margin-bottom: 0.15rem;
}

.msg-author { color: var(--claude-accent); font-weight: 600; }
.msg-time { color: var(--text-muted); }
.msg-body { font-size: 0.85rem; line-height: 1.4; word-break: break-word; }

.chat-input-area {
  display: flex;
  background: var(--bg-panel);
  border-radius: 12px;
  padding: 0.4rem;
  border: 1px solid var(--border-color);
}

.chat-input-area input {
  flex: 1;
  background: transparent;
  border: none;
  color: white;
  padding: 0.4rem;
  font-size: 0.85rem;
}
.chat-input-area input:focus { outline: none; }

.chat-input-area button {
  background: transparent;
  border: none;
  color: var(--text-secondary);
  cursor: pointer;
  padding: 0 0.5rem;
}

/* AI Workspace Main Elements */
.main-workspace {
  flex: 1;
  display: flex;
  flex-direction: column;
  background-color: var(--bg-deep);
  position: relative;
}

.workspace-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 1rem 2.5rem;
  border-bottom: 1px solid var(--border-color);
}

.model-badge {
  font-size: 0.85rem;
  font-weight: 500;
  color: var(--text-secondary);
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.pulse-dot {
  width: 8px;
  height: 8px;
  background-color: var(--claude-accent);
  border-radius: 50%;
  box-shadow: 0 0 8px var(--claude-accent);
}

.session-badge {
  font-family: 'Space Grotesk', sans-serif;
  font-size: 0.8rem;
  background: rgba(255,255,255,0.05);
  padding: 0.25rem 0.75rem;
  border-radius: 20px;
  border: 1px solid var(--border-color);
}

.ai-canvas {
  flex: 1;
  overflow-y: auto;
  padding: 2.5rem;
  display: flex;
  flex-direction: column;
  gap: 2rem;
}

.empty-state {
  margin: auto;
  max-width: 650px;
  text-align: center;
}

.empty-state h1 { font-size: 3rem; font-weight: 700; margin-bottom: 0.5rem; }
.empty-state h2 { font-size: 2rem; color: var(--text-muted); font-weight: 500; margin-bottom: 2.5rem; }

.suggested-chips { display: flex; gap: 1rem; justify-content: center; }
.chip {
  background: var(--bg-surface);
  border: 1px solid var(--border-color);
  padding: 0.75rem 1.25rem;
  border-radius: 16px;
  font-size: 0.88rem;
  cursor: pointer;
  transition: all 0.2s;
}
.chip:hover {
  background: var(--bg-panel);
  border-color: rgba(255,255,255,0.2);
  transform: translateY(-2px);
}

.ai-row {
  display: flex;
  width: 100%;
  max-width: 800px;
  margin: 0 auto;
  gap: 1.25rem;
}
.ai-row.user-row { justify-content: flex-end; }

.ai-avatar {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.9rem;
  flex-shrink: 0;
}
.ai-row.user-row .ai-avatar { background: var(--bg-panel); order: 2; }
.ai-row.bot-row .ai-avatar { background: var(--claude-accent); color: white; }

.ai-bubble {
  max-width: calc(100% - 50px);
  padding: 0.5rem 0;
  line-height: 1.6;
  font-size: 1rem;
}
.ai-row.user-row .ai-bubble {
  background: var(--bg-surface);
  padding: 0.85rem 1.25rem;
  border-radius: 18px;
  border-top-right-radius: 4px;
}

/* NEW: Fluid Messenger-Style Three-Dot Wave Typing Animation */
.typing-indicator-wrapper {
  display: flex;
  align-items: center;
  padding: 0.5rem 0;
}

.typing-wave {
  display: flex;
  align-items: center;
  gap: 5px;
  background: var(--bg-surface);
  padding: 12px 18px;
  border-radius: 18px;
  border-top-left-radius: 4px;
  border: 1px solid var(--border-color);
}

.typing-wave dot {
  width: 7px;
  height: 7px;
  background-color: var(--text-secondary);
  border-radius: 50%;
  display: inline-block;
  animation: messengerWave 1.2s infinite ease-in-out both;
}

.typing-wave dot:nth-child(1) { animation-delay: 0s; }
.typing-wave dot:nth-child(2) { animation-delay: 0.2s; }
.typing-wave dot:nth-child(3) { animation-delay: 0.4s; }

@keyframes messengerWave {
  0%, 80%, 100% { transform: translateY(0); }
  40% { transform: translateY(-7px); }
}

.workspace-footer {
  padding: 1.5rem 2.5rem 1rem;
  max-width: 850px;
  width: 100%;
  margin: 0 auto;
}

.ai-input-wrapper {
  background: var(--bg-surface);
  border: 1px solid var(--border-color);
  border-radius: 24px;
  padding: 0.75rem 1.5rem;
  display: flex;
  align-items: center;
  gap: 1rem;
  box-shadow: 0 8px 32px rgba(0,0,0,0.2);
  transition: border-color 0.2s;
}
.ai-input-wrapper:focus-within { border-color: rgba(204, 125, 68, 0.5); }
.ai-input-wrapper textarea {
  flex: 1;
  background: transparent;
  border: none;
  color: var(--text-primary);
  font-size: 1rem;
  resize: none;
  max-height: 200px;
}
.ai-input-wrapper textarea:focus { outline: none; }

.ai-input-wrapper button {
  background: white;
  border: none;
  width: 36px;
  height: 36px;
  border-radius: 50%;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background 0.2s;
}
.ai-input-wrapper button:hover { background: #e5e7eb; }
.ai-input-wrapper button i { color: var(--bg-deep); font-size: 1rem; }

@keyframes slideUp {
  from { transform: translateY(10px); opacity: 0; }
  to { transform: translateY(0); opacity: 1; }
}

@keyframes shake {
  0%, 100% { transform: translateX(0); }
  20%, 60% { transform: translateX(-6px); }
  40%, 80% { transform: translateX(6px); }
}
.shake { animation: shake 0.4s linear; }

.legal-footer {
  text-align: center;
  font-size: 0.75rem;
  color: var(--text-muted);
  margin-top: 1.5rem;
  letter-spacing: 0.03em;
}