/* ===============================================================================
   고객용 채팅 위젯 독립형 CSS (부트스트랩 없이 완전 독립 운영)
   네임스페이스: .chat-widget 내부에서만 작동
   =============================================================================== */

/* FontAwesome 아이콘 지원 */
.fas {
  font-family: "Font Awesome 5 Free" !important;
  font-weight: 900 !important;
  font-style: normal !important;
  font-variant: normal !important;
  text-rendering: auto !important;
  line-height: 1 !important;
}

/* 개별 아이콘 정의 */
.fas.fa-comment-dots:before { content: "\f4ad" !important; }
.fas.fa-headset:before { content: "\f590" !important; }
.fas.fa-times:before { content: "\f00d" !important; }
.fas.fa-paperclip:before { content: "\f0c6" !important; }
.fas.fa-paper-plane:before { content: "\f1d8" !important; }
.fas.fa-cloud-upload-alt:before { content: "\f382" !important; }
.fas.fa-circle:before { content: "\f111" !important; }
.fas.fa-check:before { content: "\f00c" !important; }
.fas.fa-check-double:before { content: "\f560" !important; }
.fas.fa-file-alt:before { content: "\f15c" !important; }
.fas.fa-shopping-cart:before { content: "\f07a" !important; }
.fas.fa-question-circle:before { content: "\f059" !important; }
.fas.fa-chevron-right:before { content: "\f054" !important; }
.fas.fa-spinner:before { content: "\f110" !important; }
.fas.fa-exclamation-triangle:before { content: "\f071" !important; }
.fas.fa-bell:before { content: "\f0f3" !important; }
.fas.fa-store:before { content: "\f54e" !important; }
.fas.fa-arrow-left:before { content: "\f060" !important; }
.fas.fa-clock:before { content: "\f017" !important; }

/* 기본 폰트 설정 - 채팅 위젯 내에서만 적용 */
.chat-widget * {
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
  box-sizing: border-box;
}

/* ===============================================================================
   네임스페이스 부트스트랩 대체 클래스들 - 채팅 위젯 내에서만 작동
   =============================================================================== */

/* 위치 클래스 - 채팅 위젯 내에서만 */
.chat-widget .position-absolute { position: absolute; }
.chat-widget .position-relative { position: relative; }
.chat-widget .position-fixed { position: fixed; }

/* 플렉스 시스템 - 채팅 위젯 내에서만 */
.chat-widget .d-flex { display: flex; }
.chat-widget .justify-content-between { justify-content: space-between; }
.chat-widget .justify-content-center { justify-content: center; }
.chat-widget .align-items-center { align-items: center; }
.chat-widget .align-items-start { align-items: flex-start; }
.chat-widget .align-items-end { align-items: flex-end; }
.chat-widget .flex-column { flex-direction: column; }
.chat-widget .flex-row { flex-direction: row; }

/* 간격 클래스 - 채팅 위젯 내에서만 */
.chat-widget .me-2 { margin-right: 0.5rem; }
.chat-widget .ms-2 { margin-left: 0.5rem; }
.chat-widget .mt-2 { margin-top: 0.5rem; }
.chat-widget .mb-0 { margin-bottom: 0; }
.chat-widget .mb-1 { margin-bottom: 0.25rem; }
.chat-widget .mb-2 { margin-bottom: 0.5rem; }
.chat-widget .mb-3 { margin-top: 1rem; }
.chat-widget .p-3 { padding: 1rem; }

/* 텍스트 정렬 - 채팅 위젯 내에서만 */
.chat-widget .text-center { text-align: center; }
.chat-widget .text-left { text-align: left; }
.chat-widget .text-right { text-align: right; }

/* 디스플레이 - 채팅 위젯 내에서만 */
.chat-widget .d-none { display: none; }
.chat-widget .d-block { display: block; }
.chat-widget .d-inline { display: inline; }
.chat-widget .d-inline-block { display: inline-block; }

/* ===============================================================================
   애니메이션
   =============================================================================== */

@keyframes messageSlideIn {
  from { opacity: 0; transform: translateY(10px); }
  to { opacity: 1; transform: translateY(0); }
}

@keyframes pulse {
  0%, 100% { opacity: 0.6; }
  50% { opacity: 1; }
}

@keyframes bounce {
  0%, 20%, 53%, 80%, 100% { transform: translate3d(0,0,0); }
  40%, 43% { transform: translate3d(0,-6px,0); }
  70% { transform: translate3d(0,-3px,0); }
  90% { transform: translate3d(0,-1px,0); }
}

@keyframes loading {
  0% { background-position: 200% 0; }
  100% { background-position: -200% 0; }
}

@keyframes slideInRight {
  from { transform: translateX(100%); opacity: 0; }
  to { transform: translateX(0); opacity: 1; }
}

@keyframes slideOutRight {
  from { transform: translateX(0); opacity: 1; }
  to { transform: translateX(100%); opacity: 0; }
}

