/* 채팅 버튼 */
.chat-btn {
    position: fixed;
    bottom: 100px;
    right: 30px;
    width: 60px;
    height: 60px;
    border-radius: 50%;
    background: linear-gradient(135deg, #00c4cc 0%, #7d2ae8 100%);
    border: none;
    cursor: pointer;
    box-shadow: 0 4px 15px rgba(0, 196, 204, 0.4);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 24px;
    z-index: 1000;
    transition: all 0.3s ease;
}

.chat-btn:hover {
    transform: scale(1.1);
    box-shadow: 0 6px 20px rgba(0, 196, 204, 0.6);
}

/* 읽지 않은 메시지 뱃지 */
.chat-unread-badge {
    position: absolute;
    top: -5px;
    right: -5px;
    background: #ff4757;
    color: white;
    border-radius: 12px;
    padding: 2px 6px;
    font-size: 12px;
    font-weight: bold;
    min-width: 20px;
    text-align: center;
    box-shadow: 0 2px 8px rgba(255, 71, 87, 0.6);
    animation: pulse 2s infinite;
    pointer-events: none;
    z-index: 1001;  /* 버튼보다 위에 표시 */
}

@keyframes pulse {
    0% {
        box-shadow: 0 2px 8px rgba(255, 71, 87, 0.6);
        transform: scale(1);
    }
    50% {
        box-shadow: 0 2px 12px rgba(255, 71, 87, 0.8);
        transform: scale(1.05);
    }
    100% {
        box-shadow: 0 2px 8px rgba(255, 71, 87, 0.6);
        transform: scale(1);
    }
}

/* 채팅 모달 */
.chat-modal {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
    z-index: 2001;
}

.chat-modal.active {
    display: block;
}

/* 채팅 컨테이너 */
.chat-container {
    width: 540px;
    height: 910px;
    background: #1a1d29;
    border-radius: 20px;
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.7);
    display: flex;
    flex-direction: column;
    position: fixed;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    transition: width 0.3s ease, height 0.3s ease;
    pointer-events: all;
    border: 1px solid rgba(102, 126, 234, 0.3);
}

/* 리사이즈 핸들 스타일 */
.resize-handle {
    position: absolute;
    background: transparent;
}

.resize-n, .resize-s {
    left: 0;
    right: 0;
    height: 8px;
    cursor: ns-resize;
}

.resize-n {
    top: -4px;
}

.resize-s {
    bottom: -4px;
}

.resize-e, .resize-w {
    top: 0;
    bottom: 0;
    width: 8px;
    cursor: ew-resize;
}

.resize-e {
    right: -4px;
}

.resize-w {
    left: -4px;
}

.resize-ne, .resize-se, .resize-sw, .resize-nw {
    width: 12px;
    height: 12px;
}

.resize-ne {
    top: -4px;
    right: -4px;
    cursor: nesw-resize;
}

.resize-se {
    bottom: -4px;
    right: -4px;
    cursor: nwse-resize;
}

.resize-sw {
    bottom: -4px;
    left: -4px;
    cursor: nesw-resize;
}

.resize-nw {
    top: -4px;
    left: -4px;
    cursor: nwse-resize;
}

/* 리사이즈 중 시각 피드백 */
.resize-handle:hover {
    background: rgba(102, 126, 234, 0.3);
}

/* 채팅 헤더 */
.chat-header {
    padding: 20px;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    border-radius: 20px 20px 0 0;
    display: flex;
    justify-content: space-between;
    align-items: center;
    cursor: move;
    user-select: none;
}

.chat-title {
    display: flex;
    align-items: center;
    gap: 10px;
    color: white;
    font-weight: 600;
}

.chat-icon {
    font-size: 24px;
}

.user-count {
    font-size: 14px;
    opacity: 0.9;
}

.chat-controls {
    display: flex;
    gap: 10px;
}

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

.chat-close-btn:hover {
    background: rgba(255, 255, 255, 0.3);
}

.chat-close-btn {
    font-size: 20px;
}

