/* =============================================
   Forum — components.css
   Buttons, inputs, avatars, modals, sidebar
   ============================================= */

/* ── Buttons ── */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  padding: 0.6rem 1.25rem;
  border-radius: var(--radius-full);
  font-family: var(--font-display);
  font-size: 0.9375rem;
  font-weight: 700;
  transition: background var(--dur) var(--ease);
  white-space: nowrap;
  cursor: pointer;
}

.btn:active { opacity: 0.85; }

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

.btn-outline {
  background: transparent;
  border: 1.5px solid var(--border);
  color: var(--text);
}
.btn-outline:hover { background: rgba(231,233,234,0.1); }

.btn-ghost {
  background: transparent;
  color: var(--text-muted);
  padding: 0.5rem;
  border-radius: var(--radius);
}
.btn-ghost:hover { background: rgba(231,233,234,0.1); color: var(--text); }

.btn-danger {
  background: transparent;
  border: 1.5px solid var(--danger);
  color: var(--danger);
}
.btn-danger:hover { background: rgba(244,33,46,0.1); }

/* White filled button (for auth pages) */
.btn-white {
  background: var(--text);
  color: #000;
}
.btn-white:hover { background: rgba(231,233,234,0.85); }

.btn-sm {
  padding: 0.3rem 0.85rem;
  font-size: 0.8125rem;
}

.btn-lg {
  padding: 0.8rem 1.75rem;
  font-size: 1rem;
}

.btn:disabled {
  opacity: 0.4;
  pointer-events: none;
}

/* Loading spinner in button */
.btn .spinner {
  width: 14px; height: 14px;
  border: 2px solid rgba(255,255,255,0.3);
  border-top-color: #fff;
  border-radius: 50%;
  animation: spin 0.6s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ── Inputs ── */
.form-group {
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
}

.form-label {
  font-size: 0.8rem;
  font-weight: 600;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.input {
  width: 100%;
  background: transparent;
  border: 1.5px solid var(--border);
  border-radius: var(--radius);
  color: var(--text);
  padding: 0.75rem 1rem;
  font-size: 1rem;
  transition: border-color var(--dur), box-shadow var(--dur);
  outline: none;
}
.input::placeholder { color: var(--text-muted); }
.input:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 2px var(--accent-glow);
}
.input.error {
  border-color: var(--danger);
  box-shadow: 0 0 0 2px rgba(244,33,46,0.2);
}

textarea.input {
  resize: vertical;
  min-height: 100px;
}

.input-error-msg {
  font-size: 0.8rem;
  color: var(--danger);
}

/* ── Avatar ── */
.avatar {
  border-radius: 50%;
  object-fit: cover;
  flex-shrink: 0;
  background: var(--bg-3);
}
.avatar-xs { width: 28px; height: 28px; }
.avatar-sm { width: 36px; height: 36px; }
.avatar-md { width: 48px; height: 48px; }
.avatar-lg { width: 72px; height: 72px; }
.avatar-xl { width: 96px; height: 96px; }

.avatar-placeholder {
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--bg-3);
  color: var(--text-muted);
  font-family: var(--font-display);
  font-weight: 700;
  border-radius: 50%;
  flex-shrink: 0;
}

/* ── Sidebar ── */
.sidebar {
  position: sticky;
  top: 0;
  height: 100vh;
  display: flex;
  flex-direction: column;
  padding: 0 0.75rem;
  overflow-y: auto;
  overflow-x: hidden;
}

.sidebar-logo {
  display: flex;
  align-items: center;
  padding: 0.75rem;
  margin: 0.5rem 0;
  border-radius: var(--radius-full);
  transition: background var(--dur);
  color: var(--text);
  gap: 0;
}
.sidebar-logo:hover { background: rgba(231,233,234,0.1); }

/* F logo SVG icon */
.sidebar-logo .logo-icon {
  width: 34px;
  height: 34px;
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: center;
}

.sidebar-logo .logo-text {
  font-size: 1.3rem;
  font-weight: 800;
  color: var(--text);
  margin-left: 0.6rem;
}

.sidebar-nav {
  display: flex;
  flex-direction: column;
  gap: 0.1rem;
  flex: 1;
}

.nav-link {
  display: flex;
  align-items: center;
  gap: 1rem;
  padding: 0.75rem;
  border-radius: var(--radius-full);
  color: var(--text);
  font-size: 1.1rem;
  font-weight: 400;
  transition: background var(--dur);
  position: relative;
}
.nav-link:hover { background: rgba(231,233,234,0.1); }
.nav-link.active { font-weight: 700; }

