/* 채팅 위젯 스타일 */

.chat-widget-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.3);
  z-index: 99998;
  animation: fadeIn 0.2s ease-in;
}

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

.chat-widget {
  position: fixed;
  right: 24px;
  bottom: 24px;
  width: 900px;
  height: 700px;
  max-width: calc(100vw - 48px);
  max-height: calc(100vh - 100px);
  background: white;
  border-radius: 20px;
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.2), 0 8px 16px rgba(0, 0, 0, 0.1);
  display: flex;
  flex-direction: column;
  z-index: 99999;
  animation: slideUp 0.4s cubic-bezier(0.4, 0, 0.2, 1);
  overflow: hidden;
}

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

.chat-widget-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 20px 24px;
  background: linear-gradient(135deg, #4CAF50 0%, #66BB6A 100%);
  box-shadow: 0 4px 16px rgba(76, 175, 80, 0.2);
  position: relative;
}

.chat-widget-header::after {
  content: '';
  position: absolute;
  bottom: 0;
  left: 0;
  right: 0;
  height: 1px;
  background: linear-gradient(90deg, transparent, rgba(255,255,255,0.3), transparent);
}

.chat-widget-header-left {
  display: flex;
  align-items: center;
  gap: 8px;
}

.chat-widget-icon {
  font-size: 26px;
  filter: drop-shadow(0 2px 4px rgba(0, 0, 0, 0.2));
}

.chat-widget-title {
  font-size: 1.25rem;
  font-weight: 800;
  color: white;
  margin: 0;
  text-shadow: 0 2px 4px rgba(0, 0, 0, 0.2);
  letter-spacing: -0.02em;
}

.chat-widget-back {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  border: none;
  background: rgba(255, 255, 255, 0.3);
  color: white;
  font-size: 20px;
  font-weight: bold;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.2s;
  margin-right: 4px;
}

.chat-widget-back:hover {
  background: rgba(255, 255, 255, 0.5);
  transform: translateX(-2px);
}

.chat-widget-close {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  border: none;
  background: rgba(255, 255, 255, 0.3);
  color: white;
  font-size: 20px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.2s;
}

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

/* 관리자용: 채팅방 목록 */
.chat-room-list-container {
  display: flex;
  flex-direction: column;
  flex: 1;
  border-right: 1px solid #E0E0E0;
  background: white;
  overflow: hidden;
}

.chat-room-list-header {
  padding: 20px 16px 16px 16px;
  background: linear-gradient(135deg, #F8F9FA 0%, #FFFFFF 100%);
  border-bottom: 2px solid #F0F0F0;
}

.chat-room-filter {
  width: 100%;
  padding: 12px 16px;
  border: 2px solid #E8E8E8;
  border-radius: 12px;
  font-size: 0.9375rem;
  font-weight: 600;
  color: #2C3E50;
  background: white;
  cursor: pointer;
  outline: none;
  transition: all 0.3s ease;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.04);
}

.chat-room-filter:hover {
  border-color: #4CAF50;
  box-shadow: 0 4px 12px rgba(76, 175, 80, 0.15);
  transform: translateY(-1px);
}

.chat-room-filter:focus {
  border-color: #4CAF50;
  box-shadow: 0 0 0 3px rgba(76, 175, 80, 0.1);
}

.chat-room-list {
  flex: 1;
  overflow-y: auto;
  background: #F8F9FA;
  padding: 8px;
}

.chat-room-item {
  margin-bottom: 8px;
  padding: 16px;
  border-radius: 12px;
  background: white;
  cursor: pointer;
  transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  position: relative;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.06);
  border: 2px solid transparent;
}

.chat-room-item:hover {
  transform: translateY(-2px);
  box-shadow: 0 6px 20px rgba(0, 0, 0, 0.1);
  border-color: #E8F5E9;
}

