/* ==============================================================================
   Right-side Chat Info & Media Archive Drawer (详细信息与多媒体档案抽屉)
   优化规格：
   1. 尺寸：严格收缩为屏幕一半 (width: 50% / 50vw)，半屏紧凑展示；
   2. 遮罩：半透明点击关闭背景 (chat-drawer-backdrop)，点击空白任意处立即取消关闭；
   3. 高反差色彩：光暗主题自适应，文字深色清晰可读，杜绝白底白字；
   4. 分类归档：照片 (Photo)、视频 (Video)、文件 (File) 独立归类与下载/预览。
   ============================================================================== */

/* Click-outside backdrop overlay (点击任意空白处取消关闭) */
.chat-drawer-backdrop {
  position: absolute !important;
  inset: 0 !important;
  background: rgba(0, 0, 0, 0.35) !important;
  z-index: 2400 !important;
  opacity: 0 !important;
  pointer-events: none !important;
  transition: opacity 0.22s cubic-bezier(0.16, 1, 0.3, 1) !important;
}

.chat-drawer-backdrop.active {
  opacity: 1 !important;
  pointer-events: auto !important;
}

/* Drawer Container: Exactly 50% screen width on mobile */
.chat-drawer {
  width: 50% !important;
  max-width: 50vw !important;
  min-width: 200px !important;
  background: #ffffff !important;
  color: #0f172a !important;
  border-left: 1px solid rgba(60, 60, 67, 0.15) !important;
  display: flex !important;
  flex-direction: column !important;
  height: 100% !important;
  position: absolute !important;
  top: 0 !important;
  right: 0 !important;
  z-index: 2500 !important;
  transform: translateX(100%) !important;
  visibility: hidden !important;
  pointer-events: none !important;
  box-shadow: none !important;
  box-sizing: border-box !important;
  transition: transform 0.24s cubic-bezier(0.16, 1, 0.3, 1), visibility 0.24s !important;
}

.chat-drawer.open {
  transform: translateX(0) !important;
  visibility: visible !important;
  pointer-events: auto !important;
  box-shadow: -12px 0 32px rgba(0, 0, 0, 0.22) !important;
}

[data-theme="obsidian"] .chat-drawer {
  background: #0f172a !important;
  color: #f8fafc !important;
  border-left: 1px solid rgba(255, 255, 255, 0.1) !important;
}

.drawer-header {
  display: flex !important;
  align-items: center !important;
  justify-content: space-between !important;
  padding: var(--pwa-drawer-top, max(14px, calc(env(safe-area-inset-top, 14px) + 6px))) 14px 12px 14px !important;
  border-bottom: 1px solid rgba(60, 60, 67, 0.1) !important;
  box-sizing: border-box !important;
}

[data-theme="obsidian"] .drawer-header {
  display: flex !important;
  align-items: center !important;
  justify-content: space-between !important;
  padding: var(--pwa-drawer-top, max(14px, calc(env(safe-area-inset-top, 14px) + 6px))) 14px 12px 14px !important;
  border-bottom: 1px solid rgba(60, 60, 67, 0.1) !important;
  box-sizing: border-box !important;
}

.drawer-header h3 {
  font-size: 14px !important;
  font-weight: 700 !important;
  color: #0f172a !important;
  margin: 0 !important;
}

[data-theme="obsidian"] .drawer-header h3 {
  color: #f8fafc !important;
}

.drawer-close-btn {
  background: transparent !important;
  border: none !important;
  color: #64748b !important;
  cursor: pointer !important;
  font-size: 18px !important;
  width: 28px !important;
  height: 28px !important;
  border-radius: 50% !important;
  display: flex !important;
  align-items: center !important;
  justify-content: center !important;
  transition: background 0.15s ease !important;
}

.drawer-close-btn:active {
  background: rgba(142, 142, 147, 0.15) !important;
}

.drawer-body {
  flex: 1 !important;
  overflow-y: auto !important;
  padding: 12px 10px max(14px, env(safe-area-inset-bottom, 14px)) 10px !important;
  box-sizing: border-box !important;
}

