/* messages/msg-style.css — 디스코드 스타일 메시지 페이지 */

/* ─────────────────────────────────────────
   메시지 전체 레이아웃
───────────────────────────────────────── */
.msg-layout {
    display: flex;
    flex: 1;
    height: 100vh;
    overflow: hidden;
    background-color: var(--bg-0);
}

/* ─────────────────────────────────────────
   채널/DM 사이드바 (디스코드 왼쪽 채널 패널)
───────────────────────────────────────── */
.msg-sidebar {
    width: 240px;
    min-width: 240px;
    background-color: var(--bg-1);
    border-right: 1px solid var(--border);
    display: flex;
    flex-direction: column;
    height: 100%;
    overflow: hidden;
}

.msg-sidebar-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 18px 16px 14px;
    border-bottom: 1px solid var(--border);
    flex-shrink: 0;
}

.msg-sidebar-header h2 {
    font-size: 1rem;
    font-weight: 800;
    color: var(--text-0);
    letter-spacing: -0.5px;
}

/* 검색창 */
.msg-search-wrap {
    position: relative;
    margin: 12px 10px;
    flex-shrink: 0;
}

.msg-search-wrap .search-icon {
    position: absolute;
    left: 10px;
    top: 50%;
    transform: translateY(-50%);
    font-size: 18px;
    color: var(--text-3);
    pointer-events: none;
}

.msg-search-wrap input {
    width: 100%;
    background-color: var(--bg-0);
    border: 1px solid var(--border);
    border-radius: 8px;
    padding: 8px 12px 8px 36px;
    color: var(--text-0);
    font-size: 0.85rem;
    font-family: inherit;
    outline: none;
    transition: var(--transition-fast);
}

.msg-search-wrap input:focus {
    border-color: var(--primary);
    background-color: var(--bg-2);
}

.msg-search-wrap input::placeholder {
    color: var(--text-3);
}

/* 채널 섹션 */
.msg-channel-section {
    margin-top: 4px;
    overflow: hidden;
    flex-shrink: 0;
}

.channel-section-label {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 6px 8px 4px 12px;
    color: var(--text-3);
    font-size: 0.72rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.06em;
}

.add-channel-btn {
    color: var(--text-3);
    padding: 2px;
    border-radius: 4px;
    line-height: 1;
    transition: var(--transition-fast);
}

.add-channel-btn:hover {
    color: var(--text-0);
    background: var(--bg-2);
}

.add-channel-btn .material-symbols-rounded {
    font-size: 18px;
}

/* 채널 리스트 */
.channel-list {
    list-style: none;
    padding: 0 6px;
    max-height: 220px;
    overflow-y: auto;
    scrollbar-width: thin;
    scrollbar-color: var(--border) transparent;
}

.channel-list::-webkit-scrollbar { width: 4px; }
.channel-list::-webkit-scrollbar-track { background: transparent; }
.channel-list::-webkit-scrollbar-thumb { background: var(--border); border-radius: 4px; }

.channel-loading {
    display: flex;
    justify-content: center;
    padding: 16px;
    color: var(--text-3);
}

.channel-item {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 6px 10px;
    border-radius: 6px;
    cursor: pointer;
    color: var(--text-2);
    font-size: 0.9rem;
    font-weight: 500;
    transition: var(--transition-fast);
    position: relative;
    margin-bottom: 1px;
}

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

.channel-item.active {
    background: var(--primary-alpha);
    color: var(--primary);
    font-weight: 700;
}

.channel-item .channel-avatar {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    object-fit: cover;
    flex-shrink: 0;
}

.channel-item .channel-hash {
    font-size: 18px;
    color: var(--text-3);
    flex-shrink: 0;
}

.channel-item.active .channel-hash {
    color: var(--primary);
}

.channel-item .channel-name {
    flex: 1;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.channel-item .unread-badge {
    background: var(--primary);
    color: white;
    font-size: 0.7rem;
    font-weight: 700;
    min-width: 18px;
    height: 18px;
    border-radius: 9px;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 0 5px;
}

.channel-item .online-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: #3ba55c;
    flex-shrink: 0;
}

/* 하단 유저 바 */
.msg-user-bar {
    margin-top: auto;
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px 12px;
    background-color: var(--bg-2);
    border-top: 1px solid var(--border);
    flex-shrink: 0;
}

.msg-user-avatar {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    object-fit: cover;
    flex-shrink: 0;
}

.msg-user-info {
    flex: 1;
    min-width: 0;
}

