/**
 * DAE-A Electronics Live Chat System Styles
 * 실시간 고객 지원 채팅 시스템 스타일
 */

/* =================================
   Chat Widget (Floating Button)
   ================================= */
.livechat-widget {
    position: fixed;
    bottom: 20px;
    right: 20px;
    z-index: 9998;
    cursor: pointer;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

.chat-bubble {
    position: relative;
    width: 60px;
    height: 60px;
    background: linear-gradient(135deg, #4A6FA5 0%, #357ABD 100%);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 4px 20px rgba(74, 111, 165, 0.4);
    transition: all 0.3s ease;
    animation: pulse 2s infinite;
}

.chat-bubble:hover {
    transform: scale(1.1);
    box-shadow: 0 6px 25px rgba(74, 111, 165, 0.6);
}

.livechat-widget.active .chat-bubble {
    background: linear-gradient(135deg, #357ABD 0%, #4A6FA5 100%);
    animation: none;
}

.chat-icon {
    position: relative;
    color: white;
    font-size: 24px;
}

.chat-badge {
    position: absolute;
    top: -8px;
    right: -8px;
    background: #ff4757;
    color: white;
    border-radius: 50%;
    width: 20px;
    height: 20px;
    font-size: 12px;
    font-weight: 600;
    display: none;
    align-items: center;
    justify-content: center;
    animation: bounce 1s infinite;
}

.chat-tooltip {
    position: absolute;
    bottom: 70px;
    right: 0;
    background: #2c3e50;
    color: white;
    padding: 8px 12px;
    border-radius: 8px;
    font-size: 14px;
    white-space: nowrap;
    opacity: 0;
    visibility: hidden;
    transform: translateY(10px);
    transition: all 0.3s ease;
    pointer-events: none;
}

.chat-tooltip::after {
    content: '';
    position: absolute;
    top: 100%;
    right: 20px;
    border: 6px solid transparent;
    border-top-color: #2c3e50;
}

.livechat-widget:hover .chat-tooltip {
    opacity: 1;
    visibility: visible;
    transform: translateY(0);
}

/* =================================
   Chat Window
   ================================= */
.livechat-window {
    position: fixed;
    bottom: 90px;
    right: 20px;
    width: 380px;
    max-width: calc(100vw - 40px);
    height: 500px;
    max-height: calc(100vh - 120px);
    background: white;
    border-radius: 16px;
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.15);
    z-index: 9999;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    transform: translateY(20px) scale(0.95);
    opacity: 0;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
}

.livechat-window:not(.hidden) {
    transform: translateY(0) scale(1);
    opacity: 1;
}

.livechat-window.minimized {
    height: 60px;
    overflow: hidden;
}

.livechat-window.hidden {
    display: none;
}

/* =================================
   Chat Header
   ================================= */
.chat-header {
    background: linear-gradient(135deg, #4A6FA5 0%, #357ABD 100%);
    color: white;
    padding: 16px 20px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    min-height: 60px;
    box-sizing: border-box;
}

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

.operator-avatar {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    overflow: hidden;
    position: relative;
}

.operator-avatar img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.avatar-fallback {
    width: 100%;
    height: 100%;
    background: rgba(255, 255, 255, 0.2);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 18px;
    color: white;
}

.chat-title h4 {
    margin: 0;
    font-size: 16px;
    font-weight: 600;
    line-height: 1.2;
}

.chat-status {
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 12px;
    opacity: 0.9;
    margin-top: 2px;
}

.chat-status i {
    font-size: 8px;
}

.chat-status.online i {
    color: #2ecc71;
}

.chat-status.offline i {
    color: #e74c3c;
}

.chat-status.busy i {
    color: #f39c12;
}

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

.chat-controls button {
    width: 32px;
    height: 32px;
    border: none;
    background: rgba(255, 255, 255, 0.2);
    color: white;
    border-radius: 6px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background-color 0.2s ease;
    font-size: 14px;
}

.chat-controls button:hover {
    background: rgba(255, 255, 255, 0.3);
}

/* =================================
   Chat Body
   ================================= */
.chat-body {
    flex: 1;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    background: #f8f9fa;
}

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

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

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

.chat-messages::-webkit-scrollbar-thumb {
    background: rgba(0, 0, 0, 0.2);
    border-radius: 3px;
}

.chat-messages::-webkit-scrollbar-thumb:hover {
    background: rgba(0, 0, 0, 0.3);
}

/* =================================
   Messages
   ================================= */
.message {
    display: flex;
    margin-bottom: 8px;
    opacity: 0;
    transform: translateY(10px);
    transition: all 0.3s ease;
}

.message.visible {
    opacity: 1;
    transform: translateY(0);
}

.message.user {
    justify-content: flex-end;
}

.message.operator {
    justify-content: flex-start;
}

.message-content {
    max-width: 80%;
    background: white;
    border-radius: 18px;
    padding: 12px 16px;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
    position: relative;
}

.message.user .message-content {
    background: linear-gradient(135deg, #4A6FA5 0%, #357ABD 100%);
    color: white;
    border-bottom-right-radius: 6px;
}

.message.operator .message-content {
    background: white;
    color: #2c3e50;
    border-bottom-left-radius: 6px;
}

.message-text {
    font-size: 14px;
    line-height: 1.4;
    margin-bottom: 4px;
    word-wrap: break-word;
}

.message-time {
    font-size: 11px;
    opacity: 0.7;
    text-align: right;
}

.message.operator .message-time {
    text-align: left;
}

/* =================================
   Typing Indicator
   ================================= */
.typing-indicator {
    padding: 0 20px 16px;
    display: flex;
    align-items: center;
    gap: 12px;
    opacity: 1;
    transition: opacity 0.3s ease;
}

.typing-indicator.hidden {
    opacity: 0;
    height: 0;
    padding: 0 20px;
    overflow: hidden;
}

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

.typing-dots span {
    width: 8px;
    height: 8px;
    background: #bdc3c7;
    border-radius: 50%;
    animation: typing 1.4s infinite ease-in-out;
}

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

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

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

/* =================================
   Chat Footer
   ================================= */
.chat-footer {
    background: white;
    border-top: 1px solid #e9ecef;
    padding: 16px;
}

.chat-input-container {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

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

.action-btn {
    width: 32px;
    height: 32px;
    border: none;
    background: #f8f9fa;
    color: #6c757d;
    border-radius: 6px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s ease;
    font-size: 14px;
}

.action-btn:hover {
    background: #e9ecef;
    color: #495057;
}

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

.input-wrapper:focus-within {
    border-color: #4A6FA5;
    background: white;
}

#chat-input {
    flex: 1;
    border: none;
    background: transparent;
    outline: none;
    resize: none;
    font-family: inherit;
    font-size: 14px;
    line-height: 1.4;
    max-height: 120px;
    padding: 4px 0;
    color: #2c3e50;
}

#chat-input::placeholder {
    color: #95a5a6;
}

.send-btn {
    width: 36px;
    height: 36px;
    border: none;
    background: #4A6FA5;
    color: white;
    border-radius: 50%;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s ease;
    font-size: 14px;
    flex-shrink: 0;
}

.send-btn:hover:not(:disabled) {
    background: #357ABD;
    transform: scale(1.05);
}

.send-btn:disabled {
    background: #bdc3c7;
    cursor: not-allowed;
    transform: none;
}

.chat-footer-info {
    margin-top: 8px;
    text-align: center;
}

.chat-footer-info small {
    font-size: 11px;
    color: #95a5a6;
}

/* =================================
   Emoji Picker
   ================================= */
.emoji-popup {
    position: absolute;
    bottom: 60px;
    left: 16px;
    background: white;
    border-radius: 12px;
    padding: 12px;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.15);
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    max-width: 200px;
    z-index: 10000;
    animation: fadeInUp 0.3s ease;
}

.emoji-btn {
    width: 32px;
    height: 32px;
    border: none;
    background: transparent;
    font-size: 18px;
    cursor: pointer;
    border-radius: 6px;
    transition: background-color 0.2s ease;
}

.emoji-btn:hover {
    background: #f8f9fa;
}

/* =================================
   Responsive Design
   ================================= */
@media (max-width: 768px) {
    .livechat-window {
        width: 100%;
        height: 100%;
        max-width: none;
        max-height: none;
        bottom: 0;
        right: 0;
        border-radius: 0;
    }
    
    .livechat-widget {
        bottom: 80px;
    }
    
    .chat-tooltip {
        display: none;
    }
}

@media (max-width: 480px) {
    .chat-header {
        padding: 12px 16px;
    }
    
    .chat-messages {
        padding: 16px;
    }
    
    .chat-footer {
        padding: 12px;
    }
    
    .message-content {
        max-width: 85%;
    }
}

/* =================================
   Animations
   ================================= */
@keyframes pulse {
    0%, 100% {
        transform: scale(1);
    }
    50% {
        transform: scale(1.05);
    }
}

@keyframes bounce {
    0%, 20%, 50%, 80%, 100% {
        transform: translateY(0);
    }
    40% {
        transform: translateY(-5px);
    }
    60% {
        transform: translateY(-3px);
    }
}

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

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

/* =================================
   Dark Mode Support
   ================================= */
@media (prefers-color-scheme: dark) {
    .livechat-window {
        background: #2c3e50;
    }
    
    .chat-body {
        background: #34495e;
    }
    
    .chat-messages {
        color: #ecf0f1;
    }
    
    .message.operator .message-content {
        background: #3c4f66;
        color: #ecf0f1;
    }
    
    .chat-footer {
        background: #2c3e50;
        border-top-color: #34495e;
    }
    
    .input-wrapper {
        background: #34495e;
    }
    
    .input-wrapper:focus-within {
        background: #3c4f66;
    }
    
    #chat-input {
        color: #ecf0f1;
    }
    
    .action-btn {
        background: #34495e;
        color: #bdc3c7;
    }
    
    .action-btn:hover {
        background: #3c4f66;
        color: #ecf0f1;
    }
    
    .emoji-popup {
        background: #3c4f66;
    }
    
    .emoji-btn:hover {
        background: #4a5f7a;
    }
}

/* =================================
   Accessibility
   ================================= */
.livechat-widget:focus,
.chat-controls button:focus,
.action-btn:focus,
.send-btn:focus,
#chat-input:focus {
    outline: 2px solid #4A6FA5;
    outline-offset: 2px;
}

@media (prefers-reduced-motion: reduce) {
    .livechat-widget,
    .livechat-window,
    .message,
    .chat-bubble,
    .send-btn {
        animation: none;
        transition: none;
    }
}

/* =================================
   High Contrast Mode
   ================================= */
@media (prefers-contrast: high) {
    .chat-bubble {
        border: 2px solid #000;
    }
    
    .livechat-window {
        border: 2px solid #000;
    }
    
    .message-content {
        border: 1px solid #000;
    }
}

/* =================================
   Print Styles
   ================================= */
@media print {
    .livechat-widget,
    .livechat-window {
        display: none !important;
    }
}