/* Chat Widget Styles */
:root {
    --chat-primary: #7c3aed;
    /* Violet-600 */
    --chat-primary-hover: #6d28d9;
    /* Violet-700 */
    --chat-bg: #ffffff;
    --chat-text: #1f2937;
    /* Gray-800 */
    --chat-text-light: #6b7280;
    /* Gray-500 */
    --chat-border: #e5e7eb;
    /* Gray-200 */
    --chat-message-bg-user: #7c3aed;
    --chat-message-text-user: #ffffff;
    --chat-message-bg-admin: #f3f4f6;
    /* Gray-100 */
    --chat-message-text-admin: #1f2937;
}

.dark {
    --chat-bg: #1f2937;
    /* Gray-800 */
    --chat-text: #f9fafb;
    /* Gray-50 */
    --chat-text-light: #9ca3af;
    /* Gray-400 */
    --chat-border: #374151;
    /* Gray-700 */
    --chat-message-bg-admin: #374151;
    /* Gray-700 */
    --chat-message-text-admin: #f9fafb;
}

/* Floating Button */
#chat-widget-toggle {
    width: 60px;
    height: 60px;
    background-color: var(--chat-primary);
    color: white;
    border-radius: 50%;
    box-shadow: 0 4px 12px rgba(124, 58, 237, 0.3);
    border: none;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: transform 0.2s cubic-bezier(0.34, 1.56, 0.64, 1), box-shadow 0.2s ease;
}

#chat-widget-toggle:hover {
    transform: scale(1.1);
    background-color: var(--chat-primary-hover);
    box-shadow: 0 6px 16px rgba(124, 58, 237, 0.4);
}

#chat-widget-toggle svg {
    width: 28px;
    height: 28px;
    fill: none;
    stroke: currentColor;
    stroke-width: 2;
    stroke-linecap: round;
    stroke-linejoin: round;
}

/* WhatsApp Button */
#whatsapp-widget-toggle {
    width: 60px;
    height: 60px;
    background-color: #25D366;
    color: white;
    border-radius: 50%;
    box-shadow: 0 4px 12px rgba(37, 211, 102, 0.3);
    border: none;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: transform 0.2s cubic-bezier(0.34, 1.56, 0.64, 1), box-shadow 0.2s ease;
    text-decoration: none;
}

#whatsapp-widget-toggle:hover {
    transform: scale(1.1);
    background-color: #128C7E;
    box-shadow: 0 6px 16px rgba(37, 211, 102, 0.4);
}

#whatsapp-widget-toggle svg {
    width: 32px;
    height: 32px;
    fill: currentColor;
}

/* Email Button */
#email-widget-toggle {
    width: 60px;
    height: 60px;
    background-color: #EA4335;
    color: white;
    border-radius: 50%;
    box-shadow: 0 4px 12px rgba(234, 67, 53, 0.3);
    border: none;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: transform 0.2s cubic-bezier(0.34, 1.56, 0.64, 1), box-shadow 0.2s ease;
    text-decoration: none;
}

#email-widget-toggle:hover {
    transform: scale(1.1);
    background-color: #D33426;
    box-shadow: 0 6px 16px rgba(234, 67, 53, 0.4);
}

#email-widget-toggle svg {
    width: 28px;
    height: 28px;
}

/* Chat Window */
#chat-widget-window {
    position: fixed;
    bottom: 100px;
    right: 24px;
    width: 400px;
    height: 650px;
    max-height: calc(100vh - 120px);
    background-color: var(--chat-bg);
    border-radius: 16px;
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.15);
    display: flex;
    flex-direction: column;
    z-index: 9999;
    opacity: 0;
    transform: translateY(20px) scale(0.95);
    pointer-events: none;
    transition: opacity 0.3s ease, transform 0.3s cubic-bezier(0.34, 1.56, 0.64, 1);
    overflow: hidden;
    border: 1px solid var(--chat-border);
}

#chat-widget-window.open {
    opacity: 1;
    transform: translateY(0) scale(1);
    pointer-events: auto;
}

/* Header */
.chat-header {
    padding: 16px;
    background-color: var(--chat-primary);
    color: white;
    display: flex;
    align-items: center;
    justify-content: space-between;
    border-bottom: 1px solid rgba(255, 255, 255, 0.1);
}

.chat-header h3 {
    margin: 0;
    font-size: 16px;
    font-weight: 600;
}

.chat-header-actions button {
    background: none;
    border: none;
    color: rgba(255, 255, 255, 0.8);
    cursor: pointer;
    padding: 4px;
    border-radius: 4px;
    transition: background 0.2s;
}

.chat-header-actions button:hover {
    background: rgba(255, 255, 255, 0.1);
    color: white;
}

/* Messages Area */
.chat-messages {
    flex: 1;
    padding: 16px;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
    gap: 12px;
    background-color: var(--chat-bg);
}

.chat-message {
    max-width: 80%;
    padding: 10px 14px;
    border-radius: 12px;
    font-size: 14px;
    line-height: 1.5;
    position: relative;
    word-wrap: break-word;
}

