/* ──────────────────────────────────────────
   DESIGN TOKENS — LIGHT THEME
────────────────────────────────────────── */
html {
  --font-size-0: 0.78rem;
  --font-size-1: 0.95rem;
  --font-size-1-5: 1.05rem;
  --font-size-2: 1.15rem;
  --font-size-3: 1.35rem;
  --font-size-4: 1.55rem;
  --font-size-5: 1.8rem;
  --font-size-6: 2rem;
  --font-size-7: 2.3rem;
  --font-size-8: 2.6rem;

  /* Backgrounds */
  --bg-deep: #f0f4ff;
  --bg-surface: #ffffff;
  --bg-panel: rgba(255, 255, 255, 0.85);
  --bg-glass: rgba(255, 255, 255, 0.72);
  --bg-input: rgba(255, 255, 255, 0.9);

  /* Accent — violet + cyan (same as dark, works on light too) */
  --accent-violet: #7c3aed;
  --accent-violet-2: #6d28d9;
  --accent-cyan: #0891b2;
  --accent-cyan-2: #0e7490;
  --accent-gradient: linear-gradient(135deg, var(--accent-violet), var(--accent-cyan));

  /* Text */
  --text-primary: #1e1b4b;
  --text-secondary: #4b5563;
  --text-muted: #9ca3af;
  --text-accent: #7c3aed;

  /* Borders */
  --border-subtle: rgba(124, 58, 237, 0.1);
  --border-glass: rgba(124, 58, 237, 0.18);
  --border-accent: rgba(124, 58, 237, 0.4);

  /* Status */
  --friend-status-online: #059669;
  --friend-status-offline: #d1d5db;
  --friend-status-dimension: 9px;

  /* Error */
  --color-error-box: rgba(220, 38, 38, 0.08);
  --color-error-text: #b91c1c;
  --color-danger-zone: #dc2626;

  /* Message bubbles */
  --bubble-other: #ffffff;

  /* Sidebar */
  --friends-section-width-1: 92%;
  --friends-section-width-2: 21rem;
  --friends-section-width-3: 82%;
  --friends-chat-section-from-top-1: 3.5rem;
  --friends-chat-section-from-top-2: 4.8rem;
  --friends-chat-section-from-left-right: 0;
  --friends-selection-border-radius: 14px;
  --friends-chat-section-inner-border-radius: 14px;

  /* Misc */
  --user-messages-color: rgba(124, 58, 237, 0.12);
  --radius-sm: 8px;
  --radius-md: 14px;
  --radius-lg: 20px;
  --radius-pill: 999px;
  --shadow-glow-violet: 0 0 14px rgba(124, 58, 237, 0.22);
  --shadow-glow-cyan: 0 0 14px rgba(8, 145, 178, 0.18);
  --shadow-panel: 0 4px 24px rgba(99, 58, 200, 0.08);
  --shadow-card: 0 2px 12px rgba(99, 58, 200, 0.07);
}

/* ──────────────────────────────────────────
   RESET & BASE
────────────────────────────────────────── */
*,
*::before,
*::after {
  box-sizing: border-box;
}

html {
  scroll-behavior: smooth;
}

body {
  margin: 0;
  background:
    radial-gradient(ellipse at 0% 0%, rgba(124, 58, 237, 0.08) 0%, transparent 50%),
    radial-gradient(ellipse at 100% 0%, rgba(8, 145, 178, 0.07) 0%, transparent 45%),
    radial-gradient(ellipse at 100% 100%, rgba(124, 58, 237, 0.05) 0%, transparent 40%),
    linear-gradient(180deg, #f5f3ff 0%, #eff6ff 100%);
  background-attachment: fixed;
  font-family: "Inter", "Manrope", sans-serif;
  color: var(--text-primary);
  font-size: var(--font-size-1);
  min-height: 100vh;
}

ul {
  list-style: none;
  margin: 0;
  padding: 0;
}

/* ──────────────────────────────────────────
   HEADER
────────────────────────────────────────── */
#main-header {
  box-sizing: border-box;
  margin: 0;
  background: rgba(255, 255, 255, 0.85);
  border-bottom: 1px solid var(--border-subtle);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  position: sticky;
  top: 0;
  z-index: 15;
  box-shadow: 0 1px 12px rgba(99, 58, 200, 0.07);
}

.main-header-content {
  margin: 0;
  padding: 0 1.2rem;
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  align-items: center;
  height: 3.5rem;
  gap: 0.75rem;
}

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

.header-right {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 0.5rem;
}