@keyframes fadeIn {
  from { opacity: 0; }
  to { opacity: 1; }
}

@keyframes modalSlideUp {
  from { 
    opacity: 0; 
    transform: translateY(30px) scale(0.9); 
  }
  to { 
    opacity: 1; 
    transform: translateY(0) scale(1); 
  }
}

/* ===============================================================================
   채팅 토글 버튼
   =============================================================================== */

.chat-widget #chat-toggle-btn {
  position: fixed;
  bottom: 100px;
  right: 15px;
  z-index: 10000;
}

.chat-widget #chat-toggle-btn button {
  width: 64px;
  height: 64px;
  background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
  border: none;
  border-radius: 50%;
  box-shadow: 0 8px 32px rgba(102, 126, 234, 0.4);
  transition: all 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275);
  position: relative;
  overflow: visible;
  cursor: pointer;
  color: white;
  display: flex;
  align-items: center;
  justify-content: center;
}

.chat-widget #chat-toggle-btn button::before {
  content: '';
  position: absolute;
  top: 0;
  left: -100%;
  width: 100%;
  height: 100%;
  background: linear-gradient(90deg, transparent, rgba(255,255,255,0.2), transparent);
  transition: left 0.5s;
}

.chat-widget #chat-toggle-btn button:hover {
  transform: translateY(-2px) scale(1.05);
  box-shadow: 0 12px 40px rgba(102, 126, 234, 0.5);
}

.chat-widget #chat-toggle-btn button:hover::before {
  left: 100%;
}

.chat-widget #chat-toggle-btn button:active {
  transform: translateY(0) scale(0.98);
}

/* 안읽은 메시지 뱃지 */
.chat-widget #chat-badge {
  position: absolute;
  animation: bounce 1s infinite;
  top: -8px;
  left: -8px;
  min-width: 24px;
  height: 24px;
  font-size: 11px;
  font-weight: 600;
  display: flex;
  align-items: center;
  justify-content: center;
  background: linear-gradient(135deg, #ff6b6b, #ee5a52);
  border: 3px solid white;
  box-shadow: 0 2px 12px rgba(255, 107, 107, 0.5);
  border-radius: 50%;
  z-index: 1;
  white-space: nowrap;
  padding: 0 6px;
  max-width: 50px;
  overflow: hidden;
  text-overflow: ellipsis;
  color: white;
}

/* ===============================================================================
   문의 선택 모달 - 제공하신 이미지와 동일한 디자인 구현
   =============================================================================== */

.chat-widget #inquiry-modal {
  position: fixed;
  bottom: 24px;
  right: 24px;
  width: 400px;
  min-height: 560px;
  max-height: calc(100vh - 80px); /* 화면 높이에 맞춰 조정 */
  background: rgba(255, 255, 255, 0.98);
  backdrop-filter: blur(20px);
  border-radius: 20px;
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.15);
  display: none;
  z-index: 9999;
  border: 1px solid rgba(255, 255, 255, 0.3);
  font-family: 'Inter', sans-serif;
  flex-direction: column;
  animation: modalSlideUp 0.3s ease-out;
}

/* 모달 헤더 - 제공하신 이미지와 동일한 그라데이션 */
.chat-widget .inquiry-modal-header {
  background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
  color: white;
  padding: 20px;
  border-radius: 20px 20px 0 0;
  position: relative;
  overflow: hidden;
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-shrink: 0;
}

.chat-widget .inquiry-modal-header h5 {
  margin: 0;
  font-weight: 600;
  font-size: 18px;
  display: flex;
  align-items: center;
}

.chat-widget .inquiry-close-btn {
  background: rgba(255, 255, 255, 0.2) !important;
  border: 1px solid rgba(255, 255, 255, 0.3) !important;
  color: white !important;
  width: 32px;
  height: 32px;
  border-radius: 16px;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.2s ease;
  cursor: pointer;
  font-size: 16px;
}

.chat-widget .inquiry-close-btn:hover {
  background: rgba(255, 255, 255, 0.3) !important;
  transform: rotate(90deg);
}

/* 모달 바디 */
.chat-widget .inquiry-modal-body {
  padding: 24px;
  flex: 1;
  overflow-y: auto; /* 스크롤 가능하도록 변경 */
  display: flex;
  flex-direction: column;
  max-height: calc(100% - 120px); /* 헤더와 여백을 고려한 최대 높이 */
}

/* ===============================================================================
   문의 유형 선택 카드 - 제공하신 이미지와 동일한 디자인
   =============================================================================== */

.chat-widget #inquiry-types {
  margin-bottom: 20px;
}

.chat-widget .inquiry-option {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 20px;
  margin-bottom: 16px;
  border: 2px solid #e2e8f0;
  border-radius: 16px;
  cursor: pointer;
  transition: all 0.2s ease;
  background: rgba(255, 255, 255, 0.9);
}

