/* ============================================================
   SCRATCH CHAT — Stylesheet
   ساختار: متغیرها → ریست → اسکرول‌بار → چیدمان → سایدبار
           → چت → پیام‌ها → کامپوزر → حالت خالی → موبایل
           → انیمیشن‌ها → احراز هویت
   ============================================================ */

/* ---------- 1. متغیرها ---------- */
:root {
  /* رنگ پس‌زمینه */
  --bg: #06090d;
  --bg-2: #0b1118;
  --bg-card: rgba(13, 19, 28, 0.88);
  --bg-input: rgba(8, 18, 28, 0.82);
  --bg-hover: rgba(0, 255, 255, 0.1);

  /* رنگ متن */
  --text: #eafaff;
  --text-soft: #b9dff1;
  --text-muted: #7ea3b8;

  /* رنگ نئون */
  --neon: #00ffff;
  --neon-2: #00cfff;
  --border: rgba(0, 255, 255, 0.18);

  /* افکت نئون */
  --glow: 0 0 18px rgba(0, 255, 255, 0.3);
  --glow-strong: 0 0 32px rgba(0, 255, 255, 0.55);

  /* اندازه‌ها */
  --radius: 16px;
  --radius-sm: 10px;
  --radius-lg: 22px;
  --radius-pill: 999px;
  --sidebar-w: 320px;

  /* انیمیشن */
  --transition: all 0.22s ease;
}

/* ---------- 2. ریست ---------- */
*,
*::before,
*::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

html {
  height: 100%;
  -webkit-text-size-adjust: 100%;
  -webkit-tap-highlight-color: transparent;
}

body {
  height: 100%;
  font-family: 'Vazirmatn', system-ui, sans-serif;
  font-size: 15px;
  line-height: 1.55;
  color: var(--text);
  overflow: hidden;
  overscroll-behavior: none;
  -webkit-font-smoothing: antialiased;
  background:
    radial-gradient(ellipse at top, rgba(0, 207, 255, 0.08), transparent 55%),
    radial-gradient(ellipse at bottom, rgba(0, 255, 255, 0.05), transparent 55%),
    var(--bg);
}

/* ---------- 3. اسکرول‌بار ---------- */
* {
  scrollbar-width: thin;
  scrollbar-color: rgba(0, 255, 255, 0.25) transparent;
}

::-webkit-scrollbar {
  width: 6px;
  height: 6px;
}

::-webkit-scrollbar-thumb {
  background: rgba(0, 255, 255, 0.2);
  border-radius: var(--radius-pill);
}

::-webkit-scrollbar-thumb:hover {
  background: rgba(0, 255, 255, 0.4);
}

/* ---------- 4. چیدمان کلی ---------- */
.app {
  display: flex;
  height: 100vh;
  height: 100dvh; /* رفع باگ ارتفاع در موبایل */
  overflow: hidden;
}

/* ---------- 5. سایدبار ---------- */
.sidebar {
  width: var(--sidebar-w);
  flex-shrink: 0;
  display: flex;
  flex-direction: column;
  background: var(--bg-2);
  border-left: 1px solid var(--border);
}

.sidebar-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 10px;
  padding: 18px;
  font-size: 1.05rem;
  font-weight: 700;
  border-bottom: 1px solid var(--border);
  background: linear-gradient(180deg, rgba(0, 255, 255, 0.06), transparent);
}

.room-list {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  padding: 8px;
  list-style: none;
}

/* آیتم لیست گفتگوها — هاور نئونی */
.room-item {
  position: relative;
  display: block;
  padding: 12px 14px;
  font-size: 0.95rem;
  color: var(--text-soft);
  text-decoration: none;
  cursor: pointer;
  border: 1px solid transparent;
  border-right: 3px solid transparent;
  border-radius: var(--radius-sm);
  transition: var(--transition);
}

.room-item:hover {
  color: var(--text);
  background: var(--bg-hover);
  border-color: rgba(0, 255, 255, 0.3);
  border-right-color: var(--neon);
  box-shadow:
    0 0 16px rgba(0, 255, 255, 0.18),
    inset 0 0 20px rgba(0, 255, 255, 0.06);
  text-shadow: 0 0 10px rgba(0, 255, 255, 0.5);
  transform: translateX(-3px);
}

.room-item.active {
  color: var(--neon);
  font-weight: 600;
  background: var(--bg-hover);
  border-color: rgba(0, 255, 255, 0.3);
  border-right-color: var(--neon);
  box-shadow:
    inset 0 0 20px rgba(0, 255, 255, 0.08),
    0 0 12px rgba(0, 255, 255, 0.12);
}

/* ---------- 6. پنل چت ---------- */
.chat {
  flex: 1;
  min-width: 0;
  min-height: 0;
  display: flex;
  flex-direction: column;
  background: var(--bg);
}

.chat-header {
  position: relative;
  z-index: 2;
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 16px 18px;
  font-weight: 700;
  border-bottom: 1px solid var(--border);
  background: var(--bg-2);
  box-shadow: 0 4px 20px rgba(0, 0, 0, 0.25);
}

.chat-header .back {
  display: none;
  padding: 4px 10px;
  font-size: 1.4rem;
  line-height: 1;
  color: var(--neon);
  text-decoration: none;
  border-radius: var(--radius-sm);
  transition: var(--transition);
}

.chat-header .back:hover {
  background: var(--bg-hover);
  text-shadow: 0 0 12px var(--neon);
}

/* ---------- 7. پیام‌ها ---------- */
.messages {
  flex: 1;
  min-height: 0;
  display: flex;
  flex-direction: column;
  gap: 10px;
  padding: 18px 16px;
  overflow-y: auto;
  scroll-behavior: smooth;
}