.msg-username {
    font-size: 0.88rem;
    font-weight: 700;
    color: var(--text-0);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.msg-user-status {
    font-size: 0.75rem;
    color: var(--text-3);
    display: flex;
    align-items: center;
    gap: 4px;
}

.status-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    flex-shrink: 0;
}

.status-dot.online { background: #3ba55c; }
.status-dot.offline { background: var(--text-3); }

/* ─────────────────────────────────────────
   채팅 메인 영역
───────────────────────────────────────── */
.msg-chat-area {
    flex: 1;
    display: flex;
    flex-direction: column;
    height: 100%;
    overflow: hidden;
    background-color: var(--bg-0);
}

/* 웰컴 화면 */
.chat-welcome {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    color: var(--text-3);
    text-align: center;
    gap: 12px;
}

.welcome-icon {
    font-size: 64px;
    color: var(--primary);
    opacity: 0.5;
}

.chat-welcome h2 {
    font-size: 1.4rem;
    font-weight: 800;
    color: var(--text-1);
}

.chat-welcome p {
    font-size: 0.9rem;
    color: var(--text-2);
    line-height: 1.7;
}

/* 채팅방 */
.chat-room {
    flex: 1;
    display: flex;
    flex-direction: column;
    height: 100%;
    overflow: hidden;
}

/* 채팅 헤더 */
.chat-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 14px 20px;
    border-bottom: 1px solid var(--border);
    background: rgba(5,5,5,0.88);
    backdrop-filter: blur(20px);
    flex-shrink: 0;
    z-index: 10;
}

.chat-header-info {
    display: flex;
    align-items: center;
    gap: 12px;
}

.chat-room-avatar {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    object-fit: cover;
}

.chat-room-name {
    font-size: 1rem;
    font-weight: 800;
    color: var(--text-0);
    letter-spacing: -0.3px;
}

.chat-room-sub {
    font-size: 0.78rem;
    color: var(--text-3);
    margin-top: 1px;
}

.chat-header-actions {
    display: flex;
    align-items: center;
    gap: 6px;
}

/* 메시지 목록 */
.chat-messages {
    flex: 1;
    overflow-y: auto;
    padding: 20px 16px 10px;
    display: flex;
    flex-direction: column;
    gap: 2px;
    scrollbar-width: thin;
    scrollbar-color: var(--border) transparent;
}

.chat-messages::-webkit-scrollbar { width: 6px; }
.chat-messages::-webkit-scrollbar-track { background: transparent; }
.chat-messages::-webkit-scrollbar-thumb { background: var(--border); border-radius: 4px; }

.messages-loader {
    display: flex;
    justify-content: center;
    padding: 40px;
    color: var(--text-3);
}

/* 메시지 그룹 (연속 메시지) */
.msg-group {
    display: flex;
    gap: 14px;
    padding: 4px 8px;
    border-radius: 8px;
    transition: background 0.1s;
    position: relative;
}

.msg-group:hover {
    background: var(--bg-2);
}

.msg-group .msg-avatar {
    width: 38px;
    height: 38px;
    border-radius: 50%;
    object-fit: cover;
    flex-shrink: 0;
    margin-top: 2px;
}

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

.msg-group-header {
    display: flex;
    align-items: baseline;
    gap: 8px;
    margin-bottom: 3px;
}

.msg-author {
    font-size: 0.92rem;
    font-weight: 700;
    color: var(--text-0);
    cursor: pointer;
}

.msg-author:hover { text-decoration: underline; }

.msg-timestamp {
    font-size: 0.72rem;
    color: var(--text-3);
}

.msg-text {
    font-size: 0.92rem;
    color: var(--text-1);
    line-height: 1.55;
    word-break: break-word;
    white-space: pre-wrap;
}

/* 연속 메시지 (아바타 없이) */
.msg-continuation {
    display: flex;
    gap: 14px;
    padding: 2px 8px;
    border-radius: 8px;
    transition: background 0.1s;
}

.msg-continuation:hover {
    background: var(--bg-2);
}

.msg-continuation .msg-time-stub {
    width: 38px;
    flex-shrink: 0;
    font-size: 0.68rem;
    color: transparent;
    text-align: right;
    line-height: 1.55;
    padding-top: 2px;
}

.msg-continuation:hover .msg-time-stub {
    color: var(--text-3);
}

.msg-continuation .msg-text {
    flex: 1;
}