.chat-widget .inquiry-option:hover {
  border-color: #667eea;
  background: rgba(102, 126, 234, 0.05);
  transform: translateY(-1px);
  box-shadow: 0 4px 12px rgba(102, 126, 234, 0.1);
}

.chat-widget .inquiry-option:last-child {
  margin-bottom: 0;
}

.chat-widget .inquiry-option-content {
  display: flex;
  align-items: center;
}

.chat-widget .inquiry-option-icon {
  width: 48px;
  height: 48px;
  border-radius: 50%;
  background: linear-gradient(135deg, #667eea, #764ba2);
  display: flex;
  align-items: center;
  justify-content: center;
  color: white;
  font-size: 20px;
  margin-right: 16px;
}

.chat-widget .inquiry-option-text h6 {
  margin: 0;
  font-weight: 600;
  color: #2d3748;
  font-size: 17px;
}

.chat-widget .inquiry-option-text p {
  margin: 4px 0 0 0;
  font-size: 13px;
  color: #718096;
}

.chat-widget .inquiry-option-arrow {
  color: #cbd5e0;
  font-size: 18px;
  transition: all 0.2s ease;
}

.chat-widget .inquiry-option:hover .inquiry-option-arrow {
  color: #667eea;
  transform: translateX(4px);
}

/* ===============================================================================
   읽지않은 메시지 영역 - 제공하신 이미지와 동일한 디자인 구현
   =============================================================================== */

.chat-widget #unread-messages-section {
  margin-top: 20px;
  flex: 1;
  display: flex;
  flex-direction: column;
  min-height: 200px; /* 최소 높이 줄임 */
  max-height: 380px; /* 최대 높이 추가 */
  overflow: hidden; /* 넘치는 내용 숨김 */
}

.chat-widget .unread-messages-header {
  margin-bottom: 16px;
  padding: 12px 16px;
  background: linear-gradient(135deg, #f8fafc, #f1f5f9);
  border-radius: 12px;
  border: 1px solid #e2e8f0;
}

.chat-widget .unread-messages-header h6 {
  margin: 0;
  font-weight: 600;
  color: #2d3748;
  font-size: 16px;
  display: flex;
  align-items: center;
}

.chat-widget .unread-messages-header i {
  color: #ff6b6b;
  margin-right: 8px;
  animation: pulse 2s infinite;
}

.chat-widget .unread-rooms-container {
  flex: 1;
  overflow-y: auto;
  max-height: 240px; /* 높이 조정 */
  padding-right: 4px;
  margin-bottom: 8px; /* 하단 여백 추가 */
}

/* 읽지않은 메시지 방 아이템 - 제공하신 이미지와 완전히 동일한 디자인 */
.chat-widget .room-item,
.chat-widget .unread-room-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 20px;
  margin-bottom: 6px;
  background: white;
  border-radius: 12px;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.06);
  border: 1px solid #e2e8f0;
  cursor: pointer;
  transition: all 0.3s ease;
}

.chat-widget .room-item:hover,
.chat-widget .unread-room-item:hover {
  transform: translateY(0px);
  box-shadow: 0 4px 16px rgba(102, 126, 234, 0.12);
  border-color: #667eea;
}

.chat-widget .room-item:last-child,
.chat-widget .unread-room-item:last-child {
  margin-bottom: 0;
}

/* 방 정보 영역 */
.chat-widget .room-info,
.chat-widget .unread-room-info {
  flex: 1;
  min-width: 0;
}

.chat-widget .room-seller,
.chat-widget .unread-room-seller {
  display: flex;
  align-items: center;
  gap: 8px;
  font-weight: 700;
  font-size: 16px;
  color: #2d3748;
  margin-bottom: 6px;
}

.chat-widget .room-seller i,
.chat-widget .unread-room-seller i {
  color: #667eea;
  font-size: 14px;
  width: 16px;
  text-align: center;
}

