/* ── BebeshGPT — Luna Theme ────────────────────────── */

:root {
  color-scheme: dark;
  --bg: #0c1016;
  --bg-soft: #111723;
  --panel: rgba(21, 29, 43, 0.65);
  --panel-solid: #151d2b;
  --text: #e8edf5;
  --muted: #8a95a8;
  --accent: #79d4ff;
  --accent-hover: #a3e2ff;
  --accent-soft: rgba(121, 212, 255, 0.1);
  --border: rgba(255, 255, 255, 0.08);
  --font: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  --mono: ui-monospace, 'SF Mono', 'Cascadia Code', 'Consolas', monospace;
  --ease: cubic-bezier(0.22, 1, 0.36, 1);
}

*, *::before, *::after { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }

body {
  min-height: 100vh;
  font-family: var(--font);
  font-size: 15px;
  line-height: 1.6;
  color: var(--text);
  background: var(--bg);
  -webkit-font-smoothing: antialiased;
}

/* ── Splash Screen ────────────────────────────────────── */

.splash {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  position: relative;
  overflow: hidden;
}

.splash::before {
  content: '';
  position: absolute;
  inset: 0;
  background:
    radial-gradient(ellipse 80% 60% at 50% 40%, rgba(121, 212, 255, 0.08) 0%, transparent 70%),
    radial-gradient(ellipse 60% 80% at 30% 60%, rgba(100, 140, 255, 0.05) 0%, transparent 60%);
  animation: breathe 8s ease-in-out infinite;
}

@keyframes breathe {
  0%, 100% { opacity: 0.6; transform: scale(1); }
  50% { opacity: 1; transform: scale(1.05); }
}

.splash-content {
  position: relative;
  z-index: 1;
  text-align: center;
}

.wordmark {
  font-size: clamp(4rem, 12vw, 8rem);
  font-weight: 800;
  letter-spacing: 0.15em;
  color: var(--text);
  text-shadow:
    0 0 40px rgba(121, 212, 255, 0.3),
    0 0 80px rgba(121, 212, 255, 0.15),
    0 0 120px rgba(121, 212, 255, 0.05);
  animation: glow 4s ease-in-out infinite alternate;
  margin: 0;
}

@keyframes glow {
  from {
    text-shadow:
      0 0 40px rgba(121, 212, 255, 0.3),
      0 0 80px rgba(121, 212, 255, 0.15);
  }
  to {
    text-shadow:
      0 0 60px rgba(121, 212, 255, 0.5),
      0 0 100px rgba(121, 212, 255, 0.25),
      0 0 140px rgba(121, 212, 255, 0.1);
  }
}

.tagline {
  color: var(--muted);
  font-size: 0.95rem;
  letter-spacing: 0.3em;
  text-transform: uppercase;
  margin: 0.5rem 0 3rem;
}

.splash-actions {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
  align-items: center;
}

.btn {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.75rem 2rem;
  border: 1px solid rgba(121, 212, 255, 0.3);
  border-radius: 8px;
  background: var(--accent-soft);
  color: var(--text);
  font-family: var(--font);
  font-size: 1rem;
  cursor: pointer;
  transition: all 0.2s ease;
  text-decoration: none;
}

.btn:hover {
  background: rgba(121, 212, 255, 0.2);
  border-color: rgba(121, 212, 255, 0.5);
  transform: translateY(-1px);
}

.btn-primary {
  background: rgba(121, 212, 255, 0.15);
  border-color: rgba(121, 212, 255, 0.4);
}

.btn-small {
  padding: 0.4rem 1rem;
  font-size: 0.85rem;
}

.splash-error {
  color: #ff6b6b;
  margin-top: 1rem;
  font-size: 0.9rem;
  min-height: 1.5em;
}

.splash-status {
  color: var(--muted);
  margin-top: 1rem;
  font-size: 0.9rem;
  min-height: 1.5em;
}

/* Registration form */
.register-form {
  display: none;
  flex-direction: column;
  gap: 0.75rem;
  align-items: center;
  margin-top: 1rem;
}

