/* ============================================
   v2/css/chat.css
   استایل صفحه‌ی کامل گپ
   سایت اخبار استقلال — نسخه ۲
   نسخه: 2.4 — فیکس قطعی: ورودی چسبیده بالای bottom-nav (fixed)
   ============================================ */

/* ============================================
   Page layout
   ============================================ */

body.chat-page-active {
  overflow: hidden !important;
  height: 100vh;
  height: 100dvh;
  position: fixed;
  width: 100%;
  top: 0;
  left: 0;
}

body.chat-page-active .app-container {
  height: 100vh;
  height: 100dvh;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  padding-bottom: 0;
}

body.chat-page-active #main-content {
  flex: 1;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  min-height: 0;
  padding-bottom: 0;
}

body.chat-page-active .chat-page {
  flex: 1;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  min-height: 0;
  position: relative;
}

/* 🎯 bottom-nav در صفحه گپ نمایش داده می‌شه */
body.chat-page-active .floating-chat-btn {
  display: none !important;
}

/* ============================================
   Header (ثابت)
   ============================================ */
.chat-page-header {
  background: linear-gradient(145deg, var(--primary), var(--primary-dark));
  color: #fff;
  padding: 14px 16px;
  box-shadow: 0 2px 12px rgba(0,0,0,.15);
  flex-shrink: 0;
  z-index: 10;
}

.chat-page-title {
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 1rem;
  font-weight: 700;
}

.chat-page-title i {
  color: var(--gold);
  font-size: 1.15rem;
}

.chat-online-badge {
  font-size: .7rem;
  color: rgba(255, 255, 255, .85);
  font-weight: 500;
  margin-right: auto;
  background: rgba(255, 255, 255, .15);
  padding: 3px 10px;
  border-radius: 20px;
}

.chat-online-badge::before {
  content: '• ';
  color: #2ecc71;
  font-size: 1rem;
}

/* ============================================
   Ad wrap (sticky زیر هدر)
   ============================================ */
.chat-page-ad-wrap {
  flex-shrink: 0;
  position: relative;
  z-index: 9;
  background: #fff;
  border-bottom: 1px solid var(--border);
}

.chat-page-ad-wrap:empty {
  display: none;
}

/* ============================================
   Messages (scrolling area)
   ============================================ */
.chat-page-messages {
  flex: 1;
  overflow-y: auto;
  overflow-x: hidden;
  padding: 12px 12px 16px;
  display: flex;
  flex-direction: column-reverse;
  gap: 8px;
  -webkit-overflow-scrolling: touch;
  min-height: 0;
  background: var(--bg);
  /* 🎯 فضای پایین برای ورودی fixed + bottom-nav */
  padding-bottom: 90px;
}

.chat-page-messages::-webkit-scrollbar { width: 4px; }
.chat-page-messages::-webkit-scrollbar-thumb {
  background: rgba(21, 96, 189, .3);
  border-radius: 2px;
}

/* ============================================
   Chat messages
   ============================================ */
.chat-msg {
  display: flex;
  gap: 8px;
  align-items: flex-start;
  max-width: 88%;
  position: relative;
}

.chat-msg.own { align-self: flex-end; flex-direction: row-reverse; }
.chat-msg.other { align-self: flex-start; }

.chat-msg .msg-avatar {
  width: 34px;
  height: 34px;
  border-radius: 50%;
  overflow: hidden;
  flex-shrink: 0;
  background: linear-gradient(145deg, var(--primary), var(--primary-dark));
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--gold);
  font-size: .85rem;
  font-weight: 700;
  border: 2px solid #fff;
  cursor: pointer;
  position: relative;
}

.chat-msg .msg-avatar img { width: 100%; height: 100%; object-fit: cover; }

.chat-msg .msg-avatar.vip-avatar-sm {
  border: 2px solid var(--gold);
  box-shadow: 0 0 0 1px rgba(245, 200, 66, .4), 0 0 8px rgba(245, 200, 66, .5);
}

.chat-msg .msg-body {
  display: flex;
  flex-direction: column;
  gap: 2px;
  min-width: 0;
}

.chat-msg .msg-name {
  font-size: .68rem;
  color: #5a6a7a;
  font-weight: 600;
  padding: 0 4px;
  margin-bottom: 2px;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 4px;
}

.chat-msg.own .msg-name { text-align: left; color: var(--primary); }

