/* =========================
  CSS 변수 (전역 기준)
========================= */
:root {
  --ab-header-h: 56px;
  --wp-admin-h: 0px;
}

/* WP admin bar */
body.admin-bar {
  --wp-admin-h: 32px;
}

@media (max-width: 782px) {
  body.admin-bar {
    --wp-admin-h: 46px;
  }
}

/* =========================
  MESSAGE PANEL (오버레이 역할만)
========================= */
.message-panel {
  position: fixed;
  inset: 0;
  z-index: 20000;

  display: none;
}

.message-panel.active {
  display: block;
}

.message-overlay {
  position: absolute;
  inset: 0;
  background: rgba(0,0,0,0.4);
}
/* =========================
MESSAGE BOX (실제 채팅 UI 핵심)
========================= */

.message-box {
  position: absolute;
  top: 0;
  right: 0;

  width: 420px;
  max-width: 100%;
  height: 100%;

  display: flex;
  flex-direction: column;

  background: #fff;
  z-index: 1;
}

/* =========================
HEADER / BODY / FOOTER (flex 안정화)
========================= */

.message-header {
   height: 44px;
  display: grid;
  grid-template-columns: 44px 1fr 44px;
  align-items: center;
  height: 52px;
  padding: 0 12px;
  position: relative;
 background: #fff;
   border-bottom: 1px solid #e5e7eb;
  z-index: 10;
}

.message-back{
  grid-column: 1;
  justify-self: start;
  width: 44px;
  height: 44px;
}

.message-title {
  display: block;
  max-width: 100%;
  grid-column: 2;

  white-space: nowrap;     /* 줄바꿈 금지 */
  overflow: hidden;        /* 넘치는 부분 숨김 */
  text-overflow: ellipsis; /* ... 처리 */

  text-align: center;
  pointer-events: none;
  
  font-weight: 600;
}

.message-header-actions{
  grid-column: 3;
  justify-content: flex-end;
  width: 44px;
  height: 44px;
  display: flex;
  align-items: center;
  
}
.message-close{
  width: 40px;
  height: 44px;
}


/*=================================
    seller와 buyer 구분하기
========================= */

.chat-role {
  font-size: 10px;
  font-weight: 600;
  margin-left: 6px;
  padding: 2px 6px;
  border-radius: 6px;
  vertical-align: middle;
}

.chat-role.seller {
  background: #e0f2fe;
  color: #0369a1;
}

.chat-role.buyer {
  background: #ecfdf5;
  color: #065f46;
}

/*=================================
    Message panel에서 구분하기
========================= */

.message-chat-preview.is-me {
  color: #9ca3af;
  font-weight: 400;
   font-size: 11px;
}

.message-chat-preview.is-them {
  color: #111;
  font-weight: 500;
}

.message-chat-item.has-unread .message-chat-name {
  font-weight: 600;
}

.message-placeholder {
  color: #9ca3af;
  padding: 12px;
  font-size: 14px;
}

.message-empty {
  display: flex;
  align-items: center;
  justify-content: center;
  height: 100%;
  color: #9ca3af;
  font-size: 14px;
  text-align: center;
}

/*=================================
        리뷰
========================= */
/* 왼쪽: Back */
.message-back {
  min-width: 32px;
  font-size: 18px;
  background: none;
  border: none;
}

/* 가운데: Title */
.message-title {
  flex: 0 1 auto;
  text-align: center;
  font-weight: 600;
  margin: 0 auto;
  pointer-events: none; /* 드래그/클릭 방지 */
}

/* 오른쪽: Review + Close */
.message-header-actions {
  display: grid;
  align-items: center;
  gap: 8px;
  min-width: 32px;
}

.ab-review-btn {
    
  position: absolute;
  right: 56px;   /* X 옆 */
  top: 50%;
  
  font-size: 13px;
  padding: 4px 10px;
  border-radius: 14px;
  background: #ff8c3a;
  color: #fff;
  border: none;
  white-space: nowrap;
}

.ab-face-rating {
  display: flex;
  justify-content: space-between;
  margin: 12px 0 16px;
}

.ab-face-rating button {
  font-size: 30px;
  background: none;
  border: none;
  cursor: pointer;
  opacity: .35;
  transition: transform .15s ease, opacity .15s ease;
}