.chat-widget .room-message,
.chat-widget .unread-room-message {
  font-size: 13px;
  color: #718096;
  line-height: 1.3;
  margin-bottom: 4px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.chat-widget .room-time,
.chat-widget .unread-room-time {
  font-size: 12px;
  color: #a0aec0;
  display: flex;
  align-items: center;
  gap: 4px;
}

.chat-widget .room-time i,
.chat-widget .unread-room-time i {
  font-size: 10px;
}

/* 읽지않은 개수 배지 - 제공하신 이미지와 동일한 빨간 원형 */
.chat-widget .room-badge,
.chat-widget .unread-room-badge {
  background: linear-gradient(135deg, #ff6b6b 0%, #ee5a52 100%);
  color: white;
  width: 28px;
  height: 28px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 12px;
  font-weight: 700;
  box-shadow: 0 2px 8px rgba(255, 107, 107, 0.3);
  min-width: 28px;
  flex-shrink: 0;
}

.chat-widget .room-badge:hover,
.chat-widget .unread-room-badge:hover {
  animation: pulse 0.5s ease-in-out;
}

/* 빈 상태 */
.chat-widget .unread-rooms-empty {
  text-align: center;
  padding: 40px 20px;
  color: #718096;
}

.chat-widget .unread-rooms-empty i {
  font-size: 2em;
  color: #cbd5e0;
  margin-bottom: 12px;
  display: block;
}

/* 스크롤바 */
.chat-widget .unread-rooms-container::-webkit-scrollbar {
  width: 6px;
}

.chat-widget .unread-rooms-container::-webkit-scrollbar-track {
  background: rgba(0, 0, 0, 0.05);
  border-radius: 3px;
}

.chat-widget .unread-rooms-container::-webkit-scrollbar-thumb {
  background: rgba(102, 126, 234, 0.3);
  border-radius: 3px;
  transition: all 0.2s ease;
}

.chat-widget .unread-rooms-container::-webkit-scrollbar-thumb:hover {
  background: rgba(102, 126, 234, 0.5);
}

/* ===============================================================================
   문의유형 선택 스타일
   =============================================================================== */

.chat-widget .inquiry-type-header {
  text-align: center;
  margin-bottom: 20px;
}

.chat-widget .inquiry-type-header h6 {
  font-size: 18px;
  font-weight: 600;
  color: #333;
  margin-bottom: 8px;
}

.chat-widget .inquiry-type-header p {
  font-size: 14px;
  color: #666;
  margin: 0;
}

.chat-widget .inquiry-type-options {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 15px;
  padding: 0 10px;
}

.chat-widget .inquiry-type-option {
  display: flex;
  align-items: center;
  padding: 20px 15px;
  border: 2px solid #e9ecef;
  border-radius: 12px;
  cursor: pointer;
  transition: all 0.3s ease;
  background: #fff;
}

.chat-widget .inquiry-type-option:hover {
  border-color: #007bff;
  background: #f8f9ff;
  transform: translateY(-2px);
  box-shadow: 0 4px 12px rgba(0, 123, 255, 0.15);
}

.chat-widget .inquiry-type-option.selected {
  border-color: #007bff;
  background: #007bff;
  color: #fff;
}

.chat-widget .inquiry-type-option.selected .inquiry-type-text h6,
.chat-widget .inquiry-type-option.selected .inquiry-type-text p {
  color: #fff;
}

.chat-widget .inquiry-type-icon {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 50px;
  height: 50px;
  background: #f8f9fa;
  border-radius: 50%;
  margin-right: 15px;
  font-size: 20px;
  color: #007bff;
  transition: all 0.3s ease;
}

.chat-widget .inquiry-type-option.selected .inquiry-type-icon {
  background: rgba(255, 255, 255, 0.2);
  color: #fff;
}

.chat-widget .inquiry-type-text h6 {
  font-size: 16px;
  font-weight: 600;
  color: #333;
  margin: 0 0 5px 0;
}

.chat-widget .inquiry-type-text p {
  font-size: 12px;
  color: #666;
  margin: 0;
  line-height: 1.4;
}

/* 문의유형 선택 - 모바일 대응 */
@media (max-width: 480px) {
  .chat-widget .inquiry-type-options {
    grid-template-columns: 1fr;
    gap: 10px;
  }
  
  .chat-widget .inquiry-type-option {
    padding: 15px 10px;
  }
  
  .chat-widget .inquiry-type-icon {
    width: 40px;
    height: 40px;
    font-size: 18px;
    margin-right: 12px;
  }
  
  .chat-widget .inquiry-type-text h6 {
    font-size: 14px;
  }
  
  .chat-widget .inquiry-type-text p {
    font-size: 11px;
  }
}

/* 추가 아이콘들 */
.fas.fa-clipboard-list:before { content: "\f46d" !important; }
.fas.fa-truck:before { content: "\f0d1" !important; }
.fas.fa-undo:before { content: "\f0e2" !important; }
.fas.fa-times-circle:before { content: "\f057" !important; }

/* ===============================================================================
   주문 상품 목록 - 제공하신 두 번째 이미지와 동일한 디자인 구현
   =============================================================================== */

.chat-widget #order-products {
  display: none;
  flex: 1;
  overflow-y: auto;
  max-height: 360px;
  padding-right: 8px;
}

/* 주문 상품 아이템 - 가로 배치로 변경, 컴팩트한 디자인 */
.chat-widget .product-item {
  display: flex !important;
  flex-direction: row !important;
  align-items: center !important;
  padding: 12px !important;
  margin-bottom: 12px !important;
  border: 1px solid #e2e8f0 !important;
  border-radius: 12px !important;
  cursor: pointer !important;
  transition: all 0.2s ease !important;
  background: white !important;
  width: 100% !important;
  box-sizing: border-box !important;
  position: relative !important;
  min-height: 70px !important;
}

.chat-widget .product-item:hover {
  border-color: #667eea !important;
  background: rgba(102, 126, 234, 0.05) !important;
  transform: translateY(0px) !important;
  box-shadow: 0 8px 24px rgba(102, 126, 234, 0.12) !important;
}

.chat-widget .product-item.selected {
  border-color: #667eea !important;
  background: rgba(102, 126, 234, 0.1) !important;
}

.chat-widget .product-item:last-child {
  margin-bottom: 0 !important;
}

/* 상품 상단 정보 영역 - 가로 배치에서는 사용하지 않음 */
.chat-widget .product-header {
  display: none !important;
}

/* 상품 이미지 - 왼쪽에 위치, 크기 조정 */
.chat-widget .product-image {
  width: 50px !important;
  height: 50px !important;
  border-radius: 8px !important;
  object-fit: cover !important;
  margin-right: 12px !important;
  background: #f7fafc !important;
  flex-shrink: 0 !important;
  border: 1px solid #e2e8f0 !important;
}

/* 상품 정보 영역 */
.chat-widget .product-info {
  flex: 1 !important;
  min-width: 0 !important;
  display: flex !important;
  flex-direction: column !important;
  justify-content: center !important;
}

/* 상품명 - 볼드 처리, 컴팩트한 디자인 */
.chat-widget .product-name {
  font-weight: 600 !important;
  color: #2d3748 !important;
  font-size: 14px !important;
  margin-bottom: 4px !important;
  line-height: 1.3 !important;
  display: block !important;
  overflow: hidden !important;
  text-overflow: ellipsis !important;
  white-space: nowrap !important;
  opacity: 1 !important;
  visibility: visible !important;
  position: static !important;
}

/* 주문 세부사항 - 회색 텍스트, 컴팩트한 디자인 */
.chat-widget .product-details {
  font-size: 12px !important;
  color: #718096 !important;
  margin-bottom: 4px !important;
  line-height: 1.3 !important;
  display: block !important;
  opacity: 1 !important;
  visibility: visible !important;
  position: static !important;
  transform: none !important;
  transition: none !important;
}

/* 상품 상태 메시지 - 배지 형태로 디자인 */
.chat-widget .product-status {
  display: inline-block !important;
  padding: 4px 8px !important;
  border-radius: 12px !important;
  font-size: 11px !important;
  font-weight: 600 !important;
  line-height: 1.2 !important;
  margin-left: auto !important;
  margin-right: 0 !important;
  flex-shrink: 0 !important;
  text-align: center !important;
  min-width: 60px !important;
  white-space: nowrap !important;
}

/* 상태별 색상 지정 - 기본 */
.chat-widget .product-status {
  background: #e2e8f0 !important;
  color: #4a5568 !important;
}

/* 배송준비중 */
.chat-widget .product-status.status-preparing {
  background: #fef5e7 !important;
  color: #d69e2e !important;
}

/* 배송중 */
.chat-widget .product-status.status-shipping {
  background: #e6fffa !important;
  color: #319795 !important;
}

/* 취소요청 */
.chat-widget .product-status.status-cancel {
  background: #fed7d7 !important;
  color: #e53e3e !important;
}

/* 교환요청 */
.chat-widget .product-status.status-exchange {
  background: #fbb6ce !important;
  color: #d53f8c !important;
}

/* 하단 버튼 영역 - 가로 배치에서는 사용하지 않음 */
.chat-widget .product-actions {
  display: none !important;
}

/* 뒤로 버튼과 문의하기 버튼 */
.chat-widget .product-btn {
  padding: 12px 20px !important;
  border-radius: 12px !important;
  border: none !important;
  font-weight: 600 !important;
  cursor: pointer !important;
  transition: all 0.2s ease !important;
  font-size: 14px !important;
  flex: 1 !important;
}

.chat-widget .product-btn-back {
  background: #f7fafc !important;
  color: #718096 !important;
  border: 1px solid #e2e8f0 !important;
}

.chat-widget .product-btn-back:hover {
  background: #edf2f7 !important;
  border-color: #cbd5e0 !important;
}

.chat-widget .product-btn-inquiry {
  background: linear-gradient(135deg, #667eea 0%, #764ba2 100%) !important;
  color: white !important;
}

.chat-widget .product-btn-inquiry:hover {
  transform: translateY(-1px) !important;
  box-shadow: 0 4px 12px rgba(102, 126, 234, 0.3) !important;
}

/* ===============================================================================
   로딩 및 빈 상태
   =============================================================================== */

.chat-widget .loading-spinner {
  text-align: center;
  padding: 40px 20px;
  color: #718096;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 12px;
}

.chat-widget .loading-spinner i {
  font-size: 24px;
  color: #667eea;
  animation: fa-spin 1s infinite linear;
}

@keyframes fa-spin {
  0% { transform: rotate(0deg); }
  100% { transform: rotate(360deg); }
}

/* ===============================================================================
   모달 하단 버튼
   =============================================================================== */

.chat-widget .modal-buttons {
  padding: 20px;
  border-top: 1px solid #e2e8f0;
  display: flex;
  gap: 12px;
  background: rgba(255, 255, 255, 0.95);
  backdrop-filter: blur(10px);
  flex-shrink: 0;
  border-radius: 0 0 20px 20px;
}

.chat-widget .btn-modal {
  flex: 1;
  padding: 12px;
  border-radius: 12px;
  border: none;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s ease;
  font-size: 14px;
}

.chat-widget .btn-back {
  background: #f7fafc;
  color: #718096;
  border: 1px solid #e2e8f0;
}

.chat-widget .btn-back:hover {
  background: #edf2f7;
  border-color: #cbd5e0;
}

.chat-widget .btn-confirm {
  background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
  color: white;
}

.chat-widget .btn-confirm:hover {
  transform: translateY(-1px);
  box-shadow: 0 4px 12px rgba(102, 126, 234, 0.3);
}

.chat-widget .btn-confirm:disabled {
  opacity: 0.5;
  cursor: not-allowed;
  transform: none;
  box-shadow: none;
}

/* ===============================================================================
   채팅창
   =============================================================================== */

.chat-widget #chat-box-wrapper {
  position: fixed;
  bottom: 24px;
  right: 24px;
  width: 500px;
  height: 660px;
  background: rgba(255, 255, 255, 0.98);
  backdrop-filter: blur(20px);
  border-radius: 20px;
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.15);
  display: none;
  z-index: 9999;
  overflow: hidden;
  border: 1px solid rgba(255, 255, 255, 0.3);
  font-family: 'Inter', sans-serif;
}

