/* DPEX 고객 채팅 위젯 스타일 */

.dpex-customer-chat-widget {
    position: fixed;
    bottom: 20px;
    right: 20px;
    z-index: 9999;
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
    font-size: 14px;
    line-height: 1.5;
}

/* 플로팅 버튼 - 파란색으로 통일 */
.customer-chat-floating-btn {
    width: 60px;
    height: 60px;
    background: linear-gradient(135deg, #2196f3, #1976d2);
    border: none;
    border-radius: 50%;
    box-shadow: 0 4px 12px rgba(33, 150, 243, 0.3);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    color: white;
    font-size: 24px;
    transition: all 0.3s ease;
    position: relative;
}

/* 채팅 아이콘 표시 - 이모지 사용 */
.customer-chat-floating-btn .fas.fa-comments {
    font-family: inherit !important;
    font-size: 24px !important;
}

.customer-chat-floating-btn .fas.fa-comments::before {
    content: "💬" !important;
    font-family: inherit !important;
    font-size: 24px !important;
    display: inline-block !important;
}

.customer-chat-floating-btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(33, 150, 243, 0.4);
}

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

.customer-chat-floating-btn.active {
    background: linear-gradient(135deg, #00bcd4, #0097a7);
    transform: rotate(45deg);
}

.customer-chat-floating-btn.has-unread {
    animation: pulse 2s infinite;
}

@keyframes pulse {
    0% { box-shadow: 0 0 0 0 rgba(33, 150, 243, 0.7); }
    70% { box-shadow: 0 0 0 15px rgba(33, 150, 243, 0); }
    100% { box-shadow: 0 0 0 0 rgba(33, 150, 243, 0); }
}

/* 펄스 링 효과 */
.chat-pulse-ring {
    position: absolute;
    width: 100%;
    height: 100%;
    border: 2px solid #667eea;
    border-radius: 50%;
    opacity: 0;
    animation: pulse-ring 2s infinite;
}

@keyframes pulse-ring {
    0% {
        transform: scale(1);
        opacity: 1;
    }
    100% {
        transform: scale(1.5);
        opacity: 0;
    }
}

/* 미읽은 메시지 배지 - 관리자 페이지 디자인으로 통일 */
.customer-chat-badge {
    position: absolute;
    top: -5px;
    right: -5px;
    background: #ff6b6b;
    color: white;
    min-width: 20px;
    height: 20px;
    border-radius: 10px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 12px;
    font-weight: bold;
    border: 2px solid white;
}

/* 채팅창 - 관리자 페이지 디자인으로 통일 */
.customer-chat-window {
    position: absolute;
    bottom: 70px;
    right: 0;
    width: 350px;
    max-height: 500px;
    background: white;
    border-radius: 12px;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.15);
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

/* 채팅 헤더 - 파란색으로 통일 */
.chat-header {
    background: linear-gradient(135deg, #2196f3, #1976d2);
    color: white;
    padding: 15px;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.header-info {
    flex: 1;
}

.chat-title {
    font-size: 16px;
    font-weight: 600;
    margin-bottom: 2px;
}

.chat-status {
    font-size: 12px;
    opacity: 0.9;
}

.header-actions {
    display: flex;
    gap: 8px;
}

.header-actions button {
    background: none;
    border: none;
    color: white;
    cursor: pointer;
    padding: 5px;
    border-radius: 4px;
    transition: background 0.2s;
}

.header-actions button:hover {
    background: rgba(255, 255, 255, 0.2);
}

/* 메시지 컨테이너 */
.chat-messages {
    flex: 1;
    overflow-y: auto;
    overflow-x: hidden;
    padding: 20px;
    background: #f8f9fa;
    position: relative;
}

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

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

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

/* 환영 메시지 */
.welcome-message {
    text-align: center;
    padding: 40px 20px;
    color: #666;
}

.welcome-icon {
    font-size: 48px;
    margin-bottom: 16px;
}

.welcome-message h3 {
    margin: 0 0 8px 0;
    color: #333;
    font-size: 18px;
    font-weight: 600;
}

.welcome-message p {
    margin: 0;
    line-height: 1.6;
}

/* 메시지 스타일 */
.message {
    margin-bottom: 16px;
    display: flex;
    align-items: flex-start;
    gap: 12px;
}

.message.user {
    flex-direction: row-reverse;
}

.message.user .message-content {
    align-items: flex-end;
}

.message-avatar {
    width: 36px;
    height: 36px;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    color: white;
    font-size: 16px;
    flex-shrink: 0;
}

.message-content {
    max-width: 75%;
    display: flex;
    flex-direction: column;
}

.message-header {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-bottom: 4px;
}

.sender-name {
    font-size: 12px;
    font-weight: 600;
    color: #667eea;
}

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

.bubble {
    background: white;
    padding: 12px 16px;
    border-radius: 18px;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
    position: relative;
    word-wrap: break-word;
    border: 1px solid rgba(0, 0, 0, 0.05);
}

.message.user .bubble {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    margin-left: auto;
}

.message.user .message-time {
    text-align: right;
    margin-top: 4px;
}

/* 메시지 상태 */
.message-status {
    position: absolute;
    bottom: 4px;
    right: 8px;
    font-size: 10px;
    opacity: 0.7;
}

.message-status.sending::after {
    content: '⏳';
}

.message-status.sent::after {
    content: '✓';
}

.message-status.delivered::after {
    content: '✓✓';
}

/* 시스템 메시지 */
.system-message {
    margin: 16px 0;
    text-align: center;
}

.system-content {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    background: rgba(102, 126, 234, 0.1);
    color: #667eea;
    padding: 8px 12px;
    border-radius: 12px;
    font-size: 12px;
}

/* 타이핑 인디케이터 */
.typing-indicator {
    padding: 12px 20px;
    display: flex;
    align-items: center;
    gap: 12px;
    background: white;
    border-top: 1px solid #f0f0f0;
}

.typing-dots {
    display: flex;
    gap: 4px;
}

.typing-dots span {
    width: 6px;
    height: 6px;
    background: #667eea;
    border-radius: 50%;
    animation: typing-bounce 1.4s infinite;
}

.typing-dots span:nth-child(2) {
    animation-delay: 0.2s;
}

.typing-dots span:nth-child(3) {
    animation-delay: 0.4s;
}

@keyframes typing-bounce {
    0%, 60%, 100% {
        transform: translateY(0);
    }
    30% {
        transform: translateY(-8px);
    }
}

.typing-text {
    font-size: 12px;
    color: #666;
    font-style: italic;
}

/* 입력 영역 */
.chat-input-container {
    background: white;
    border-top: 1px solid #f0f0f0;
    padding: 16px 20px;
}

.input-wrapper {
    display: flex;
    align-items: flex-end;
    gap: 12px;
    background: #f8f9fa;
    border-radius: 24px;
    padding: 8px 16px;
    border: 2px solid transparent;
    transition: border-color 0.2s;
    position: relative;
}

.input-wrapper:focus-within {
    border-color: #667eea;
}

.chat-input {
    flex: 1;
    border: none;
    background: transparent;
    resize: none;
    outline: none;
    font-family: inherit;
    font-size: 14px;
    line-height: 1.5;
    padding: 8px 0;
    max-height: 100px;
    min-height: 20px;
}

.chat-input::placeholder {
    color: #999;
}

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

.input-actions button {
    width: 32px;
    height: 32px;
    border: none;
    background: none;
    cursor: pointer;
    border-radius: 8px;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background 0.2s;
    font-size: 16px;
}

.input-actions button:hover:not(:disabled) {
    background: rgba(102, 126, 234, 0.1);
}

.btn-send {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    font-size: 14px;
}

.btn-send:disabled {
    background: #ddd;
    cursor: not-allowed;
}

.btn-send:hover:not(:disabled) {
    background: linear-gradient(135deg, #5a6fd8 0%, #6a4190 100%);
}

/* 입력 푸터 */
.input-footer {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-top: 8px;
    font-size: 11px;
    color: #999;
}

.char-count {
    margin-left: auto;
}

.connection-status {
    display: flex;
    align-items: center;
    gap: 6px;
}

.status-dot {
    width: 6px;
    height: 6px;
    border-radius: 50%;
    background: #10ac84;
}

.connection-status.connecting .status-dot {
    background: #f39c12;
    animation: pulse 1s infinite;
}

.connection-status.disconnected .status-dot {
    background: #e55039;
}

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

/* 반응형 디자인 - 관리자 페이지 디자인으로 통일 */
@media (max-width: 768px) {
    .customer-chat-window {
        width: 100%;
        max-width: 350px;
        bottom: 0;
        right: 0;
        border-radius: 12px 12px 0 0;
        max-height: 80vh;
    }

    .customer-chat-floating-btn {
        width: 56px;
        height: 56px;
        font-size: 22px;
    }
}

@media (max-width: 480px) {
    .customer-chat-floating-btn {
        width: 52px;
        height: 52px;
        font-size: 20px;
    }

    .customer-chat-window {
        width: 100%;
        max-width: none;
    }

    .chat-messages {
        padding: 12px;
    }

    .chat-input-container {
        padding: 12px 15px;
    }
}

/* 다크 테마 지원 */
@media (prefers-color-scheme: dark) {
    .customer-chat-window {
        background: #1a1a1a;
        border-color: #333;
        box-shadow: 0 16px 70px rgba(0, 0, 0, 0.5);
    }
    
    .chat-messages {
        background: #1a1a1a;
    }
    
    .bubble {
        background: #2d2d2d;
        color: #e6e6e6;
        border-color: #444;
    }
    
    .message.user .bubble {
        background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
        color: white;
    }
    
    .input-wrapper {
        background: #2d2d2d;
        border-color: #444;
    }
    
    .input-wrapper:focus-within {
        border-color: #667eea;
    }
    
    .chat-input {
        color: #e6e6e6;
    }
    
    .chat-input::placeholder {
        color: #999;
    }
    
    .chat-input-container {
        background: #1a1a1a;
        border-color: #333;
    }
    
    .typing-indicator {
        background: #1a1a1a;
        border-color: #333;
    }
    
    .welcome-message {
        color: #ccc;
    }
    
    .welcome-message h3 {
        color: #e6e6e6;
    }
}

/* 접근성 개선 */
.customer-chat-floating-btn:focus {
    outline: 2px solid #667eea;
    outline-offset: 2px;
}

.chat-input:focus {
    outline: none;
}

.header-actions button:focus,
.input-actions button:focus {
    outline: 2px solid rgba(255, 255, 255, 0.5);
    outline-offset: 2px;
}

/* 애니메이션 비활성화 사용자를 위한 처리 */
@media (prefers-reduced-motion: reduce) {
    .customer-chat-floating-btn,
    .customer-chat-window,
    .input-wrapper,
    .bubble {
        transition: none;
    }
    
    .chat-pulse-ring,
    .customer-chat-floating-btn.has-unread,
    .typing-dots span {
        animation: none;
    }
}

/* 파일 업로드 진행 표시 */
.file-upload-progress {
    display: flex;
    align-items: center;
    padding: 12px;
    margin: 8px 0;
    background: rgba(255, 255, 255, 0.1);
    border-radius: 8px;
    border: 1px solid rgba(255, 255, 255, 0.2);
    animation: fadeIn 0.3s ease;
}

.file-upload-icon {
    font-size: 16px;
    margin-right: 12px;
    color: #2196f3;
}

.file-upload-info {
    flex: 1;
}

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

.file-upload-status {
    font-size: 12px;
    color: rgba(255, 255, 255, 0.7);
}

.file-upload-close {
    cursor: pointer;
    color: rgba(255, 255, 255, 0.5);
    font-size: 14px;
    padding: 4px;
    border-radius: 4px;
    transition: all 0.2s ease;
}

.file-upload-close:hover {
    color: white;
    background: rgba(255, 255, 255, 0.1);
}

/* 파일 메시지 스타일 */
.message-file, .message-image {
    max-width: 250px;
    margin: 8px 0;
}

.file-info {
    display: flex;
    align-items: center;
    padding: 12px;
    background: rgba(255, 255, 255, 0.1);
    border-radius: 8px;
    border: 1px solid rgba(255, 255, 255, 0.2);
    text-decoration: none;
    color: white;
    transition: all 0.2s ease;
}

.file-info:hover {
    background: rgba(255, 255, 255, 0.15);
    transform: translateY(-1px);
}

.file-icon {
    font-size: 24px;
    margin-right: 12px;
    color: #2196f3;
}

.file-details {
    flex: 1;
}

.file-name {
    font-size: 14px;
    font-weight: 500;
    margin-bottom: 4px;
    word-break: break-all;
    display: block;
}

.file-size {
    font-size: 12px;
    color: rgba(255, 255, 255, 0.7);
}

.file-download {
    color: #2196f3;
    font-size: 16px;
    margin-left: 12px;
}

/* 이미지 메시지 스타일 */
.image-preview {
    max-width: 250px;
    max-height: 200px;
    border-radius: 8px;
    cursor: pointer;
    transition: all 0.2s ease;
    border: 2px solid rgba(255, 255, 255, 0.2);
}

.image-preview:hover {
    transform: scale(1.02);
    border-color: rgba(255, 255, 255, 0.4);
}

/* 애니메이션 */
@keyframes fadeIn {
    from {
        opacity: 0;
        transform: translateY(10px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* 모바일 파일 메시지 */
@media (max-width: 768px) {
    .file-info {
        padding: 10px;
    }

    .file-name {
        font-size: 13px;
    }

    .file-size {
        font-size: 11px;
    }

    .image-preview {
        max-width: 200px;
        max-height: 150px;
    }
}

/* 프린트 시 숨김 */
@media print {
    .dpex-customer-chat-widget {
        display: none !important;
    }
}

/* Emoji picker */
.emoji-picker {
    position: absolute;
    right: 16px; /* will be set by JS too */
    bottom: 56px; /* will be set by JS too */
    width: 260px;
    max-height: 220px;
    background: #fff;
    border: 1px solid #e5e7eb;
    border-radius: 12px;
    box-shadow: 0 10px 25px rgba(0,0,0,0.12);
    padding: 10px;
    overflow: auto;
    display: none;
    z-index: 10000;
}

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

.emoji-grid .emoji-btn {
    border: none;
    background: transparent;
    cursor: pointer;
    font-size: 20px;
    line-height: 1;
    padding: 6px;
    border-radius: 6px;
}

.emoji-grid .emoji-btn:hover {
    background: #f3f4f6;
}
