/* ===================================================================
   Group Chat Styles - 아바타 그룹 채팅 UI
   기존 chat-panel.css의 스타일 확장
   보라-핑크 그래디언트 테마 유지
   =================================================================== */

/* ================================================================
   📌 그룹 초대 버튼 (헤더 내)
   ================================================================ */
.group-invite-btn {
  background: rgba(255, 255, 255, 0.2);
  border: 1px solid rgba(255, 255, 255, 0.3);
  color: white;
  /* 정원 강제 - 절대 타원 금지 */
  width: 32px !important;
  height: 32px !important;
  min-width: 32px !important;
  max-width: 32px !important;
  min-height: 32px !important;
  max-height: 32px !important;
  aspect-ratio: 1 / 1 !important;
  border-radius: 50% !important;
  padding: 0 !important;
  box-sizing: border-box !important;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 13px;
  transition: all 0.2s ease;
  flex-shrink: 0;
  flex-grow: 0;
  margin-right: 8px;
  overflow: hidden;
}

.group-invite-btn:hover {
  background: rgba(255, 255, 255, 0.35);
  transform: scale(1.1);
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.2);
}

.group-invite-btn:active {
  transform: scale(0.95);
}

/* ================================================================
   👥 멤버 바 (헤더 아래)
   ================================================================ */
.group-member-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 16px 8px 16px;
  background: linear-gradient(135deg, rgba(94, 66, 166, 0.08), rgba(183, 78, 145, 0.08));
  border-bottom: 1px solid rgba(183, 78, 145, 0.15);
  flex-shrink: 0;
  overflow: visible;
}

.member-bar-avatars {
  display: flex;
  gap: 4px;
  overflow-x: auto;
  flex: 1;
  scrollbar-width: none;
  -ms-overflow-style: none;
}

.member-bar-avatars::-webkit-scrollbar {
  display: none;
}

.member-bar-item {
  position: relative;
  flex-shrink: 0;
  cursor: pointer;
  overflow: visible;
  margin: 4px 2px;
}

.member-bar-img {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  object-fit: cover;
  border: 2px solid rgba(183, 78, 145, 0.4);
  transition: border-color 0.2s, transform 0.2s;
}

.member-bar-item:hover .member-bar-img {
  border-color: #b74e91;
  transform: scale(1.05);
}

.member-remove-btn {
  position: absolute;
  top: -6px;
  right: -6px;
  width: 18px;
  height: 18px;
  min-width: 18px !important;
  min-height: 18px !important;
  aspect-ratio: 1 / 1 !important;
  border-radius: 50% !important;
  background: #e74c3c;
  border: 2px solid white;
  color: white;
  font-size: 8px;
  cursor: pointer;
  display: none;
  align-items: center;
  justify-content: center;
  padding: 0 !important;
  box-sizing: border-box !important;
  line-height: 1;
  transition: transform 0.2s;
  z-index: 10;
  box-shadow: 0 1px 4px rgba(0,0,0,0.3);
}

.member-bar-item:hover .member-remove-btn {
  display: flex;
}

.member-remove-btn:hover {
  transform: scale(1.15);
  background: #c0392b;
}

/* 메인 아바타 배지 (별표) */
.member-main-badge {
  position: absolute;
  top: -5px;
  right: -5px;
  width: 16px;
  height: 16px;
  border-radius: 50%;
  background: linear-gradient(135deg, #f6d365, #fda085);
  color: white;
  font-size: 9px;
  display: flex;
  align-items: center;
  justify-content: center;
  border: 1.5px solid white;
  box-shadow: 0 1px 3px rgba(0,0,0,0.2);
  z-index: 10;
  pointer-events: none;
}

.member-bar-item.main-avatar .member-bar-img {
  border: 2px solid #fda085;
}

.member-bar-count {
  font-size: 11px;
  color: #b74e91;
  font-weight: 600;
  white-space: nowrap;
  margin-left: 8px;
  flex-shrink: 0;
}

/* ================================================================
   🎭 아바타 초대 모달
   ================================================================ */
.avatar-invite-modal {
  display: none;
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  z-index: 2000;
}

.avatar-invite-modal.active {
  display: block;
}

.avatar-modal-overlay {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(0, 0, 0, 0.5);
  backdrop-filter: blur(4px);
}

.avatar-modal-content {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  width: 90%;
  max-width: 420px;
  max-height: 80vh;
  background: white;
  border-radius: 16px;
  overflow: hidden;
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.3);
  animation: modalSlideUp 0.3s ease;
}

