/* Live Chat Widget Styles - Redesigned */
#chat-widget {
    position: fixed;
    bottom: 20px;
    right: 20px;
    z-index: 9999;
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
}

body.chat-open,
html.chat-open {
    overflow: hidden !important;
    height: 100% !important;
    position: fixed !important;
    width: 100% !important;
}

#chat-button {
    width: 60px;
    height: 60px;
    border-radius: 50% !important;
    background: linear-gradient(135deg, #00a2ff 0%, #004C99 100%);
    border: none !important;
    box-shadow: 0 4px 12px rgba(0, 76, 153, 0.4);
    cursor: pointer;
    display: flex !important;
    align-items: center !important;
    justify-content: center !important;
    transition: transform 0.2s, box-shadow 0.2s;
    position: relative;
    padding: 0 !important;
    overflow: hidden !important;
}

#chat-button:hover {
    transform: scale(1.05);
    box-shadow: 0 6px 20px rgba(0, 76, 153, 0.5);
}

#chat-button svg {
    width: 28px;
    height: 28px;
    fill: white;
}

#chat-button.unread::after {
    content: '';
    position: absolute;
    top: 8px;
    right: 8px;
    width: 12px;
    height: 12px;
    background: #ef4444;
    border-radius: 50%;
    border: 2px solid white;
    animation: pulse-dot 2s infinite;
}

@keyframes pulse-dot {

    0%,
    100% {
        transform: scale(1);
        opacity: 1;
    }

    50% {
        transform: scale(1.1);
        opacity: 0.8;
    }
}

#chat-popup {
    position: fixed;
    bottom: 90px;
    right: 20px;
    width: 380px;
    height: 600px;
    background: white;
    border-radius: 16px;
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.15);
    display: none;
    flex-direction: column;
    overflow: hidden;
    animation: slideUp 0.3s ease-out;
}

#chat-popup.open {
    display: flex;
}

