/* =====================================================
   LIVE CHAT WIDGET STYLES
   ===================================================== */

/* Chat Toggle Button */
.chat-widget-btn {
    position: fixed;
    bottom: 24px;
    right: 24px;
    width: 60px;
    height: 60px;
    border-radius: 50%;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    border: none;
    box-shadow: 0 4px 20px rgba(102, 126, 234, 0.4);
    cursor: pointer;
    z-index: 9999;
    transition: all 0.3s ease;
    display: flex;
    align-items: center;
    justify-content: center;
}

.chat-widget-btn:hover {
    transform: scale(1.1);
    box-shadow: 0 6px 30px rgba(102, 126, 234, 0.5);
}

.chat-widget-btn svg {
    width: 28px;
    height: 28px;
    color: white;
    transition: transform 0.3s ease;
}

.chat-widget-btn.open svg {
    transform: rotate(180deg);
}

/* Online indicator on button */
.chat-widget-btn .online-dot {
    position: absolute;
    top: 8px;
    right: 8px;
    width: 14px;
    height: 14px;
    background: #10b981;
    border: 3px solid white;
    border-radius: 50%;
    animation: pulse 2s infinite;
}

.chat-widget-btn .online-dot.offline {
    background: #9ca3af;
    animation: none;
}

@keyframes pulse {
    0% { box-shadow: 0 0 0 0 rgba(16, 185, 129, 0.4); }
    70% { box-shadow: 0 0 0 10px rgba(16, 185, 129, 0); }
    100% { box-shadow: 0 0 0 0 rgba(16, 185, 129, 0); }
}

/* Unread badge */
.chat-widget-btn .unread-badge {
    position: absolute;
    top: -5px;
    right: -5px;
    min-width: 22px;
    height: 22px;
    background: #ef4444;
    color: white;
    font-size: 12px;
    font-weight: 600;
    border-radius: 11px;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 0 6px;
}

/* Chat Box Container */
.chat-widget-box {
    position: fixed;
    bottom: 100px;
    right: 24px;
    width: 380px;
    height: 520px;
    max-height: calc(100vh - 140px);
    background: white;
    border-radius: 16px;
    box-shadow: 0 10px 50px rgba(0, 0, 0, 0.15);
    z-index: 9998;
    display: none;
    flex-direction: column;
    overflow: hidden;
    animation: slideUp 0.3s ease;
}

.chat-widget-box.show {
    display: flex;
}

/* Chat Content Area */
.chat-content {
    flex: 1;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    min-height: 0;
}