/* 날짜 구분선 */
.msg-date-divider {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 16px 8px 8px;
    color: var(--text-3);
    font-size: 0.75rem;
    font-weight: 700;
}

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

/* 채팅방 시작 안내 */
.chat-start-notice {
    padding: 20px 8px;
    color: var(--text-2);
}

.chat-start-notice .start-avatar {
    width: 64px;
    height: 64px;
    border-radius: 50%;
    margin-bottom: 12px;
}

.chat-start-notice h3 {
    font-size: 1.4rem;
    font-weight: 800;
    color: var(--text-0);
    margin-bottom: 6px;
}

.chat-start-notice p {
    font-size: 0.9rem;
    color: var(--text-3);
}

/* 입력창 */
.chat-input-area {
    padding: 10px 16px 16px;
    flex-shrink: 0;
}

.chat-input-wrap {
    display: flex;
    align-items: flex-end;
    gap: 6px;
    background: var(--bg-2);
    border: 1px solid var(--border);
    border-radius: 12px;
    padding: 8px 10px;
    transition: border-color 0.2s;
}

.chat-input-wrap:focus-within {
    border-color: var(--primary);
}

.chat-input-wrap textarea {
    flex: 1;
    background: none;
    border: none;
    outline: none;
    color: var(--text-0);
    font-size: 0.93rem;
    font-family: inherit;
    resize: none;
    line-height: 1.5;
    max-height: 160px;
    overflow-y: auto;
    padding: 2px 0;
    scrollbar-width: thin;
}

.chat-input-wrap textarea::placeholder {
    color: var(--text-3);
}

.attach-btn, .emoji-btn {
    color: var(--text-3);
    padding: 4px;
    border-radius: 6px;
    line-height: 1;
    flex-shrink: 0;
}

.attach-btn:hover, .emoji-btn:hover {
    color: var(--primary);
}

.attach-btn .material-symbols-rounded,
.emoji-btn .material-symbols-rounded {
    font-size: 24px;
}

.send-btn {
    background: var(--primary);
    color: white;
    width: 34px;
    height: 34px;
    border-radius: 8px;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    transition: var(--transition-fast);
}

.send-btn:hover {
    background: var(--primary-hover);
    transform: scale(1.05);
}

.send-btn .material-symbols-rounded {
    font-size: 20px;
}

.send-btn:disabled {
    background: var(--bg-2);
    color: var(--text-3);
    transform: none;
    cursor: not-allowed;
}

/* ─────────────────────────────────────────
   멤버 패널 (오른쪽)
───────────────────────────────────────── */
.msg-members-panel {
    width: 220px;
    min-width: 220px;
    background-color: var(--bg-1);
    border-left: 1px solid var(--border);
    display: flex;
    flex-direction: column;
    height: 100%;
    overflow: hidden;
}

.members-panel-header {
    padding: 18px 16px 14px;
    border-bottom: 1px solid var(--border);
    flex-shrink: 0;
}

.members-panel-header h3 {
    font-size: 0.85rem;
    font-weight: 700;
    color: var(--text-2);
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

.members-list {
    padding: 10px 8px;
    overflow-y: auto;
    flex: 1;
    scrollbar-width: thin;
    scrollbar-color: var(--border) transparent;
}

.member-item {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 7px 8px;
    border-radius: 6px;
    cursor: pointer;
    transition: var(--transition-fast);
}

.member-item:hover {
    background: var(--bg-2);
}

.member-avatar {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    object-fit: cover;
    flex-shrink: 0;
    position: relative;
}

.member-name {
    font-size: 0.88rem;
    font-weight: 600;
    color: var(--text-2);
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

/* ─────────────────────────────────────────
   공통 버튼
───────────────────────────────────────── */
.icon-btn {
    width: 32px;
    height: 32px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 6px;
    color: var(--text-2);
    transition: var(--transition-fast);
    flex-shrink: 0;
}

.icon-btn:hover {
    background: var(--bg-2);
    color: var(--text-0);
}

.icon-btn .material-symbols-rounded {
    font-size: 22px;
}

.btn-primary {
    background: var(--primary);
    color: white;
    padding: 10px 20px;
    border-radius: 10px;
    font-weight: 700;
    font-size: 0.9rem;
    display: inline-flex;
    align-items: center;
    gap: 6px;
    transition: var(--transition-fast);
    cursor: pointer;
}

.btn-primary:hover {
    background: var(--primary-hover);
    transform: translateY(-1px);
}

.btn-primary .material-symbols-rounded {
    font-size: 18px;
}

.btn-secondary {
    background: var(--bg-2);
    color: var(--text-1);
    padding: 10px 20px;
    border-radius: 10px;
    font-weight: 600;
    font-size: 0.9rem;
    transition: var(--transition-fast);
    cursor: pointer;
    border: 1px solid var(--border);
}

.btn-secondary:hover {
    background: var(--border);
    color: var(--text-0);
}

/* ─────────────────────────────────────────
   모달
───────────────────────────────────────── */
.modal-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,0.7);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1000;
    backdrop-filter: blur(4px);
    animation: fadeIn 0.15s ease;
}

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