/* 닉네임 설정 화면 */
.nickname-setup {
    padding: 30px;
    display: flex;
    flex-direction: column;
    gap: 20px;
    height: 100%;
    min-height: 640px;
    overflow-y: auto;
}

.setup-title {
    font-size: 24px;
    font-weight: 600;
    text-align: center;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
}

.emoji-selector {
    display: flex;
    flex-direction: column;
    gap: 15px;
}

.emoji-label {
    font-size: 14px;
    color: #888;
    text-align: center;
}

.emoji-grid {
    display: grid;
    grid-template-columns: repeat(5, 1fr);
    gap: 10px;
}

.emoji-option {
    background: #252837;
    border: 2px solid transparent;
    border-radius: 10px;
    padding: 10px;
    font-size: 24px;
    cursor: pointer;
    transition: all 0.3s ease;
}

.emoji-option:hover {
    background: #2d303f;
    transform: scale(1.1);
}

.emoji-option.selected {
    border-color: #667eea;
    background: rgba(102, 126, 234, 0.2);
}

/* 직접 이모지 입력 섹션 */
.custom-emoji-section {
    margin-top: 20px;
    padding: 15px;
    background: #252837;
    border-radius: 10px;
    border: 1px dashed rgba(102, 126, 234, 0.3);
}

.custom-emoji-label {
    font-size: 14px;
    color: #888;
    margin-bottom: 10px;
    text-align: center;
    font-weight: 600;
}

.custom-emoji-input-group {
    display: flex;
    gap: 10px;
    margin-bottom: 8px;
}

.custom-emoji-input {
    flex: 1;
    padding: 10px;
    background: #1a1d29;
    border: 2px solid #353847;
    border-radius: 8px;
    color: white;
    font-size: 18px;
    text-align: center;
    transition: all 0.3s ease;
}

.custom-emoji-input:focus {
    outline: none;
    border-color: #667eea;
}

.custom-emoji-apply-btn {
    padding: 10px 20px;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    border: none;
    border-radius: 8px;
    color: white;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s ease;
}

.custom-emoji-apply-btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 5px 15px rgba(102, 126, 234, 0.4);
}

.custom-emoji-help {
    font-size: 12px;
    color: #666;
    text-align: center;
}

.selected-emoji-preview {
    text-align: center;
    padding: 15px;
    background: #252837;
    border-radius: 10px;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
    margin-top: 15px;
}

.selected-emoji {
    font-size: 32px;
}

.nickname-input-group {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.nickname-input {
    padding: 15px;
    background: #252837;
    border: 2px solid #353847;
    border-radius: 10px;
    color: white;
    font-size: 16px;
    text-align: center;
}

.nickname-input:focus {
    outline: none;
    border-color: #667eea;
}

.start-chat-btn {
    padding: 15px 30px;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    border: none;
    border-radius: 10px;
    color: white;
    font-size: 16px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s ease;
}

.start-chat-btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 5px 20px rgba(102, 126, 234, 0.4);
}

/* 채팅 룸 */
.chat-room {
    display: none;
    flex-direction: column;
    height: calc(100% - 80px);
}