/* Contact Profile Details Card */
.drawer-profile-card {
  text-align: center !important;
  padding-bottom: 12px !important;
  border-bottom: 1px solid rgba(60, 60, 67, 0.08) !important;
  margin-bottom: 12px !important;
}

[data-theme="obsidian"] .drawer-profile-card {
  border-bottom: 1px solid rgba(255, 255, 255, 0.08) !important;
}

.drawer-avatar {
  width: 54px !important;
  height: 54px !important;
  border-radius: 50% !important;
  background: #0284c7 !important;
  display: inline-flex !important;
  align-items: center !important;
  justify-content: center !important;
  font-size: 22px !important;
  font-weight: 700 !important;
  color: #ffffff !important;
  margin-bottom: 8px !important;
  box-shadow: 0 4px 10px rgba(0, 0, 0, 0.1) !important;
}

.drawer-name {
  font-size: 15px !important;
  font-weight: 700 !important;
  color: #0f172a !important;
  line-height: 1.25 !important;
  white-space: nowrap !important;
  overflow: hidden !important;
  text-overflow: ellipsis !important;
}

[data-theme="obsidian"] .drawer-name {
  color: #f8fafc !important;
}

.drawer-handle {
  font-size: 11.5px !important;
  color: #64748b !important;
  margin-top: 2px !important;
}

[data-theme="obsidian"] .drawer-handle {
  color: #94a3b8 !important;
}

.drawer-status-pill {
  display: inline-flex !important;
  align-items: center !important;
  gap: 5px !important;
  background: rgba(34, 197, 94, 0.12) !important;
  color: #16a34a !important;
  padding: 3px 8px !important;
  border-radius: 9999px !important;
  font-size: 10.5px !important;
  font-weight: 600 !important;
  margin-top: 6px !important;
}

[data-theme="obsidian"] .drawer-status-pill {
  background: rgba(34, 197, 94, 0.2) !important;
  color: #4ade80 !important;
}

/* Sections */
.drawer-section {
  margin-bottom: 14px !important;
}

.drawer-section-title {
  font-size: 11px !important;
  font-weight: 700 !important;
  color: #475569 !important;
  letter-spacing: 0.2px !important;
  margin-bottom: 8px !important;
  display: flex !important;
  align-items: center !important;
  justify-content: space-between !important;
}

[data-theme="obsidian"] .drawer-section-title {
  color: #94a3b8 !important;
}

/* 2-Column Photo Grid (Adapted for 50% half screen) */
.drawer-media-grid {
  display: grid !important;
  grid-template-columns: repeat(2, 1fr) !important;
  gap: 6px !important;
}

.drawer-media-thumb {
  aspect-ratio: 1 !important;
  border-radius: 8px !important;
  overflow: hidden !important;
  background: #f1f5f9 !important;
  cursor: pointer !important;
  border: 1px solid rgba(0, 0, 0, 0.06) !important;
  position: relative !important;
}

[data-theme="obsidian"] .drawer-media-thumb {
  background: #1e293b !important;
  border: 1px solid rgba(255, 255, 255, 0.08) !important;
}

.drawer-media-thumb img {
  width: 100% !important;
  height: 100% !important;
  object-fit: cover !important;
  display: block !important;
}

/* Video Items */
.drawer-video-item {
  display: flex !important;
  align-items: center !important;
  gap: 8px !important;
  padding: 6px 8px !important;
  background: rgba(0, 0, 0, 0.03) !important;
  border-radius: 8px !important;
  border: 1px solid rgba(0, 0, 0, 0.06) !important;
  cursor: pointer !important;
  margin-bottom: 6px !important;
  color: #0f172a !important;
  text-decoration: none !important;
}

[data-theme="obsidian"] .drawer-video-item {
  background: rgba(255, 255, 255, 0.04) !important;
  border: 1px solid rgba(255, 255, 255, 0.08) !important;
  color: #f8fafc !important;
}

.drawer-video-icon {
  width: 26px !important;
  height: 26px !important;
  border-radius: 6px !important;
  background: rgba(14, 165, 233, 0.15) !important;
  color: #0284c7 !important;
  display: flex !important;
  align-items: center !important;
  justify-content: center !important;
  flex-shrink: 0 !important;
}