.main-header-content-error-page {
  padding: 2rem;
}

.main-header-content-error-page h1 {
  font-size: var(--font-size-4);
  margin-top: 0;
}

#main-header p {
  margin: 0;
  font-size: var(--font-size-1);
  color: var(--text-secondary);
}

#main-header a {
  text-decoration: none;
  color: inherit;
}

#main-header .website-logo {
  font-family: "Space Grotesk", sans-serif;
  font-weight: 700;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  font-size: var(--font-size-2);
  background: var(--accent-gradient);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
  display: flex;
  align-items: center;
  gap: 0.4rem;
}

#main-header .website-logo .logo-dot {
  display: inline-block;
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--accent-gradient);
  -webkit-text-fill-color: unset;
  margin-bottom: 1px;
  box-shadow: var(--shadow-glow-violet);
}

#main-header .chat-status {
  display: none;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
}

#main-header .chat-status-chip {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.28rem 0.8rem;
  border-radius: var(--radius-pill);
  background: rgba(124, 58, 237, 0.07);
  border: 1px solid var(--border-glass);
  font-size: var(--font-size-0);
  color: var(--text-secondary);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 16rem;
}

.header-user-name {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

#main-header p.user-chat-status {
  margin: 0;
  padding: 0;
  width: var(--friend-status-dimension);
  height: var(--friend-status-dimension);
  border-radius: 100%;
  border: none;
  flex-shrink: 0;
}

#main-header p.user-chat-status-offline {
  background-color: var(--friend-status-offline);
}

#main-header p.user-chat-status-online {
  background-color: var(--friend-status-online);
  box-shadow: 0 0 5px var(--friend-status-online);
}

#main-header a {
  font-weight: bold;
}

/* ── Header logout and profile button ── */
#main-header .log-out-btn,
#main-header .profile-btn,
#main-header .header-profile-link {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 36px;
  height: 36px;
  border: 1px solid var(--border-glass);
  border-radius: var(--radius-pill);
  background: rgba(124, 58, 237, 0.06);
  cursor: pointer;
  color: var(--text-secondary);
  transition: background 150ms ease, color 150ms ease, border-color 150ms ease;
  padding: 0;
  font: inherit;
}

#main-header .sidebar-toggle-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 36px;
  height: 36px;
  border: 1px solid var(--border-glass);
  border-radius: var(--radius-pill);
  background: rgba(124, 58, 237, 0.06);
  color: var(--text-secondary);
  cursor: pointer;
  margin-right: 0.55rem;
}

#main-header .header-user-avatar {
  width: 20px;
  height: 20px;
  border-radius: 50%;
  background: var(--accent-gradient);
  color: #fff;
  font-size: 0.62rem;
  font-weight: 700;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

#main-header .header-user-presence {
  color: var(--text-muted);
  font-size: 0.72rem;
}

/* ──────────────────────────────────────────
   CHAT APP SHELL
────────────────────────────────────────── */
#chat-page-main {
  position: relative;
  height: calc(100vh - 3.5rem);
  min-height: calc(100vh - 3.5rem);
  padding: 0.75rem;
}

.chat-app-shell {
  display: flex;
  gap: 0.75rem;
  height: calc(100vh - 5rem);
  min-height: calc(100vh - 5rem);
  width: 100%;
}

body.auth-mode #chat-app-shell,
body.auth-mode #mobile-sidebar-backdrop {
  display: none !important;
}

.chat-main-pane {
  display: flex;
  gap: 0.75rem;
  align-items: stretch;
  flex: 1;
  min-width: 0;
  min-height: 0;
  overflow: hidden;
  padding: 0.6rem;
  border-radius: var(--radius-md);
  border: 1px solid var(--border-glass);
  background: rgba(255, 255, 255, 0.6);
  box-shadow: var(--shadow-panel);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
}

.right-panel-content {
  width: min(24rem, 38%);
  min-width: 18rem;
  display: flex;
  min-height: 0;
}

.right-panel-content .sidebar-tab-content {
  width: 100%;
}

.chat-main-pane.sidebar-content-only .right-panel-content {
  width: 100%;
  min-width: 0;
}

.chat-main-pane.sidebar-content-only #chat-section {
  display: none !important;
}

.chat-main-pane.conversation-focus .right-panel-content {
  display: none;
  width: 0;
  min-width: 0;
}

.chat-main-pane.conversation-focus #chat-section {
  display: flex;
  flex: 1;
  min-width: 0;
}

