/* =========================================================
   Mission Olympics — Real-Time Live Support Chat Widget CSS
   ========================================================= */

:root {
    --mo-chat-primary: #1F4788;
    --mo-chat-primary-dark: #122b56;
    --mo-chat-accent: #DC143C;
    --mo-chat-gold: #FFD700;
    --mo-chat-bg: #f8fafc;
    --mo-chat-text: #1e293b;
    --mo-chat-text-muted: #64748b;
    --mo-chat-border: #e2e8f0;
    --mo-chat-radius: 16px;
    --mo-chat-shadow: 0 12px 40px rgba(0, 0, 0, 0.18);
}

/* Floating Chat Toggle Button */
.mo-chat-toggle-btn {
    position: fixed;
    bottom: 24px;
    right: 24px;
    width: 62px;
    height: 62px;
    border-radius: 50%;
    background: linear-gradient(135deg, #1F4788 0%, #0D3B66 100%);
    color: #ffffff;
    border: none;
    box-shadow: 0 8px 24px rgba(31, 71, 136, 0.45);
    cursor: pointer;
    z-index: 999990;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 26px;
    transition: all 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275);
    outline: none;
}

.mo-chat-toggle-btn:hover {
    transform: scale(1.08) translateY(-3px);
    box-shadow: 0 12px 30px rgba(31, 71, 136, 0.6);
}

.mo-chat-toggle-btn .mo-chat-icon-open,
.mo-chat-toggle-btn .mo-chat-icon-close {
    transition: all 0.3s ease;
}

.mo-chat-toggle-btn.active .mo-chat-icon-open {
    display: none;
}

.mo-chat-toggle-btn:not(.active) .mo-chat-icon-close {
    display: none;
}

/* Pulse Beacon */
.mo-chat-pulse {
    position: absolute;
    top: 2px;
    right: 2px;
    width: 14px;
    height: 14px;
    background-color: #22c55e;
    border-radius: 50%;
    border: 2.5px solid #ffffff;
}

.mo-chat-pulse::after {
    content: '';
    position: absolute;
    top: -2.5px;
    left: -2.5px;
    width: 14px;
    height: 14px;
    border-radius: 50%;
    border: 2px solid #22c55e;
    animation: mo-pulse-animation 2s infinite;
}

@keyframes mo-pulse-animation {
    0% { transform: scale(1); opacity: 1; }
    100% { transform: scale(2.4); opacity: 0; }
}

/* Unread Badge */
.mo-chat-badge {
    position: absolute;
    top: -4px;
    left: -4px;
    background: #DC143C;
    color: white;
    font-size: 11px;
    font-weight: 700;
    height: 22px;
    min-width: 22px;
    padding: 0 6px;
    border-radius: 11px;
    display: flex;
    align-items: center;
    justify-content: center;
    border: 2px solid #ffffff;
    box-shadow: 0 2px 6px rgba(0,0,0,0.25);
    animation: mo-bounce 0.5s ease;
}

@keyframes mo-bounce {
    0%, 100% { transform: scale(1); }
    50% { transform: scale(1.25); }
}

/* Floating Tooltip */
.mo-chat-tooltip {
    position: fixed;
    bottom: 96px;
    right: 24px;
    background: #ffffff;
    color: #1e293b;
    padding: 10px 16px;
    border-radius: 12px;
    font-size: 13px;
    font-weight: 600;
    box-shadow: 0 8px 24px rgba(0,0,0,0.12);
    border: 1px solid #e2e8f0;
    z-index: 999989;
    display: flex;
    align-items: center;
    gap: 8px;
    animation: mo-fade-in 0.4s ease;
    cursor: pointer;
    max-width: 250px;
    font-family: 'Poppins', sans-serif;
}

.mo-chat-tooltip::after {
    content: '';
    position: absolute;
    bottom: -8px;
    right: 24px;
    border-width: 8px 8px 0;
    border-style: solid;
    border-color: #ffffff transparent;
    display: block;
    width: 0;
}

/* Main Chat Container Box */
.mo-chat-box {
    position: fixed;
    bottom: 98px;
    right: 24px;
    width: 380px;
    height: 580px;
    max-height: calc(100vh - 120px);
    background: #ffffff;
    border-radius: var(--mo-chat-radius);
    box-shadow: var(--mo-chat-shadow);
    display: flex;
    flex-direction: column;
    overflow: hidden;
    z-index: 999990;
    opacity: 0;
    pointer-events: none;
    transform: translateY(20px) scale(0.95);
    transition: all 0.3s cubic-bezier(0.16, 1, 0.3, 1);
    font-family: 'Poppins', sans-serif;
    border: 1px solid rgba(226, 232, 240, 0.8);
}

