/* =====================================================
   CHAT.CSS — 디스코드 스타일 채팅
===================================================== */

.chat-container {
  display: flex;
  height: calc(100vh - var(--nav-h));
  background: var(--bg-primary);
}

/* ── 왼쪽 사이드바 ── */
.chat-sidebar {
  width: 260px;
  background: var(--bg-secondary);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  flex-shrink: 0;
}

.chat-sidebar-header {
  padding: 16px;
  border-bottom: 1px solid var(--border);
}

.chat-sidebar-header h3 {
  font-size: 15px;
  font-weight: 700;
  color: var(--text-primary);
  margin-bottom: 8px;
}

.online-count {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 12px;
  color: var(--text-muted);
}

.online-dot {
  width: 8px;
  height: 8px;
  background: #22c55e;
  border-radius: 50%;
  animation: pulse 2s ease infinite;
}

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

.chat-channels {
  flex: 1;
  overflow-y: auto;
  padding: 12px 8px;
}

.channel-section {
  margin-bottom: 20px;
}

.channel-section-title {
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--text-muted);
  padding: 0 8px 6px;
}

.channel-item {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 6px 10px;
  border-radius: 8px;
  cursor: pointer;
  transition: all 0.15s;
  color: var(--text-secondary);
  font-size: 14px;
  font-weight: 500;
  position: relative;
}

.channel-item:hover {
  background: var(--bg-hover);
  color: var(--text-primary);
}

.channel-item.active {
  background: rgba(91,141,238,0.12);
  color: var(--sky-600);
  font-weight: 600;
}

.channel-icon {
  font-size: 18px;
  color: var(--text-muted);
  font-weight: 600;
}

.channel-item.active .channel-icon {
  color: var(--sky-600);
}

.channel-name { flex: 1; }

.unread-badge {
  background: #ef4444;
  color: white;
  font-size: 10px;
  font-weight: 700;
  padding: 2px 6px;
  border-radius: 10px;
  min-width: 18px;
  text-align: center;
}

/* 온라인 사용자 */
.online-users {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.online-user-item {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 6px 10px;
  border-radius: 6px;
  font-size: 13px;
  color: var(--text-secondary);
  transition: all 0.15s;
}

.online-user-item:hover {
  background: var(--bg-hover);
  color: var(--text-primary);
}

.online-user-avatar {
  width: 24px;
  height: 24px;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--sky-400), var(--sky-600));
  color: white;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 11px;
  font-weight: 700;
  flex-shrink: 0;
}

.online-user-name {
  flex: 1;
  font-weight: 500;
}

.online-status {
  width: 8px;
  height: 8px;
  background: #22c55e;
  border-radius: 50%;
  flex-shrink: 0;
}

/* ── 중앙 채팅 영역 ── */
.chat-main {
  flex: 1;
  display: flex;
  flex-direction: column;
  background: var(--bg-card);
  min-width: 0;
}

.chat-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 20px;
  border-bottom: 1px solid var(--border);
  background: var(--bg-card);
  box-shadow: 0 1px 3px rgba(0,0,0,0.03);
}

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

.chat-channel-icon {
  font-size: 22px;
  color: var(--text-muted);
  font-weight: 700;
}

.chat-channel-name {
  font-size: 16px;
  font-weight: 700;
  color: var(--text-primary);
}

.chat-channel-desc {
  font-size: 12px;
  color: var(--text-muted);
  padding-left: 12px;
  border-left: 1px solid var(--border);
}

/* 채팅 메시지 영역 */
.chat-messages {
  flex: 1;
  overflow-y: auto;
  padding: 16px 20px;
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.chat-messages::-webkit-scrollbar { width: 8px; }
.chat-messages::-webkit-scrollbar-thumb {
  background: var(--border-strong);
  border-radius: 4px;
}
.chat-messages::-webkit-scrollbar-thumb:hover {
  background: var(--text-muted);
}

/* 환영 메시지 */
.chat-welcome {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 60px 20px;
  text-align: center;
  color: var(--text-muted);
}

.chat-welcome-icon {
  font-size: 48px;
  margin-bottom: 16px;
  filter: grayscale(0.3);
}

.chat-welcome h3 {
  font-size: 18px;
  font-weight: 700;
  color: var(--text-primary);
  margin-bottom: 8px;
}

.chat-welcome p {
  font-size: 14px;
  color: var(--text-secondary);
}

/* 채팅 메시지 아이템 */
.chat-message {
  display: flex;
  gap: 14px;
  padding: 6px 10px;
  border-radius: 6px;
  transition: background 0.1s;
  animation: fadeIn 0.2s ease;
}

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

.chat-message:hover {
  background: var(--bg-secondary);
}

.chat-message.own-message {
  background: rgba(59,130,246,0.05);
}

.chat-message.own-message:hover {
  background: rgba(59,130,246,0.08);
}

.chat-msg-avatar {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--sky-400), var(--sky-600));
  color: white;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 14px;
  font-weight: 700;
  flex-shrink: 0;
}

.chat-msg-content {
  flex: 1;
  min-width: 0;
}

.chat-msg-header {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 2px;
}

.chat-msg-username {
  font-size: 14px;
  font-weight: 700;
  color: var(--text-primary);
}

.chat-msg-time {
  font-size: 11px;
  color: var(--text-muted);
  font-weight: 500;
}

.chat-msg-text {
  font-size: 14px;
  color: var(--text-primary);
  line-height: 1.5;
  word-wrap: break-word;
  white-space: pre-wrap;
}