.chat-room-item.active {
  background: linear-gradient(135deg, #E8F5E9 0%, #F1F8F4 100%);
  border-color: #4CAF50;
  box-shadow: 0 6px 20px rgba(76, 175, 80, 0.2);
  transform: translateY(-2px);
}

.chat-room-item.active::before {
  content: '';
  position: absolute;
  left: 0;
  top: 50%;
  transform: translateY(-50%);
  width: 4px;
  height: 60%;
  background: linear-gradient(180deg, #4CAF50 0%, #66BB6A 100%);
  border-radius: 0 4px 4px 0;
}

.room-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  margin-bottom: 8px;
}

.user-email {
  font-weight: 700;
  color: #1A1A1A;
  font-size: 0.9375rem;
  letter-spacing: -0.01em;
  flex: 1;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.unread-badge {
  background: linear-gradient(135deg, #FF5252 0%, #F44336 100%);
  color: white;
  min-width: 22px;
  height: 22px;
  padding: 0 7px;
  border-radius: 11px;
  font-size: 11px;
  font-weight: 700;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 2px 8px rgba(244, 67, 54, 0.3);
  animation: pulse 2s ease-in-out infinite;
}

@keyframes pulse {
  0%, 100% {
    transform: scale(1);
  }
  50% {
    transform: scale(1.05);
  }
}

.room-title {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 8px;
}

.report-type {
  font-size: 0.6875rem;
  padding: 4px 10px;
  background: linear-gradient(135deg, #E3F2FD 0%, #BBDEFB 100%);
  border-radius: 8px;
  color: #1565C0;
  font-weight: 700;
  flex-shrink: 0;
  text-transform: uppercase;
  letter-spacing: 0.02em;
  box-shadow: 0 2px 4px rgba(25, 118, 210, 0.15);
}

.report-title {
  font-size: 0.875rem;
  color: #546E7A;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  flex: 1;
  font-weight: 500;
}

.last-message-time {
  font-size: 0.75rem;
  color: #90A4AE;
  font-weight: 500;
  display: flex;
  align-items: center;
  gap: 4px;
}

.last-message-time::before {
  content: '🕐';
  font-size: 0.875rem;
}

/* 메시지 컨테이너 (목록과 분리) */
.chat-messages-container {
  display: flex;
  flex-direction: column;
  flex: 1;
  overflow: hidden;
}

/* 메시지 영역 */
.chat-widget-messages {
  flex: 1;
  overflow-y: auto;
  background: #FAFAFA;
  padding: 16px 0;
  position: relative;
}

.chat-widget-loading,
.chat-widget-empty {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  height: 100%;
  padding: 32px;
  text-align: center;
  color: #616161;
}

.spinner {
  width: 48px;
  height: 48px;
  border: 4px solid #F0F0F0;
  border-top-color: #4CAF50;
  border-right-color: #66BB6A;
  border-radius: 50%;
  animation: spin 0.8s cubic-bezier(0.4, 0, 0.2, 1) infinite;
  margin-bottom: 20px;
  box-shadow: 0 4px 12px rgba(76, 175, 80, 0.15);
}

@keyframes spin {
  to { transform: rotate(360deg); }
}

.empty-icon {
  font-size: 56px;
  margin-bottom: 20px;
  filter: drop-shadow(0 4px 8px rgba(0, 0, 0, 0.1));
  animation: float 3s ease-in-out infinite;
}

@keyframes float {
  0%, 100% {
    transform: translateY(0);
  }
  50% {
    transform: translateY(-10px);
  }
}

.chat-messages-list {
  padding: 0 16px;
}

.message-bubble {
  display: flex;
  padding: 8px 0;
  animation: fadeInMsg 0.3s ease-in;
}

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

.message-bubble.user {
  justify-content: flex-end;
}

.message-bubble.admin,
.message-bubble.system {
  justify-content: flex-start;
}

.message-content {
  max-width: 75%;
  padding: 12px 16px;
  border-radius: 16px;
}

.message-bubble.user .message-content {
  background: linear-gradient(135deg, #FFC107 0%, #FFD54F 100%);
  border-bottom-right-radius: 4px;
  box-shadow: 0 4px 12px rgba(255, 193, 7, 0.25);
  position: relative;
}

.message-bubble.user .message-content::before {
  content: '';
  position: absolute;
  right: -8px;
  bottom: 0;
  width: 0;
  height: 0;
  border-style: solid;
  border-width: 0 0 16px 16px;
  border-color: transparent transparent #FFD54F transparent;
}

.message-bubble.admin .message-content {
  background: white;
  border: 2px solid #F0F0F0;
  border-bottom-left-radius: 4px;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.08);
  position: relative;
}

.message-bubble.admin .message-content::before {
  content: '';
  position: absolute;
  left: -8px;
  bottom: 0;
  width: 0;
  height: 0;
  border-style: solid;
  border-width: 0 16px 16px 0;
  border-color: transparent white transparent transparent;
  filter: drop-shadow(-2px 2px 2px rgba(0,0,0,0.05));
}

.message-bubble.system .message-content {
  background: linear-gradient(135deg, #F5F5F5 0%, #FAFAFA 100%);
  border: 2px solid #E8E8E8;
  border-radius: 12px;
  text-align: center;
  max-width: 85%;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.05);
}

.message-text {
  color: #212121;
  font-size: 0.9375rem;
  line-height: 1.5;
  margin: 0 0 8px 0;
  white-space: pre-wrap;
  word-break: break-word;
  font-family: inherit;
}

.message-time {
  font-size: 0.75rem;
  color: #616161;
}

.message-bubble.user .message-time {
  color: #9E6300;
}

/* 입력 영역 */
.chat-widget-input {
  display: flex;
  align-items: flex-end;
  gap: 12px;
  padding: 16px 20px;
  border-top: 2px solid #F0F0F0;
  background: linear-gradient(135deg, #FAFAFA 0%, #FFFFFF 100%);
  box-shadow: 0 -4px 12px rgba(0, 0, 0, 0.03);
}

.chat-input-textarea {
  flex: 1;
  min-height: 44px;
  max-height: 120px;
  padding: 12px 16px;
  border: 2px solid #E8E8E8;
  border-radius: 22px;
  font-size: 0.9375rem;
  font-family: inherit;
  resize: none;
  outline: none;
  transition: all 0.3s ease;
  overflow-y: auto;
  background: white;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.04);
}

.chat-input-textarea:focus {
  border-color: #4CAF50;
  box-shadow: 0 4px 12px rgba(76, 175, 80, 0.15), 0 0 0 3px rgba(76, 175, 80, 0.1);
}

.chat-input-textarea::placeholder {
  color: #B0BEC5;
}

.chat-send-btn {
  width: 44px;
  height: 44px;
  border-radius: 50%;
  border: none;
  background: linear-gradient(135deg, #4CAF50 0%, #66BB6A 100%);
  color: white;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  flex-shrink: 0;
  box-shadow: 0 4px 12px rgba(76, 175, 80, 0.3);
}

.chat-send-btn:hover:not(:disabled) {
  background: linear-gradient(135deg, #66BB6A 0%, #81C784 100%);
  transform: scale(1.08);
  box-shadow: 0 6px 20px rgba(76, 175, 80, 0.4);
}

.chat-send-btn:active:not(:disabled) {
  transform: scale(0.95);
}

.chat-send-btn:disabled {
  background: linear-gradient(135deg, #E0E0E0 0%, #EEEEEE 100%);
  cursor: not-allowed;
  color: #BDBDBD;
  box-shadow: none;
}

/* 빈 상태 */
.empty-state {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  height: 100%;
  padding: 40px;
  text-align: center;
  color: #78909C;
}

.empty-state p {
  margin: 0;
  font-size: 1rem;
  font-weight: 500;
  line-height: 1.6;
}

/* 스크롤바 커스터마이징 */
.chat-room-list::-webkit-scrollbar,
.chat-widget-messages::-webkit-scrollbar {
  width: 6px;
}

.chat-room-list::-webkit-scrollbar-track,
.chat-widget-messages::-webkit-scrollbar-track {
  background: transparent;
}

.chat-room-list::-webkit-scrollbar-thumb,
.chat-widget-messages::-webkit-scrollbar-thumb {
  background: #CFD8DC;
  border-radius: 3px;
  transition: background 0.3s ease;
}

.chat-room-list::-webkit-scrollbar-thumb:hover,
.chat-widget-messages::-webkit-scrollbar-thumb:hover {
  background: #B0BEC5;
}

/* 반응형 */
@media (max-width: 1024px) {
  .chat-widget {
    inset: 0 !important;
    width: 100% !important;
    height: 100% !important;
    max-width: 100vw !important;
    max-height: 100vh !important;
    border-radius: 0;
    right: 0 !important;
    bottom: 0 !important;
  }

  .chat-widget-header {
    border-radius: 0;
  }

  .chat-room-list-container {
    flex: 1;
    border-right: none;
  }

  .chat-messages-container {
    flex: 1;
  }
}

@media (max-width: 768px) {
  .message-content {
    max-width: 85%;
  }

  .message-text {
    font-size: 0.875rem;
  }

  .chat-input-textarea {
    font-size: 16px; /* iOS 확대 방지 */
  }
}