.mo-chat-box.open {
    opacity: 1;
    pointer-events: auto;
    transform: translateY(0) scale(1);
}

/* Chat Header */
.mo-chat-header {
    background: linear-gradient(135deg, #1F4788 0%, #0D3B66 100%);
    color: #ffffff;
    padding: 16px 20px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    box-shadow: 0 2px 10px rgba(0,0,0,0.1);
}

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

.mo-chat-avatar {
    width: 42px;
    height: 42px;
    border-radius: 50%;
    background: #ffffff;
    padding: 3px;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 2px 8px rgba(0,0,0,0.2);
}

.mo-chat-avatar img {
    width: 100%;
    height: 100%;
    object-fit: contain;
    border-radius: 50%;
}

.mo-chat-title h4 {
    margin: 0;
    font-size: 15px;
    font-weight: 700;
    color: #ffffff;
    letter-spacing: 0.3px;
}

.mo-chat-status-text {
    font-size: 11px;
    color: #a7f3d0;
    display: flex;
    align-items: center;
    gap: 5px;
    margin-top: 2px;
}

.mo-chat-status-dot {
    width: 7px;
    height: 7px;
    border-radius: 50%;
    background: #22c55e;
}

.mo-chat-header-actions {
    display: flex;
    gap: 8px;
}

.mo-chat-btn-icon {
    background: rgba(255, 255, 255, 0.15);
    border: none;
    color: #ffffff;
    width: 32px;
    height: 32px;
    border-radius: 8px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 14px;
    transition: background 0.2s;
}

.mo-chat-btn-icon:hover {
    background: rgba(255, 255, 255, 0.3);
}

/* Visitor Details Bar (Collapsible/Optional) */
.mo-chat-visitor-bar {
    background: #f1f5f9;
    padding: 8px 16px;
    font-size: 12px;
    color: #475569;
    display: flex;
    align-items: center;
    justify-content: space-between;
    border-bottom: 1px solid #e2e8f0;
}

.mo-chat-visitor-bar span {
    font-weight: 600;
}

.mo-chat-visitor-bar a {
    color: #1F4788;
    text-decoration: none;
    font-weight: 600;
    cursor: pointer;
}

/* Chat Messages Stream */
.mo-chat-messages {
    flex: 1;
    padding: 16px;
    overflow-y: auto;
    background: #f8fafc;
    display: flex;
    flex-direction: column;
    gap: 12px;
}

/* Date Separator */
.mo-chat-date-sep {
    text-align: center;
    font-size: 11px;
    color: #94a3b8;
    margin: 6px 0;
    position: relative;
}

.mo-chat-date-sep span {
    background: #e2e8f0;
    padding: 3px 10px;
    border-radius: 10px;
}

/* Message Bubble Styles */
.mo-message-wrapper {
    display: flex;
    flex-direction: column;
    max-width: 82%;
    animation: mo-fade-in 0.25s ease-out;
}

.mo-message-wrapper.visitor {
    align-self: flex-end;
}

.mo-message-wrapper.admin,
.mo-message-wrapper.system {
    align-self: flex-start;
}

.mo-message-sender {
    font-size: 11px;
    font-weight: 600;
    margin-bottom: 3px;
    color: #64748b;
    padding: 0 4px;
}

.mo-message-wrapper.visitor .mo-message-sender {
    text-align: right;
    color: #1F4788;
}

.mo-message-bubble {
    padding: 10px 14px;
    border-radius: 14px;
    font-size: 13.5px;
    line-height: 1.45;
    word-break: break-word;
    position: relative;
}

.mo-message-wrapper.visitor .mo-message-bubble {
    background: #1F4788;
    color: #ffffff;
    border-bottom-right-radius: 4px;
    box-shadow: 0 3px 10px rgba(31, 71, 136, 0.2);
}

.mo-message-wrapper.admin .mo-message-bubble {
    background: #ffffff;
    color: #1e293b;
    border: 1px solid #e2e8f0;
    border-bottom-left-radius: 4px;
    box-shadow: 0 2px 6px rgba(0,0,0,0.04);
}

.mo-message-wrapper.system .mo-message-bubble {
    background: #f0fdf4;
    color: #166534;
    border: 1px solid #bbf7d0;
    border-radius: 12px;
    font-size: 12.5px;
}

.mo-message-meta {
    font-size: 10px;
    margin-top: 3px;
    color: #94a3b8;
    padding: 0 4px;
    display: flex;
    align-items: center;
    gap: 4px;
}

.mo-message-wrapper.visitor .mo-message-meta {
    justify-content: flex-end;
}

/* Typing Indicator Animation */
.mo-chat-typing-box {
    display: none;
    align-self: flex-start;
    background: #ffffff;
    border: 1px solid #e2e8f0;
    padding: 8px 14px;
    border-radius: 14px;
    margin-bottom: 8px;
    box-shadow: 0 2px 6px rgba(0,0,0,0.04);
}

.mo-chat-typing-box.active {
    display: flex;
    align-items: center;
    gap: 5px;
}

.mo-typing-dot {
    width: 6px;
    height: 6px;
    background: #94a3b8;
    border-radius: 50%;
    animation: mo-typing 1.4s infinite ease-in-out both;
}

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

@keyframes mo-typing {
    0%, 80%, 100% { transform: scale(0.6); opacity: 0.5; }
    40% { transform: scale(1); opacity: 1; }
}

/* Quick Question Chips */
.mo-chat-chips-container {
    padding: 8px 12px;
    background: #f8fafc;
    border-top: 1px solid #e2e8f0;
    display: flex;
    gap: 6px;
    overflow-x: auto;
    scrollbar-width: none;
}

.mo-chat-chips-container::-webkit-scrollbar {
    display: none;
}

.mo-chat-chip {
    white-space: nowrap;
    background: #ffffff;
    border: 1px solid #cbd5e1;
    color: #1F4788;
    padding: 4px 10px;
    border-radius: 16px;
    font-size: 11.5px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s;
}

.mo-chat-chip:hover {
    background: #1F4788;
    color: #ffffff;
    border-color: #1F4788;
}

/* Chat Input Bar */
.mo-chat-input-area {
    background: #ffffff;
    padding: 12px 16px;
    border-top: 1px solid #e2e8f0;
    display: flex;
    align-items: center;
    gap: 10px;
    position: relative;
}

.mo-chat-input-area input {
    flex: 1;
    min-width: 0;
    border: 1.5px solid #cbd5e1;
    padding: 11px 16px;
    border-radius: 24px;
    font-size: 14.5px;
    outline: none;
    transition: all 0.2s;
    font-family: inherit;
    background: #f8fafc;
    color: #1e293b;
    box-sizing: border-box;
}

.mo-chat-input-area input:focus {
    background: #ffffff;
    border-color: #1F4788;
    box-shadow: 0 0 0 3px rgba(31, 71, 136, 0.12);
}

.mo-chat-attach-btn {
    width: 38px;
    height: 38px;
    min-width: 38px;
    min-height: 38px;
    border-radius: 50%;
    background: #f1f5f9;
    color: #64748b;
    border: 1px solid #cbd5e1;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 15px;
    transition: all 0.2s;
    outline: none;
    flex-shrink: 0;
}

.mo-chat-attach-btn:hover {
    background: #e2e8f0;
    color: #1F4788;
    transform: scale(1.05);
}

.mo-chat-send-btn {
    width: 44px;
    height: 44px;
    min-width: 44px;
    min-height: 44px;
    border-radius: 50%;
    background: linear-gradient(135deg, #1F4788 0%, #0D3B66 100%);
    color: #ffffff;
    border: none;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 16px;
    transition: all 0.2s;
    outline: none;
    flex-shrink: 0;
    box-shadow: 0 3px 10px rgba(31, 71, 136, 0.35);
}

.mo-chat-send-btn:hover {
    background: linear-gradient(135deg, #2557a7 0%, #104c82 100%);
    transform: scale(1.06);
    box-shadow: 0 5px 14px rgba(31, 71, 136, 0.45);
}

.mo-chat-send-btn:active {
    transform: scale(0.94);
}

.mo-chat-send-btn:disabled {
    background: #cbd5e1 !important;
    box-shadow: none !important;
    cursor: not-allowed;
    transform: none !important;
    opacity: 0.6;
}

/* Chat Message Attachment Styles */
.mo-message-attachment {
    margin: 4px 0 6px 0;
    max-width: 240px;
}

.mo-attachment-img-wrap {
    display: block;
    position: relative;
    border-radius: 10px;
    overflow: hidden;
    border: 1px solid rgba(0, 0, 0, 0.12);
    box-shadow: 0 3px 10px rgba(0, 0, 0, 0.08);
    cursor: pointer;
    text-decoration: none;
}

.mo-attachment-img {
    width: 100%;
    max-height: 180px;
    object-fit: cover;
    display: block;
    transition: transform 0.2s ease;
}

.mo-attachment-img-wrap:hover .mo-attachment-img {
    transform: scale(1.03);
}

.mo-attachment-overlay {
    position: absolute;
    bottom: 0;
    left: 0;
    right: 0;
    background: rgba(15, 23, 42, 0.7);
    color: #ffffff;
    font-size: 11px;
    font-weight: 600;
    padding: 3px 6px;
    text-align: center;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 4px;
}

.mo-attachment-file-wrap {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    background: #f1f5f9;
    padding: 6px 12px;
    border-radius: 8px;
    font-size: 12px;
    font-weight: 600;
    color: #1e293b;
    text-decoration: none;
    border: 1px solid #cbd5e1;
}

/* Image Lightbox Modal */
.mo-img-lightbox-modal {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(15, 23, 42, 0.85);
    backdrop-filter: blur(4px);
    z-index: 9999999;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 20px;
}

.mo-img-lightbox-content {
    max-width: 90vw;
    max-height: 90vh;
    border-radius: 12px;
    overflow: hidden;
    position: relative;
    box-shadow: 0 20px 40px rgba(0, 0, 0, 0.4);
}

.mo-img-lightbox-content img {
    max-width: 100%;
    max-height: 85vh;
    display: block;
    object-fit: contain;
}

.mo-img-lightbox-close {
    position: absolute;
    top: 10px;
    right: 10px;
    width: 36px;
    height: 36px;
    border-radius: 50%;
    background: rgba(0, 0, 0, 0.6);
    color: white;
    border: none;
    cursor: pointer;
    font-size: 18px;
    display: flex;
    align-items: center;
    justify-content: center;
}

/* Visitor Info Edit Modal inside Chat Widget */
.mo-chat-modal {
    position: absolute;
    inset: 0;
    background: rgba(15, 23, 42, 0.7);
    backdrop-filter: blur(4px);
    z-index: 100;
    display: none;
    align-items: center;
    justify-content: center;
    padding: 20px;
}

.mo-chat-modal.active {
    display: flex;
}

.mo-chat-modal-content {
    background: #ffffff;
    width: 100%;
    max-width: 320px;
    border-radius: 14px;
    padding: 20px;
    box-shadow: 0 10px 30px rgba(0,0,0,0.25);
}

.mo-chat-modal-content h4 {
    margin: 0 0 12px;
    font-size: 15px;
    color: #1F4788;
    font-weight: 700;
}

.mo-chat-modal-content .form-group {
    margin-bottom: 12px;
}

.mo-chat-modal-content label {
    display: block;
    font-size: 11.5px;
    font-weight: 600;
    color: #475569;
    margin-bottom: 4px;
}

.mo-chat-modal-content input {
    width: 100%;
    padding: 10px 12px;
    border: 1px solid #cbd5e1;
    border-radius: 8px;
    font-size: 14px;
    box-sizing: border-box;
}

.mo-chat-modal-actions {
    display: flex;
    justify-content: flex-end;
    gap: 8px;
    margin-top: 16px;
}

/* Pre-Chat Form View */
.mo-prechat-container {
    flex: 1;
    display: flex;
    flex-direction: column;
    justify-content: center;
    padding: 24px 20px;
    background: #f8fafc;
    overflow-y: auto;
}

.mo-prechat-card {
    background: #ffffff;
    border-radius: 16px;
    padding: 24px 20px;
    box-shadow: 0 4px 20px rgba(0,0,0,0.06);
    border: 1px solid #e2e8f0;
}

.mo-prechat-header {
    text-align: center;
    margin-bottom: 20px;
}

.mo-prechat-icon {
    width: 52px;
    height: 52px;
    border-radius: 50%;
    background: linear-gradient(135deg, #1F4788, #3b82f6);
    color: #ffffff;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-size: 22px;
    margin-bottom: 10px;
    box-shadow: 0 4px 12px rgba(31, 71, 136, 0.25);
}

.mo-prechat-header h3 {
    margin: 0 0 6px;
    font-size: 17px;
    font-weight: 700;
    color: #1e293b;
}

.mo-prechat-header p {
    margin: 0;
    font-size: 13px;
    color: #64748b;
    line-height: 1.4;
}

.mo-prechat-group {
    margin-bottom: 14px;
}

.mo-prechat-group label {
    display: block;
    font-size: 12px;
    font-weight: 700;
    color: #334155;
    margin-bottom: 6px;
}

.mo-prechat-group label span {
    color: #DC143C;
}

.mo-prechat-group input {
    width: 100%;
    padding: 11px 14px;
    border: 1.5px solid #cbd5e1;
    border-radius: 10px;
    font-size: 14.5px;
    outline: none;
    transition: all 0.2s;
    box-sizing: border-box;
    font-family: inherit;
    background: #ffffff;
}

.mo-prechat-group input:focus {
    border-color: #1F4788;
    box-shadow: 0 0 0 3px rgba(31, 71, 136, 0.12);
}

.mo-prechat-btn {
    width: 100%;
    padding: 12px;
    background: linear-gradient(135deg, #1F4788 0%, #0D3B66 100%);
    color: #ffffff;
    border: none;
    border-radius: 10px;
    font-size: 14.5px;
    font-weight: 700;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    box-shadow: 0 4px 14px rgba(31, 71, 136, 0.3);
    transition: transform 0.1s, box-shadow 0.2s;
    margin-top: 18px;
}

.mo-prechat-btn:hover {
    box-shadow: 0 6px 18px rgba(31, 71, 136, 0.45);
}

.mo-prechat-btn:active {
    transform: scale(0.98);
}

/* Verified User Indicator Banner */
.mo-chat-verified-bar {
    background: #f0fdf4;
    border-bottom: 1px solid #bbf7d0;
    padding: 6px 14px;
    font-size: 11.5px;
    font-weight: 600;
    color: #166534;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 6px;
}

.mo-chat-verified-bar .badge-role {
    background: #15803d;
    color: white;
    padding: 1px 6px;
    border-radius: 10px;
    font-size: 10.5px;
    font-weight: 700;
}

/* Animations */
@keyframes mo-fade-in {
    from { opacity: 0; transform: translateY(6px); }
    to { opacity: 1; transform: translateY(0); }
}

/* =========================================================
   Mobile Responsiveness (Phones & Small Tablets)
   ========================================================= */
@media (max-width: 640px) {
    .mo-chat-box {
        position: fixed !important;
        top: 0 !important;
        bottom: 0 !important;
        left: 0 !important;
        right: 0 !important;
        width: 100% !important;
        height: 100% !important;
        height: 100dvh !important;
        max-height: 100dvh !important;
        border-radius: 0 !important;
        border: none !important;
        box-shadow: none !important;
        z-index: 9999999 !important;
        display: flex !important;
        flex-direction: column !important;
        transform: translateY(100%);
        transition: transform 0.3s cubic-bezier(0.16, 1, 0.3, 1), opacity 0.2s ease;
    }

    .mo-chat-box.open {
        transform: translateY(0) !important;
    }

    .mo-chat-header {
        padding: max(14px, env(safe-area-inset-top)) 16px 14px 16px !important;
        border-radius: 0 !important;
    }

    .mo-chat-header-actions .mo-chat-btn-icon {
        width: 36px;
        height: 36px;
        font-size: 16px;
    }

    .mo-chat-messages {
        padding: 12px 14px;
        -webkit-overflow-scrolling: touch;
        overscroll-behavior: contain;
    }

    .mo-message-wrapper {
        max-width: 88%;
    }

    .mo-message-bubble {
        font-size: 14px;
        padding: 10px 14px;
    }

    .mo-chat-chips-container {
        padding: 8px 12px;
        gap: 6px;
    }

    .mo-chat-chip {
        padding: 6px 12px;
        font-size: 12px;
    }

    .mo-chat-input-area {
        padding: 10px 14px !important;
        padding-bottom: max(12px, env(safe-area-inset-bottom)) !important;
        background: #ffffff !important;
        border-top: 1px solid #e2e8f0 !important;
        gap: 8px !important;
    }

    .mo-chat-input-area input {
        font-size: 16px !important; /* Prevents auto-zoom on iOS */
        padding: 11px 16px !important;
        height: 44px !important;
        border-radius: 22px !important;
    }

    .mo-chat-send-btn {
        width: 44px !important;
        height: 44px !important;
        min-width: 44px !important;
        min-height: 44px !important;
        font-size: 17px !important;
    }

    .mo-chat-toggle-btn {
        bottom: 18px !important;
        right: 18px !important;
        width: 58px !important;
        height: 58px !important;
        font-size: 24px !important;
    }

    .mo-chat-tooltip {
        display: none !important;
    }
}