@keyframes slideUp {
    from {
        opacity: 0;
        transform: translateY(20px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* Chat Header */
.chat-widget-header {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    padding: 16px 20px;
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.chat-widget-header-info {
    display: flex;
    align-items: center;
    gap: 12px;
}

.chat-widget-header-avatar {
    width: 42px;
    height: 42px;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.2);
    display: flex;
    align-items: center;
    justify-content: center;
}

.chat-widget-header-avatar svg {
    width: 24px;
    height: 24px;
}

.chat-widget-header-text h4 {
    margin: 0;
    font-size: 16px;
    font-weight: 600;
}

.chat-widget-header-status {
    font-size: 12px;
    opacity: 0.9;
    display: flex;
    align-items: center;
    gap: 6px;
}

.chat-widget-header-status .status-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: #10b981;
}

.chat-widget-header-status .status-dot.offline {
    background: #9ca3af;
}

.chat-widget-close {
    background: none;
    border: none;
    color: white;
    cursor: pointer;
    padding: 4px;
    opacity: 0.8;
    transition: opacity 0.2s;
}

.chat-widget-close:hover {
    opacity: 1;
}

/* Start Form */
.chat-start-form {
    flex: 1;
    padding: 20px;
    display: flex;
    flex-direction: column;
    overflow-y: auto;
}

.chat-start-form-content {
    flex: 1;
}

.chat-start-form h5 {
    margin: 0 0 6px;
    font-size: 17px;
    color: #1f2937;
}

.chat-start-form p {
    margin: 0 0 16px;
    color: #6b7280;
    font-size: 13px;
}

.chat-start-form .form-group {
    margin-bottom: 12px;
}

.chat-start-form label {
    display: block;
    margin-bottom: 4px;
    font-size: 13px;
    font-weight: 500;
    color: #374151;
}

.chat-start-form input,
.chat-start-form textarea {
    width: 100%;
    padding: 10px 12px;
    border: 1px solid #e5e7eb;
    border-radius: 8px;
    font-size: 14px;
    transition: border-color 0.2s, box-shadow 0.2s;
    box-sizing: border-box;
}

.chat-start-form input:focus,
.chat-start-form textarea:focus {
    outline: none;
    border-color: #667eea;
    box-shadow: 0 0 0 3px rgba(102, 126, 234, 0.1);
}

.chat-start-form textarea {
    resize: vertical;
    min-height: 60px;
    max-height: 120px;
}

.chat-start-form button {
    width: 100%;
    padding: 12px;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    border: none;
    border-radius: 8px;
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    transition: transform 0.2s, box-shadow 0.2s;
    margin-top: 12px;
    flex-shrink: 0;
}

.chat-start-form button:hover {
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(102, 126, 234, 0.3);
}

.chat-start-form button:disabled {
    opacity: 0.7;
    cursor: not-allowed;
}

/* Messages Container */
.chat-messages {
    flex: 1;
    overflow-y: auto;
    padding: 16px;
    background: #f9fafb;
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.chat-messages::-webkit-scrollbar {
    width: 6px;
}

.chat-messages::-webkit-scrollbar-track {
    background: transparent;
}

.chat-messages::-webkit-scrollbar-thumb {
    background: #d1d5db;
    border-radius: 3px;
}

/* Message Bubble */
.chat-message {
    max-width: 85%;
    display: flex;
    flex-direction: column;
}

.chat-message.user {
    align-self: flex-end;
}

.chat-message.operator,
.chat-message.system {
    align-self: flex-start;
}

.chat-message-bubble {
    padding: 12px 16px;
    border-radius: 16px;
    font-size: 14px;
    line-height: 1.5;
    word-wrap: break-word;
}

.chat-message.user .chat-message-bubble {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    border-bottom-right-radius: 4px;
}

.chat-message.operator .chat-message-bubble {
    background: white;
    color: #1f2937;
    border: 1px solid #e5e7eb;
    border-bottom-left-radius: 4px;
}

.chat-message.system .chat-message-bubble {
    background: #f3f4f6;
    color: #6b7280;
    font-size: 13px;
    text-align: center;
    border-radius: 8px;
    align-self: center;
}

.chat-message-time {
    font-size: 11px;
    color: #9ca3af;
    margin-top: 4px;
    padding: 0 4px;
}

.chat-message.user .chat-message-time {
    text-align: right;
}

/* Typing Indicator */
.chat-typing-indicator {
    display: none;
    align-items: center;
    gap: 8px;
    padding: 8px 12px;
    font-size: 13px;
    color: #6b7280;
}

.chat-typing-indicator.show {
    display: flex;
}

.chat-typing-indicator .dots {
    display: flex;
    gap: 4px;
}

.chat-typing-indicator .dot {
    width: 6px;
    height: 6px;
    background: #9ca3af;
    border-radius: 50%;
    animation: typingDot 1.4s infinite;
}

.chat-typing-indicator .dot:nth-child(2) {
    animation-delay: 0.2s;
}

.chat-typing-indicator .dot:nth-child(3) {
    animation-delay: 0.4s;
}

@keyframes typingDot {
    0%, 60%, 100% { transform: translateY(0); }
    30% { transform: translateY(-4px); }
}

/* Input Area */
.chat-input-area {
    padding: 12px 16px;
    background: white;
    border-top: 1px solid #e5e7eb;
    display: flex;
    gap: 8px;
    align-items: center;
}

.chat-input-wrapper {
    flex: 1;
    position: relative;
}

.chat-input-area textarea {
    width: 100%;
    padding: 10px 12px;
    border: 1px solid #e5e7eb;
    border-radius: 12px;
    font-size: 14px;
    resize: none;
    height: 44px;
    line-height: 1.5;
    transition: border-color 0.2s;
    overflow: hidden;
    box-sizing: border-box;
}

.chat-input-area textarea:focus {
    outline: none;
    border-color: #667eea;
}

.chat-input-area textarea::placeholder {
    color: #9ca3af;
}

.chat-send-btn {
    width: 44px;
    height: 44px;
    border-radius: 12px;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    border: none;
    color: white;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: transform 0.2s, box-shadow 0.2s;
    flex-shrink: 0;
}

.chat-send-btn:hover:not(:disabled) {
    transform: scale(1.05);
    box-shadow: 0 4px 12px rgba(102, 126, 234, 0.3);
}

.chat-send-btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

.chat-send-btn svg {
    width: 20px;
    height: 20px;
}

/* Session closed message */
.chat-session-closed {
    padding: 16px;
    background: #f3f4f6;
    text-align: center;
}

.chat-session-closed p {
    margin: 0 0 12px;
    color: #6b7280;
    font-size: 14px;
}

.chat-session-closed button {
    padding: 10px 20px;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    border: none;
    border-radius: 8px;
    font-size: 14px;
    cursor: pointer;
}

/* Mobile Responsive */
@media (max-width: 480px) {
    .chat-widget-box {
        width: calc(100% - 16px);
        right: 8px;
        bottom: 80px;
        height: calc(100vh - 100px);
        max-height: none;
        border-radius: 12px;
    }
    
    .chat-widget-btn {
        right: 16px;
        bottom: 16px;
        width: 56px;
        height: 56px;
    }
}

/* Dark mode support */
@media (prefers-color-scheme: dark) {
    .chat-widget-box {
        background: #1f2937;
    }
    
    .chat-messages {
        background: #111827;
    }
    
    .chat-message.operator .chat-message-bubble {
        background: #374151;
        color: #f9fafb;
        border-color: #4b5563;
    }
    
    .chat-message.system .chat-message-bubble {
        background: #374151;
        color: #9ca3af;
    }
    
    .chat-input-area {
        background: #1f2937;
        border-color: #374151;
    }
    
    .chat-input-area textarea {
        background: #374151;
        border-color: #4b5563;
        color: #f9fafb;
    }
    
    .chat-start-form input,
    .chat-start-form textarea {
        background: #374151;
        border-color: #4b5563;
        color: #f9fafb;
    }
    
    .chat-start-form h5 {
        color: #f9fafb;
    }
    
    .chat-start-form p {
        color: #9ca3af;
    }
}

/* =====================================================
   FILE ATTACHMENT STYLES
   ===================================================== */

/* Attach Button */
.chat-attach-btn {
    width: 36px;
    height: 36px;
    border: none;
    background: transparent;
    color: #6b7280;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
    transition: all 0.2s ease;
    flex-shrink: 0;
}

.chat-attach-btn:hover {
    background: #f3f4f6;
    color: #667eea;
}

.chat-attach-btn i {
    font-size: 16px;
}

/* File Preview */
.chat-file-preview {
    display: none;
    padding: 8px 12px;
    background: #f9fafb;
    border-top: 1px solid #e5e7eb;
    align-items: center;
    gap: 10px;
}

.chat-file-preview.show {
    display: flex;
}

.chat-file-preview-icon {
    width: 40px;
    height: 40px;
    border-radius: 8px;
    overflow: hidden;
    flex-shrink: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    background: #e5e7eb;
}

.chat-file-preview-icon img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.chat-file-preview-icon i {
    font-size: 20px;
    color: #ef4444;
}

.chat-file-preview-info {
    flex: 1;
    min-width: 0;
}

.chat-file-preview-name {
    font-size: 13px;
    font-weight: 500;
    color: #374151;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.chat-file-preview-size {
    font-size: 11px;
    color: #9ca3af;
}

.chat-file-remove {
    width: 28px;
    height: 28px;
    border: none;
    background: #fee2e2;
    color: #dc2626;
    cursor: pointer;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s ease;
    flex-shrink: 0;
}

.chat-file-remove:hover {
    background: #fca5a5;
}

/* File in Message */
.chat-file-attachment {
    margin-bottom: 8px;
}

.chat-file-image-link {
    display: block;
}

.chat-file-image {
    max-width: 100%;
    max-height: 200px;
    border-radius: 8px;
    display: block;
    cursor: pointer;
    transition: opacity 0.2s ease;
}

.chat-file-image:hover {
    opacity: 0.9;
}

.chat-file-pdf {
    background: #fff7ed;
    border: 1px solid #fed7aa;
    border-radius: 8px;
    padding: 10px 12px;
}

.chat-file-link {
    display: flex;
    align-items: center;
    gap: 10px;
    text-decoration: none;
    color: #c2410c;
}

.chat-file-link:hover {
    color: #ea580c;
}

.chat-file-link i {
    font-size: 24px;
    color: #ea580c;
}

.chat-file-name {
    flex: 1;
    font-size: 13px;
    font-weight: 500;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.chat-file-size {
    font-size: 11px;
    color: #9a3412;
    flex-shrink: 0;
}

/* Message text when file present */
.chat-message-text {
    margin-top: 4px;
}

/* Dark mode for file attachments */
@media (prefers-color-scheme: dark) {
    .chat-attach-btn:hover {
        background: #374151;
    }
    
    .chat-file-preview {
        background: #1f2937;
        border-color: #374151;
    }
    
    .chat-file-preview-icon {
        background: #374151;
    }
    
    .chat-file-preview-name {
        color: #f9fafb;
    }
    
    .chat-file-remove {
        background: #7f1d1d;
        color: #fca5a5;
    }
    
    .chat-file-remove:hover {
        background: #991b1b;
    }
    
    .chat-file-pdf {
        background: #292524;
        border-color: #78350f;
    }
    
    .chat-file-link {
        color: #fdba74;
    }
    
    .chat-file-link:hover {
        color: #fb923c;
    }
    
    .chat-file-size {
        color: #fdba74;
    }
}