.chat-widget .chat-card {
  width: 100%;
  height: 100%;
  display: flex;
  flex-direction: column;
  background: transparent;
  border: none;
}

/* 채팅 헤더 */
.chat-widget .chat-header {
  background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
  color: white;
  padding: 20px;
  border-bottom: none;
  border-radius: 20px 20px 0 0;
  position: relative;
  overflow: hidden;
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.chat-widget .chat-header h5 {
  margin: 0;
  font-weight: 600;
  font-size: 18px;
  position: relative;
  z-index: 1;
  display: flex;
  align-items: center;
}

.chat-widget .close-btn {
  background: rgba(255, 255, 255, 0.2) !important;
  border: 1px solid rgba(255, 255, 255, 0.3) !important;
  color: white !important;
  width: 36px;
  height: 36px;
  border-radius: 18px;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.2s ease;
  cursor: pointer;
}

.chat-widget .close-btn:hover {
  background: rgba(255, 255, 255, 0.3) !important;
  transform: rotate(90deg);
}

/* 뒤로가기 섹션 */
.chat-widget .chat-back-section {
  background: rgba(248, 250, 252, 0.95);
  backdrop-filter: blur(10px);
  border-bottom: 1px solid rgba(0, 0, 0, 0.05);
  padding: 12px 20px;
  position: relative;
}

.chat-widget .chat-back-button {
  background: rgba(102, 126, 234, 0.1) !important;
  border: 1px solid rgba(102, 126, 234, 0.2) !important;
  color: #667eea !important;
  padding: 8px 16px;
  border-radius: 20px;
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 14px;
  font-weight: 500;
  transition: all 0.2s ease;
  cursor: pointer;
  box-shadow: 0 2px 8px rgba(102, 126, 234, 0.1);
}

.chat-widget .chat-back-button:hover {
  background: rgba(102, 126, 234, 0.15) !important;
  border-color: rgba(102, 126, 234, 0.3) !important;
  transform: translateX(-2px);
  box-shadow: 0 4px 12px rgba(102, 126, 234, 0.2);
}

/* 채팅 박스 */
.chat-widget #chat-box {
  flex-grow: 1;
  overflow-y: auto;
  padding: 20px;
  padding-bottom: 20px;
  background: linear-gradient(to bottom, rgba(248, 250, 252, 0.8), rgba(255, 255, 255, 0.9));
}

