/* === RESET & BASE === */
*, *::before, *::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

:root {
  --bg-primary: #0D0D0D;
  --bg-secondary: #1A1A1A;
  --bg-card: #141414;
  --pink: #D4549A;
  --pink-light: #E8A0B4;
  --mauve: #C97A8A;
  --text-primary: #FFFFFF;
  --text-secondary: #CCCCCC;
  --text-muted: #888888;
  --border: #2A2A2A;
  --message-user-bg: #252525;
  --message-julia-border: #D4549A;
  --font-serif: 'Playfair Display', Georgia, serif;
  --font-sans: 'Inter', -apple-system, sans-serif;
  --radius: 16px;
  --radius-sm: 8px;
  --sidebar-width: 280px;
}

html, body {
  height: 100%;
  background: var(--bg-primary);
  color: var(--text-primary);
  font-family: var(--font-sans);
  font-size: 16.5px;
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
}

.hidden { display: none !important; }

/* === AUTH SCREEN === */
.auth-overlay {
  position: fixed;
  inset: 0;
  background: var(--bg-primary);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
  z-index: 100;
}

.auth-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 24px;
  padding: 48px 40px;
  max-width: 420px;
  width: 100%;
  text-align: center;
}

.auth-logo { margin-bottom: 24px; }

.auth-name {
  display: block;
  font-family: var(--font-serif);
  font-style: italic;
  font-size: 2rem;
  color: var(--text-primary);
  line-height: 1.2;
}

.auth-tagline {
  display: block;
  font-size: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 0.15em;
  color: var(--pink);
  margin-top: 4px;
  font-weight: 500;
}

.auth-description {
  color: var(--text-secondary);
  font-size: 0.9rem;
  margin-bottom: 32px;
  line-height: 1.7;
}

.input-group {
  margin-bottom: 12px;
}

.input-group input {
  width: 100%;
  background: var(--bg-secondary);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text-primary);
  font-family: var(--font-sans);
  font-size: 0.95rem;
  padding: 14px 18px;
  outline: none;
  transition: border-color 0.2s;
}

.input-group input:focus {
  border-color: var(--pink);
}

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

.btn-primary {
  width: 100%;
  background: var(--pink);
  color: white;
  border: none;
  border-radius: var(--radius-sm);
  font-family: var(--font-sans);
  font-size: 0.85rem;
  font-weight: 500;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  padding: 14px;
  cursor: pointer;
  transition: background 0.2s, transform 0.1s;
  margin-top: 4px;
}

.btn-primary:hover { background: #c0457f; }
.btn-primary:active { transform: scale(0.98); }

.error-text {
  color: var(--pink-light);
  font-size: 0.82rem;
  margin-top: 12px;
}

.success-text {
  color: #4CAF50;
  font-size: 0.82rem;
  margin-top: 12px;
}

.auth-links {
  margin-top: 20px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.btn-link {
  background: none;
  border: none;
  color: var(--text-muted);
  font-size: 0.82rem;
  cursor: pointer;
  font-family: var(--font-sans);
  transition: color 0.2s;
}

.btn-link:hover { color: var(--pink-light); }

/* === CHAT APP LAYOUT === */
#chat-app {
  display: flex;
  height: 100vh;
}

/* === SIDEBAR === */
.sidebar {
  width: var(--sidebar-width);
  background: var(--bg-card);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  flex-shrink: 0;
}

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

.sidebar-title {
  font-weight: 600;
  font-size: 0.95rem;
}

.btn-new-chat {
  background: var(--pink);
  border: none;
  border-radius: var(--radius-sm);
  color: white;
  cursor: pointer;
  padding: 6px;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background 0.2s;
}

.btn-new-chat:hover { background: #c0457f; }

.chat-list {
  flex: 1;
  overflow-y: auto;
  padding: 8px;
}

.chat-list-empty {
  color: var(--text-muted);
  font-size: 0.82rem;
  text-align: center;
  padding: 24px 16px;
}

.chat-list-item {
  padding: 12px 14px;
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: background 0.15s;
  margin-bottom: 2px;
}

.chat-list-item:hover { background: var(--bg-secondary); }
.chat-list-item.active { background: var(--bg-secondary); border-left: 3px solid var(--pink); }

.chat-list-title {
  font-size: 0.85rem;
  color: var(--text-primary);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.chat-list-date {
  font-size: 0.72rem;
  color: var(--text-muted);
  margin-top: 2px;
}

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

.btn-logout-sidebar {
  width: 100%;
  background: none;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text-muted);
  font-family: var(--font-sans);
  font-size: 0.82rem;
  padding: 10px;
  cursor: pointer;
  transition: color 0.2s, border-color 0.2s;
}

.btn-logout-sidebar:hover {
  color: var(--text-primary);
  border-color: var(--text-muted);
}

/* === CHAT AREA === */
.chat-area {
  flex: 1;
  display: flex;
  flex-direction: column;
  min-width: 0;
}

/* Header */
.chat-header {
  background: var(--bg-card);
  border-bottom: 1px solid var(--border);
  padding: 0 20px;
  flex-shrink: 0;
}

.header-inner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  height: 64px;
}

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

.btn-sidebar-toggle {
  display: none;
  background: none;
  border: none;
  color: var(--text-muted);
  cursor: pointer;
  padding: 4px;
}

.header-identity {
  display: flex;
  align-items: center;
  gap: 12px;
}

.avatar {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--pink), var(--mauve));
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.75rem;
  font-weight: 600;
  color: white;
  flex-shrink: 0;
}

.header-name {
  font-family: var(--font-serif);
  font-style: italic;
  font-size: 1.1rem;
  color: var(--text-primary);
}

