/* === Viktor LLM - Clean Minimal Design === */

:root {
  --bg: #0a0a0a;
  --bg-card: #1a1a1a;
  --bg-elevated: #242424;
  --bg-input: #1e1e1e;
  --fg: #fafafa;
  --fg-dim: #a1a1aa;
  --fg-muted: #71717a;
  --border: #2a2a2a;
  --accent: #a855f7;
  --accent-hover: #9333ea;
  --accent-glow: rgba(168, 85, 247, 0.2);
  --success: #22c55e;
  --error: #ef4444;
  --font: -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  --font-mono: 'SF Mono', 'Fira Code', Consolas, monospace;
}

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

html, body {
  height: 100%;
  overflow: hidden;
}

body {
  font-family: var(--font);
  background: var(--bg);
  color: var(--fg);
}

/* === Loading State === */
#loading {
  position: fixed;
  inset: 0;
  background: var(--bg);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 9999;
}

.spinner {
  width: 40px;
  height: 40px;
  border: 3px solid var(--border);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}

@keyframes spin {
  to { transform: rotate(360deg); }
}

/* === Auth Gate - Landing Page === */
#auth-gate {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--bg);
  padding: 2rem;
}

.login-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 1rem;
  padding: 3rem;
  text-align: center;
  max-width: 400px;
  width: 100%;
}

.login-logo {
  font-size: 3rem;
  margin-bottom: 1rem;
}