/* ── 채팅 메시지 삭제 버튼 ── */
.chat-msg-delete-btn {
  background: none;
  border: none;
  cursor: pointer;
  font-size: 13px;
  opacity: 0;
  padding: 2px 5px;
  border-radius: 4px;
  transition: opacity 0.15s, background 0.15s;
  line-height: 1;
  margin-left: 2px;
  flex-shrink: 0;
}

.chat-message:hover .chat-msg-delete-btn {
  opacity: 1;
}

.chat-msg-delete-btn:hover {
  background: rgba(239, 68, 68, 0.12);
}

/* 날짜 구분선 */
.chat-date-divider {
  display: flex;
  align-items: center;
  gap: 12px;
  margin: 20px 0 12px;
}

.chat-date-divider::before,
.chat-date-divider::after {
  content: '';
  flex: 1;
  height: 1px;
  background: var(--border);
}

.chat-date-label {
  font-size: 11px;
  font-weight: 700;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

/* 채팅 입력 */
.chat-input-container {
  padding: 16px 20px;
  border-top: 1px solid var(--border);
  background: var(--bg-card);
}

.chat-input-wrapper {
  display: flex;
  align-items: flex-end;
  gap: 10px;
  background: var(--bg-secondary);
  border: 1.5px solid var(--border-strong);
  border-radius: 12px;
  padding: 10px 12px;
  transition: all 0.2s;
}

.chat-input-wrapper:focus-within {
  border-color: var(--sky-500);
  box-shadow: 0 0 0 3px rgba(59,130,246,0.1);
}

.chat-input-wrapper textarea {
  flex: 1;
  border: none;
  background: transparent;
  resize: none;
  outline: none;
  font-family: 'DM Sans', sans-serif;
  font-size: 14px;
  color: var(--text-primary);
  line-height: 1.5;
  max-height: 120px;
  overflow-y: auto;
}

.chat-input-wrapper textarea::placeholder {
  color: var(--text-muted);
}

.chat-send-btn {
  width: 36px;
  height: 36px;
  border: none;
  border-radius: 8px;
  background: linear-gradient(135deg, var(--sky-500), var(--sky-600));
  color: white;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.2s;
  flex-shrink: 0;
}

.chat-send-btn:hover {
  transform: translateY(-2px);
  box-shadow: 0 4px 12px rgba(59,130,246,0.4);
}

.chat-send-btn:active { transform: translateY(0); }

.chat-send-btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
  transform: none;
}

.chat-input-hint {
  margin-top: 8px;
  font-size: 11px;
  color: var(--text-muted);
  text-align: center;
}

.chat-input-hint span {
  padding: 2px 6px;
  background: var(--bg-secondary);
  border-radius: 4px;
  font-weight: 600;
}

/* ── 오른쪽 공지 패널 ── */
.chat-info-panel {
  width: 300px;
  background: var(--bg-secondary);
  border-left: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  flex-shrink: 0;
}

.info-panel-header {
  padding: 16px;
  border-bottom: 1px solid var(--border);
}

.info-panel-header h3 {
  font-size: 14px;
  font-weight: 700;
  color: var(--text-primary);
}

.info-panel-body {
  flex: 1;
  overflow-y: auto;
  padding: 12px;
}

.notice-panel-item {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-left: 3px solid var(--sky-500);
  border-radius: 8px;
  padding: 12px;
  margin-bottom: 10px;
  transition: all 0.2s;
}

.notice-panel-item:hover {
  box-shadow: 0 2px 8px rgba(0,0,0,0.06);
}

.notice-panel-item.pinned {
  border-left-color: #f59e0b;
  background: rgba(251,191,36,0.05);
}

.notice-panel-type {
  display: inline-block;
  padding: 2px 8px;
  border-radius: 6px;
  font-size: 10px;
  font-weight: 700;
  text-transform: uppercase;
  margin-bottom: 6px;
}

.notice-panel-type.info    { background: rgba(59,130,246,0.1);  color: #2563eb; }
.notice-panel-type.warning { background: rgba(251,191,36,0.1);  color: #d97706; }
.notice-panel-type.event   { background: rgba(168,85,247,0.1);  color: #9333ea; }
.notice-panel-type.update  { background: rgba(34,197,94,0.1);   color: #16a34a; }

.notice-panel-title {
  font-size: 13px;
  font-weight: 700;
  color: var(--text-primary);
  margin-bottom: 4px;
  line-height: 1.3;
}

.notice-panel-content {
  font-size: 12px;
  color: var(--text-secondary);
  line-height: 1.4;
  margin-bottom: 6px;
}

.notice-panel-time {
  font-size: 10px;
  color: var(--text-muted);
}

.notice-empty {
  text-align: center;
  padding: 40px 20px;
  color: var(--text-muted);
  font-size: 13px;
}

/* 로딩 */
.loading-small {
  display: flex;
  justify-content: center;
  align-items: center;
  padding: 20px;
  gap: 6px;
}

.loading-small::before,
.loading-small::after {
  content: '';
  width: 8px;
  height: 8px;
  background: var(--sky-500);
  border-radius: 50%;
  animation: bounce 1.4s ease infinite;
}

.loading-small::after { animation-delay: 0.2s; }

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

/* 반응형 */
@media (max-width: 1200px) {
  .chat-info-panel { display: none; }
}

@media (max-width: 768px) {
  .chat-sidebar { width: 220px; }
  .chat-channel-desc { display: none; }
}

@media (max-width: 600px) {
  .chat-sidebar {
    position: absolute;
    left: -260px;
    z-index: 100;
    height: 100%;
    transition: left 0.3s;
  }
  .chat-sidebar.open {
    left: 0;
    box-shadow: 4px 0 12px rgba(0,0,0,0.1);
  }
}