/* 채팅 메시지 */
.chat-widget .chat-message {
  max-width: 75%;
  word-break: break-word;
  padding: 12px 16px;
  margin-bottom: 12px;
  position: relative;
  font-size: 14px;
  line-height: 1.4;
}

.chat-widget .chat-message-user {
  background: linear-gradient(135deg, rgba(248, 250, 252, 0.95) 0%, rgba(241, 245, 249, 0.95) 100%);
  color: #334155; /* 어두운 회색 텍스트 */
  border: 2px solid rgba(102, 126, 234, 0.3); /* 컬러 테두리로 구분 */
  border-radius: 20px 20px 20px 6px;
  box-shadow: 0 2px 12px rgba(102, 126, 234, 0.2);
  margin-left: auto;
}

.chat-widget .chat-message-admin {
  background: #ffffff;
  color: #2d3748;
  border-radius: 20px 20px 6px 20px;
  box-shadow: 0 2px 12px rgba(0, 0, 0, 0.08);
  border: 1px solid #e2e8f0;
}

.chat-widget .chat-message-wrapper {
  display: flex;
  flex-direction: column;
  margin-bottom: 16px;
}

.chat-widget .chat-message-wrapper.left {
  align-items: flex-start;
}

.chat-widget .chat-message-wrapper.right {
  align-items: flex-end;
}

