﻿
:root {
    --chat-primary: #2563eb;
    --chat-primary-dark: #1e40af;
    --chat-white: #ffffff;
    --chat-gray-light: #f3f4f6;
    --chat-gray: #e5e7eb;
    --chat-gray-dark: #6b7280;
    --chat-text: #111827;
    --chat-success: #10b981;
    --chat-shadow: 0 10px 25px rgba(0, 0, 0, 0.15);
    --chat-shadow-lg: 0 20px 40px rgba(0, 0, 0, 0.2);
}


/* ==========================================
   Chat Widget Container
   ========================================== */
.chat-widget {
    position: fixed;
    bottom: 20px;
    right: 20px;
    z-index: 9999;
}

/* ==========================================
   Chat Toggle Button
   ========================================== */
.chat-toggle-btn {
    width: 60px;
    height: 60px;
    border-radius: 50%;
    background: linear-gradient(135deg, var(--chat-primary), var(--chat-primary-dark));
    color: var(--chat-white);
    border: none;
    font-size: 24px;
    cursor: pointer;
    box-shadow: var(--chat-shadow);
    transition: all 0.3s ease;
    position: relative;
    animation: pulse 2s infinite;
}

    .chat-toggle-btn:hover {
        transform: scale(1.1);
        box-shadow: var(--chat-shadow-lg);
    }

    .chat-toggle-btn.active {
        background: var(--chat-gray-dark);
    }

@keyframes pulse {
    0%, 100% {
        box-shadow: 0 10px 25px rgba(37, 99, 235, 0.4);
    }

    50% {
        box-shadow: 0 10px 40px rgba(37, 99, 235, 0.6);
    }
}

.chat-badge {
    position: absolute;
    top: -5px;
    right: -5px;
    background: #ef4444;
    color: var(--chat-white);
    font-size: 12px;
    font-weight: 700;
    padding: 3px 7px;
    border-radius: 12px;
    min-width: 20px;
    text-align: center;
    display: none;
}

    .chat-badge.show {
        display: block;
        animation: bounce 0.5s;
    }

@keyframes bounce {
    0%, 100% {
        transform: scale(1);
    }

    50% {
        transform: scale(1.2);
    }
}

/* ==========================================
   Chat Window
   ========================================== */
.chat-window {
    position: absolute;
    bottom: 80px;
    right: 0;
    width: 380px;
    max-width: calc(100vw - 40px);
    height: 600px;
    max-height: calc(100vh - 120px);
    background: var(--chat-white);
    border-radius: 16px;
    box-shadow: var(--chat-shadow-lg);
    display: none;
    flex-direction: column;
    overflow: hidden;
    animation: slideUp 0.3s ease;
}

    .chat-window.show {
        display: flex;
    }

    .chat-window.minimized {
        height: 60px;
    }

