/* Movia AI Chat Widget — dark theme matching Movia Lab branding */

#movia-chat-bubble {
    position: fixed;
    bottom: 24px;
    right: 24px;
    width: 60px;
    height: 60px;
    border-radius: 50%;
    background: linear-gradient(135deg, #7c3aed, #4f46e5);
    color: #fff;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    box-shadow: 0 4px 20px rgba(124, 58, 237, 0.4);
    z-index: 99999;
    transition: transform 0.2s ease, box-shadow 0.2s ease;
}

#movia-chat-bubble:hover {
    transform: scale(1.08);
    box-shadow: 0 6px 28px rgba(124, 58, 237, 0.55);
}

#movia-chat-window {
    position: fixed;
    bottom: 96px;
    right: 24px;
    width: 380px;
    max-width: calc(100vw - 48px);
    height: 520px;
    max-height: calc(100vh - 140px);
    background: #111113;
    border: 1px solid #2a2a2e;
    border-radius: 16px;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    z-index: 99999;
    box-shadow: 0 12px 48px rgba(0, 0, 0, 0.5);
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
}

#movia-chat-header {
    background: linear-gradient(135deg, #1a1a1e, #232328);
    padding: 14px 16px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    border-bottom: 1px solid #2a2a2e;
    color: #fff;
}

#movia-chat-header strong {
    display: block;
    font-size: 15px;
}

#movia-chat-status {
    font-size: 12px;
    color: #4ade80;
}

#movia-chat-close {
    background: none;
    border: none;
    color: #888;
    font-size: 24px;
    cursor: pointer;
    line-height: 1;
    padding: 0 4px;
}

#movia-chat-close:hover {
    color: #fff;
}

#movia-chat-actions {
    display: flex;
    align-items: center;
    gap: 4px;
}

#movia-chat-history-btn,
#movia-chat-new-btn {
    background: none !important;
    border: none !important;
    color: #888 !important;
    cursor: pointer;
    padding: 6px !important;
    margin: 0 !important;
    min-width: 0 !important;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 6px;
    line-height: 1;
}

#movia-chat-history-btn:hover,
#movia-chat-new-btn:hover {
    color: #fff !important;
    background: rgba(255,255,255,0.08) !important;
}

#movia-chat-history-list {
    flex: 1;
    overflow-y: auto;
    padding: 12px 16px;
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.movia-hist-title-bar {
    font-size: 13px;
    font-weight: 600;
    color: #aaa;
    padding: 4px 2px;
}

.movia-hist-empty {
    font-size: 13px;
    color: #777;
    text-align: center;
    padding: 24px 0;
}

.movia-hist-item {
    background: #232328 !important;
    border: 1px solid #2e2e33 !important;
    border-radius: 10px;
    padding: 10px 12px !important;
    margin: 0 !important;
    cursor: pointer;
    text-align: start;
    display: flex;
    flex-direction: column;
    gap: 4px;
    width: 100%;
}

.movia-hist-item:hover {
    border-color: #7c3aed !important;
}

.movia-hist-item-title {
    font-size: 13px;
    color: #eee;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.movia-hist-item-date {
    font-size: 11px;
    color: #777;
}

.movia-msg-img {
    max-width: 220px;
    width: 100%;
    border-radius: 10px;
    display: block;
    margin-bottom: 6px;
}

#movia-chat-attach {
    width: 42px !important;
    height: 42px !important;
    min-width: 42px !important;
    flex-shrink: 0 !important;
    border-radius: 50% !important;
    background: transparent !important;
    border: 1px solid #3a3a40 !important;
    color: #aaa !important;
    cursor: pointer;
    display: flex !important;
    align-items: center;
    justify-content: center;
    padding: 0 !important;
    margin: 0 !important;
    line-height: 1;
}

#movia-chat-attach:hover {
    color: #fff !important;
    border-color: #7c3aed !important;
}