.modal {
    background: var(--bg-1);
    border: 1px solid var(--border);
    border-radius: 16px;
    width: 460px;
    max-width: 92vw;
    max-height: 80vh;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    animation: slideUp 0.2s cubic-bezier(0.34,1.56,0.64,1);
}

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

.modal-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 20px 20px 16px;
    border-bottom: 1px solid var(--border);
    flex-shrink: 0;
}

.modal-header h3 {
    font-size: 1.1rem;
    font-weight: 800;
    color: var(--text-0);
}

.modal-body {
    padding: 20px;
    overflow-y: auto;
    flex: 1;
}

.modal-label {
    display: block;
    font-size: 0.8rem;
    font-weight: 700;
    color: var(--text-2);
    text-transform: uppercase;
    letter-spacing: 0.05em;
    margin-bottom: 8px;
}

.modal-input {
    width: 100%;
    background: var(--bg-0);
    border: 1px solid var(--border);
    border-radius: 8px;
    padding: 11px 14px;
    color: var(--text-0);
    font-size: 0.92rem;
    font-family: inherit;
    outline: none;
    transition: border-color 0.2s;
}

.modal-input:focus {
    border-color: var(--primary);
}

.modal-search-wrap {
    position: relative;
    margin-bottom: 10px;
}

.modal-search-wrap .search-icon {
    position: absolute;
    left: 12px;
    top: 50%;
    transform: translateY(-50%);
    font-size: 18px;
    color: var(--text-3);
    pointer-events: none;
}

.modal-input-inline {
    width: 100%;
    background: var(--bg-0);
    border: 1px solid var(--border);
    border-radius: 8px;
    padding: 11px 14px 11px 38px;
    color: var(--text-0);
    font-size: 0.92rem;
    font-family: inherit;
    outline: none;
    transition: border-color 0.2s;
}

.modal-input-inline:focus {
    border-color: var(--primary);
}

.invite-list {
    max-height: 220px;
    overflow-y: auto;
    scrollbar-width: thin;
}

.invite-item {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 9px 10px;
    border-radius: 8px;
    cursor: pointer;
    transition: var(--transition-fast);
    margin-bottom: 2px;
}

.invite-item:hover {
    background: var(--bg-2);
}

.invite-item.selected {
    background: var(--primary-alpha);
}

.invite-avatar {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    object-fit: cover;
    flex-shrink: 0;
}

.invite-username {
    flex: 1;
    font-size: 0.9rem;
    font-weight: 600;
    color: var(--text-0);
}

.invite-check {
    color: var(--primary);
    font-size: 20px;
}

.selected-members {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    margin-top: 12px;
    min-height: 0;
}

.selected-tag {
    display: flex;
    align-items: center;
    gap: 6px;
    background: var(--primary-alpha);
    border: 1px solid var(--primary);
    color: var(--primary);
    padding: 4px 10px 4px 8px;
    border-radius: 20px;
    font-size: 0.82rem;
    font-weight: 600;
}

.selected-tag img {
    width: 20px;
    height: 20px;
    border-radius: 50%;
}

.selected-tag button {
    color: var(--primary);
    font-size: 16px;
    line-height: 1;
    padding: 0;
}

.modal-footer {
    display: flex;
    gap: 10px;
    justify-content: flex-end;
    padding: 16px 20px;
    border-top: 1px solid var(--border);
    flex-shrink: 0;
}

/* ─────────────────────────────────────────
   애니메이션
───────────────────────────────────────── */
@keyframes spin {
    to { transform: rotate(360deg); }
}

.animation-spin {
    animation: spin 1s linear infinite;
    display: inline-block;
}

/* 빈 상태 */
.channel-empty {
    padding: 12px 12px;
    color: var(--text-3);
    font-size: 0.82rem;
    text-align: center;
}