@keyframes slideUp {
    from {
        opacity: 0;
        transform: translateY(20px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* Header */
.chat-header {
    background: white;
    color: #1f2937;
    padding: 16px 20px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    border-bottom: 1px solid #e5e7eb;
}

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

.chat-avatar {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    background: #e5e7eb;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.25rem;
}

.chat-header h3 {
    margin: 0;
    font-size: 1.125rem;
    font-weight: 600;
    color: #1f2937;
}

.chat-close {
    background: transparent;
    border: none;
    color: #9ca3af;
    cursor: pointer;
    font-size: 1.5rem;
    line-height: 1;
    padding: 0;
    width: 32px;
    height: 32px;
    border-radius: 8px;
    transition: background 0.2s;
}

.chat-close:hover {
    background: #f3f4f6;
}

/* Messages Area */
.chat-messages {
    flex: 1;
    padding: 20px;
    overflow-y: auto;
    background: #f9fafb;
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.chat-message {
    display: flex;
    flex-direction: column;
    max-width: 80%;
    animation: fadeIn 0.2s ease-out;
}

@keyframes fadeIn {
    from {
        opacity: 0;
        transform: translateY(10px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.chat-message.customer {
    align-self: flex-end;
}

.chat-message.admin {
    align-self: flex-start;
}

.message-bubble {
    padding: 12px 16px;
    border-radius: 16px;
    word-wrap: break-word;
    font-size: 0.9375rem;
    line-height: 1.5;
}

.chat-message.customer .message-bubble {
    background: #004C99;
    color: white;
    border-bottom-right-radius: 4px;
}

.chat-message.admin .message-bubble {
    background: #f3f4f6;
    color: #1f2937;
    border-bottom-left-radius: 4px;
}

.message-time {
    font-size: 0.6875rem;
    color: #9ca3af;
    margin-top: 4px;
    padding: 0 8px;
}

.chat-message.customer .message-time {
    text-align: right;
}

/* Welcome Message */
.welcome-message {
    background: #f3f4f6;
    padding: 16px;
    border-radius: 16px;
    color: #1f2937;
    font-size: 0.9375rem;
    margin-bottom: 8px;
    line-height: 1.6;
}

/* Name Input Screen */
.name-input-screen {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 32px;
    text-align: center;
}

.name-input-screen h2 {
    font-size: 1.5rem;
    font-weight: 600;
    color: #1f2937;
    margin-bottom: 8px;
}

.name-input-screen p {
    color: #6b7280;
    margin-bottom: 24px;
}

.name-input-screen input {
    width: 100%;
    padding: 12px 16px;
    border: 2px solid #e5e7eb;
    border-radius: 8px;
    font-size: 1rem;
    margin-bottom: 16px;
    transition: border-color 0.2s;
}

.name-input-screen input:focus {
    outline: none;
    border-color: #004C99;
}

.name-input-screen button {
    width: 100%;
    padding: 12px;
    background: linear-gradient(135deg, #004C99 0%, #0066cc 100%);
    color: white;
    border: none;
    border-radius: 8px;
    font-size: 1rem;
    font-weight: 600;
    cursor: pointer;
    transition: transform 0.2s;
}

.name-input-screen button:hover {
    transform: translateY(-1px);
}

.name-input-screen button:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

/* Input Area */
.chat-input-area {
    padding: 16px;
    background: white;
    border-top: 1px solid #e5e7eb;
    display: flex;
    gap: 8px;
    align-items: center;
}

.emoji-btn {
    background: transparent;
    border: none;
    font-size: 1.5rem;
    cursor: pointer;
    padding: 8px;
    border-radius: 8px;
    transition: background 0.2s;
    line-height: 1;
}

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

.chat-input {
    flex: 1;
    padding: 10px 14px;
    border: 1px solid #e5e7eb;
    border-radius: 20px;
    font-size: 0.9375rem;
    outline: none;
    transition: border-color 0.2s;
    background: #f9fafb;
}

.chat-input:focus {
    border-color: #004C99;
    background: white;
}

.chat-send-btn {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    background: #10b981;
    border: none;
    color: white;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: transform 0.2s, background 0.2s;
    flex-shrink: 0;
}

.chat-send-btn:hover {
    transform: scale(1.05);
    background: #059669;
}

.chat-send-btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
    background: #d1d5db;
}

.chat-send-btn svg {
    width: 18px;
    height: 18px;
    fill: white;
}

/* Footer */
.chat-footer {
    padding: 12px;
    text-align: center;
    font-size: 0.75rem;
    color: #9ca3af;
    border-top: 1px solid #e5e7eb;
    background: white;
}

/* Mobile Responsive */
@media (max-width: 480px) {
    #chat-widget {
        bottom: 30px !important;
        right: 20px !important;
        width: 60px !important;
        height: 60px !important;
        z-index: 100000 !important;
        position: fixed !important;
        overflow: visible !important;
    }

    #chat-popup {
        position: fixed !important;
        top: 0 !important;
        left: 0 !important;
        width: 100vw !important;
        height: 100vh !important;
        height: -webkit-fill-available !important;
        background: white !important;
        z-index: 100001 !important;
        display: none;
        flex-direction: column;
        border-radius: 0 !important;
        margin: 0 !important;
        padding: 0 !important;
    }

    #chat-popup.open {
        display: flex !important;
    }

    #chat-button {
        width: 60px !important;
        height: 60px !important;
        border-radius: 50% !important;
        display: flex !important;
        align-items: center !important;
        justify-content: center !important;
        padding: 0 !important;
        margin: 0 !important;
        box-sizing: border-box !important;
        flex-shrink: 0 !important;
        box-shadow: none !important;
        position: relative !important;
        overflow: visible !important;
    }

    #chat-button svg {
        width: 32px !important;
        height: 32px !important;
        display: block !important;
    }

    .chat-header {
        padding: 15px 20px !important;
        padding-top: calc(env(safe-area-inset-top, 15px) + 10px) !important;
        flex-shrink: 0 !important;
    }

    .chat-messages {
        padding: 15px !important;
        flex: 1 1 auto !important;
        overflow-y: auto !important;
        min-height: 0 !important;
    }

    .chat-input-area {
        padding: 15px !important;
        padding-bottom: calc(env(safe-area-inset-bottom, 15px) + 10px) !important;
        flex-shrink: 0 !important;
        background: white !important;
    }

    #chatMessagesContainer {
        height: 100% !important;
        display: flex !important;
        flex-direction: column !important;
    }
}

/* Typing Indicator */
.typing-indicator {
    display: flex;
    align-items: center;
    gap: 4px;
    padding: 12px 16px;
    background: #f3f4f6;
    border-radius: 16px;
    border-bottom-left-radius: 4px;
    width: fit-content;
    margin-bottom: 8px;
    animation: fadeIn 0.2s ease-out;
}

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

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

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

@keyframes typing-bounce {

    0%,
    80%,
    100% {
        transform: translateY(0);
    }

    40% {
        transform: translateY(-6px);
    }
}

/* Read Receipts */
.read-receipt {
    font-size: 0.6875rem;
    color: #9ca3af;
    text-align: right;
    margin-top: 2px;
    padding: 0 8px;
    display: flex;
    align-items: center;
    justify-content: flex-end;
    gap: 4px;
}

.read-receipt i {
    color: #10b981;
    /* Green for read */
}

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

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

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

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