.header-status {
  display: flex;
  align-items: center;
  gap: 5px;
  font-size: 0.75rem;
  color: var(--text-muted);
}

.status-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: #4CAF50;
  display: inline-block;
}

/* Messages */
.chat-main {
  flex: 1;
  overflow-y: auto;
  padding: 24px 20px;
  scroll-behavior: smooth;
}

.chat-main.drag-over {
  outline: 2px dashed var(--pink);
  outline-offset: -8px;
}

.messages-container {
  display: flex;
  flex-direction: column;
  gap: 16px;
  max-width: 720px;
  margin: 0 auto;
}

.message {
  display: flex;
  flex-direction: column;
  max-width: 82%;
}

.message.user {
  align-self: flex-end;
  align-items: flex-end;
}

.message.julia {
  align-self: flex-start;
  align-items: flex-start;
}

.message-bubble {
  padding: 14px 18px;
  border-radius: var(--radius);
  line-height: 1.65;
  font-size: 0.98rem;
}

.message-bubble a {
  color: var(--pink);
  text-decoration: underline;
}

.message.user .message-bubble {
  background: var(--message-user-bg);
  border: 1px solid var(--border);
  border-bottom-right-radius: 4px;
  color: var(--text-primary);
}

.message.julia .message-bubble {
  background: var(--bg-card);
  border: 1px solid var(--message-julia-border);
  border-bottom-left-radius: 4px;
  color: var(--text-primary);
}

.message-bubble p + p { margin-top: 10px; }

/* Images in messages */
.message-image {
  margin-bottom: 10px;
}

.message-image img {
  max-width: 100%;
  max-height: 300px;
  border-radius: var(--radius-sm);
  object-fit: contain;
}

.message-file a {
  color: var(--pink);
  text-decoration: underline;
  font-size: 0.85rem;
}

/* Typing indicator */
.typing-indicator .message-bubble { padding: 14px 20px; }

.typing-dots {
  display: flex;
  gap: 5px;
  align-items: center;
}

.typing-dots span {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--pink);
  animation: bounce 1.2s infinite ease-in-out;
}

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

@keyframes bounce {
  0%, 80%, 100% { transform: translateY(0); opacity: 0.4; }
  40% { transform: translateY(-6px); opacity: 1; }
}

/* Footer */
.chat-footer {
  background: var(--bg-card);
  border-top: 1px solid var(--border);
  padding: 12px 20px 16px;
  flex-shrink: 0;
}

/* File Preview */
.file-preview {
  display: flex;
  gap: 8px;
  padding: 8px 0;
  overflow-x: auto;
}

.file-preview-item {
  position: relative;
  flex-shrink: 0;
}

.file-preview-item img {
  width: 60px;
  height: 60px;
  object-fit: cover;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
}

.file-preview-name {
  display: inline-block;
  background: var(--bg-secondary);
  padding: 6px 12px;
  border-radius: var(--radius-sm);
  font-size: 0.75rem;
  color: var(--text-secondary);
  max-width: 120px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.file-preview-remove {
  position: absolute;
  top: -6px;
  right: -6px;
  width: 20px;
  height: 20px;
  border-radius: 50%;
  background: var(--pink);
  color: white;
  border: none;
  font-size: 14px;
  line-height: 1;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
}

.input-bar {
  display: flex;
  align-items: flex-end;
  gap: 8px;
  background: var(--bg-secondary);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 10px 12px;
  transition: border-color 0.2s;
}

.input-bar:focus-within { border-color: var(--pink); }

#question-input {
  flex: 1;
  background: none;
  border: none;
  color: var(--text-primary);
  font-family: var(--font-sans);
  font-size: 0.98rem;
  line-height: 1.5;
  resize: none;
  outline: none;
  max-height: 120px;
  min-height: 24px;
  align-self: center;
}

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

.btn-mic, .btn-send, .btn-upload {
  background: none;
  border: none;
  color: var(--text-muted);
  cursor: pointer;
  padding: 6px;
  border-radius: var(--radius-sm);
  display: flex;
  align-items: center;
  justify-content: center;
  transition: color 0.2s;
  flex-shrink: 0;
}

.btn-mic:hover, .btn-upload:hover { color: var(--pink-light); }
.btn-send:hover { color: var(--pink); }

.btn-mic.recording {
  color: var(--pink);
  animation: pulse 1.5s infinite;
}

@keyframes pulse {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.5; }
}

.footer-note {
  font-size: 0.72rem;
  color: var(--text-muted);
  text-align: center;
  margin-top: 10px;
}

/* === RESPONSIVE === */
@media (max-width: 768px) {
  .sidebar {
    position: fixed;
    left: 0;
    top: 0;
    bottom: 0;
    z-index: 200;
    transform: translateX(-100%);
    transition: transform 0.25s ease;
    box-shadow: none;
  }

  .sidebar.open {
    transform: translateX(0);
    box-shadow: 4px 0 20px rgba(0, 0, 0, 0.4);
  }

  .btn-sidebar-toggle { display: flex; }

  .chat-area { width: 100%; }

  .auth-card { padding: 36px 24px; }
  .auth-name { font-size: 1.6rem; }
  .chat-main { padding: 16px 14px; }
  .message { max-width: 92%; }
  .chat-footer { padding: 10px 14px 14px; }
}

/* Scrollbar */
.chat-main::-webkit-scrollbar,
.chat-list::-webkit-scrollbar { width: 4px; }
.chat-main::-webkit-scrollbar-track,
.chat-list::-webkit-scrollbar-track { background: transparent; }
.chat-main::-webkit-scrollbar-thumb,
.chat-list::-webkit-scrollbar-thumb { background: var(--border); border-radius: 2px; }