.nav-link svg  { width: 26px; height: 26px; flex-shrink: 0; }
.nav-link .nav-label { white-space: nowrap; }

.nav-link .badge {
  margin-left: auto;
  background: var(--accent);
  color: #fff;
  font-size: 0.7rem;
  font-weight: 700;
  padding: 0.1rem 0.45rem;
  border-radius: var(--radius-full);
  min-width: 18px;
  text-align: center;
}

/* ── Post button (Twitter-style big blue pill) ── */
.sidebar-post-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  width: 100%;
  padding: 0.85rem 1.5rem;
  background: var(--accent);
  color: #fff;
  border-radius: var(--radius-full);
  font-size: 1rem;
  font-weight: 700;
  cursor: pointer;
  border: none;
  transition: background var(--dur);
  margin-top: 0.75rem;
  white-space: nowrap;
}
.sidebar-post-btn:hover { background: var(--accent-hover); }
.sidebar-post-btn svg { width: 20px; height: 20px; }

.sidebar-user {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 0.85rem 0.75rem;
  border-radius: var(--radius-full);
  margin: 0.5rem 0;
  cursor: pointer;
  transition: background var(--dur);
}
.sidebar-user:hover { background: rgba(231,233,234,0.1); }

.sidebar-user .user-info { flex: 1; overflow: hidden; }
.sidebar-user .display-name { font-weight: 700; font-size: 0.9375rem; line-height: 1.25; }
.sidebar-user .handle { font-size: 0.875rem; color: var(--text-muted); }

/* Three-dot icon on sidebar user */
.sidebar-user-dots {
  color: var(--text-muted);
  flex-shrink: 0;
}
.sidebar-user-dots svg { width: 18px; height: 18px; }

/* ── Feed Header ── */
.feed-header {
  position: sticky;
  top: 0;
  z-index: 10;
  background: rgba(0,0,0,0.75);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--border);
  padding: 0 1rem;
  height: 53px;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.feed-header h2 {
  font-size: 1.0625rem;
  font-weight: 700;
}

.feed-tabs {
  display: flex;
  border-bottom: 1px solid var(--border);
}

.feed-tab {
  flex: 1;
  padding: 1rem;
  text-align: center;
  font-family: var(--font-display);
  font-weight: 500;
  font-size: 0.9375rem;
  color: var(--text-muted);
  cursor: pointer;
  border-bottom: 2px solid transparent;
  transition: color var(--dur), border-color var(--dur), background var(--dur);
  position: relative;
}
.feed-tab:hover { background: rgba(231,233,234,0.06); color: var(--text); }
.feed-tab.active {
  color: var(--text);
  font-weight: 700;
}
.feed-tab.active::after {
  content: '';
  position: absolute;
  bottom: -1px; left: 50%;
  transform: translateX(-50%);
  width: 60px; height: 4px;
  background: var(--accent);
  border-radius: var(--radius-full);
}

/* ── Post Composer ── */
.composer {
  display: flex;
  gap: 0.85rem;
  padding: 0.75rem 1rem 0;
  border-bottom: 1px solid var(--border);
}

.composer-body { flex: 1; display: flex; flex-direction: column; }

.composer textarea {
  background: transparent;
  border: none;
  color: var(--text);
  font-size: 1.1rem;
  resize: none;
  outline: none;
  width: 100%;
  min-height: 72px;
  line-height: 1.5;
  padding: 0.6rem 0;
}
.composer textarea::placeholder { color: var(--text-muted); }

.composer-actions {
  display: flex;
  align-items: center;
  justify-content: space-between;
  border-top: 1px solid var(--border);
  padding: 0.5rem 0 0.75rem;
}

.composer-tools {
  display: flex;
  gap: 0;
}

.composer-tool {
  width: 36px; height: 36px;
  display: flex; align-items: center; justify-content: center;
  border-radius: 50%;
  color: var(--accent);
  transition: background var(--dur);
  cursor: pointer;
}
.composer-tool:hover { background: var(--accent-light); }
.composer-tool svg { width: 18px; height: 18px; }

.char-count {
  font-size: 0.8rem;
  color: var(--text-muted);
}
.char-count.warning { color: var(--warning); }
.char-count.error   { color: var(--danger); }

/* ── Divider ── */
.divider {
  display: flex;
  align-items: center;
  gap: 1rem;
  color: var(--text-dim);
  font-size: 0.8rem;
  margin: 1rem 0;
}
.divider::before, .divider::after {
  content: '';
  flex: 1;
  height: 1px;
  background: var(--border);
}

