/**
 * Webzieh Sophie Chat Styles
 * Version: 2.0.0
 * Author: Lino Titto Sam
 * Company: Webzieh Creations Ltd
 */

/* Main Container */
#sophie-chat-container {
    position: relative;
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
    z-index: 9999;
}

/* Trigger Button */
#sophie-chat-trigger {
    background: linear-gradient(135deg, #880000 0%, #a00000 100%);
    color: #fff;
    border: none;
    padding: 12px 24px;
    border-radius: 50px;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    gap: 10px;
    font-weight: 600;
    font-size: 14px;
    box-shadow: 0 8px 20px rgba(136, 0, 0, 0.4);
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    position: relative;
    overflow: hidden;
    -webkit-tap-highlight-color: transparent;
    touch-action: manipulation;
    user-select: none;
    -webkit-user-select: none;
    border: 2px solid rgba(255, 255, 255, 0.2);
}

#sophie-chat-trigger::before {
    content: '';
    position: absolute;
    top: 50%;
    left: 50%;
    width: 0;
    height: 0;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.1);
    transform: translate(-50%, -50%);
    transition: width 0.6s, height 0.6s;
}

#sophie-chat-trigger:hover::before {
    width: 300px;
    height: 300px;
}

#sophie-chat-trigger:hover {
    background: linear-gradient(135deg, #D20103 0%, #ff0000 100%);
    transform: translateY(-2px);
    box-shadow: 0 12px 28px rgba(210, 1, 3, 0.5);
    border-color: rgba(255, 255, 255, 0.3);
}

#sophie-chat-trigger .sophie-icon {
    display: flex;
    align-items: center;
    position: relative;
    z-index: 1;
}

#sophie-chat-trigger .sophie-label {
    position: relative;
    z-index: 1;
}

/* Chat Window */
#sophie-window {
    position: absolute;
    top: 65px;
    right: 0;
    width: 380px;
    max-width: 95vw;
    background: #ffffff;
    border-radius: 20px;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.3);
    z-index: 99999;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    border: 1px solid rgba(0, 0, 0, 0.08);
    animation: slideDown 0.4s cubic-bezier(0.4, 0, 0.2, 1);
}

@keyframes slideDown {
    from {
        opacity: 0;
        transform: translateY(-20px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

@keyframes slideDown {
    from {
        opacity: 0;
        transform: translateY(-20px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.sophie-hidden {
    display: none !important;
}

/* Header */
.sophie-header {
    background: linear-gradient(135deg, #000080 0%, #0000b3 100%);
    color: white;
    padding: 16px;
    display: flex;
    align-items: center;
    gap: 12px;
    border-bottom: 3px solid #D20103;
    position: relative;
}

.sophie-header::after {
    content: '';
    position: absolute;
    bottom: -3px;
    left: 0;
    width: 100%;
    height: 3px;
    background: linear-gradient(90deg, #D20103 0%, #ff4444 50%, #D20103 100%);
    background-size: 200% 100%;
    animation: shimmer 3s linear infinite;
}

@keyframes shimmer {
    0% { background-position: -200% 0; }
    100% { background-position: 200% 0; }
}

/* Avatar */
.sophie-avatar-frame {
    position: relative;
    width: 50px;
    height: 50px;
    flex-shrink: 0;
}

.sophie-face {
    width: 100%;
    height: 100%;
    border-radius: 50%;
    object-fit: cover;
    border: 3px solid rgba(255, 255, 255, 0.3);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.2);
}

.sophie-avatar-initial {
    width: 100%;
    height: 100%;
    background: linear-gradient(135deg, #D20103 0%, #ff4444 100%);
    color: #fff;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: bold;
    font-size: 20px;
    border: 3px solid rgba(255, 255, 255, 0.3);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.2);
}

.sophie-online-dot {
    position: absolute;
    bottom: 2px;
    right: 2px;
    width: 12px;
    height: 12px;
    background: #22c55e;
    border-radius: 50%;
    border: 2px solid #000080;
    animation: pulse 2s infinite;
}

@keyframes pulse {
    0%, 100% { box-shadow: 0 0 0 0 rgba(34, 197, 94, 0.7); }
    50% { box-shadow: 0 0 0 6px rgba(34, 197, 94, 0); }
}

/* Info */
.sophie-info {
    flex-grow: 1;
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.sophie-info strong {
    font-size: 17px;
    font-weight: 700;
    letter-spacing: -0.3px;
}

.sophie-subtitle {
    font-size: 12px;
    opacity: 0.85;
    font-weight: 500;
}

#sophie-close {
    background: rgba(255, 255, 255, 0.1);
    border: none;
    color: white;
    font-size: 28px;
    cursor: pointer;
    padding: 0;
    line-height: 1;
    width: 32px;
    height: 32px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s;
    -webkit-tap-highlight-color: transparent;
    touch-action: manipulation;
    user-select: none;
    -webkit-user-select: none;
}

#sophie-close:hover {
    background: rgba(255, 255, 255, 0.2);
    transform: rotate(90deg);
}

/* Body */
#sophie-body {
    height: 400px;
    padding: 20px;
    overflow-y: auto;
    background: linear-gradient(to bottom, #f8fafc 0%, #ffffff 100%);
    scroll-behavior: smooth;
}

#sophie-body::-webkit-scrollbar {
    width: 6px;
}

#sophie-body::-webkit-scrollbar-track {
    background: #f1f5f9;
    border-radius: 10px;
}

#sophie-body::-webkit-scrollbar-thumb {
    background: #cbd5e1;
    border-radius: 10px;
}

#sophie-body::-webkit-scrollbar-thumb:hover {
    background: #94a3b8;
}

/* Messages */
.msg-sophie {
    background: #ffffff;
    border-left: 4px solid #D20103;
    padding: 16px;
    border-radius: 0 16px 16px 16px;
    margin-bottom: 16px;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.08);
    animation: messageSlide 0.3s ease-out;
    position: relative;
}

@keyframes messageSlide {
    from {
        opacity: 0;
        transform: translateX(-20px);
    }
    to {
        opacity: 1;
        transform: translateX(0);
    }
}

.msg-content {
    font-size: 14px;
    color: #334155;
    line-height: 1.6;
}

.msg-content strong {
    color: #000080;
    font-weight: 700;
}

.sophie-read-more {
    display: inline-block;
    margin-top: 8px;
    font-size: 13px;
    color: #D20103;
    text-decoration: none;
    font-weight: 600;
    transition: all 0.2s;
    border-bottom: 2px solid transparent;
}

.sophie-read-more:hover {
    color: #000080;
    border-bottom-color: #000080;
}

/* Typing Indicator */
#sophie-typing {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 12px 16px;
    background: rgba(0, 0, 128, 0.05);
    border-radius: 20px;
    width: fit-content;
    margin-bottom: 16px;
}