.chat-widget .message-info {
  font-size: 11px;
  color: #718096;
  margin-bottom: 4px;
  font-weight: 500;
}

.chat-widget .chat-message-wrapper.right .message-info {
  text-align: right;
}

.chat-widget .read-status {
  font-size: 10px !important;
  margin-top: 4px;
  opacity: 0.7;
  text-align: right;
}

/* 입력 영역 */
.chat-widget .chat-footer {
  display: flex;
  gap: 12px;
  padding: 20px;
  background: rgba(255, 255, 255, 0.95);
  backdrop-filter: blur(10px);
  border-top: 1px solid rgba(0, 0, 0, 0.05);
}

.chat-widget #chat-input {
  resize: none;
  border-radius: 24px;
  padding: 12px 20px;
  border: 2px solid #e2e8f0;
  background: rgba(255, 255, 255, 0.9);
  transition: all 0.2s ease;
  font-size: 14px;
  line-height: 1.4;
  flex: 1;
  outline: none;
  font-family: 'Inter', sans-serif;
}

.chat-widget #chat-input:focus {
  border-color: #667eea;
  box-shadow: 0 0 0 3px rgba(102, 126, 234, 0.1);
  background: white;
}

.chat-widget .btn-action {
  width: 48px;
  height: 48px;
  border-radius: 24px;
  border: 2px solid #e2e8f0;
  background: rgba(255, 255, 255, 0.9);
  color: #667eea;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.2s ease;
  backdrop-filter: blur(10px);
  cursor: pointer;
}

.chat-widget .btn-action:hover {
  background: #667eea;
  color: white;
  border-color: #667eea;
  transform: translateY(-1px);
  box-shadow: 0 4px 12px rgba(102, 126, 234, 0.3);
}

.chat-widget .btn-send {
  background: linear-gradient(135deg, #667eea 0%, #764ba2 100%) !important;
  color: white !important;
  border: none !important;
}

.chat-widget .btn-send:hover {
  transform: translateY(-1px) scale(1.05);
  box-shadow: 0 6px 20px rgba(102, 126, 234, 0.4);
}

/* ===============================================================================
   파일 관련
   =============================================================================== */

.chat-widget #drop-zone {
  display: none;
  text-align: center;
  padding: 40px 20px;
  border: 3px dashed #cbd5e0;
  color: #718096;
  border-radius: 16px;
  margin: 20px;
  background: rgba(255, 255, 255, 0.5);
  transition: all 0.3s ease;
  position: relative;
  z-index: 100;
}

.chat-widget #drop-zone.dragover {
  background: rgba(102, 126, 234, 0.1);
  border-color: #667eea;
  color: #667eea;
  transform: scale(1.02);
  box-shadow: 0 8px 32px rgba(102, 126, 234, 0.2);
}

.chat-widget #drop-zone-close {
  position: absolute;
  top: 8px;
  right: 8px;
  width: 28px;
  height: 28px;
  background: rgba(255, 255, 255, 0.9);
  border: 1px solid #e2e8f0;
  border-radius: 50%;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 14px;
  color: #718096;
  transition: all 0.2s ease;
  z-index: 101;
}

.chat-widget #drop-zone-close:hover {
  background: #f56565;
  color: white;
  border-color: #f56565;
  transform: scale(1.1);
}

.chat-widget .chat-image {
  max-width: 200px;
  max-height: 200px;
  border-radius: 12px;
  cursor: pointer;
  transition: all 0.2s ease;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
  display: block;
  object-fit: cover;
  background: rgba(0, 0, 0, 0.1);
}

.chat-widget .chat-image:hover {
  transform: scale(1.02);
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.2);
}

/* ===============================================================================
   리사이즈 핸들
   =============================================================================== */

.chat-widget #resize-handle {
  position: absolute;
  width: 24px;
  height: 24px;
  top: 8px;
  left: 8px;
  cursor: nwse-resize;
  z-index: 10;
  background: rgba(255, 255, 255, 0.1);
  border-radius: 6px;
  display: flex;
  align-items: center;
  justify-content: center;
  opacity: 0;
  transition: opacity 0.2s ease;
}

.chat-widget #chat-box-wrapper:hover #resize-handle {
  opacity: 1;
}

.chat-widget #resize-handle::after {
  content: '⋮⋮';
  color: rgba(255, 255, 255, 0.6);
  font-size: 12px;
  transform: rotate(45deg);
}