.register-form.visible {
  display: flex;
}

.register-form input {
  padding: 0.6rem 1rem;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: var(--bg-soft);
  color: var(--text);
  font-family: var(--font);
  font-size: 0.95rem;
  width: 240px;
  text-align: center;
  outline: none;
  transition: border-color 0.2s;
}

.register-form input:focus {
  border-color: rgba(121, 212, 255, 0.4);
}

/* ── Chat Layout ──────────────────────────────────────── */

.chat-layout {
  display: flex;
  height: 100vh;
}

/* Sidebar */
.sidebar {
  width: 280px;
  min-width: 280px;
  background: var(--bg-soft);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.sidebar-header {
  padding: 1rem;
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.sidebar-brand {
  font-size: 1.1rem;
  font-weight: 700;
  color: var(--accent);
  letter-spacing: 0.08em;
}

.sidebar-user {
  font-size: 0.8rem;
  color: var(--muted);
}

.new-chat-btn {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  width: calc(100% - 2rem);
  margin: 0.75rem 1rem;
  padding: 0.6rem 0.75rem;
  border: 1px dashed rgba(121, 212, 255, 0.2);
  border-radius: 6px;
  background: transparent;
  color: var(--muted);
  font-family: var(--font);
  font-size: 0.85rem;
  cursor: pointer;
  transition: all 0.2s;
}

.new-chat-btn:hover {
  border-color: rgba(121, 212, 255, 0.4);
  color: var(--text);
  background: var(--accent-soft);
}

.conversation-list {
  flex: 1;
  overflow-y: auto;
  padding: 0.5rem;
}

.conversation-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0.6rem 0.75rem;
  border-radius: 6px;
  cursor: pointer;
  transition: background 0.15s;
  font-size: 0.85rem;
  color: var(--muted);
}

.conversation-item:hover {
  background: rgba(121, 212, 255, 0.05);
  color: var(--text);
}

.conversation-item.active {
  background: var(--accent-soft);
  color: var(--text);
}

.conversation-title {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  flex: 1;
}

.conversation-delete {
  opacity: 0;
  background: none;
  border: none;
  color: var(--muted);
  cursor: pointer;
  padding: 0.2rem;
  font-size: 0.8rem;
  transition: opacity 0.15s, color 0.15s;
}

.conversation-item:hover .conversation-delete {
  opacity: 1;
}

.conversation-delete:hover {
  color: #ff6b6b;
}

.sidebar-footer {
  padding: 0.75rem 1rem;
  border-top: 1px solid var(--border);
}

.logout-btn {
  display: block;
  width: 100%;
  padding: 0.5rem;
  border: none;
  border-radius: 6px;
  background: transparent;
  color: var(--muted);
  font-family: var(--font);
  font-size: 0.85rem;
  cursor: pointer;
  transition: all 0.2s;
}

.logout-btn:hover {
  background: rgba(255, 107, 107, 0.1);
  color: #ff6b6b;
}

/* Main chat area */
.chat-main {
  flex: 1;
  display: flex;
  flex-direction: column;
  min-width: 0;
}

.chat-header {
  padding: 0.75rem 1.5rem;
  border-bottom: 1px solid var(--border);
  font-size: 0.9rem;
  color: var(--muted);
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.messages {
  flex: 1;
  overflow-y: auto;
  padding: 1.5rem;
  display: flex;
  flex-direction: column;
  gap: 1.5rem;
}

.message {
  max-width: 720px;
  width: 100%;
  margin: 0 auto;
}

.message-role {
  font-size: 0.75rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--muted);
  margin-bottom: 0.3rem;
}

.message-role.user { color: var(--accent); }
.message-role.assistant { color: #c4b5fd; }

.message-content {
  font-size: 0.95rem;
  line-height: 1.7;
}

.message-content p { margin: 0 0 0.75rem; }
.message-content p:last-child { margin-bottom: 0; }

.message-content pre {
  background: var(--bg-soft);
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 0.75rem 1rem;
  overflow-x: auto;
  font-family: var(--mono);
  font-size: 0.85rem;
  margin: 0.75rem 0;
}

.message-content code {
  background: var(--bg-soft);
  padding: 0.15rem 0.35rem;
  border-radius: 3px;
  font-family: var(--mono);
  font-size: 0.85em;
}

.message-content pre code {
  background: none;
  padding: 0;
}

.message-content ul, .message-content ol {
  padding-left: 1.5rem;
  margin: 0.5rem 0;
}

.message-content blockquote {
  border-left: 3px solid var(--accent);
  margin: 0.75rem 0;
  padding: 0.25rem 0 0.25rem 1rem;
  color: var(--muted);
}

/* Welcome state */
.welcome {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  color: var(--muted);
  text-align: center;
  padding: 2rem;
}

.welcome-icon {
  font-size: 2.5rem;
  margin-bottom: 1rem;
  opacity: 0.5;
}

.welcome h2 {
  color: var(--text);
  margin: 0 0 0.5rem;
  font-weight: 600;
}

.welcome p {
  margin: 0;
  font-size: 0.9rem;
}

/* Input area */
.input-area {
  padding: 1rem 1.5rem 1.5rem;
  border-top: 1px solid var(--border);
}

.input-wrapper {
  max-width: 720px;
  margin: 0 auto;
  display: flex;
  gap: 0.75rem;
  align-items: flex-end;
}

.input-wrapper textarea {
  flex: 1;
  padding: 0.7rem 1rem;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--bg-soft);
  color: var(--text);
  font-family: var(--font);
  font-size: 0.95rem;
  line-height: 1.5;
  resize: none;
  outline: none;
  min-height: 44px;
  max-height: 200px;
  transition: border-color 0.2s;
}

.input-wrapper textarea:focus {
  border-color: rgba(121, 212, 255, 0.4);
}

.send-btn {
  padding: 0.7rem 1.2rem;
  border: 1px solid rgba(121, 212, 255, 0.3);
  border-radius: 8px;
  background: var(--accent-soft);
  color: var(--accent);
  font-family: var(--font);
  font-size: 0.9rem;
  cursor: pointer;
  transition: all 0.2s;
  white-space: nowrap;
}

.send-btn:hover:not(:disabled) {
  background: rgba(121, 212, 255, 0.2);
  border-color: rgba(121, 212, 255, 0.5);
}

.send-btn:disabled {
  opacity: 0.4;
  cursor: not-allowed;
}

/* Streaming cursor */
.streaming-cursor::after {
  content: '';
  display: inline-block;
  width: 2px;
  height: 1em;
  background: var(--accent);
  margin-left: 2px;
  animation: blink 0.8s step-end infinite;
  vertical-align: text-bottom;
}

@keyframes blink {
  50% { opacity: 0; }
}

/* ── Responsive ───────────────────────────────────────── */

@media (max-width: 768px) {
  .sidebar {
    position: fixed;
    left: -280px;
    top: 0;
    bottom: 0;
    z-index: 100;
    transition: left 0.3s var(--ease);
  }

  .sidebar.open {
    left: 0;
  }

  .sidebar-overlay {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.5);
    z-index: 99;
  }

  .sidebar-overlay.visible {
    display: block;
  }

  .menu-toggle {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 36px;
    height: 36px;
    border: 1px solid var(--border);
    border-radius: 6px;
    background: var(--bg-soft);
    color: var(--muted);
    cursor: pointer;
    font-size: 1.2rem;
  }

  .messages { padding: 1rem; }
  .input-area { padding: 0.75rem 1rem 1rem; }
}

@media (min-width: 769px) {
  .menu-toggle { display: none; }
  .sidebar-overlay { display: none !important; }
}

/* ── Scrollbar ────────────────────────────────────────── */

::-webkit-scrollbar { width: 6px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb {
  background: rgba(255, 255, 255, 0.1);
  border-radius: 3px;
}
::-webkit-scrollbar-thumb:hover {
  background: rgba(255, 255, 255, 0.2);
}