.msg {
  align-self: flex-start;
  max-width: min(72%, 560px);
  padding: 10px 14px;
  line-height: 1.55;
  color: var(--text);
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  word-wrap: break-word;
  overflow-wrap: anywhere;
  animation: fadeIn 0.2s ease both;
}

.msg.me {
  align-self: flex-end;
  color: #001018;
  background: linear-gradient(135deg, var(--neon-2), var(--neon));
  border-color: transparent;
  box-shadow: var(--glow);
}

.msg .author {
  display: block;
  margin-bottom: 3px;
  font-size: 0.72rem;
  font-weight: 600;
  color: var(--text-muted);
}

.msg.me .author {
  color: rgba(0, 16, 24, 0.7);
}

/* ---------- 8. نوار ارسال ---------- */
.composer {
  display: flex;
  gap: 8px;
  padding: 12px 14px calc(12px + env(safe-area-inset-bottom, 0px));
  border-top: 1px solid var(--border);
  background: var(--bg-2);
  box-shadow: 0 -4px 20px rgba(0, 0, 0, 0.25);
}

.composer input {
  flex: 1;
  min-width: 0;
  padding: 11px 16px;
  font-family: inherit;
  font-size: 0.95rem;
  color: var(--text);
  background: var(--bg-input);
  border: 1px solid var(--border);
  border-radius: var(--radius-pill);
  outline: none;
  transition: var(--transition);
}

.composer input::placeholder {
  color: var(--text-muted);
}

.composer input:focus {
  background: rgba(8, 18, 28, 0.95);
  border-color: var(--neon);
  box-shadow: var(--glow);
}

.composer button {
  padding: 11px 22px;
  font-family: inherit;
  font-size: 0.95rem;
  font-weight: 700;
  color: #001018;
  white-space: nowrap;
  cursor: pointer;
  background: linear-gradient(135deg, var(--neon-2), var(--neon));
  border: none;
  border-radius: var(--radius-pill);
  transition: var(--transition);
}

.composer button:hover {
  box-shadow: var(--glow-strong);
  transform: translateY(-1px);
}

/* ---------- 9. حالت خالی ---------- */
.empty-state {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
  font-size: 0.95rem;
  line-height: 1.7;
  color: var(--text-muted);
  text-align: center;
}

/* ---------- 10. ریسپانسیو — موبایل ---------- */
@media (max-width: 768px) {
  .sidebar {
    width: 100%;
    border-left: none;
  }

  .chat {
    display: none;
  }

  .chat.mobile-show {
    display: flex;
  }

  .sidebar.mobile-hide {
    display: none;
  }

  .chat-header .back {
    display: inline-block;
  }

  .chat-header,
  .sidebar-header {
    padding-top: max(16px, env(safe-area-inset-top, 0px));
  }
}

/* ---------- 11. انیمیشن‌ها ---------- */
@keyframes fadeIn {
  from {
    opacity: 0;
    transform: translateY(6px);
  }
  to {
    opacity: 1;
    transform: none;
  }
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation-duration: 0.01ms !important;
    transition-duration: 0.01ms !important;
  }
}

/* ---------- 12. فرم‌های احراز هویت ---------- */
.auth-page {
  min-height: 100vh;
  min-height: 100dvh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
  background:
    radial-gradient(circle at 30% 20%, rgba(0, 255, 255, 0.1), transparent 45%),
    radial-gradient(circle at 70% 80%, rgba(0, 207, 255, 0.07), transparent 45%);
}

.auth-card {
  width: 100%;
  max-width: 420px;
  padding: 30px 26px;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  box-shadow: var(--glow), 0 20px 60px rgba(0, 0, 0, 0.4);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  animation: fadeIn 0.3s ease both;
}

.auth-card h1 {
  margin-bottom: 22px;
  font-size: 1.4rem;
  color: var(--text);
  text-align: center;
  letter-spacing: 0.3px;
  text-shadow: 0 0 20px rgba(0, 255, 255, 0.3);
}

.auth-card .field {
  margin-bottom: 14px;
}

.auth-card label {
  display: block;
  margin-bottom: 6px;
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--text-soft);
}

.auth-card input {
  width: 100%;
  padding: 11px 14px;
  font-family: inherit;
  font-size: 0.95rem;
  color: var(--text);
  background: var(--bg-input);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  outline: none;
  transition: var(--transition);
}

.auth-card input:focus {
  border-color: var(--neon);
  box-shadow: var(--glow);
}

.auth-card button {
  width: 100%;
  margin-top: 10px;
  padding: 12px;
  font-family: inherit;
  font-size: 0.95rem;
  font-weight: 700;
  color: #001018;
  cursor: pointer;
  background: linear-gradient(135deg, var(--neon-2), var(--neon));
  border: none;
  border-radius: var(--radius-pill);
  transition: var(--transition);
}

.auth-card button:hover {
  box-shadow: var(--glow-strong);
  transform: translateY(-1px);
}

.auth-card .error {
  padding: 9px 12px;
  margin-bottom: 14px;
  font-size: 0.85rem;
  color: #ff9ea8;
  background: rgba(255, 95, 109, 0.12);
  border: 1px solid rgba(255, 95, 109, 0.3);
  border-radius: var(--radius-sm);
  animation: fadeIn 0.2s ease both;
}

.auth-card .hint {
  margin-top: 16px;
  font-size: 0.85rem;
  color: var(--text-muted);
  text-align: center;
}

.auth-card .hint a {
  font-weight: 600;
  color: var(--neon);
  text-decoration: none;
  transition: var(--transition);
}

.auth-card .hint a:hover {
  text-shadow: 0 0 12px rgba(0, 255, 255, 0.7);
}