#movia-chat-attach-preview {
    align-items: center;
    gap: 8px;
    padding: 8px 16px;
    border-top: 1px solid #2a2a2e;
    background: #161618;
}

#movia-chat-attach-preview img {
    width: 52px;
    height: 52px;
    object-fit: cover;
    border-radius: 8px;
    border: 1px solid #3a3a40;
}

#movia-chat-attach-remove {
    background: none !important;
    border: none !important;
    color: #888 !important;
    font-size: 22px;
    cursor: pointer;
    padding: 0 4px !important;
    margin: 0 !important;
    min-width: 0 !important;
    line-height: 1;
}

#movia-chat-attach-remove:hover {
    color: #fff !important;
}

#movia-chat-messages {
    flex: 1;
    overflow-y: auto;
    padding: 16px;
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.movia-msg {
    max-width: 85%;
    padding: 10px 14px;
    border-radius: 14px;
    font-size: 14px;
    line-height: 1.5;
    word-wrap: break-word;
}

.movia-msg.bot {
    background: #1e1e22;
    color: #e8e8e8;
    align-self: flex-start;
    border-bottom-left-radius: 4px;
}

.movia-msg.bot strong {
    color: #fff;
    font-weight: 700;
}

.movia-msg.bot em {
    color: #c9b8ff;
}

.movia-msg.bot a {
    color: #a78bfa;
    text-decoration: underline;
    word-break: break-all;
}

.movia-msg.bot a:hover {
    color: #c4b5fd;
}

.movia-msg.bot .movia-h3 {
    display: block;
    font-size: 15px;
    margin: 10px 0 6px;
    color: #fff;
}

.movia-msg.bot p .movia-h3:first-child,
.movia-msg.bot p:first-child .movia-h3 {
    margin-top: 0;
}

.movia-msg.bot .movia-hr {
    border: none;
    border-top: 1px solid #3a3a40;
    margin: 12px 0;
}

.movia-msg.bot p {
    margin: 0 0 12px;
}

.movia-msg.bot p:last-child {
    margin-bottom: 0;
}

.movia-msg.user {
    background: linear-gradient(135deg, #7c3aed, #4f46e5);
    color: #fff;
    align-self: flex-end;
    border-bottom-right-radius: 4px;
}

.movia-msg.typing {
    color: #888;
    font-style: italic;
}

#movia-chat-input-area {
    display: flex;
    gap: 8px;
    padding: 12px;
    border-top: 1px solid #2a2a2e;
    background: #161618;
}

#movia-chat-input {
    flex: 1;
    background: #1e1e22;
    border: 1px solid #2a2a2e;
    border-radius: 24px;
    padding: 10px 16px;
    color: #fff;
    font-size: 14px;
    outline: none;
}

#movia-chat-input:focus {
    border-color: #7c3aed;
}

#movia-chat-input::placeholder {
    color: #666;
}

#movia-chat-send {
    width: 42px !important;
    height: 42px !important;
    min-width: 42px !important;
    max-width: 42px !important;
    min-height: 42px !important;
    max-height: 42px !important;
    border-radius: 50% !important;
    background: linear-gradient(135deg, #7c3aed, #4f46e5) !important;
    border: none !important;
    padding: 0 !important;
    margin: 0 !important;
    color: #fff;
    cursor: pointer;
    display: flex !important;
    align-items: center;
    justify-content: center;
    flex-shrink: 0 !important;
    flex-grow: 0 !important;
}

#movia-chat-send:hover {
    opacity: 0.9;
}

#movia-chat-send:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

/* RTL support for Arabic */
#movia-chat-window[dir="rtl"] #movia-chat-messages {
    text-align: right;
}

@media (max-width: 480px) {
    #movia-chat-window {
        bottom: 88px;
        right: 12px;
        left: 12px;
        width: auto;
    }
    #movia-chat-bubble {
        bottom: 16px;
        right: 16px;
    }
}
