.chat-container {
    position: fixed;
    bottom: 20px;
    right: 20px;
    z-index: 1000;
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
}

.chat-toggle {
    width: 60px;
    height: 60px;
    border-radius: 50%;
    background: #007bff;
    border: none;
    color: white;
    font-size: 24px;
    cursor: pointer;
    box-shadow: 0 2px 10px rgba(0,0,0,0.2);
    position: relative;
    transition: all 0.3s ease;
}

.chat-toggle:hover {
    background: #0056b3;
    transform: scale(1.05);
}

.chat-badge {
    position: absolute;
    top: -5px;
    right: -5px;
    background: #dc3545;
    color: white;
    border-radius: 50%;
    width: 20px;
    height: 20px;
    font-size: 12px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: bold;
}

.chat-window {
    position: absolute;
    bottom: 80px;
    right: 0;
    width: 400px;
    height: 600px;
    background: #ffffff;
    border-radius: 8px;
    box-shadow: 0 5px 15px rgba(0,0,0,0.2);
    display: none;
    flex-direction: column;
    border: 1px solid #e9ecef;
    overflow: hidden;
}

.chat-window.active {
    display: flex;
}

.chat-header {
    padding: 15px 20px;
    background: #f8f9fa;
    color: #333;
    border-radius: 8px 8px 0 0;
    display: flex;
    justify-content: space-between;
    align-items: center;
    border-bottom: 1px solid #e9ecef;
}

.chat-header h3 {
    margin: 0;
    font-size: 16px;
    font-weight: 600;
}

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

.online-count {
    font-size: 12px;
    opacity: 0.7;
}

.chat-minimize,
.chat-close {
    background: none;
    border: none;
    color: #6c757d;
    cursor: pointer;
    padding: 5px;
    font-size: 14px;
    border-radius: 4px;
    transition: background-color 0.2s ease;
}

.chat-minimize:hover,
.chat-close:hover {
    background: #e9ecef;
}

.chat-messages {
    flex: 1;
    overflow-y: auto;
    padding: 15px;
    display: flex;
    flex-direction: column;
    gap: 8px;
    background: #ffffff;
    scroll-behavior: smooth;
    -webkit-overflow-scrolling: touch;
    will-change: scroll-position;
}

.message {
    display: flex;
    max-width: 80%;
    word-break: break-word;
    white-space: pre-line;
    padding: 8px 12px;
    border-radius: 8px;
    font-size: 14px;
    line-height: 1.4;
}

.message.sent {
    align-self: flex-end;
    background: #007bff;
    color: white;
    margin-left: auto;
}

.message.received {
    align-self: flex-start;
    background: #f8f9fa;
    color: #333;
    border: 1px solid #e9ecef;
}

.message .timestamp {
    font-size: 11px;
    opacity: 0.6;
    margin-top: 3px;
    text-align: right;
}

.message.received .timestamp {
    text-align: left;
}

.system-message {
    padding: 8px 12px;
    border-radius: 8px;
    background: #e3f2fd;
    color: #1976d2;
    text-align: center;
    font-size: 13px;
    margin: 8px 0;
    border: 1px solid #bbdefb;
    max-width: 90%;
    align-self: center;
}

.nickname-container {
    padding: 10px;
    background: #f8f9fa;
    display: flex;
    gap: 10px;
    border-bottom: 1px solid #e9ecef;
}

.nickname-input {
    flex: 1;
    padding: 8px 12px;
    border: 1px solid #ced4da;
    border-radius: 6px;
    font-size: 14px;
    outline: none;
    transition: border-color 0.2s ease;
}

.nickname-input:focus {
    border-color: #007bff;
}

.nickname-submit {
    padding: 8px 16px;
    background: #007bff;
    color: white;
    border: none;
    border-radius: 6px;
    cursor: pointer;
    font-size: 14px;
    font-weight: 500;
    transition: background-color 0.2s ease;
}

.nickname-submit:hover {
    background: #0056b3;
}

.message-input-container {
    padding: 15px;
    background: #f8f9fa;
    border-top: 1px solid #e9ecef;
}

.chat-input {
    width: 100%;
    height: 60px;
    padding: 8px 12px;
    border: 1px solid #ced4da;
    border-radius: 6px;
    resize: none;
    font-size: 14px;
    margin-bottom: 5px;
    outline: none;
    transition: border-color 0.2s ease;
    background: white;
}