/* ===============================================================================
   타이핑 인디케이터
   =============================================================================== */

.chat-widget #typing-indicator {
  padding: 8px 20px;
  font-size: 12px;
  color: #718096;
  display: none;
  font-style: italic;
  animation: pulse 1.5s infinite;
}

/* ===============================================================================
   반응형 디자인
   =============================================================================== */

@media (max-width: 768px) {
  .chat-widget #chat-toggle-btn {
    bottom: 100px;
    right: 16px;
  }

  .chat-widget #chat-box-wrapper {
    position: fixed !important;
    top: 0 !important;
    left: 0 !important;
    right: 0 !important;
    bottom: 0 !important;
    width: 100vw !important;
    height: 100vh !important;
    border-radius: 0 !important;
    border: none !important;
  }

  .chat-widget #chat-box {
    padding: 16px !important;
    padding-bottom: 140px !important;
    height: calc(100vh - 200px) !important;
    -webkit-overflow-scrolling: touch !important;
  }

  .chat-widget .chat-footer {
    position: fixed !important;
    bottom: 0 !important;
    left: 0 !important;
    right: 0 !important;
    background: rgba(255, 255, 255, 0.98) !important;
    backdrop-filter: blur(20px) !important;
    z-index: 1000 !important;
    padding: 16px !important;
    padding-bottom: calc(16px + env(safe-area-inset-bottom, 0px)) !important;
  }

  .chat-widget #inquiry-modal {
    position: fixed !important;
    top: 0 !important;
    left: 0 !important;
    right: 0 !important;
    bottom: 0 !important;
    width: 100vw !important;
    height: 100vh !important;
    border-radius: 0 !important;
    border: none !important;
  }

  .chat-widget .inquiry-modal-header {
    border-radius: 0 !important;
    padding-top: calc(20px + env(safe-area-inset-top, 0px)) !important;
  }

  .chat-widget .product-item {
    padding: 16px !important;
    margin-bottom: 12px !important;
  }

  .chat-widget .product-header {
    margin-bottom: 12px !important;
  }

  .chat-widget .product-image {
    width: 50px !important;
    height: 50px !important;
    margin-right: 12px !important;
  }

  .chat-widget .product-name {
    font-size: 15px !important;
    margin-bottom: 6px !important;
  }

  .chat-widget .product-details {
    font-size: 12px !important;
    margin-bottom: 6px !important;
  }
}

@media (max-width: 480px) {
  .chat-widget #chat-toggle-btn button {
    width: 56px;
    height: 56px;
  }

  .chat-widget #chat-badge {
    top: -6px;
    left: -6px;
    min-width: 20px;
    height: 20px;
    font-size: 10px;
    border: 2px solid white;
  }

  .chat-widget .chat-footer {
    padding: 12px !important;
    gap: 8px;
  }

  .chat-widget .btn-action {
    width: 44px;
    height: 44px;
  }

  .chat-widget #chat-input {
    font-size: 16px !important;
    min-height: 44px;
  }
}

/* 안전 영역 대응 (iPhone X 이상) */
@supports (padding-top: env(safe-area-inset-top)) {
  @media (max-width: 768px) {
    .chat-widget .chat-header {
      padding-top: calc(20px + env(safe-area-inset-top, 0px)) !important;
    }
    
    .chat-widget .chat-footer {
      padding-bottom: calc(45px + env(safe-area-inset-bottom, 0px)) !important;
    }

    .chat-widget .inquiry-modal-header {
      padding-top: calc(20px + env(safe-area-inset-top, 0px)) !important;
    }
  }
}

/* 파일 메시지 스타일 */
.chat-widget .chat-message a {
  color: #667eea;
  text-decoration: none;
  word-break: break-all;
}

.chat-widget .chat-message a:hover {
  text-decoration: underline;
}

/* 이미지 파일명 스타일 */
.chat-widget .chat-message a > div {
  font-size: 12px;
  color: #6b7280;
  margin-top: 4px;
  word-break: break-all;
}

/* 일반 파일명 스타일 */
.chat-widget .chat-message a > i + text,
.chat-widget .chat-message a {
  font-size: 14px;
}

/* 터치 디바이스 최적화 */
@media (hover: none) and (pointer: coarse) {
  .chat-widget .inquiry-option:hover {
    transform: none;
    box-shadow: none;
  }

  .chat-widget .inquiry-option:active {
    background: rgba(102, 126, 234, 0.1) !important;
    transform: scale(0.98);
  }

  .chat-widget .room-item:hover,
  .chat-widget .unread-room-item:hover {
    transform: none;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.06);
  }

  .chat-widget .room-item:active,
  .chat-widget .unread-room-item:active {
    background: rgba(102, 126, 234, 0.05) !important;
    transform: scale(0.98);
  }

  .chat-widget #chat-box {
    overscroll-behavior: contain;
    scroll-behavior: smooth;
  }
}