/* File Items */
.drawer-file-list {
  display: flex !important;
  flex-direction: column !important;
  gap: 6px !important;
}

.drawer-file-item {
  display: flex !important;
  align-items: center !important;
  gap: 8px !important;
  padding: 7px 8px !important;
  background: rgba(0, 0, 0, 0.03) !important;
  border-radius: 8px !important;
  border: 1px solid rgba(0, 0, 0, 0.06) !important;
  text-decoration: none !important;
  color: #0f172a !important;
}

[data-theme="obsidian"] .drawer-file-item {
  background: rgba(255, 255, 255, 0.04) !important;
  border: 1px solid rgba(255, 255, 255, 0.08) !important;
  color: #f8fafc !important;
}

.drawer-file-name {
  font-size: 11px !important;
  font-weight: 600 !important;
  white-space: nowrap !important;
  overflow: hidden !important;
  text-overflow: ellipsis !important;
  color: #0f172a !important;
  flex: 1 !important;
}

[data-theme="obsidian"] .drawer-file-name {
  color: #f8fafc !important;
}

.drawer-empty-hint {
  font-size: 11px !important;
  color: #94a3b8 !important;
  padding: 4px 0 !important;
}

/* Group Members */
.drawer-member-list {
  display: flex !important;
  flex-direction: column !important;
  gap: 6px !important;
}

.drawer-member-item {
  display: flex !important;
  align-items: center !important;
  gap: 8px !important;
  padding: 6px 8px !important;
  background: rgba(0, 0, 0, 0.02) !important;
  border: 1px solid rgba(0, 0, 0, 0.05) !important;
  border-radius: 8px !important;
}

[data-theme="obsidian"] .drawer-member-item {
  background: rgba(255, 255, 255, 0.03) !important;
  border: 1px solid rgba(255, 255, 255, 0.08) !important;
}

.drawer-member-avatar {
  width: 28px !important;
  height: 28px !important;
  border-radius: 50% !important;
  display: flex !important;
  align-items: center !important;
  justify-content: center !important;
  font-size: 12px !important;
  font-weight: 700 !important;
  color: #ffffff !important;
  flex-shrink: 0 !important;
}

.drawer-member-info {
  flex: 1 !important;
  min-width: 0 !important;
}

.drawer-member-name {
  font-size: 12px !important;
  font-weight: 600 !important;
  color: #0f172a !important;
  white-space: nowrap !important;
  overflow: hidden !important;
  text-overflow: ellipsis !important;
}

[data-theme="obsidian"] .drawer-member-name {
  color: #f8fafc !important;
}

/* Group Member Roles & Badges */
.member-role-badge {
  display: inline-block !important;
  padding: 1px 5px !important;
  border-radius: 4px !important;
  font-size: 10px !important;
  font-weight: 600 !important;
  line-height: 1.2 !important;
}

.role-owner {
  background: rgba(245, 158, 11, 0.15) !important;
  color: #f59e0b !important;
  border: 1px solid rgba(245, 158, 11, 0.3) !important;
}

.role-member {
  background: rgba(100, 116, 139, 0.1) !important;
  color: #64748b !important;
}

.btn-remove-member {
  background: rgba(239, 68, 68, 0.1) !important;
  color: #ef4444 !important;
  border: 1px solid rgba(239, 68, 68, 0.25) !important;
  border-radius: 4px !important;
  padding: 2px 6px !important;
  font-size: 11px !important;
  cursor: pointer !important;
  transition: all 0.15s ease !important;
}

@media (hover: hover) and (pointer: fine) {
.btn-remove-member:hover {
  background: #ef4444 !important;
  color: #ffffff !important;
}
}

/* v228：群主转让按钮（样式同「移出群聊」，蓝色） */
.btn-transfer-owner {
  background: rgba(37, 99, 235, 0.06);
  color: #2563eb;
  border: 1px solid rgba(37, 99, 235, 0.3);
  border-radius: 6px;
  padding: 3px 8px;
  font-size: 11.5px;
  font-weight: 600;
  cursor: pointer;
  white-space: nowrap;
  -webkit-tap-highlight-color: transparent;
}
