/* =========================
   VYBE — Modern Dark Social
   ========================= */

:root {
  --bg: #0a0a0b;
  --bg-elevated: #121214;
  --bg-card: #161618;
  --bg-hover: #1c1c1f;
  --border: #27272a;
  --border-light: #3f3f46;
  --text: #fafafa;
  --text-secondary: #a1a1aa;
  --text-muted: #71717a;
  --accent: #8b5cf6;
  --accent-hover: #7c3aed;
  --accent-soft: rgba(139, 92, 246, 0.15);
  --danger: #ef4444;
  --danger-hover: #dc2626;
  --success: #22c55e;
  --like: #f43f5e;
  --radius: 16px;
  --radius-sm: 10px;
  --radius-full: 9999px;
  --shadow: 0 4px 24px rgba(0,0,0,0.4);
  --font: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  --nav-height: 64px;
  --sidebar-width: 240px;
  --transition: 0.2s ease;
}

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

html {
  font-size: 16px;
  -webkit-text-size-adjust: 100%;
}

body {
  font-family: var(--font);
  background: var(--bg);
  color: var(--text);
  line-height: 1.5;
  min-height: 100dvh;
  overflow-x: hidden;
  -webkit-font-smoothing: antialiased;
}

button, input, textarea, select {
  font-family: inherit;
  font-size: inherit;
  color: inherit;
}

button {
  cursor: pointer;
  border: none;
  background: none;
}

a { color: var(--accent); text-decoration: none; }

img { max-width: 100%; display: block; }

.hidden { display: none !important; }

/* ========== LOADING ========== */
.loading-screen {
  position: fixed;
  inset: 0;
  background: var(--bg);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 24px;
  z-index: 9999;
}