.typing-dot {
    width: 8px;
    height: 8px;
    background: #000080;
    border-radius: 50%;
    animation: typingBounce 1.4s infinite;
}

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

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

@keyframes typingBounce {
    0%, 60%, 100% { transform: translateY(0); }
    30% { transform: translateY(-10px); }
}

.typing-text {
    font-size: 12px;
    color: #64748b;
    font-style: italic;
    margin-left: 4px;
}

/* Footer */
#sophie-footer {
    padding: 16px;
    background: #ffffff;
    border-top: 1px solid #f1f5f9;
}

#sophie-options {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.sophie-btn {
    padding: 12px 20px;
    border-radius: 12px;
    cursor: pointer;
    font-weight: 600;
    font-size: 14px;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    border: 2px solid transparent;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    -webkit-tap-highlight-color: transparent;
    touch-action: manipulation;
    user-select: none;
    -webkit-user-select: none;
    min-height: 44px;
}

.sophie-btn-primary {
    background: linear-gradient(135deg, #000080 0%, #0000b3 100%);
    color: #fff;
    border-color: #000080;
}

.sophie-btn-primary:hover {
    background: linear-gradient(135deg, #D20103 0%, #ff0000 100%);
    border-color: #D20103;
    transform: translateY(-2px);
    box-shadow: 0 8px 16px rgba(210, 1, 3, 0.3);
}

.sophie-btn-secondary {
    background: #ffffff;
    color: #64748b;
    border-color: #e2e8f0;
}

.sophie-btn-secondary:hover {
    background: #f8fafc;
    color: #334155;
    border-color: #cbd5e1;
}

/* Responsive */
@media (max-width: 768px) {
    #sophie-chat-container {
        position: relative;
        display: inline-block;
    }
    
    #sophie-chat-trigger {
        padding: 14px 20px;
        font-size: 15px;
        box-shadow: 0 8px 24px rgba(136, 0, 0, 0.5);
    }
    
    /* Backdrop for tablet */
    #sophie-window:not(.sophie-hidden)::before {
        content: '';
        position: fixed;
        top: 0;
        left: 0;
        right: 0;
        bottom: 0;
        background: rgba(0, 0, 0, 0.6);
        z-index: 99998;
        animation: fadeIn 0.3s ease;
    }
    
    @keyframes fadeIn {
        from { opacity: 0; }
        to { opacity: 1; }
    }
    
    #sophie-window {
        width: calc(100vw - 40px);
        max-width: 450px;
        position: fixed;
        top: 50%;
        left: 50%;
        transform: translate(-50%, -50%);
        bottom: auto;
        right: auto;
        border-radius: 20px;
        max-height: 80vh;
        z-index: 99999;
        animation: popupCenter 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    }
    
    @keyframes popupCenter {
        from {
            transform: translate(-50%, -50%) scale(0.9);
            opacity: 0;
        }
        to {
            transform: translate(-50%, -50%) scale(1);
            opacity: 1;
        }
    }
    
    #sophie-body {
        height: 50vh;
        max-height: 450px;
    }
}

@media (max-width: 480px) {
    #sophie-chat-container {
        position: relative;
        display: block;
        width: 100%;
    }
    
    #sophie-chat-trigger {
        width: 100%;
        justify-content: center;
        padding: 14px 24px;
    }
    
    /* Backdrop overlay */
    #sophie-window:not(.sophie-hidden)::before {
        content: '';
        position: fixed;
        top: 0;
        left: 0;
        right: 0;
        bottom: 0;
        background: rgba(0, 0, 0, 0.7);
        z-index: 99998;
        animation: fadeIn 0.3s ease;
    }
    
    #sophie-window {
        width: calc(100% - 30px);
        max-width: 500px;
        border-radius: 20px;
        position: fixed;
        top: 50%;
        left: 50%;
        transform: translate(-50%, -50%);
        bottom: auto;
        right: auto;
        max-height: 85vh;
        z-index: 99999;
        animation: popupCenter 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    }
    
    @keyframes popupCenter {
        from {
            transform: translate(-50%, -50%) scale(0.9);
            opacity: 0;
        }
        to {
            transform: translate(-50%, -50%) scale(1);
            opacity: 1;
        }
    }
    
    #sophie-body {
        height: 55vh;
        max-height: 450px;
    }
    
    .sophie-header {
        padding: 14px;
    }
    
    .sophie-avatar-frame {
        width: 45px;
        height: 45px;
    }
    
    .msg-sophie {
        padding: 14px;
        font-size: 13px;
    }
    
    .sophie-btn {
        padding: 14px 18px;
        font-size: 13px;
    }
}