/* ── Modal ── */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(91,112,131,0.4);
  z-index: 1000;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1rem;
  opacity: 0;
  pointer-events: none;
  transition: opacity var(--dur);
}
.modal-overlay.open {
  opacity: 1;
  pointer-events: all;
}

.modal {
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  width: 100%;
  max-width: 560px;
  max-height: 90vh;
  overflow-y: auto;
  transform: translateY(20px);
  transition: transform var(--dur) var(--ease);
}
.modal-overlay.open .modal { transform: translateY(0); }

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

.modal-body   { padding: 1.25rem 1rem; }
.modal-footer {
  padding: 0.75rem 1rem;
  border-top: 1px solid var(--border);
  display: flex;
  justify-content: flex-end;
  gap: 0.75rem;
}

/* ── Toast ── */
.toast-container {
  position: fixed;
  bottom: 1.5rem;
  left: 50%;
  transform: translateX(-50%);
  z-index: 2000;
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  align-items: center;
}

/* Lift toast above the mobile bottom nav */
@media (max-width: 599px) {
  .toast-container { bottom: 5rem; }
}

.toast {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  background: var(--accent);
  color: #fff;
  border-radius: var(--radius);
  padding: 0.85rem 1.25rem;
  font-size: 0.9375rem;
  font-weight: 500;
  animation: slideUp 0.3s var(--ease) forwards;
  box-shadow: 0 4px 24px rgba(0,0,0,0.6);
}
.toast.error { background: var(--danger); }

@keyframes slideUp {
  from { transform: translateY(20px); opacity: 0; }
  to   { transform: translateY(0);    opacity: 1; }
}
@keyframes slideDown {
  to { transform: translateY(20px); opacity: 0; }
}
.toast.hide { animation: slideDown 0.25s var(--ease) forwards; }

/* ── Right Panel ── */
.right-panel {
  padding: 0 1rem;
  position: sticky;
  top: 0;
  height: 100vh;
  overflow-y: auto;
}

.panel-card {
  background: var(--bg-3);
  border-radius: var(--radius-lg);
  overflow: hidden;
  margin: 1rem 0;
}

.panel-card-header {
  padding: 0.9rem 1rem;
  font-family: var(--font-display);
  font-size: 1.1rem;
  font-weight: 800;
}

/* ── Search bar ── */
.search-bar {
  position: relative;
}

.search-bar input {
  background: var(--bg-3);
  border: 1.5px solid transparent;
  border-radius: var(--radius-full);
  color: var(--text);
  padding: 0.65rem 1rem 0.65rem 2.75rem;
  width: 100%;
  font-size: 0.9375rem;
  outline: none;
  transition: border-color var(--dur), background var(--dur);
}
.search-bar input:focus {
  background: transparent;
  border-color: var(--accent);
}
.search-bar input::placeholder { color: var(--text-muted); }

.search-bar .search-icon {
  position: absolute;
  left: 0.85rem; top: 50%;
  transform: translateY(-50%);
  color: var(--text-muted);
  width: 18px; height: 18px;
  pointer-events: none;
}
.search-bar input:focus ~ .search-icon { color: var(--accent); }

/* ── Skeleton loader ── */
.skeleton {
  background: linear-gradient(90deg, var(--bg-3) 25%, var(--border) 50%, var(--bg-3) 75%);
  background-size: 200% 100%;
  animation: shimmer 1.4s infinite;
  border-radius: var(--radius);
}
@keyframes shimmer {
  from { background-position: 200% 0; }
  to   { background-position: -200% 0; }
}

.skeleton-avatar { border-radius: 50%; }
.skeleton-text   { height: 12px; margin: 4px 0; }

/* ── Mobile overrides ── */
@media (max-width: 599px) {
  /* Compose / post modal — bottom sheet */
  .compose-modal-overlay {
    align-items: flex-end !important;
    padding: 0 !important;
  }
  .compose-modal-overlay > div {
    border-radius: var(--radius-lg) var(--radius-lg) 0 0 !important;
    max-width: 100% !important;
    padding-bottom: max(1.25rem, env(safe-area-inset-bottom)) !important;
  }

  /* General modals — also bottom-sheet */
  .modal-overlay {
    align-items: flex-end;
    padding: 0;
  }
  .modal {
    border-radius: var(--radius-lg) var(--radius-lg) 0 0;
    max-width: 100%;
    max-height: 92vh;
  }

  /* Settings rows — stack on narrow screens */
  .settings-row {
    flex-wrap: wrap;
    gap: 0.75rem;
  }

  /* Right panel hidden — ensure it doesn't bleed */
  .right-panel { display: none !important; }

  /* Inputs — prevent iOS zoom (font-size >= 16px) */
  .input, input, textarea, select {
    font-size: 16px !important;
  }
}