@keyframes slideUp {
    from {
        opacity: 0;
        transform: translateY(20px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* ==========================================
   Chat Header
   ========================================== */
.chat-header {
    background: linear-gradient(135deg, var(--chat-primary), var(--chat-primary-dark));
    color: var(--chat-white);
    padding: 16px;
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.header-info {
    display: flex;
    align-items: center;
    gap: 12px;
}

.support-avatar {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    border: 2px solid var(--chat-white);
}

.header-text h3 {
    font-size: 16px;
    font-weight: 600;
    margin-bottom: 2px;
}

.status-text {
    font-size: 12px;
    display: flex;
    align-items: center;
    gap: 6px;
    opacity: 0.9;
}

.status-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: var(--chat-gray-light);
    animation: blink 2s infinite;
}

@keyframes blink {
    0%, 100% {
        opacity: 1;
    }

    50% {
        opacity: 0.5;
    }
}

.header-actions {
    display: flex;
    gap: 8px;
}

.header-btn {
    width: 32px;
    height: 32px;
    background: rgba(255, 255, 255, 0.2);
    border: none;
    border-radius: 8px;
    color: var(--chat-white);
    cursor: pointer;
    transition: all 0.2s;
}

    .header-btn:hover {
        background: rgba(255, 255, 255, 0.3);
    }

/* ==========================================
   Chat Messages Area
   ========================================== */
.chat-messages {
    flex: 1;
    overflow-y: auto;
    background: var(--chat-gray-light);
}

.messages-container {
    padding: 20px;
    display: flex;
    flex-direction: column;
    gap: 16px;
}

/* Message Bubble */
.message {
    display: flex;
    gap: 8px;
    max-width: 80%;
    animation: fadeInMessage 0.3s;
}

@keyframes fadeInMessage {
    from {
        opacity: 0;
        transform: translateY(10px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.message.received {
    align-self: flex-start;
}

.message.sent {
    align-self: flex-end;
    flex-direction: row-reverse;
}

.message-avatar {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    flex-shrink: 0;
}

.message-content {
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.message-bubble {
    padding: 12px 16px;
    border-radius: 16px;
    font-size: 14px;
    line-height: 1.5;
    word-wrap: break-word;
}

.message.received .message-bubble {
    background: var(--chat-white);
    color: var(--chat-text);
    border-bottom-right-radius: 4px;
}

.message.sent .message-bubble {
    background: var(--chat-primary);
    color: var(--chat-white);
    border-bottom-left-radius: 4px;
}

.message-time {
    font-size: 11px;
    color: var(--chat-gray-dark);
    padding: 0 4px;
}

.message.sent .message-time {
    text-align: left;
}

/* Message Image */
.message-image {
    max-width: 200px;
    border-radius: 12px;
    cursor: pointer;
    transition: all 0.2s;
}

    .message-image:hover {
        transform: scale(1.05);
    }

/* System Message */
.message.system {
    align-self: center;
    max-width: 90%;
}

    .message.system .message-bubble {
        background: rgba(37, 99, 235, 0.1);
        color: var(--chat-primary);
        border-radius: 8px;
        font-size: 12px;
        text-align: center;
        padding: 8px 12px;
    }

/* ==========================================
   Typing Indicator
   ========================================== */
.typing-indicator {
    padding: 12px 20px;
    background: var(--chat-white);
    border-top: 1px solid var(--chat-gray);
    display: flex;
    align-items: center;
    gap: 8px;
}

.typing-dots {
    display: flex;
    gap: 4px;
}

    .typing-dots span {
        width: 8px;
        height: 8px;
        background: var(--chat-primary);
        border-radius: 50%;
        animation: typing 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 {
    0%, 60%, 100% {
        transform: translateY(0);
        opacity: 0.5;
    }

    30% {
        transform: translateY(-10px);
        opacity: 1;
    }
}

.typing-text {
    font-size: 13px;
    color: var(--chat-gray-dark);
}

/* ==========================================
   Chat Input Area
   ========================================== */
.chat-input-area {
    background: var(--chat-white);
    border-top: 1px solid var(--chat-gray);
}

.message-form {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 12px;
}

.attach-btn,
.emoji-btn {
    width: 36px;
    height: 36px;
    background: none;
    border: none;
    color: var(--chat-gray-dark);
    font-size: 18px;
    cursor: pointer;
    border-radius: 8px;
    transition: all 0.2s;
}

    .attach-btn:hover,
    .emoji-btn:hover {
        background: var(--chat-gray-light);
        color: var(--chat-primary);
    }

.input-wrapper {
    flex: 1;
    display: flex;
    align-items: center;
    gap: 8px;
    background: var(--chat-gray-light);
    border-radius: 24px;
    padding: 0 12px;
}

    .input-wrapper input {
        flex: 1;
        padding: 10px 0;
        border: none;
        background: none;
        font-size: 14px;
        outline: none;
    }

.send-btn {
    width: 36px;
    height: 36px;
    background: var(--chat-primary);
    color: var(--chat-white);
    border: none;
    border-radius: 50%;
    font-size: 16px;
    cursor: pointer;
    transition: all 0.2s;
}

    .send-btn:hover {
        background: var(--chat-primary-dark);
        transform: scale(1.1);
    }

    .send-btn:disabled {
        opacity: 0.5;
        cursor: not-allowed;
    }

/* ==========================================
   Quick Replies
   ========================================== */
.quick-replies {
    padding: 12px;
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
    border-top: 1px solid var(--chat-gray);
}

.quick-reply-btn {
    padding: 8px 16px;
    background: var(--chat-white);
    border: 2px solid var(--chat-primary);
    color: var(--chat-primary);
    border-radius: 20px;
    font-size: 13px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s;
}

    .quick-reply-btn:hover {
        background: var(--chat-primary);
        color: var(--chat-white);
    }

/* ==========================================
   Chat Footer
   ========================================== */
.chat-footer {
    padding: 8px 16px;
    text-align: center;
    font-size: 11px;
    color: var(--chat-gray-dark);
    border-top: 1px solid var(--chat-gray);
    background: var(--chat-gray-light);
}

    .chat-footer strong {
        color: var(--chat-primary);
    }

/* ==========================================
   Scrollbar Styling
   ========================================== */
.chat-messages::-webkit-scrollbar {
    width: 6px;
}

.chat-messages::-webkit-scrollbar-track {
    background: var(--chat-gray-light);
}

.chat-messages::-webkit-scrollbar-thumb {
    background: var(--chat-gray);
    border-radius: 3px;
}

    .chat-messages::-webkit-scrollbar-thumb:hover {
        background: var(--chat-gray-dark);
    }

/* ==========================================
   Responsive Design
   ========================================== */
@media (max-width: 480px) {
    .chat-widget {
        bottom: 10px;
        left: 10px;
        right: 10px;
    }

    .chat-window {
        width: calc(100vw - 20px);
        right: 50%;
        transform: translateX(50%);
        height: calc(100vh - 80px);
        bottom: 70px;
    }

    .chat-toggle-btn {
        width: 56px;
        height: 56px;
        font-size: 22px;
    }

    .auth-modal {
        width: 95%;
        max-width: none;
    }

    .auth-body {
        padding: 20px;
    }
}

/* ==========================================
   Animations
   ========================================== */
.shake {
    animation: shake 0.5s;
}

@keyframes shake {
    0%, 100% {
        transform: translateX(0);
    }

    25% {
        transform: translateX(-5px);
    }

    75% {
        transform: translateX(5px);
    }
}

.fade-in {
    animation: fadeIn 0.3s;
}

.slide-up {
    animation: slideUp 0.3s;
}


.edited-indicator {
    font-size: 0.75em;
    color: rgba(0, 0, 0, 0.5);
    font-style: italic;
    margin-left: 4px;
}

.message.received .edited-indicator {
    color: rgba(255, 255, 255, 0.7);
}

.message-actions {
    display: flex;
    gap: 4px;
    margin-top: 4px;
    opacity: 0;
    transition: opacity 0.2s;
}

.message:hover .message-actions {
    opacity: 1;
}

.action-btn {
    background: transparent;
    border: 1px solid rgba(0, 0, 0, 0.1);
    border-radius: 4px;
    padding: 4px 8px;
    cursor: pointer;
    font-size: 12px;
    color: #666;
    transition: all 0.2s;
}

    .action-btn:hover {
        background: rgba(0, 0, 0, 0.05);
        border-color: rgba(0, 0, 0, 0.2);
    }

.edit-btn:hover {
    color: #2563eb;
}

.delete-btn:hover {
    color: #dc2626;
}


/* ==========================================
   Emoji Button & Picker Styles
   ========================================== */

.emoji-btn {
    background: transparent;
    border: none;
    color: #6b7280;
    cursor: pointer;
    padding: 8px;
    border-radius: 8px;
    transition: all 0.2s;
    font-size: 20px;
    display: flex;
    align-items: center;
    justify-content: center;
}

    .emoji-btn:hover {
        background: #f3f4f6;
        color: #2563eb;
    }

    .emoji-btn.active {
        color: #2563eb;
        background: #eff6ff;
    }

/* Emoji Picker Container */
.emoji-picker {
    position: absolute;
    bottom: 70px;
    left: 10px;
    width: 320px;
    height: 350px;
    background: white;
    border-radius: 12px;
    box-shadow: 0 10px 25px rgba(0, 0, 0, 0.15);
    display: flex;
    flex-direction: column;
    z-index: 1000;
    animation: slideUp 0.2s ease;
}

@keyframes slideUp {
    from {
        opacity: 0;
        transform: translateY(10px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* Emoji Categories */
.emoji-categories {
    display: flex;
    gap: 4px;
    padding: 10px;
    border-bottom: 1px solid #e5e7eb;
    background: #f9fafb;
    border-radius: 12px 12px 0 0;
    overflow-x: auto;
    scrollbar-width: thin;
}

.emoji-category {
    background: transparent;
    border: none;
    font-size: 20px;
    padding: 6px 10px;
    cursor: pointer;
    border-radius: 6px;
    transition: all 0.2s;
    flex-shrink: 0;
}

    .emoji-category:hover {
        background: #e5e7eb;
    }

    .emoji-category.active {
        background: #2563eb;
        transform: scale(1.1);
    }

/* Emoji Grid */
.emoji-grid {
    display: grid;
    grid-template-columns: repeat(8, 1fr);
    gap: 4px;
    padding: 10px;
    overflow-y: auto;
    flex: 1;
}

.emoji-item {
    background: transparent;
    border: none;
    font-size: 24px;
    padding: 8px;
    cursor: pointer;
    border-radius: 6px;
    transition: all 0.15s;
    display: flex;
    align-items: center;
    justify-content: center;
}

    .emoji-item:hover {
        background: #f3f4f6;
        transform: scale(1.2);
    }

    .emoji-item:active {
        transform: scale(1.1);
    }

/* Scrollbar styling */
.emoji-grid::-webkit-scrollbar {
    width: 6px;
}

.emoji-grid::-webkit-scrollbar-track {
    background: #f1f1f1;
    border-radius: 10px;
}

.emoji-grid::-webkit-scrollbar-thumb {
    background: #cbd5e1;
    border-radius: 10px;
}

    .emoji-grid::-webkit-scrollbar-thumb:hover {
        background: #94a3b8;
    }

/* Responsive adjustments */
@media (max-width: 480px) {
    .emoji-picker {
        width: calc(100% - 20px);
        left: 10px;
        right: 10px;
    }

    .emoji-grid {
        grid-template-columns: repeat(7, 1fr);
    }
}


/* File Preview Container */
.file-previews-container {
    display: flex;
    flex-direction: column;
    gap: 8px;
    padding: 10px;
    background: #f9fafb;
    border-top: 1px solid #e5e7eb;
}

.file-preview {
    background: white;
    border-radius: 8px;
    padding: 8px;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
}

.file-preview-content {
    display: flex;
    align-items: center;
    gap: 10px;
}

.preview-image {
    width: 48px;
    height: 48px;
    object-fit: cover;
    border-radius: 6px;
}

.file-icon {
    width: 48px;
    height: 48px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: #eff6ff;
    border-radius: 6px;
    color: #2563eb;
    font-size: 24px;
}

.file-info {
    flex: 1;
    min-width: 0;
}

.file-name {
    font-weight: 500;
    color: #1f2937;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.file-size {
    font-size: 12px;
    color: #6b7280;
    margin-top: 2px;
}

.remove-file {
    background: transparent;
    border: none;
    color: #dc2626;
    cursor: pointer;
    padding: 6px;
    border-radius: 4px;
    transition: all 0.2s;
}

    .remove-file:hover {
        background: #fee2e2;
    }


.message-attachments {
    margin-top: 8px;
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.attachment {
    border-radius: 12px;
    overflow: hidden;
    max-width: 100%;
}

.attachment-image img {
    width: 100%;
    max-width: 320px; /* adjust as needed */
    height: auto;
    display: block;
    border-radius: 12px;
    cursor: pointer;
    box-shadow: 0 2px 8px rgba(0,0,0,0.15);
    transition: transform 0.2s;
}

    .attachment-image img:hover {
        transform: scale(1.02);
    }

.attachment-file {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 10px;
    background: rgba(0,0,0,0.04);
    border-radius: 10px;
}

    .attachment-file .file-name {
        font-weight: 500;
        max-width: 220px;
        white-space: nowrap;
        overflow: hidden;
        text-overflow: ellipsis;
    }

    .attachment-file .file-size {
        font-size: 12px;
        color: #6b7280;
    }

.image-modal {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.9);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 10000;
    cursor: pointer;
}

.modal-content {
    position: relative;
    max-width: 90vw;
    max-height: 90vh;
}

.modal-image {
    max-width: 100%;
    max-height: 85vh;
    object-fit: contain;
}

.modal-close {
    position: absolute;
    top: -40px;
    right: 0;
    font-size: 40px;
    color: white;
    cursor: pointer;
    user-select: none;
}