/* 🌫️ 오버레이 */
.ab-review-modal {
  position: fixed;
  top: 0;
  left: 0;
  width: 100vw;
  height: 90vh;

  background: rgba(0, 0, 0, 0.45);

  display: flex;
  align-items: center;
  justify-content: center;

  z-index: 2147483647; /* 모바일 최상위 */
}

/* hidden 속성 대응 */
.ab-review-modal[hidden] {
  display: none !important;
}

/* 📦 리뷰 박스 */
.ab-review-box {
  background: #fff;
  width: calc(100% - 32px);
  max-width: 360px;
  padding: 20px;
  border-radius: 16px;

  box-shadow: 0 10px 40px rgba(0,0,0,0.25);
}


.ab-review-box h3 {
  margin: 0 0 14px;
  font-size: 18px;
  text-align: center;
}

#ab-face-rating {
  display: flex;
  justify-content: space-between;
  gap: 10px;
  margin: 16px 0;
}

#ab-face-rating button {
  background: none;
  border: none;
  font-size: 28px;
  cursor: pointer;

  opacity: 0.35;               /* 기본 흐림 */
  transition: transform 0.15s ease, opacity 0.15s ease;
}

#ab-face-rating button.selected {
  transform: scale(1.25);
  opacity: 1;
}

#ab-face-rating button.dimmed {
  opacity: 0.15;
}

#ab-review-comment {
  width: 100%;
  min-height: 70px;
  resize: vertical;
  padding: 8px 10px;
  border-radius: 8px;
  border: 1px solid #ddd;
  font-size: 14px;
  margin-bottom: 12px;
}

.ab-review-actions {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
}

#ab-review-submit {
  background: #6b6cff;
  color: #fff;
  border: none;
  border-radius: 6px;
  padding: 6px 12px;
}

#ab-review-cancel {
  background: #f1f1f1;
  border: none;
  border-radius: 6px;
  padding: 6px 12px;
}


/*******************
 Sold일때 표시시
 *********************/

.chat-sold {
  color: #d9534f;
  font-size: 0.8em;
  margin-right: 4px;
}

.message-chat-item.is-sold {
  opacity: 0.75;
}

/* =========================
  Body
  ========================*/
.message-body {
  flex: 1 1 auto;
  min-height: 0;      /* 🔥 스크롤 안정 핵심 */
  z-index: 1;
  overflow-y: auto;
  padding: 14px;
  -webkit-overflow-scrolling: touch;
}

/* 리스트 모드 */
.message-body.list {
  display: block;
  padding: 8px 0;
  background: #fff;
}

/* 채팅 모드 */
.message-body.chat {
  display: flex;
  flex-direction: column;
  background: #fafafa;
}

/* =========================
  FOOTER (입력 영역)
  ========================*/

.message-footer {
 flex: 0 0 auto;
  display: flex;
  gap: 8px;
  padding: 12px;
  border-top: 1px solid #eee;
  background: #fff;
  position: relative;
   z-index: 2;
 
}

.message-input {
  flex: 1;
  resize: none;
   max-height: 120px;
  padding: 10px 14px;
  border-radius: 18px;
  border: 1px solid #ddd;
  font-size: 14px;
}

.message-input:focus {
  outline: none;
  border-color: #6b6cff;
  box-shadow: 0 0 0 2px rgba(107,108,255,0.12);
}

.message-send {
  padding: 0 16px;
  border-radius: 18px;
  border: none;
  background: #6b6cff;
  color: #fff;
  font-weight: 600;
  cursor: pointer;
}


/* =========================
리스트 / 채팅 모드
========================= */
.message-body.list {
  display: block;
  padding: 8px 0;
  background: #fff;
}

.message-body.chat {
  display: flex;
  flex-direction: column;
  background: #fafafa;
}

/* 리스트에서는 입력창 숨김 */
.message-body.list + .message-footer {
  display: none;
}


/* =========================
  말풍선
  ========================*/
  
.message-row {
  display: flex;
  width: 100%;
  margin-bottom: 6px;  /* 🔥 전체 간격 줄이기 */
}


.message-row.other {
  display: flex;
  flex-direction: column;   /* 🔥 세로 배치 */
  align-items: flex-start;
  gap: 2px;  /* 닉네임-버블 간 간격 */
}

.message-row.me {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
}