.chat-message.customer {
    align-self: flex-end;
    background-color: var(--chat-message-bg-user);
    color: var(--chat-message-text-user);
    border-bottom-right-radius: 4px;
}

.chat-message.admin {
    align-self: flex-start;
    background-color: var(--chat-message-bg-admin);
    color: var(--chat-message-text-admin);
    border-bottom-left-radius: 4px;
}

.chat-message-time {
    font-size: 10px;
    opacity: 0.7;
    margin-top: 4px;
    display: block;
    text-align: right;
}

/* Input Area */
.chat-input-area {
    padding: 16px;
    border-top: 1px solid var(--chat-border);
    background-color: var(--chat-bg);
    display: flex;
    gap: 8px;
    align-items: flex-end;
}

.chat-input-area textarea {
    flex: 1;
    border: 1px solid var(--chat-border);
    border-radius: 20px;
    padding: 10px 14px;
    font-family: inherit;
    font-size: 14px;
    resize: none;
    max-height: 100px;
    background-color: var(--chat-bg);
    color: var(--chat-text);
    outline: none;
    transition: border-color 0.2s;
}

.chat-input-area textarea:focus {
    border-color: var(--chat-primary);
}

.chat-input-area button {
    background-color: var(--chat-primary);
    color: white;
    border: none;
    border-radius: 50%;
    width: 40px;
    height: 40px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: background 0.2s;
    flex-shrink: 0;
}

.chat-input-area button:hover {
    background-color: var(--chat-primary-hover);
}

.chat-input-area button:disabled {
    background-color: var(--chat-border);
    cursor: not-allowed;
}

/* Widget Container for Mobile Collapse */
#widget-container {
    position: fixed;
    bottom: 20px;
    right: 20px;
    display: flex;
    flex-direction: column-reverse;
    align-items: flex-end;
    gap: 12px;
    z-index: 9999;
}

/* Main Toggle (visible on both desktop and mobile) */
#widget-main-toggle {
    display: flex;
    width: 60px;
    height: 60px;
    background: linear-gradient(135deg, var(--chat-primary) 0%, #25D366 100%);
    color: white;
    border-radius: 50%;
    box-shadow: 0 4px 12px rgba(124, 58, 237, 0.3);
    border: none;
    cursor: pointer;
    align-items: center;
    justify-content: center;
    transition: transform 0.2s cubic-bezier(0.34, 1.56, 0.64, 1), box-shadow 0.2s ease;
}

#widget-main-toggle:hover {
    transform: scale(1.1);
    box-shadow: 0 6px 16px rgba(124, 58, 237, 0.4);
}

#widget-main-toggle svg {
    width: 28px;
    height: 28px;
    transition: transform 0.3s ease;
}

#widget-main-toggle.expanded svg {
    transform: rotate(45deg);
}

/* Widget Buttons Container */
.widget-buttons {
    display: flex;
    flex-direction: column;
    align-items: flex-end;
    gap: 12px;
    opacity: 0;
    transform: translateY(20px) scale(0.8);
    pointer-events: none;
    transition: opacity 0.3s ease, transform 0.3s cubic-bezier(0.34, 1.56, 0.64, 1);
}

.widget-buttons.expanded {
    opacity: 1;
    transform: translateY(0) scale(1);
    pointer-events: auto;
}

/* Mobile Responsiveness */
@media (max-width: 768px) {
    #chat-widget-window {
        bottom: 0;
        right: 0;
        width: 100%;
        height: 100%;
        max-height: 100%;
        border-radius: 0;
    }

    #widget-container {
        bottom: 20px !important;
        right: 16px !important;
    }
}

/* Typing Indicator */
.typing-indicator {
    display: flex;
    gap: 4px;
    padding: 8px 12px;
    background-color: var(--chat-message-bg-admin);
    border-radius: 12px;
    border-bottom-left-radius: 4px;
    align-self: flex-start;
    width: fit-content;
}

.typing-dot {
    width: 6px;
    height: 6px;
    background-color: var(--chat-text-light);
    border-radius: 50%;
    animation: typing 1.4s infinite ease-in-out both;
}

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

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

@keyframes typing {

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

    40% {
        transform: scale(1);
    }
}

/* Login Prompt Styling */
.chat-login-prompt {
    max-width: 90% !important;
    background: linear-gradient(135deg, rgba(124, 58, 237, 0.05), rgba(109, 40, 217, 0.08)) !important;
    border: 2px solid rgba(124, 58, 237, 0.3) !important;
    box-shadow: 0 4px 12px rgba(124, 58, 237, 0.15) !important;
}

.chat-login-prompt a:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(124, 58, 237, 0.4);
}

.chat-login-prompt a:active {
    transform: translateY(0);
}

/* Notification Badge */
.chat-notification-badge {
    position: absolute;
    top: -4px;
    right: -4px;
    width: 20px;
    height: 20px;
    background: #ef4444;
    color: white;
    font-size: 12px;
    font-weight: 700;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    border: 2px solid white;
    box-shadow: 0 2px 8px rgba(239, 68, 68, 0.4);
    animation: pulse-badge 2s infinite;
}

@keyframes pulse-badge {

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

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

#chat-widget-toggle {
    position: relative;
}