.chat-messages {
    flex: 1;
    padding: 20px;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.chat-messages::-webkit-scrollbar {
    width: 8px;
}

.chat-messages::-webkit-scrollbar-track {
    background: #252837;
}

.chat-messages::-webkit-scrollbar-thumb {
    background: #667eea;
    border-radius: 4px;
}

/* 메시지 스타일 */
.chat-message {
    max-width: 70%;
    animation: messageSlide 0.3s ease;
}

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

.chat-message.my-message {
    align-self: flex-end;
}

.chat-message.my-message .message-header {
    justify-content: flex-end;
}

.chat-message.my-message .message-content {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
}

.message-header {
    display: flex;
    align-items: center;
    gap: 5px;
    margin-bottom: 5px;
    font-size: 12px;
    color: #888;
}

.message-emoji {
    font-size: 16px;
}

.message-nickname {
    font-weight: 600;
    color: #aaa;
}

.message-time {
    font-size: 11px;
    color: #666;
}

.message-content {
    background: #252837;
    padding: 10px 15px;
    border-radius: 15px;
    color: white;
    word-wrap: break-word;
}

/* 시스템 메시지 */
.system-message {
    align-self: center;
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 8px 16px;
    background: rgba(102, 126, 234, 0.1);
    border-radius: 20px;
    font-size: 13px;
    color: #888;
    animation: messageSlide 0.3s ease;
}

.system-icon {
    font-size: 16px;
}

.join-message {
    background: rgba(76, 175, 80, 0.1);
    color: #4caf50;
}

.leave-message {
    background: rgba(244, 67, 54, 0.1);
    color: #f44336;
}

.profile-change-message {
    background: rgba(255, 193, 7, 0.1);
    color: #ffc107;
}

/* 채팅 입력 영역 */
.chat-input-container {
    padding: 20px;
    border-top: 1px solid #353847;
    background: #1a1d29;
    border-radius: 0 0 20px 20px;
}

.chat-user-info {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-bottom: 10px;
    padding: 5px 10px;
    background: #252837;
    border-radius: 8px;
    width: fit-content;
}

.profile-edit-btn {
    background: rgba(102, 126, 234, 0.2);
    border: 1px solid rgba(102, 126, 234, 0.3);
    border-radius: 6px;
    padding: 4px 8px;
    cursor: pointer;
    font-size: 14px;
    transition: all 0.3s ease;
}

.profile-edit-btn:hover {
    background: rgba(102, 126, 234, 0.4);
    transform: scale(1.1);
}

.user-emoji {
    font-size: 20px;
}

.user-nickname {
    font-size: 14px;
    color: #aaa;
    font-weight: 600;
}

.chat-input-group {
    display: flex;
    gap: 10px;
}

.chat-input {
    flex: 1;
    padding: 12px 16px;
    background: #252837;
    border: 2px solid #353847;
    border-radius: 10px;
    color: white;
    font-size: 14px;
}

.chat-input:focus {
    outline: none;
    border-color: #667eea;
}

.chat-send-btn {
    padding: 12px 24px;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    border: none;
    border-radius: 10px;
    color: white;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s ease;
}

.chat-send-btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 5px 20px rgba(102, 126, 234, 0.4);
}

/* 관리자 모드 스타일 */
.admin-message {
    background: rgba(138, 43, 226, 0.1) !important;
    color: #8a2be2 !important;
}

.admin-indicator {
    background: linear-gradient(135deg, #8a2be2 0%, #4b0082 100%);
    color: white;
    padding: 8px 15px;
    border-radius: 8px;
    margin-bottom: 10px;
    text-align: center;
    font-weight: 600;
    font-size: 14px;
    animation: pulse 2s infinite;
}

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

.admin-help {
    margin-top: 10px;
    padding: 8px;
    background: rgba(138, 43, 226, 0.1);
    border-radius: 6px;
    text-align: center;
    color: #8a2be2;
}

.admin-controls {
    display: flex;
    gap: 5px;
    margin-top: 8px;
    align-items: center;
}

.admin-btn {
    padding: 4px 8px;
    border: none;
    border-radius: 4px;
    font-size: 12px;
    cursor: pointer;
    transition: all 0.3s ease;
    font-weight: 600;
}

.kick-btn {
    background: #ff9800;
    color: white;
}

.kick-btn:hover {
    background: #f57c00;
    transform: scale(1.05);
}

.ban-btn {
    background: #f44336;
    color: white;
}

.ban-btn:hover {
    background: #d32f2f;
    transform: scale(1.05);
}

.session-id {
    font-size: 10px;
    color: #666;
    margin-left: auto;
    font-family: monospace;
    padding: 2px 6px;
    background: rgba(0, 0, 0, 0.1);
    border-radius: 3px;
}

/* 반응형 디자인 */
@media (max-width: 500px) {
    .chat-container {
        width: 95%;
        height: 90vh;
        border-radius: 10px;
    }
    
    .chat-header {
        padding: 15px;
        border-radius: 10px 10px 0 0;
    }
    
    .emoji-grid {
        grid-template-columns: repeat(4, 1fr);
    }
}