@keyframes modalSlideUp {
  from {
    opacity: 0;
    transform: translate(-50%, -45%);
  }
  to {
    opacity: 1;
    transform: translate(-50%, -50%);
  }
}

.avatar-modal-header {
  padding: 16px 20px;
  background: linear-gradient(135deg, #5e42a6 0%, #b74e91 100%);
  color: white;
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.avatar-modal-header h3 {
  margin: 0;
  font-size: 16px;
  font-weight: 600;
}

.avatar-modal-header h3 i {
  margin-right: 8px;
}

.avatar-modal-close {
  background: rgba(255, 255, 255, 0.2);
  border: none;
  color: white;
  /* 정원 강제 - 절대 타원 금지 */
  width: 28px !important;
  height: 28px !important;
  min-width: 28px !important;
  max-width: 28px !important;
  min-height: 28px !important;
  max-height: 28px !important;
  aspect-ratio: 1 / 1 !important;
  border-radius: 50% !important;
  padding: 0 !important;
  box-sizing: border-box !important;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 14px;
  transition: background 0.2s;
  flex-shrink: 0;
  flex-grow: 0;
  overflow: hidden;
}

.avatar-modal-close:hover {
  background: rgba(255, 255, 255, 0.35);
}

.avatar-modal-body {
  padding: 12px;
  max-height: 60vh;
  overflow-y: auto;
}

.avatar-modal-loading,
.avatar-modal-empty {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 40px 20px;
  color: #999;
  text-align: center;
}

.avatar-modal-loading .loading-dot {
  background: #b74e91;
}

.avatar-modal-empty i {
  font-size: 40px;
  color: #ddd;
  margin-bottom: 12px;
}

.avatar-modal-empty p {
  margin: 4px 0;
}

/* 아바타 목록 아이템 */
.avatar-modal-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.avatar-modal-item {
  display: flex;
  align-items: center;
  padding: 10px 12px;
  border-radius: 12px;
  background: #f8f9fa;
  border: 1px solid #eee;
  transition: all 0.2s ease;
  cursor: default;
}

.avatar-modal-item:hover {
  background: #f0ecf9;
  border-color: rgba(183, 78, 145, 0.2);
}

.avatar-modal-item.already-invited {
  background: rgba(200, 200, 200, 0.15);
  border-color: rgba(200, 200, 200, 0.3);
  opacity: 0.45;
  pointer-events: none;
  filter: grayscale(40%);
}

.avatar-modal-img {
  width: 44px;
  height: 44px;
  border-radius: 50%;
  object-fit: cover;
  flex-shrink: 0;
  border: 2px solid #eee;
  transition: border-color 0.2s;
}

.avatar-modal-item:hover .avatar-modal-img {
  border-color: rgba(183, 78, 145, 0.4);
}

.avatar-modal-info {
  flex: 1;
  margin-left: 12px;
  min-width: 0;
}

.avatar-modal-name {
  font-size: 14px;
  font-weight: 600;
  color: #333;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.avatar-modal-role {
  font-size: 11px;
  color: #999;
  margin-top: 2px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.avatar-modal-action {
  flex-shrink: 0;
  padding: 6px 14px;
  border-radius: 20px;
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
  border: none;
  transition: all 0.2s ease;
  display: flex;
  align-items: center;
  gap: 4px;
}

.avatar-modal-action.invite {
  background: linear-gradient(135deg, #5e42a6 0%, #b74e91 100%);
  color: white;
}

.avatar-modal-action.invite:hover {
  transform: scale(1.05);
  box-shadow: 0 2px 8px rgba(183, 78, 145, 0.3);
}

.avatar-modal-action.invited {
  background: rgba(94, 66, 166, 0.1);
  color: #5e42a6;
  cursor: default;
}

/* ================================================================
   💬 그룹 메시지 스타일
   ================================================================ */

/* 아바타 메시지 (그룹 전용) */
.chat-message.group-avatar-message {
  align-self: flex-start;
  display: flex;
  gap: 8px;
  max-width: 88%;
  padding: 0;
  background: transparent;
  border-radius: 0;
  box-shadow: none;
  animation: fadeIn 0.3s ease-out;
}

.group-msg-avatar {
  flex-shrink: 0;
}

.group-msg-avatar img {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  object-fit: cover;
  border: 2px solid rgba(183, 78, 145, 0.3);
}

.group-msg-content {
  background: #1a1a1a;
  border-radius: 12px;
  border-top-left-radius: 4px;
  padding: 8px 12px;
  min-width: 0;
  box-shadow: 0 2px 4px rgba(0, 0, 0, 0.2);
}

.group-msg-sender {
  font-size: 11px;
  font-weight: 600;
  color: #b74e91;
  margin-bottom: 4px;
}

.group-msg-text {
  font-size: 14px;
  color: white;
  line-height: 1.4;
  word-wrap: break-word;
}

/* 시스템 메시지 */
.chat-message.system-message {
  align-self: center;
  background: rgba(183, 78, 145, 0.1);
  color: #888;
  font-size: 12px;
  padding: 6px 16px;
  border-radius: 20px;
  text-align: center;
  max-width: 90%;
  border: 1px solid rgba(183, 78, 145, 0.15);
}

/* 그룹 로딩 */
.chat-message.group-loading {
  align-self: flex-start;
  background: transparent;
  padding: 0;
  box-shadow: none;
}

.group-loading-content {
  display: flex;
  align-items: center;
  gap: 8px;
  background: #1a1a1a;
  padding: 8px 14px;
  border-radius: 12px;
  border-top-left-radius: 4px;
}

.group-loading-avatars {
  display: flex;
  margin-right: 4px;
}

.group-loading-img {
  width: 24px;
  height: 24px;
  border-radius: 50%;
  object-fit: cover;
  border: 2px solid #1a1a1a;
  margin-left: -8px;
}

.group-loading-img:first-child {
  margin-left: 0;
}

.group-loading-text {
  display: flex;
  gap: 4px;
  align-items: center;
}

/* ================================================================
   📱 반응형
   ================================================================ */
@media (max-width: 480px) {
  .avatar-modal-content {
    width: 95%;
    max-height: 85vh;
    border-radius: 12px;
  }
  
  .avatar-modal-item {
    padding: 8px 10px;
  }
  
  .avatar-modal-img {
    width: 38px;
    height: 38px;
  }
  
  .member-bar-img {
    width: 28px;
    height: 28px;
  }
  
  .group-msg-avatar img {
    width: 28px;
    height: 28px;
  }
  
  .group-msg-sender {
    font-size: 10px;
  }
  
  .group-msg-text {
    font-size: 13px;
  }
  
  .chat-message.group-avatar-message {
    max-width: 92%;
  }
}

@media (min-width: 481px) and (max-width: 768px) {
  .avatar-modal-content {
    max-width: 380px;
  }
}

/* 폴더블 디바이스 */
@media screen and (min-width: 700px) and (max-width: 1400px) and (max-height: 1100px) and (min-height: 600px) {
  .avatar-modal-content {
    max-width: 400px;
  }
}

/* ================================================================
   🔧 도구 사용 뱃지 (실시간 정보 표시)
   ================================================================ */
.tool-badge {
  display: inline-block;
  background: linear-gradient(135deg, rgba(52, 152, 219, 0.2), rgba(155, 89, 182, 0.2));
  border: 1px solid rgba(52, 152, 219, 0.3);
  border-radius: 10px;
  padding: 1px 7px;
  font-size: 0.65em;
  color: #3498db;
  margin-left: 6px;
  vertical-align: middle;
  font-weight: 500;
  letter-spacing: 0.3px;
}
