/* ==========================================================
   THE NEW DISCORD — styles
   ========================================================== */

:root {
  --bg-deep: #0b0e17;
  --bg-navy: #10141f;
  --bg-charcoal: #161a24;
  --panel: rgba(24, 28, 40, 0.62);
  --panel-strong: rgba(20, 23, 34, 0.82);
  --border-subtle: rgba(255, 255, 255, 0.08);
  --border-hover: rgba(255, 255, 255, 0.16);
  --text-primary: #f2f3f7;
  --text-secondary: #9aa3b8;
  --text-muted: #6b7488;
  --accent: #7c6cf6;
  --accent-strong: #6a58f0;
  --accent-soft: rgba(124, 108, 246, 0.16);
  --accent-gradient: linear-gradient(135deg, #7c6cf6 0%, #a06cf6 100%);
  --danger: #f0556c;
  --danger-soft: rgba(240, 85, 108, 0.14);
  --success: #4fd18b;
  --success-soft: rgba(79, 209, 139, 0.14);
  --gold: #d8b356;
  --gold-soft: rgba(216, 179, 86, 0.16);
  --radius-sm: 8px;
  --radius-md: 14px;
  --radius-lg: 20px;
  --shadow-soft: 0 8px 32px rgba(0, 0, 0, 0.35);
  --shadow-lift: 0 12px 40px rgba(0, 0, 0, 0.45);
  --sidebar-width: 260px;
}

* { box-sizing: border-box; }
html, body { height: 100%; margin: 0; padding: 0; }
body {
  font-family: "Inter", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  color: var(--text-primary);
  background: radial-gradient(circle at 20% 10%, #171c2c 0%, transparent 45%),
              radial-gradient(circle at 85% 80%, #1b1430 0%, transparent 50%),
              linear-gradient(160deg, var(--bg-deep) 0%, var(--bg-navy) 50%, var(--bg-charcoal) 100%);
  overflow: hidden;
}
button, input, textarea { font-family: inherit; }
.hidden { display: none !important; }
.glass {
  background: var(--panel);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  border: 1px solid var(--border-subtle);
  box-shadow: var(--shadow-soft);
}

.screen { position: fixed; inset: 0; display: flex; align-items: center; justify-content: center; }
#main-app.screen { align-items: stretch; justify-content: stretch; flex-direction: column; }

.loading-brand { display: flex; flex-direction: column; align-items: center; gap: 14px; }
.loading-title { font-size: 22px; font-weight: 600; letter-spacing: 0.3px; }
.spinner { width: 28px; height: 28px; border-radius: 50%; border: 3px solid var(--border-subtle); border-top-color: var(--accent); animation: spin 0.8s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

.logo-mark { width: 56px; height: 56px; border-radius: var(--radius-md); background: var(--accent-gradient); display: flex; align-items: center; justify-content: center; font-weight: 700; font-size: 20px; color: white; box-shadow: 0 6px 20px rgba(124, 108, 246, 0.4); }
.logo-mark.small { width: 34px; height: 34px; font-size: 13px; border-radius: 9px; }

.auth-card { width: 380px; max-width: 92vw; padding: 32px 28px; border-radius: var(--radius-lg); }
.auth-brand { display: flex; flex-direction: column; align-items: center; gap: 10px; margin-bottom: 22px; }
.auth-brand h1 { margin: 4px 0 0; font-size: 22px; font-weight: 700; }
.auth-subtitle { margin: 0; color: var(--text-secondary); font-size: 13px; }
.auth-tabs { display: flex; background: rgba(255, 255, 255, 0.04); border-radius: var(--radius-sm); padding: 4px; margin-bottom: 20px; }
.auth-tab { flex: 1; padding: 9px 0; border: none; background: transparent; color: var(--text-secondary); border-radius: 6px; cursor: pointer; font-weight: 600; font-size: 13.5px; transition: all 0.18s ease; }
.auth-tab.active { background: var(--accent-soft); color: var(--text-primary); }
.auth-form { display: flex; flex-direction: column; gap: 4px; }
.field-label { font-size: 12.5px; font-weight: 600; color: var(--text-secondary); margin: 12px 0 6px; display: flex; justify-content: space-between; }
.field-input { width: 100%; padding: 11px 13px; border-radius: var(--radius-sm); border: 1px solid var(--border-subtle); background: rgba(255, 255, 255, 0.03); color: var(--text-primary); font-size: 14px; outline: none; resize: vertical; transition: border-color 0.15s ease, background 0.15s ease; }
.field-input:focus { border-color: var(--accent); background: rgba(124, 108, 246, 0.06); }
.char-counter { font-weight: 400; color: var(--text-muted); font-size: 11.5px; }
.auth-error { margin-top: 10px; padding: 9px 12px; border-radius: var(--radius-sm); background: var(--danger-soft); border: 1px solid rgba(240, 85, 108, 0.3); color: #ffb3bd; font-size: 13px; }

.btn { border: none; border-radius: var(--radius-sm); padding: 11px 18px; font-weight: 600; font-size: 14px; cursor: pointer; display: inline-flex; align-items: center; justify-content: center; gap: 8px; transition: transform 0.12s ease, filter 0.15s ease, background 0.15s ease; }
.btn:hover { filter: brightness(1.08); }
.btn:active { transform: scale(0.98); }
.btn-block { width: 100%; margin-top: 18px; }
.btn-primary { background: var(--accent-gradient); color: white; }
.btn-secondary { background: rgba(255, 255, 255, 0.06); color: var(--text-primary); border: 1px solid var(--border-subtle); }
.btn-secondary:hover { background: rgba(255, 255, 255, 0.1); }
.btn-danger { background: var(--danger); color: white; }
.btn-spinner { width: 14px; height: 14px; border-radius: 50%; border: 2px solid rgba(255,255,255,0.4); border-top-color: white; animation: spin 0.7s linear infinite; }
.icon-btn { background: transparent; border: none; color: var(--text-secondary); height: 34px; min-width: 34px; padding: 0 8px; border-radius: var(--radius-sm); display: flex; align-items: center; justify-content: center; cursor: pointer; font-size: 13px; font-weight: 500; transition: background 0.15s ease, color 0.15s ease; }
.icon-btn:hover { background: rgba(255,255,255,0.07); color: var(--text-primary); }

.blocked-card { width: 420px; max-width: 90vw; padding: 40px 32px; border-radius: var(--radius-lg); text-align: center; }
.blocked-icon { font-size: 40px; margin-bottom: 14px; }
.blocked-card h1 { font-size: 19px; color: #ffb3bd; margin: 0 0 10px; }
.blocked-card p { color: var(--text-secondary); font-size: 13.5px; margin-bottom: 20px; }

.broadcast-banner { background: var(--accent-gradient); color: white; text-align: center; padding: 10px 16px; font-weight: 600; font-size: 13.5px; box-shadow: 0 4px 20px rgba(124, 108, 246, 0.35); animation: bannerIn 0.25s ease; }
@keyframes bannerIn { from { transform: translateY(-100%); } to { transform: translateY(0); } }
.app-shell { flex: 1; display: flex; min-height: 0; }

.sidebar { width: var(--sidebar-width); flex-shrink: 0; display: flex; flex-direction: column; border-right: 1px solid var(--border-subtle); }
.sidebar-header { display: flex; align-items: center; gap: 10px; padding: 16px 14px; border-bottom: 1px solid var(--border-subtle); }
.sidebar-title { font-weight: 700; font-size: 14.5px; }
.connection-status { display: flex; align-items: center; gap: 7px; padding: 10px 16px; font-size: 11.5px; color: var(--text-muted); }
.status-dot { width: 7px; height: 7px; border-radius: 50%; background: var(--text-muted); }
.status-dot.connected { background: var(--success); box-shadow: 0 0 8px rgba(79,209,139,0.6); }
.channel-list { padding: 6px 10px; display: flex; flex-direction: column; gap: 2px; }
.channel-btn { display: flex; align-items: center; gap: 8px; padding: 8px 10px; border: none; background: transparent; color: var(--text-secondary); border-radius: var(--radius-sm); cursor: pointer; font-size: 14px; text-align: left; transition: background 0.15s ease, color 0.15s ease; }
.channel-btn:hover { background: rgba(255,255,255,0.05); color: var(--text-primary); }
.channel-btn.active { background: var(--accent-soft); color: var(--text-primary); font-weight: 600; }
.channel-btn.unread {
  background: rgba(255, 215, 0, 0.22) !important;
  color: #ffd700 !important;
  font-weight: 600;
  box-shadow: inset 0 0 0 1px rgba(255, 215, 0, 0.45);
}
.channel-btn.unread.active {
  background: rgba(255, 215, 0, 0.28) !important;
  color: #ffd700 !important;
}
.sidebar-section-title { font-size: 11px; text-transform: uppercase; font-weight: 700; color: var(--text-muted); margin: 10px 14px 4px; }
.sidebar-spacer { flex: 1; overflow-y: auto; }
.user-panel { display: flex; align-items: center; gap: 10px; padding: 10px 12px; border-top: 1px solid var(--border-subtle); }
.user-avatar-btn { background: none; border: none; padding: 0; cursor: pointer; border-radius: 50%; }
.avatar { width: 36px; height: 36px; border-radius: 50%; object-fit: cover; display: block; background: var(--bg-charcoal); }
.avatar.large { width: 76px; height: 76px; }
.user-panel-info { flex: 1; min-width: 0; }
.user-panel-name { font-size: 13.5px; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.user-panel-role { font-size: 11px; color: var(--text-muted); }
.user-panel-actions { display: flex; gap: 2px; }

.chat-area { flex: 1; display: flex; flex-direction: column; min-width: 0; position: relative; }
.chat-header { display: flex; align-items: center; justify-content: space-between; padding: 14px 20px; }
.chat-header-left { display: flex; align-items: center; gap: 10px; }
.channel-name { font-weight: 700; font-size: 15px; }
.chat-header-right { display: flex; align-items: center; gap: 8px; }
.messages-scroll { flex: 1; overflow-y: auto; padding: 16px 20px; }
.messages-list { display: flex; flex-direction: column; gap: 2px; }
.message-row { display: flex; gap: 12px; padding: 6px 8px; border-radius: var(--radius-sm); position: relative; transition: background 0.12s ease; }
.message-row:hover { background: rgba(255,255,255,0.025); }
.message-row.highlighted-reply { background: var(--gold-soft); }
.message-body { flex: 1; min-width: 0; }
.message-meta { display: flex; align-items: baseline; gap: 8px; }
.message-author { font-weight: 600; font-size: 14px; cursor: pointer; }
.message-time { font-size: 11px; color: var(--text-muted); }
.message-text { font-size: 14.5px; line-height: 1.5; white-space: pre-wrap; word-break: break-word; margin-top: 2px; }
.message-actions { position: absolute; top: -14px; right: 8px; display: none; background: var(--panel-strong); border: 1px solid var(--border-subtle); border-radius: var(--radius-sm); padding: 2px; gap: 2px; box-shadow: var(--shadow-soft); }
.message-row:hover .message-actions { display: flex; }

.typing-indicator { margin: 0 20px 6px; font-size: 12px; color: var(--text-muted); font-style: italic; min-height: 18px; }
.search-dropdown-results { margin-top: 5px; max-height: 200px; overflow-y: auto; background: var(--panel-strong); border: 1px solid var(--border-subtle); border-radius: var(--radius-sm); }
.search-result-item { padding: 10px; cursor: pointer; display: flex; align-items: center; gap: 10px; transition: background 0.1s; }
.search-result-item:hover { background: rgba(255,255,255,0.05); }

.empty-state { text-align: center; color: var(--text-muted); padding: 40px 0; font-size: 14px; }
.new-messages-btn { position: absolute; align-self: center; bottom: 130px; left: 50%; transform: translateX(-50%); background: var(--accent); color: white; border: none; padding: 7px 16px; border-radius: 20px; font-size: 12.5px; font-weight: 600; cursor: pointer; box-shadow: var(--shadow-lift); }

.mute-notice { margin: 0 20px 8px; padding: 8px 14px; background: var(--danger-soft); border: 1px solid rgba(240, 85, 108, 0.3); border-radius: var(--radius-sm); color: #ffb3bd; font-size: 12.5px; }
.reply-preview { margin: 0 20px 6px; padding: 8px 14px; background: rgba(255,255,255,0.04); border-left: 3px solid var(--accent); border-radius: var(--radius-sm); display: flex; align-items: center; justify-content: space-between; font-size: 13px; }
.composer { display: flex; align-items: flex-end; gap: 8px; margin: 0 20px 20px; padding: 8px 10px; background: rgba(255,255,255,0.035); border: 1px solid var(--border-subtle); border-radius: var(--radius-md); }
.composer-icon { flex-shrink: 0; }
.send-btn { color: var(--accent); }
.message-input { flex: 1; background: transparent; border: none; outline: none; color: var(--text-primary); font-size: 14.5px; resize: none; max-height: 160px; padding: 8px 4px; line-height: 1.4; }

/* DM Home */
#dm-home-view { padding: 20px; flex: 1; overflow-y: auto; display: flex; flex-direction: column; }
.dm-home-layout { display: flex; gap: 24px; align-items: flex-start; max-width: 900px; }
.dm-home-search-col { flex: 1; min-width: 0; max-width: 400px; }
.dm-home-list-col { flex: 1; min-width: 220px; max-width: 320px; }
.dm-home-list-col .channel-list { padding: 0; max-height: 420px; overflow-y: auto; }
.dm-home-list-col .sidebar-section-title { margin: 0 0 8px 0; }

.modal-overlay { position: fixed; inset: 0; background: rgba(6, 8, 14, 0.6); display: flex; align-items: center; justify-content: center; z-index: 100; padding: 20px; }
.modal { width: 440px; max-width: 100%; max-height: 86vh; display: flex; flex-direction: column; border-radius: var(--radius-lg); overflow: hidden; }
.modal.small { width: 380px; }
.modal-header { display: flex; align-items: center; justify-content: space-between; padding: 18px 20px; border-bottom: 1px solid var(--border-subtle); }
.modal-header h2 { margin: 0; font-size: 16px; }
.modal-body { padding: 18px 20px; overflow-y: auto; }
.modal-footer { display: flex; justify-content: flex-end; gap: 10px; padding: 16px 20px; border-top: 1px solid var(--border-subtle); }

.view-profile-body { display: flex; flex-direction: column; align-items: center; text-align: center; gap: 4px; }
.vp-name { font-size: 17px; font-weight: 700; margin-top: 10px; }
.vp-username { font-size: 12.5px; color: var(--text-muted); }
.vp-role { font-size: 11.5px; color: var(--accent); font-weight: 600; text-transform: uppercase; letter-spacing: 0.4px; }
.vp-bio { font-size: 13.5px; color: var(--text-secondary); margin-top: 10px; white-space: pre-wrap; }
.staff-menu-body { display: flex; flex-direction: column; gap: 10px; }

.user-search-results { margin-top: 12px; display: flex; flex-direction: column; gap: 4px; max-height: 320px; overflow-y: auto; }
.user-result-row { display: flex; align-items: center; gap: 10px; padding: 8px 10px; border-radius: var(--radius-sm); cursor: pointer; transition: background 0.15s ease; }
.user-result-row:hover { background: rgba(255,255,255,0.05); }
.user-result-info { flex: 1; min-width: 0; }
.user-result-name { font-size: 13.5px; font-weight: 600; }
.user-result-sub { font-size: 11.5px; color: var(--text-muted); }

.manage-user-header { display: flex; align-items: center; gap: 12px; margin-bottom: 16px; }
.mu-display-name { font-size: 15px; font-weight: 700; }
.mu-username { font-size: 12px; color: var(--text-muted); }
.mu-actions { display: flex; flex-direction: column; gap: 8px; }

.block-requests-list { display: flex; flex-direction: column; gap: 10px; }
.block-request-card { padding: 12px 14px; background: rgba(255,255,255,0.035); border: 1px solid var(--border-subtle); border-radius: var(--radius-sm); }
.br-target { font-weight: 600; font-size: 13.5px; }

.toast-container { position: fixed; bottom: 20px; right: 20px; display: flex; flex-direction: column; gap: 8px; z-index: 200; }
.toast { padding: 12px 16px; border-radius: var(--radius-sm); background: var(--panel-strong); border: 1px solid var(--border-subtle); color: var(--text-primary); font-size: 13.5px; box-shadow: var(--shadow-lift); animation: toastIn 0.2s ease; max-width: 320px; }
.toast.success { border-color: rgba(79,209,139,0.4); }
.toast.error { border-color: rgba(240,85,108,0.4); }
@keyframes toastIn { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: translateY(0); } }

.mobile-only { display: none; }
@media (max-width: 860px) {
  .mobile-only { display: flex; }
  .sidebar { position: fixed; left: 0; top: 0; bottom: 0; z-index: 50; transform: translateX(-100%); transition: transform 0.22s ease; }
  .sidebar.open { transform: translateX(0); }
  .modal { width: 100%; }
  .dm-home-layout { flex-direction: column; }
  .dm-home-search-col, .dm-home-list-col { max-width: 100%; }
}