.message-bubble {
  max-width: 78%;
  padding: 10px 14px;
  margin-bottom: 8px;
  border-radius: 16px;
  font-size: 14px;
  line-height: 1.45;
  word-break: break-word;
  box-shadow: 0 2px 6px rgba(0,0,0,0.06);
}

.message-bubble.me {
  background: #6b6cff;
  color: #fff;
  border-bottom-right-radius: 6px;
}

.message-bubble.other {
  background: #eaeaea;
  color: #111;
  border-bottom-left-radius: 6px;
}

.message-time {
  font-size: 11px;
  opacity: 0.6;
  margin-top: 4px;
  text-align: right;
}

/* 그룹 첫 메시지 */
.message-bubble.group-start {
  margin-top: 2px;
}

.message-row.other .message-bubble {
  margin-top: 2px;
}

/* 연속 메시지 */
.message-bubble.group-continue {
  margin-top: 2px;
}

/* 카톡처럼 붙이기 */
.message-row.other .group-continue {
  border-top-left-radius: 6px;
   margin-top: 2px;
}

.message-row.me .group-continue {
  border-top-right-radius: 6px;
}

.message-sender-name {
  font-size: 11px;
  font-weight: 600;
  margin-bottom: 6px;  /* 버블과 간격 */
  color: #333;
}

/* 닉네임과 버블 간격 최소화 */
.message-sender-name {
  font-size: 13px;
  font-weight: 600;
  margin: 0 0 3px 0;   /* 🔥 아래만 3px */
  line-height: 1.2;
  color: #333;
}


/* =========================
  Chat List
  ========================*/
  
.message-chat-item {
  padding: 14px 16px;
  border-bottom: 1px solid #eee;
  cursor: pointer;
  background: #fff;
}

.message-chat-item:hover {
  background: #f8f8f8;
}

.message-chat-top {
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.message-chat-name {
  font-weight: 600;
  font-size: 15px;
}

.message-chat-time {
  font-size: 12px;
  color: #999;
  white-space: nowrap;
}

.message-chat-itemtitle {
  font-size: 13px;
  color: #6b6cff;          /* 🔥 포인트 컬러 */
  font-weight: 600;
  margin: 4px 0;
}

.message-chat-preview {
  font-size: 11.5px;
  color: #666;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.message-chat-unread {
  background: #ff3b30;
  color: #fff;
  font-size: 12px;
  min-width: 18px;
  height: 18px;
  border-radius: 9px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

.message-date-divider {
  align-self: center;
  margin: 20px 0;
  font-size: 12px;
  color: #777;

  position: relative;
  padding: 0 12px;
  background: #fff;
  white-space: nowrap;
}

.message-date-divider::before,
.message-date-divider::after {
  content: '';
  position: absolute;
  top: 50%;
  width: 100px;
  height: 1px;
  background: #ddd;
}

.message-date-divider::before {
  right: 100%;
  margin-right: 12px;
}

.message-date-divider::after {
  left: 100%;
  margin-left: 12px;
}



/* =========================
날짜 구분선 (레이아웃 흔들림 방지)
========================= */
.message-date-divider {
  align-self: center;
  margin: 12px 0;
  font-size: 11px;
  color: #777;

  position: relative;
  padding: 0 12px;
  background: #fff;
  white-space: nowrap;
}

.message-date-divider::before,
.message-date-divider::after {
  content: '';
  position: absolute;
  top: 50%;
  width: 60px;
  height: 1px;
  background: #ddd;
}

.message-date-divider::before {
  right: 100%;
  margin-right: 8px;
}

.message-date-divider::after {
  left: 100%;
  margin-left: 8px;
}


#messagePanel.active {
  display: flex !important;
}

body.single #messagePanel.active {
  display: flex !important;
}

/* 🔥 채팅 패널 열리면 아이템 CTA 숨김 */
body.chat-room-open .message-cta-bar {
  display: none !important;
}

body.chat-room-open {
  overflow: hidden;
}

/* =========================
모바일
========================= */

@media (max-width: 768px) {
 
  .message-panel.active {
     display: flex;
    flex-direction: column;
    
  }
  
  .message-box {
    width: 100%;
    height: 100%;
    border-radius: 0;
  }

 
  .message-body {
    flex: 1;
    overflow-y: auto;
  }

  .message-footer {
    position: relative; /* 🔥 fixed/sticky 쓰지 말기 */
    background: #fff;
  }
  
}