.chat-msg .msg-name.vip-author {
  color: #d4a017;
  background: linear-gradient(90deg, #d4a017, #f5c842, #d4a017);
  background-clip: text;
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  font-weight: 800;
}

.chat-msg.own .msg-name.vip-author {
  background: linear-gradient(90deg, #f5c842, #ffe98a, #f5c842);
  -webkit-background-clip: text;
  background-clip: text;
  -webkit-text-fill-color: transparent;
}

.chat-msg .msg-name .vip-icon {
  color: var(--gold);
  font-size: .7rem;
  filter: drop-shadow(0 0 3px rgba(245,200,66,.7));
  -webkit-text-fill-color: var(--gold);
  background: none;
  -webkit-background-clip: initial;
  background-clip: initial;
  margin-right: 1px;
}

.chat-msg .msg-bubble {
  background: #fff;
  border-radius: 16px 16px 16px 4px;
  padding: 9px 13px;
  font-size: .87rem;
  line-height: 1.5;
  color: var(--text);
  box-shadow: 0 2px 6px rgba(0,0,0,.05);
  word-wrap: break-word;
  word-break: break-word;
  white-space: pre-wrap;
  position: relative;
}

.chat-msg.own .msg-bubble {
  background: linear-gradient(145deg, var(--primary), var(--primary-dark));
  color: #fff;
  border-radius: 16px 16px 4px 16px;
}

.chat-msg:not(.own) .msg-bubble.vip-bubble {
  background: linear-gradient(145deg, #fffdf5, #fff8e1);
  border: 1px solid rgba(245, 200, 66, .35);
}

.chat-msg .msg-time {
  font-size: .6rem;
  color: var(--text-light);
  padding: 0 6px;
  margin-top: 2px;
}

.chat-msg.own .msg-time { text-align: left; color: var(--text-muted); }

.chat-msg-actions {
  display: flex;
  gap: 10px;
  align-items: center;
  padding: 2px 6px;
  margin-top: 2px;
  flex-wrap: wrap;
}

.chat-msg-actions .action-btn {
  background: none;
  border: none;
  color: var(--text-light);
  font-size: .7rem;
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 3px;
  padding: 2px 4px;
  touch-action: manipulation;
}

.chat-msg-actions .action-btn.liked { color: var(--danger); }
.chat-msg-actions .action-btn.disliked { color: var(--info); }

/* ============================================
   Input area (fixed — دقیقاً بالای bottom-nav)
   ============================================ */
.chat-page-input {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  max-width: var(--container-width);
  margin: 0 auto;
  background: #fff;
  border-top: 1px solid var(--border);
  padding: 10px 12px;
  z-index: 1001; /* بالاتر از bottom-nav */
  box-shadow: 0 -2px 12px rgba(0,0,0,.06);
  /* 🎯 بالای bottom-nav می‌ایسته */
  bottom: var(--bottom-nav-height, 70px);
  box-sizing: border-box;
}

.chat-input-area {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.chat-input-row {
  display: flex;
  gap: 8px;
  align-items: flex-end;
}

.chat-input-area textarea {
  flex: 1;
  padding: 10px 14px;
  border: 2px solid var(--border-light);
  border-radius: 20px;
  font-size: .9rem;
  outline: none;
  resize: none;
  max-height: 100px;
  min-height: 42px;
  line-height: 1.5;
  background: var(--bg-light);
  font-family: inherit;
}

.chat-input-area textarea:focus {
  border-color: var(--gold);
  background: #fff;
}

.chat-input-area .send-btn {
  width: 42px;
  height: 42px;
  border-radius: 50%;
  background: linear-gradient(145deg, var(--primary), var(--primary-dark));
  color: #fff;
  border: none;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1rem;
  flex-shrink: 0;
  box-shadow: 0 4px 12px rgba(21, 96, 189, .3);
  touch-action: manipulation;
}

.chat-input-area .send-btn:active { transform: scale(0.95); }

/* Reply indicator */
.reply-indicator {
  background: #e8f4fd;
  border: 1px solid #b8d9ff;
  border-radius: 10px;
  padding: 8px 12px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  font-size: .75rem;
  color: #0d5aa0;
}

.reply-indicator .cancel-reply {
  background: none;
  border: none;
  color: var(--danger);
  cursor: pointer;
  font-size: 1rem;
  padding: 0 4px;
}

/* Guest prompt */
.chat-guest-prompt {
  text-align: center;
  padding: 12px;
}

.chat-guest-prompt p {
  font-size: .85rem;
  color: #5a6a7a;
  margin-bottom: 12px;
  line-height: 1.6;
}

.chat-guest-prompt button {
  background: linear-gradient(145deg, var(--primary), var(--primary-dark));
  color: #fff;
  border: none;
  padding: 10px 24px;
  border-radius: 30px;
  font-weight: 700;
  cursor: pointer;
  font-size: .85rem;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  box-shadow: 0 4px 14px rgba(21, 96, 189, .25);
  font-family: inherit;
  touch-action: manipulation;
}

/* Empty */
.chat-blocked-notice {
  background: #fff;
  border-radius: 14px;
  padding: 20px 16px;
  text-align: center;
  font-size: .85rem;
  color: var(--text-muted);
  line-height: 1.6;
  margin: 8px 0;
}

.chat-blocked-notice i {
  color: var(--primary);
  font-size: 1.8rem;
  margin-bottom: 10px;
  display: block;
}

/* Reply quote */
.reply-quote {
  border-right: 3px solid var(--gold);
  border-radius: 8px;
  padding: 6px 10px;
  margin-bottom: 6px;
  font-size: .72rem;
}

/* ============================================
   Safe area برای گوشی‌های notch‌دار
   ============================================ */
@supports (padding: env(safe-area-inset-bottom)) {
  .chat-page-input {
    bottom: calc(var(--bottom-nav-height, 70px) + env(safe-area-inset-bottom, 0px));
    padding-bottom: calc(10px + env(safe-area-inset-bottom, 0px));
  }
}

/* Responsive */
@media (max-width: 380px) {
  .chat-page-header { padding: 12px 14px; }
  .chat-page-title { font-size: .92rem; }
  .chat-page-title i { font-size: 1.05rem; }
  .chat-msg .msg-bubble { font-size: .82rem; padding: 8px 11px; }
  .chat-page-messages { padding: 10px 10px 12px; padding-bottom: 90px; }
  .chat-msg .msg-avatar.vip-avatar-sm {
    border-width: 1.5px;
  }
}