.login-title {
  font-size: 1.75rem;
  font-weight: 700;
  margin-bottom: 0.5rem;
  background: linear-gradient(135deg, #fff 0%, #a855f7 50%, #6366f1 100%);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}

.login-subtitle {
  color: var(--fg-dim);
  margin-bottom: 2rem;
}

.google-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.75rem;
  width: 100%;
  padding: 0.875rem 1.5rem;
  background: #fff;
  color: #1f1f1f;
  border: none;
  border-radius: 0.5rem;
  font-size: 1rem;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s;
}

.google-btn:hover {
  background: #f3f4f6;
  transform: translateY(-2px);
}

.login-note {
  margin-top: 1.5rem;
  font-size: 0.875rem;
  color: var(--fg-muted);
}

/* === Chat App Container === */
.chat-app {
  display: flex;
  height: 100vh;
  width: 100%;
}

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

.sidebar-header {
  padding: 16px;
  display: flex;
  justify-content: flex-end;
}

.sidebar-close {
  display: none;
  width: 32px;
  height: 32px;
  background: none;
  border: none;
  color: var(--fg-muted);
  cursor: pointer;
  border-radius: 6px;
  font-size: 1rem;
}

.sidebar-close:hover {
  background: var(--bg-elevated);
  color: var(--fg);
}

.sidebar-actions {
  padding: 0 16px 16px;
}

.new-chat-btn {
  width: 100%;
  padding: 12px 16px;
  background: var(--accent);
  border: none;
  border-radius: 8px;
  color: white;
  font-size: 0.9rem;
  font-weight: 500;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  transition: all 0.2s;
}

.new-chat-btn:hover {
  background: var(--accent-hover);
}

.chat-list-header {
  padding: 12px 16px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  border-top: 1px solid var(--border);
}

.chat-list-title {
  font-size: 0.75rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 1px;
  color: var(--fg-muted);
}

.clear-all-btn {
  padding: 4px 8px;
  background: none;
  border: none;
  color: var(--fg-muted);
  font-size: 0.75rem;
  cursor: pointer;
  border-radius: 4px;
  transition: all 0.15s;
}

.clear-all-btn:hover {
  background: var(--bg-elevated);
  color: var(--error);
}

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

.chat-item {
  padding: 12px 14px;
  border-radius: 8px;
  cursor: pointer;
  color: var(--fg-dim);
  font-size: 0.9rem;
  margin-bottom: 4px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  transition: all 0.15s;
}

.chat-item:hover {
  background: var(--bg-elevated);
  color: var(--fg);
}

.chat-item.active {
  background: var(--bg-elevated);
  color: var(--fg);
  border-left: 2px solid var(--accent);
}

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

.chat-item-delete {
  width: 24px;
  height: 24px;
  background: none;
  border: none;
  color: var(--fg-muted);
  cursor: pointer;
  border-radius: 4px;
  display: flex;
  align-items: center;
  justify-content: center;
  opacity: 0;
  transition: all 0.15s;
}

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

.chat-item-delete:hover {
  background: var(--error);
  color: white;
}

/* === Main Area === */
.main {
  flex: 1;
  display: flex;
  flex-direction: column;
  min-width: 0;
  background: var(--bg);
}

/* === Header === */
.main-header {
  padding: 12px 20px;
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  background: var(--bg);
  flex-shrink: 0;
}

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

.menu-btn {
  width: 36px;
  height: 36px;
  background: none;
  border: 1px solid var(--border);
  border-radius: 8px;
  color: var(--fg);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
}

.menu-btn:hover {
  background: var(--bg-card);
}

.brand {
  display: flex;
  align-items: center;
  gap: 8px;
  text-decoration: none;
  color: var(--fg);
}

.brand-logo {
  font-size: 1.25rem;
}

.brand-text {
  font-weight: 600;
  font-size: 1rem;
  background: linear-gradient(135deg, #fff 0%, #a855f7 100%);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}

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

.header-btn {
  width: 36px;
  height: 36px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: none;
  border: 1px solid var(--border);
  border-radius: 8px;
  color: var(--fg-dim);
  cursor: pointer;
  transition: all 0.15s;
  text-decoration: none;
}

.header-btn:hover {
  background: var(--bg-card);
  color: var(--fg);
}

.user-menu {
  display: flex;
  align-items: center;
  gap: 12px;
}

.user-avatar {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  object-fit: cover;
  border: 2px solid var(--border);
}

.signout-btn {
  padding: 8px 14px;
  background: none;
  border: 1px solid var(--border);
  border-radius: 6px;
  color: var(--fg-dim);
  font-size: 0.85rem;
  cursor: pointer;
  transition: all 0.15s;
}

.signout-btn:hover {
  background: var(--bg-card);
  color: var(--error);
  border-color: var(--error);
}

/* === Site Links (Desktop) === */
.site-links {
  display: flex;
  align-items: center;
  gap: 4px;
}

.site-link {
  width: 32px;
  height: 32px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 16px;
  text-decoration: none;
  border-radius: 6px;
  transition: all 0.15s;
  position: relative;
}

.site-link:hover {
  background: var(--bg-card);
  transform: scale(1.1);
}

.site-link-primary {
  background: var(--accent-glow);
}

.site-link-primary:hover {
  background: var(--accent);
}

/* Tooltip */
.site-link::after {
  content: attr(title);
  position: absolute;
  top: 100%;
  left: 50%;
  transform: translateX(-50%);
  padding: 4px 8px;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 4px;
  font-size: 0.7rem;
  color: var(--fg-dim);
  white-space: nowrap;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.15s;
  margin-top: 4px;
  z-index: 100;
}

.site-link:hover::after {
  opacity: 1;
}

/* === Nav Toggle (Mobile) === */
.nav-toggle {
  display: none;
  width: 36px;
  height: 36px;
  background: none;
  border: 1px solid var(--border);
  border-radius: 8px;
  color: var(--fg);
  cursor: pointer;
  align-items: center;
  justify-content: center;
}

.nav-toggle:hover {
  background: var(--bg-card);
}

/* === Nav Menu (Mobile Dropdown) === */
.nav-menu {
  display: none;
  position: absolute;
  top: 100%;
  right: 12px;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 8px;
  min-width: 200px;
  z-index: 1000;
  box-shadow: 0 8px 32px rgba(0, 0, 0, 0.4);
}

.nav-menu.open {
  display: block;
}

.nav-menu-section {
  padding: 4px 0;
}

.nav-menu-title {
  padding: 8px 12px 4px;
  font-size: 0.7rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 1px;
  color: var(--fg-muted);
}

.nav-menu-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 12px;
  font-size: 0.9rem;
  color: var(--fg-dim);
  text-decoration: none;
  border-radius: 8px;
  transition: all 0.15s;
  border: none;
  background: none;
  width: 100%;
  cursor: pointer;
  text-align: left;
}

.nav-menu-item:hover {
  background: var(--bg-elevated);
  color: var(--fg);
}

.nav-menu-primary {
  color: var(--accent);
}

.nav-menu-primary:hover {
  background: var(--accent-glow);
}

.nav-menu-divider {
  height: 1px;
  background: var(--border);
  margin: 8px 0;
}

.nav-menu-signout:hover {
  color: var(--error);
}

/* Desktop Only */
.desktop-only {
  display: flex;
}

/* === Messages Area === */
.messages {
  flex: 1;
  overflow-y: auto;
  padding: 24px 0;
}

.message {
  max-width: 800px;
  margin: 0 auto 24px;
  padding: 0 24px;
  display: flex;
  gap: 16px;
  animation: messageSlideIn 0.3s ease-out forwards;
  opacity: 0;
}

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

.message-avatar {
  width: 36px;
  height: 36px;
  border-radius: 10px;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  font-size: 1rem;
}

.message.user .message-avatar {
  background: linear-gradient(135deg, #a855f7 0%, #6366f1 100%);
}

.message.assistant .message-avatar {
  background: var(--bg-card);
  border: 1px solid var(--border);
}

.message-avatar-img {
  width: 36px;
  height: 36px;
  border-radius: 10px;
  object-fit: cover;
  flex-shrink: 0;
}

.message-body {
  flex: 1;
  min-width: 0;
}

.message-role {
  font-size: 0.8rem;
  font-weight: 600;
  margin-bottom: 6px;
  color: var(--fg-dim);
}

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

.message-content p {
  margin-bottom: 12px;
}

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

.message-content code {
  background: var(--bg-card);
  padding: 2px 6px;
  border-radius: 4px;
  font-family: var(--font-mono);
  font-size: 0.85em;
}

.message-content pre {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 16px;
  overflow-x: auto;
  margin: 16px 0;
}

.message-content pre code {
  background: none;
  padding: 0;
  font-size: 0.85rem;
  line-height: 1.6;
}

/* Response Controls */
.message-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-top: 12px;
  padding-top: 12px;
  border-top: 1px solid var(--border);
  opacity: 0;
  transition: opacity 0.2s ease;
}

.message:hover .message-footer {
  opacity: 1;
}

.response-actions {
  display: flex;
  gap: 8px;
}

.response-btn {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 6px 10px;
  background: none;
  border: 1px solid var(--border);
  border-radius: 6px;
  color: var(--fg-muted);
  font-size: 0.75rem;
  cursor: pointer;
  transition: all 0.15s ease;
}

.response-btn:hover {
  background: var(--bg-card);
  color: var(--fg);
}

.response-btn.copied {
  border-color: var(--success);
  color: var(--success);
}

.response-btn svg {
  width: 14px;
  height: 14px;
}

.feedback-btns {
  display: flex;
  gap: 4px;
}

.feedback-btn {
  width: 28px;
  height: 28px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: none;
  border: 1px solid transparent;
  border-radius: 6px;
  color: var(--fg-muted);
  font-size: 0.9rem;
  cursor: pointer;
  transition: all 0.15s ease;
}

.feedback-btn:hover {
  background: var(--bg-card);
  border-color: var(--border);
}

.feedback-btn.active {
  background: var(--bg-card);
  border-color: var(--accent);
  color: var(--accent);
}

.model-badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 3px 8px;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 4px;
  font-size: 0.7rem;
  color: var(--fg-muted);
  margin-left: 8px;
}

/* === Welcome Screen === */
.welcome {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 40px;
  text-align: center;
  height: 100%;
}

.welcome-icon {
  width: 80px;
  height: 80px;
  background: linear-gradient(135deg, var(--bg-card) 0%, var(--bg-elevated) 100%);
  border: 1px solid var(--border);
  border-radius: 24px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 2.5rem;
  margin-bottom: 24px;
}

.welcome h2 {
  font-size: 1.5rem;
  font-weight: 600;
  margin-bottom: 12px;
  background: linear-gradient(135deg, #fff 0%, #a855f7 100%);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}

.welcome p {
  color: var(--fg-dim);
  max-width: 400px;
  margin-bottom: 32px;
  line-height: 1.6;
}

.suggestions {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  justify-content: center;
  max-width: 500px;
}

.suggestion {
  padding: 12px 20px;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 10px;
  font-size: 0.9rem;
  color: var(--fg-dim);
  cursor: pointer;
  transition: all 0.15s;
}

.suggestion:hover {
  background: var(--bg-elevated);
  border-color: var(--accent);
  color: var(--fg);
  transform: translateY(-2px);
}

/* === Input Area === */
.input-area {
  padding: 16px 24px 24px;
  border-top: 1px solid var(--border);
  flex-shrink: 0;
  background: var(--bg);
}

.input-container {
  max-width: 800px;
  margin: 0 auto;
}

.input-wrapper {
  display: flex;
  align-items: flex-end;
  gap: 12px;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 12px 16px;
  transition: border-color 0.15s;
}

.input-wrapper:focus-within {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-glow);
}

.input-field {
  flex: 1;
  background: none;
  border: none;
  color: var(--fg);
  font-size: 0.95rem;
  font-family: inherit;
  resize: none;
  outline: none;
  min-height: 24px;
  max-height: 200px;
  line-height: 1.5;
}

.input-field::placeholder {
  color: var(--fg-muted);
}

.send-btn {
  width: 40px;
  height: 40px;
  background: var(--accent);
  border: none;
  border-radius: 10px;
  color: white;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.15s;
  flex-shrink: 0;
}

.send-btn:hover {
  background: var(--accent-hover);
  transform: scale(1.05);
}

.send-btn:disabled {
  background: var(--fg-muted);
  cursor: not-allowed;
  transform: none;
}

/* Loading state */
.input-wrapper.loading {
  opacity: 0.7;
  pointer-events: none;
}

.send-btn.loading::after {
  content: '';
  width: 18px;
  height: 18px;
  border: 2px solid transparent;
  border-top-color: white;
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}

/* === Typing Indicator === */
.typing {
  display: flex;
  gap: 6px;
  padding: 8px 0;
  align-items: center;
}

.typing span {
  width: 8px;
  height: 8px;
  background: var(--accent);
  border-radius: 50%;
  animation: typingBounce 1.4s ease-in-out infinite;
}

.typing span:nth-child(2) { animation-delay: 0.15s; }
.typing span:nth-child(3) { animation-delay: 0.3s; }

@keyframes typingBounce {
  0%, 80%, 100% {
    transform: translateY(0) scale(1);
    opacity: 0.5;
  }
  40% {
    transform: translateY(-8px) scale(1.1);
    opacity: 1;
  }
}

/* === Error Message === */
.error-message {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.error-text {
  color: var(--error);
}

/* === Toast Notifications === */
.toast {
  position: fixed;
  bottom: 24px;
  left: 50%;
  transform: translateX(-50%) translateY(100px);
  background: var(--bg-card);
  border: 1px solid var(--border);
  padding: 12px 20px;
  border-radius: 10px;
  font-size: 0.9rem;
  z-index: 1001;
  opacity: 0;
  transition: all 0.3s ease;
}

.toast.show {
  transform: translateX(-50%) translateY(0);
  opacity: 1;
}

.toast.error {
  border-color: var(--error);
  background: rgba(239, 68, 68, 0.1);
}

/* === Mobile Responsive === */
@media (max-width: 768px) {
  .sidebar {
    position: fixed;
    left: 0;
    top: 0;
    bottom: 0;
    transform: translateX(-100%);
    z-index: 100;
    transition: transform 0.3s ease;
  }

  .sidebar.open {
    transform: translateX(0);
  }

  .sidebar-close {
    display: flex;
  }

  .sidebar-overlay {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.6);
    z-index: 99;
    opacity: 0;
    transition: opacity 0.3s ease;
  }

  .sidebar-overlay.open {
    display: block;
    opacity: 1;
  }

  .menu-btn {
    display: flex;
  }

  /* Hide site links on mobile */
  .site-links {
    display: none;
  }

  /* Show nav toggle on mobile */
  .nav-toggle {
    display: flex;
  }

  /* Hide desktop-only elements */
  .desktop-only {
    display: none !important;
  }

  /* Make header relative for dropdown positioning */
  .main-header {
    position: relative;
  }

  .message {
    padding: 0 16px;
    gap: 12px;
  }

  .input-area {
    padding: 12px 16px 16px;
  }

  .welcome {
    padding: 24px 16px;
  }

  .suggestions {
    flex-direction: column;
    width: 100%;
  }

  .suggestion {
    width: 100%;
    text-align: center;
  }
}

@media (min-width: 769px) {
  .menu-btn {
    display: none;
  }

  /* Hide nav toggle on desktop */
  .nav-toggle {
    display: none;
  }

  /* Hide nav menu on desktop */
  .nav-menu {
    display: none !important;
  }
}