.logo-loader {
  font-size: 2.5rem;
  font-weight: 700;
  letter-spacing: 0.15em;
  background: linear-gradient(135deg, #a78bfa, #8b5cf6, #6366f1);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}

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

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

/* ========== AUTH ========== */
.auth-screen {
  min-height: 100dvh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
  background: radial-gradient(ellipse at top, #1a1025 0%, var(--bg) 60%);
}

.auth-card {
  width: 100%;
  max-width: 400px;
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 32px 28px;
  box-shadow: var(--shadow);
}

.auth-logo {
  font-size: 2rem;
  font-weight: 700;
  letter-spacing: 0.12em;
  text-align: center;
  background: linear-gradient(135deg, #a78bfa, #8b5cf6);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
  margin-bottom: 4px;
}

.auth-tagline {
  text-align: center;
  color: var(--text-secondary);
  font-size: 0.9rem;
  margin-bottom: 28px;
}

.auth-tabs {
  display: flex;
  gap: 4px;
  background: var(--bg);
  border-radius: var(--radius-sm);
  padding: 4px;
  margin-bottom: 24px;
}

.auth-tab {
  flex: 1;
  padding: 10px;
  border-radius: 8px;
  font-weight: 500;
  color: var(--text-secondary);
  transition: var(--transition);
}

.auth-tab.active {
  background: var(--bg-card);
  color: var(--text);
  box-shadow: 0 1px 3px rgba(0,0,0,0.3);
}

.auth-form { display: flex; flex-direction: column; gap: 16px; }

.auth-info {
  color: var(--text-secondary);
  font-size: 0.9rem;
  margin-bottom: 8px;
}

.form-group {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.form-group label {
  font-size: 0.85rem;
  font-weight: 500;
  color: var(--text-secondary);
}

.form-group input,
.form-group textarea,
.form-group select {
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 12px 14px;
  outline: none;
  transition: border-color var(--transition);
}

.form-group input:focus,
.form-group textarea:focus,
.form-group select:focus {
  border-color: var(--accent);
}

.form-group textarea { resize: vertical; min-height: 80px; }

.link-btn {
  align-self: flex-end;
  font-size: 0.85rem;
  color: var(--accent);
  padding: 0;
}

/* ========== BUTTONS ========== */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 10px 18px;
  border-radius: var(--radius-sm);
  font-weight: 600;
  font-size: 0.9rem;
  transition: all var(--transition);
  white-space: nowrap;
}

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

.btn-primary {
  background: var(--accent);
  color: #fff;
}

.btn-primary:hover:not(:disabled) {
  background: var(--accent-hover);
}

.btn-ghost {
  background: transparent;
  color: var(--text-secondary);
  border: 1px solid var(--border);
}

.btn-ghost:hover:not(:disabled) {
  background: var(--bg-hover);
  color: var(--text);
}

.btn-danger {
  background: var(--danger);
  color: #fff;
}

.btn-danger:hover:not(:disabled) {
  background: var(--danger-hover);
}

.btn-block { width: 100%; }
.btn-sm { padding: 7px 12px; font-size: 0.8rem; }
.btn-follow {
  background: var(--accent);
  color: #fff;
  min-width: 90px;
}
.btn-following {
  background: transparent;
  border: 1px solid var(--border);
  color: var(--text);
  min-width: 90px;
}

/* ========== APP LAYOUT ========== */
.app {
  display: flex;
  min-height: 100dvh;
}

.sidebar {
  display: none;
  width: var(--sidebar-width);
  background: var(--bg-elevated);
  border-right: 1px solid var(--border);
  flex-direction: column;
  padding: 24px 16px;
  position: fixed;
  top: 0;
  left: 0;
  bottom: 0;
  z-index: 100;
}

.sidebar-logo {
  font-size: 1.5rem;
  font-weight: 700;
  letter-spacing: 0.12em;
  background: linear-gradient(135deg, #a78bfa, #8b5cf6);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
  padding: 0 12px;
  margin-bottom: 32px;
}

.sidebar-nav {
  display: flex;
  flex-direction: column;
  gap: 4px;
  flex: 1;
}

.sidebar .nav-item {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 12px 14px;
  border-radius: var(--radius-sm);
  color: var(--text-secondary);
  font-weight: 500;
  transition: var(--transition);
  position: relative;
}

.sidebar .nav-item svg {
  width: 22px;
  height: 22px;
  flex-shrink: 0;
}

.sidebar .nav-item:hover {
  background: var(--bg-hover);
  color: var(--text);
}

.sidebar .nav-item.active {
  background: var(--accent-soft);
  color: var(--accent);
}

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

.main {
  flex: 1;
  max-width: 640px;
  margin: 0 auto;
  width: 100%;
  padding-bottom: calc(var(--nav-height) + 16px);
}

.topbar {
  position: sticky;
  top: 0;
  z-index: 50;
  background: rgba(10, 10, 11, 0.85);
  backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--border);
  padding: 14px 16px;
  display: flex;
  align-items: center;
  gap: 12px;
}

.topbar-logo {
  font-size: 1.25rem;
  font-weight: 700;
  letter-spacing: 0.1em;
  background: linear-gradient(135deg, #a78bfa, #8b5cf6);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}

.topbar-title {
  font-weight: 600;
  font-size: 1.05rem;
}

/* ========== BOTTOM NAV ========== */
.bottom-nav {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  height: var(--nav-height);
  background: rgba(18, 18, 20, 0.95);
  backdrop-filter: blur(12px);
  border-top: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-around;
  z-index: 100;
  padding-bottom: env(safe-area-inset-bottom);
}

.bottom-nav .nav-item {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 48px;
  height: 48px;
  border-radius: 50%;
  color: var(--text-muted);
  position: relative;
  transition: var(--transition);
}

.bottom-nav .nav-item svg {
  width: 24px;
  height: 24px;
}

.bottom-nav .nav-item.active {
  color: var(--accent);
}

.bottom-nav .create-btn {
  background: var(--accent);
  color: #fff !important;
  width: 48px;
  height: 48px;
  box-shadow: 0 4px 16px rgba(139, 92, 246, 0.4);
}

.bottom-nav .create-btn:hover {
  background: var(--accent-hover);
}

.badge {
  position: absolute;
  top: 6px;
  right: 6px;
  background: var(--danger);
  color: #fff;
  font-size: 0.7rem;
  font-weight: 600;
  min-width: 18px;
  height: 18px;
  border-radius: 9px;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0 4px;
}

.badge-dot {
  position: absolute;
  top: 8px;
  right: 8px;
  width: 8px;
  height: 8px;
  background: var(--danger);
  border-radius: 50%;
}

/* ========== VIEWS ========== */
.view {
  display: none;
  padding: 0;
  min-height: calc(100dvh - var(--nav-height) - 60px);
}

.view.active { display: block; }

/* ========== FEED / POSTS ========== */
.feed {
  display: flex;
  flex-direction: column;
}

.post-card {
  background: var(--bg-card);
  border-bottom: 1px solid var(--border);
  padding: 16px;
  transition: background var(--transition);
}

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

.post-header {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 10px;
}

.avatar, .avatar-sm, .avatar-lg {
  border-radius: 50%;
  object-fit: cover;
  background: var(--bg-hover);
  flex-shrink: 0;
}

.avatar { width: 44px; height: 44px; }
.avatar-sm { width: 36px; height: 36px; }
.avatar-lg { width: 96px; height: 96px; }

.avatar-placeholder {
  display: flex;
  align-items: center;
  justify-content: center;
  background: linear-gradient(135deg, #7c3aed, #4f46e5);
  color: #fff;
  font-weight: 600;
  font-size: 1rem;
}

.post-meta {
  flex: 1;
  min-width: 0;
}

.post-author {
  display: flex;
  align-items: baseline;
  gap: 6px;
  flex-wrap: wrap;
}

.post-displayname {
  font-weight: 600;
  font-size: 0.95rem;
}

.post-username {
  color: var(--text-muted);
  font-size: 0.85rem;
}

.post-date {
  color: var(--text-muted);
  font-size: 0.8rem;
}

.post-menu {
  position: relative;
}

.post-menu-btn {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--text-muted);
  transition: var(--transition);
}

.post-menu-btn:hover {
  background: var(--bg-hover);
  color: var(--text);
}

.post-menu-dropdown {
  position: absolute;
  right: 0;
  top: 100%;
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  box-shadow: var(--shadow);
  min-width: 160px;
  z-index: 20;
  overflow: hidden;
}

.post-menu-dropdown button {
  display: block;
  width: 100%;
  text-align: left;
  padding: 10px 14px;
  color: var(--text);
  font-size: 0.9rem;
  transition: var(--transition);
}

.post-menu-dropdown button:hover {
  background: var(--bg-hover);
}

.post-menu-dropdown button.danger {
  color: var(--danger);
}

.post-content {
  font-size: 0.95rem;
  line-height: 1.55;
  white-space: pre-wrap;
  word-break: break-word;
  margin-bottom: 12px;
}

.post-image {
  border-radius: var(--radius-sm);
  overflow: hidden;
  margin-bottom: 12px;
  max-height: 500px;
}

.post-image img {
  width: 100%;
  height: auto;
  object-fit: cover;
}

.post-actions {
  display: flex;
  align-items: center;
  gap: 4px;
}

.action-btn {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 8px 12px;
  border-radius: var(--radius-full);
  color: var(--text-muted);
  font-size: 0.85rem;
  transition: var(--transition);
}

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

.action-btn svg {
  width: 18px;
  height: 18px;
}

.action-btn.liked {
  color: var(--like);
}

.action-btn.liked:hover {
  background: rgba(244, 63, 94, 0.1);
}

.action-btn:hover.comment-btn {
  color: var(--accent);
  background: var(--accent-soft);
}

/* ========== EMPTY / LOADING STATES ========== */
.empty-state {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 60px 24px;
  text-align: center;
  color: var(--text-secondary);
  gap: 12px;
}

.empty-icon {
  font-size: 2.5rem;
  opacity: 0.7;
}

.feed-loading {
  display: flex;
  justify-content: center;
  padding: 32px;
}

/* ========== SEARCH ========== */
.search-box {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 16px;
  background: var(--bg-card);
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 53px;
  z-index: 10;
}

.search-box svg {
  width: 20px;
  height: 20px;
  color: var(--text-muted);
  flex-shrink: 0;
}

.search-box input {
  flex: 1;
  background: transparent;
  border: none;
  outline: none;
  font-size: 1rem;
}

.search-results {
  padding: 8px 0;
}

.user-card {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 16px;
  cursor: pointer;
  transition: var(--transition);
}

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

.user-card-info {
  flex: 1;
  min-width: 0;
}

.user-card-name {
  font-weight: 600;
  font-size: 0.95rem;
}

.user-card-username {
  color: var(--text-muted);
  font-size: 0.85rem;
}

/* ========== PROFILE ========== */
.profile-header {
  padding: 24px 16px;
  border-bottom: 1px solid var(--border);
}

.profile-top {
  display: flex;
  align-items: flex-start;
  gap: 16px;
  margin-bottom: 16px;
}

.profile-info {
  flex: 1;
}

.profile-displayname {
  font-size: 1.35rem;
  font-weight: 700;
}

.profile-username {
  color: var(--text-muted);
  font-size: 0.95rem;
  margin-bottom: 8px;
}

.profile-bio {
  color: var(--text-secondary);
  font-size: 0.95rem;
  line-height: 1.5;
  margin-bottom: 16px;
  white-space: pre-wrap;
}

.profile-stats {
  display: flex;
  gap: 20px;
  margin-bottom: 16px;
}

.stat {
  display: flex;
  flex-direction: column;
  align-items: center;
}

.stat-value {
  font-weight: 700;
  font-size: 1.1rem;
}

.stat-label {
  font-size: 0.8rem;
  color: var(--text-muted);
}

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

.profile-posts {
  display: flex;
  flex-direction: column;
}

/* ========== NOTIFICATIONS ========== */
.notifications-list {
  display: flex;
  flex-direction: column;
}

.notif-item {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  padding: 14px 16px;
  border-bottom: 1px solid var(--border);
  cursor: pointer;
  transition: var(--transition);
}

.notif-item:hover {
  background: var(--bg-hover);
}

.notif-item.unread {
  background: var(--accent-soft);
}

.notif-icon {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1rem;
  flex-shrink: 0;
  background: var(--bg-hover);
}

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

.notif-text {
  font-size: 0.9rem;
  line-height: 1.4;
}

.notif-text strong {
  font-weight: 600;
}

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

/* ========== MODALS ========== */
.modal {
  position: fixed;
  inset: 0;
  z-index: 1000;
  display: flex;
  align-items: flex-end;
  justify-content: center;
}

.modal-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(0,0,0,0.6);
  backdrop-filter: blur(4px);
}

.modal-content {
  position: relative;
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: var(--radius) var(--radius) 0 0;
  width: 100%;
  max-width: 520px;
  max-height: 90dvh;
  overflow-y: auto;
  padding: 20px;
  animation: slideUp 0.25s ease;
}

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

.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 16px;
}

.modal-header h2 {
  font-size: 1.15rem;
  font-weight: 600;
}

.modal-close {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.4rem;
  color: var(--text-muted);
  transition: var(--transition);
}

.modal-close:hover {
  background: var(--bg-hover);
  color: var(--text);
}

#create-post-form textarea {
  width: 100%;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 14px;
  resize: none;
  outline: none;
  min-height: 120px;
  margin-bottom: 12px;
}

#create-post-form textarea:focus {
  border-color: var(--accent);
}

.image-preview {
  position: relative;
  margin-bottom: 12px;
  border-radius: var(--radius-sm);
  overflow: hidden;
}

.image-preview img {
  width: 100%;
  max-height: 280px;
  object-fit: cover;
}

.remove-img-btn {
  position: absolute;
  top: 8px;
  right: 8px;
  width: 28px;
  height: 28px;
  border-radius: 50%;
  background: rgba(0,0,0,0.7);
  color: #fff;
  font-size: 1.1rem;
  display: flex;
  align-items: center;
  justify-content: center;
}

.modal-actions {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.avatar-edit {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 12px;
  margin-bottom: 20px;
}

.modal-comments {
  display: flex;
  flex-direction: column;
  max-height: 80dvh;
}

.comments-list {
  flex: 1;
  overflow-y: auto;
  margin-bottom: 12px;
  max-height: 50vh;
}

.comment-item {
  display: flex;
  gap: 10px;
  padding: 10px 0;
  border-bottom: 1px solid var(--border);
}

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

.comment-author {
  font-weight: 600;
  font-size: 0.9rem;
}

.comment-text {
  font-size: 0.9rem;
  margin-top: 2px;
  word-break: break-word;
}

.comment-meta {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-top: 4px;
}

.comment-date {
  font-size: 0.75rem;
  color: var(--text-muted);
}

.comment-delete {
  font-size: 0.75rem;
  color: var(--danger);
}

.comment-form {
  display: flex;
  gap: 8px;
  border-top: 1px solid var(--border);
  padding-top: 12px;
}

.comment-form input {
  flex: 1;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--radius-full);
  padding: 10px 16px;
  outline: none;
}

.comment-form input:focus {
  border-color: var(--accent);
}

.modal-sm {
  max-width: 360px;
}

.confirm-message {
  color: var(--text-secondary);
  margin-bottom: 20px;
  line-height: 1.5;
}

.confirm-actions {
  justify-content: flex-end;
}

/* ========== TOAST ========== */
.toast-container {
  position: fixed;
  top: 16px;
  left: 50%;
  transform: translateX(-50%);
  z-index: 2000;
  display: flex;
  flex-direction: column;
  gap: 8px;
  pointer-events: none;
  width: calc(100% - 32px);
  max-width: 400px;
}

.toast {
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 12px 16px;
  box-shadow: var(--shadow);
  font-size: 0.9rem;
  animation: toastIn 0.3s ease;
  pointer-events: auto;
  display: flex;
  align-items: center;
  gap: 10px;
}

.toast.success { border-left: 3px solid var(--success); }
.toast.error { border-left: 3px solid var(--danger); }
.toast.info { border-left: 3px solid var(--accent); }

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

/* ========== DESKTOP ========== */
@media (min-width: 768px) {
  .sidebar {
    display: flex;
  }

  .bottom-nav {
    display: none;
  }

  .main {
    margin-left: var(--sidebar-width);
    padding-bottom: 24px;
  }

  .topbar-logo {
    display: none;
  }

  .modal {
    align-items: center;
  }

  .modal-content {
    border-radius: var(--radius);
    max-height: 85vh;
  }
}

@media (min-width: 1024px) {
  .main {
    max-width: 680px;
  }
}

/* Clickable username/profile */
.clickable {
  cursor: pointer;
}

.clickable:hover {
  text-decoration: underline;
}