.mobile-sidebar-backdrop {
  position: fixed;
  inset: 3.5rem 0 0 0;
  background: rgba(30, 27, 75, 0.25);
  z-index: 20;
}

#main-header .header-profile-link {
  text-decoration: none;
}

#main-header .log-out-btn:disabled {
  cursor: auto;
  opacity: 0.4;
}

/* ──────────────────────────────────────────
   BUTTONS
────────────────────────────────────────── */
.btn {
  font-family: "Space Grotesk", sans-serif;
  font-weight: 600;
  letter-spacing: 0.01em;
  padding: 0.75rem 1.25rem;
  background: var(--accent-gradient);
  border: 1px solid transparent;
  color: #fff;
  border-radius: var(--radius-pill);
  cursor: pointer;
  font-size: var(--font-size-1);
  width: 10rem;
  box-shadow: 0 4px 16px rgba(124, 58, 237, 0.3);
  transition: transform 160ms ease, box-shadow 160ms ease, filter 160ms ease;
  position: relative;
  overflow: hidden;
}

.btn::after {
  content: '';
  position: absolute;
  inset: 0;
  background: linear-gradient(135deg, rgba(255, 255, 255, 0.15), transparent);
  pointer-events: none;
}

.btn-alt {
  background: rgba(255, 255, 255, 0.9);
  border-color: var(--border-glass);
  color: var(--text-primary);
  box-shadow: var(--shadow-card);
}

.btn-alt::after {
  display: none;
}

/* ──────────────────────────────────────────
   LOADER
────────────────────────────────────────── */
.loader {
  border: 3px solid rgba(124, 58, 237, 0.12);
  border-top: 3px solid var(--accent-violet);
  border-radius: 50%;
  animation: spin 0.65s linear infinite;
}

#main-loader {
  margin: 10rem auto;
  width: 2rem;
  height: 2rem;
}

@keyframes spin {
  0% {
    transform: rotate(0deg);
  }

  100% {
    transform: rotate(360deg);
  }
}

/* ──────────────────────────────────────────
   RESPONSIVE
────────────────────────────────────────── */
@media (min-width: 480px) {
  #main-header .website-logo {
    font-size: var(--font-size-3);
  }

  #main-loader {
    border-width: 4px;
    border-top-width: 4px;
    width: 3rem;
    height: 3rem;
  }
}

@media (min-width: 768px) {
  #main-header p {
    font-size: var(--font-size-2);
  }

  .main-header-content {
    padding: 0 1.4rem;
    height: 4.8rem;
  }

  #chat-page-main {
    height: calc(100vh - 4.8rem);
    min-height: calc(100vh - 4.8rem);
    padding: 1rem;
  }

  .chat-app-shell {
    height: calc(100vh - 6.8rem);
    min-height: calc(100vh - 6.8rem);
  }

  .chat-main-pane {
    height: calc(100vh - 8rem);
    min-height: calc(100vh - 8rem);
  }

  #main-header .sidebar-toggle-btn {
    display: none;
  }
}

@media (max-width: 1023px) {
  .chat-main-pane {
    flex-direction: column;
  }

  .right-panel-content {
    width: 100%;
    min-width: 0;
  }
}

@media (min-width: 1024px) {
  .main-header-content {
    padding: 0 2rem;
  }
}

/* ──────────────────────────────────────────
   HOVER STATES
────────────────────────────────────────── */
@media (hover: hover) {
  .btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 8px 24px rgba(124, 58, 237, 0.4);
    filter: brightness(1.06);
  }

  .btn-alt:hover {
    background: #ffffff;
    border-color: rgba(124, 58, 237, 0.3);
    box-shadow: 0 4px 14px rgba(124, 58, 237, 0.1);
  }

  .btn:disabled {
    background: rgba(124, 58, 237, 0.35);
    box-shadow: none;
    cursor: default;
    transform: none;
  }

  .btn-alt:disabled {
    opacity: 0.5;
    cursor: default;
  }

  #main-header .log-out-btn:hover {
    background: rgba(220, 38, 38, 0.07);
    border-color: rgba(220, 38, 38, 0.25);
    color: #b91c1c;
  }

  #main-header .header-profile-link:hover {
    background: rgba(14, 165, 233, 0.1);
    border-color: rgba(14, 165, 233, 0.25);
    color: #0369a1;
  }

  #main-header .sidebar-toggle-btn:hover {
    background: rgba(124, 58, 237, 0.14);
    border-color: rgba(124, 58, 237, 0.28);
    color: var(--accent-violet);
  }
}

@media (hover: none) {}