.chat-input:focus {
    border-color: #007bff;
}

.input-controls {
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.input-left {
    display: flex;
    align-items: center;
    gap: 8px;
}

.input-right {
    display: flex;
    align-items: center;
    gap: 8px;
}

.file-attach-btn {
    background: none;
    border: none;
    color: #6c757d;
    cursor: pointer;
    padding: 8px;
    border-radius: 4px;
    transition: all 0.2s ease;
    font-size: 16px;
}

.file-attach-btn:hover {
    background: #e9ecef;
    color: #007bff;
}

.file-attach-btn:active {
    background: #dee2e6;
}

.char-count {
    font-size: 12px;
    color: #6c757d;
}

.chat-send {
    background: #007bff;
    color: white;
    border: none;
    border-radius: 6px;
    padding: 8px 16px;
    cursor: pointer;
    font-size: 14px;
    font-weight: 500;
    transition: background-color 0.2s ease;
}

.chat-send:hover {
    background: #0056b3;
}

.chat-send:active {
    background: #004085;
}

.chat-send:disabled {
    background: #6c757d;
    cursor: not-allowed;
}

.typing-indicator {
    font-size: 12px;
    color: #6c757d;
    font-style: italic;
    margin: 5px 0;
    display: flex;
    align-items: center;
    gap: 5px;
    padding: 8px 12px;
    background: #f8f9fa;
    border: 1px solid #e9ecef;
    border-radius: 8px;
    max-width: 80%;
}

.typing-dot {
    width: 6px;
    height: 6px;
    border-radius: 50%;
    background: #6c757d;
    animation: typing 1.4s infinite ease-in-out;
}

.typing-dot:nth-child(1) { animation-delay: -0.32s; }
.typing-dot:nth-child(2) { animation-delay: -0.16s; }

@keyframes typing {
    0%, 80%, 100% {
        transform: scale(0);
        opacity: 0.5;
    }
    40% {
        transform: scale(1);
        opacity: 1;
    }
}

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

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

.chat-messages::-webkit-scrollbar-thumb {
    background: #ced4da;
    border-radius: 2px;
}

.chat-messages::-webkit-scrollbar-thumb:hover {
    background: #adb5bd;
}

.chat-nickname {
    font-weight: 600;
    margin-bottom: 6px;
    font-size: 11px;
    padding: 2px 6px;
    border-radius: 8px;
    display: inline-block;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.sent-nickname {
    color: #007bff;
    background-color: rgba(0, 123, 255, 0.08);
    text-align: right;
    align-self: flex-end;
    border: 1px solid rgba(0, 123, 255, 0.2);
}

.received-nickname {
    color: #6c757d;
    background-color: rgba(108, 117, 125, 0.08);
    text-align: left;
    align-self: flex-start;
    border: 1px solid rgba(108, 117, 125, 0.2);
}

.message-wrapper {
    margin-bottom: 12px;
    display: flex;
    flex-direction: column;
}

.message-wrapper.sent {
    align-items: flex-end;
}

.message-wrapper.received {
    align-items: flex-start;
}

/* 파일 메시지 스타일 */
.file-message {
    display: flex;
    align-items: flex-start;
    gap: 8px;
    padding: 12px;
    border-radius: 8px;
    max-width: 300px;
    cursor: pointer;
    transition: background-color 0.2s ease;
}

.file-message:hover {
    background-color: rgba(0, 123, 255, 0.1);
}

.file-message i {
    font-size: 24px;
    color: #6c757d;
    margin-top: 2px;
}

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

.file-name {
    font-weight: 500;
    font-size: 14px;
    color: #333;
    margin-bottom: 4px;
    word-break: break-word;
}

.file-size {
    font-size: 12px;
    color: #6c757d;
}

.file-preview {
    max-width: 200px;
    max-height: 150px;
    border-radius: 4px;
    margin-top: 8px;
    object-fit: cover;
}

/* 보낸 파일 메시지 */
.message.sent.file-message {
    background: #007bff;
    color: white;
}

.message.sent.file-message i {
    color: rgba(255, 255, 255, 0.8);
}

.message.sent.file-message .file-name {
    color: white;
}

.message.sent.file-message .file-size {
    color: rgba(255, 255, 255, 0.7);
}

/* 받은 파일 메시지 */
.message.received.file-message {
    background: #f8f9fa;
    border: 1px solid #e9ecef;
}

/* 반응형 디자인 */
@media (max-width: 768px) {
    .chat-container {
        bottom: 10px;
        right: 10px;
    }
    
    .chat-toggle {
        width: 50px;
        height: 50px;
        font-size: 20px;
    }
    
    .chat-window {
        width: calc(100vw - 20px);
        height: calc(100vh - 100px);
        bottom: 70px;
        right: 10px;
        border-radius: 12px;
        max-width: 400px;
    }
    
    .chat-header {
        padding: 12px 15px;
        border-radius: 12px 12px 0 0;
    }
    
    .chat-header h3 {
        font-size: 15px;
    }
    
    .chat-messages {
        padding: 12px;
        gap: 6px;
    }
    
    .message {
        max-width: 85%;
        font-size: 13px;
        padding: 6px 10px;
    }
    
    .file-message {
        max-width: 250px;
        padding: 10px;
    }
    
    .file-preview {
        max-width: 150px;
        max-height: 120px;
    }
    
    .message-input-container {
        padding: 12px 15px;
    }
    
    .chat-input {
        height: 50px;
        font-size: 13px;
        padding: 6px 10px;
    }
    
    .input-controls {
        gap: 6px;
    }
    
    .chat-send {
        padding: 6px 12px;
        font-size: 13px;
    }
    
    .char-count {
        font-size: 11px;
    }
    
    .chat-toggle,
    .chat-send,
    .file-attach-btn,
    .chat-minimize,
    .chat-close {
        -webkit-tap-highlight-color: transparent;
        touch-action: manipulation;
    }
    
    .chat-input {
        -webkit-appearance: none;
        -webkit-border-radius: 6px;
        border-radius: 6px;
    }
    
    .chat-messages {
        -webkit-overflow-scrolling: touch;
        overscroll-behavior: contain;
    }
    
    .message,
    .file-message {
        touch-action: manipulation;
    }
}

@media (max-width: 480px) {
    .chat-window {
        width: 100vw;
        height: 100vh;
        border-radius: 0;
        border: none;
        bottom: 0;
        right: 0;
        max-width: none;
    }
    
    .chat-header {
        padding: 15px;
        border-radius: 0;
    }
    
    .chat-messages {
        padding: 15px;
    }
    
    .message {
        max-width: 90%;
    }
    
    .file-message {
        max-width: 280px;
    }
    
    .message-input-container {
        padding: 15px;
    }
    
    .chat-input {
        height: 55px;
    }
    
    .input-controls {
        margin-top: 8px;
    }
}

/* 세로 모드에서의 최적화 */
@media (max-width: 480px) and (orientation: portrait) {
    .chat-window {
        height: 100vh;
    }
    
    .chat-messages {
        flex: 1;
        min-height: 0;
    }
}

/* 가로 모드에서의 최적화 */
@media (max-width: 768px) and (orientation: landscape) {
    .chat-window {
        height: calc(100vh - 20px);
        max-height: 500px;
    }
    
    .chat-messages {
        max-height: 300px;
    }
}

/* 다크 모드 지원 */
@media (prefers-color-scheme: dark) {
    .chat-window {
        background: #1a1a1a;
        border-color: #333;
    }
    
    .chat-header {
        background: #2d2d2d;
        color: white;
        border-bottom-color: #333;
    }
    
    .chat-messages {
        background: #1a1a1a;
    }
    
    .message.received {
        background: #2d2d2d;
        color: #e0e0e0;
        border-color: #444;
    }
    
    .message-input-container {
        background: #2d2d2d;
        border-top-color: #333;
    }
    
    .chat-input {
        background: #1a1a1a;
        color: white;
        border-color: #444;
    }
    
    .chat-input:focus {
        border-color: #007bff;
    }
    
    .typing-indicator {
        background: #2d2d2d;
        border-color: #444;
    }
    
    .system-message {
        background: #1a1a1a;
        color: #007bff;
        border-color: #333;
    }
}

/* iOS Safari 최적화 */
@supports (-webkit-touch-callout: none) {
    .chat-window {
        -webkit-transform: translateZ(0);
    }
    
    .chat-messages {
        -webkit-overflow-scrolling: touch;
    }
} 