/* ── Mobile slide-out drawer (X-style) ── */
.mobile-drawer-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0);
  z-index: 300;
  display: none;
  transition: background 300ms;
}
.mobile-drawer-backdrop.open { background: rgba(0,0,0,0.5); }

.mobile-drawer {
  position: fixed;
  top: 0; left: 0; bottom: 0;
  width: min(82vw, 320px);
  background: var(--bg);
  z-index: 301;
  transform: translateX(-100%);
  transition: transform 300ms cubic-bezier(0.22, 1, 0.36, 1);
  overflow-y: auto;
  overflow-x: hidden;
  overscroll-behavior: contain;
  padding-bottom: calc(1.5rem + env(safe-area-inset-bottom, 0px));
}
.mobile-drawer.open { transform: translateX(0); }

/* Drawer header row: large avatar left, close button right */
.drawer-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 1.25rem 1.25rem 0.5rem;
}
.drawer-close-btn {
  width: 34px; height: 34px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  background: none;
  border: none;
  color: var(--text-muted);
  cursor: pointer;
  transition: background var(--dur);
  -webkit-tap-highlight-color: transparent;
}
.drawer-close-btn:active { background: rgba(255,255,255,0.08); }
.drawer-close-btn svg { width: 20px; height: 20px; }

/* User info block */
.drawer-user-section {
  padding: 0.25rem 1.25rem 1.25rem;
  border-bottom: 1px solid var(--border);
}
.drawer-display-name {
  font-size: 1.0625rem;
  font-weight: 800;
  color: var(--text);
  margin-top: 0.5rem;
  line-height: 1.2;
}
.drawer-handle {
  font-size: 0.875rem;
  color: var(--text-muted);
  margin-top: 0.2rem;
}
.drawer-stats {
  display: flex;
  gap: 1.25rem;
  margin-top: 0.85rem;
  font-size: 0.875rem;
}
.drawer-stats a {
  display: flex;
  gap: 0.3rem;
  color: var(--text-muted);
  text-decoration: none;
}
.drawer-stats a:active { opacity: 0.7; }
.drawer-stat-count {
  font-weight: 700;
  color: var(--text);
}

/* Nav items */
.drawer-nav { padding: 0.5rem 0; }

.drawer-nav-item {
  display: flex;
  align-items: center;
  gap: 1.25rem;
  padding: 0.9rem 1.25rem;
  font-size: 1.0625rem;
  font-weight: 600;
  color: var(--text);
  text-decoration: none;
  width: 100%;
  background: none;
  border: none;
  text-align: left;
  cursor: pointer;
  font-family: inherit;
  line-height: 1.3;
  -webkit-tap-highlight-color: transparent;
  transition: background var(--dur);
}
.drawer-nav-item:active { background: rgba(255,255,255,0.05); }
.drawer-nav-item svg { width: 26px; height: 26px; flex-shrink: 0; }
.drawer-nav-item .item-label { flex: 1; }
.drawer-nav-item .item-badge {
  font-size: 0.75rem;
  background: var(--danger);
  color: #fff;
  border-radius: 999px;
  padding: 0.1rem 0.45rem;
  font-weight: 700;
  min-width: 20px;
  text-align: center;
}

/* Account row inside drawer */
.drawer-account-row {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 0.65rem 1.25rem;
  cursor: pointer;
  transition: background var(--dur);
  width: 100%;
  background: none;
  border: none;
  text-align: left;
  font-family: inherit;
  -webkit-tap-highlight-color: transparent;
}
.drawer-account-row:active { background: rgba(255,255,255,0.05); }
.drawer-account-row .acc-info { flex: 1; min-width: 0; }
.drawer-account-row .acc-name { font-weight: 700; font-size: 0.9375rem; color: var(--text); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.drawer-account-row .acc-handle { font-size: 0.8125rem; color: var(--text-muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.drawer-account-row .acc-check svg { color: var(--accent); }

/* Divider */
.drawer-divider {
  height: 1px;
  background: var(--border);
  margin: 0.4rem 0;
}

/* Section label */
.drawer-section-label {
  padding: 0.6rem 1.25rem 0.25rem;
  font-size: 0.78rem;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.08em;
  font-weight: 600;
}
