/* /public/assets/css/mt-public-styles.css */

:root {
    --mt-chat-z-index: 99999999999999;
    --mt-chat-font-family: inherit; 
    
    /* Default Colors */
    --mt-chat-accent: #1090cb;
    --mt-chat-bg: #fff;
    --mt-chat-main-bg: #ffffff;
    --mt-chat-header-bg: #1090cb;
    --mt-chat-header-text: #fff;
    --mt-chat-body-bg: #e9e9e9;
    --mt-chat-footer-bg: #fff;
    
    --mt-chat-user-bubble-bg: #e1f5fe;
    --mt-chat-user-text-color: #333;
    
    --mt-chat-admin-bubble-bg: #fff;
    --mt-chat-admin-text-color: #333;
    
    --mt-chat-footer-icon-color: #888;
    --mt-chat-input-border-color: #ddd;
    
    --mt-chat-msg-time-color: #999;
    --mt-chat-msg-status-color: #4FC3F7;
    --mt-chat-font-size: 14px;
    
    --mt-chat-bg-pattern: none;
    --mt-chat-bg-pattern-opacity: 0;
    
    /* Widget Specific Vars */
    --mt-widget-grad-start: #1090cb;
    --mt-widget-grad-end: #2962ff;
    
    /* Default size fallback */
    --mt-widget-size: 60px;
    
    /* AI Colors */
    --mt-ai-blue: #4361ee;
    --mt-ai-purple: #7209b7;
    --mt-ai-cyan: #4cc9f0;

    /* Positioning Defaults */
    --mt-window-left: auto;
    --mt-window-right: 0;
    --mt-window-origin: bottom right;
}

/* =========================================
   1. MAIN CONTAINER
   ========================================= */
#mt-chat-widget-container {
    position: fixed; 
    /* Bottom/Left/Right are set via inline styles from PHP */
    z-index: var(--mt-chat-z-index);
    direction: rtl; 
    font-family: var(--mt-chat-font-family); 
    box-sizing: border-box;
    display: flex;
    justify-content: center;
    align-items: center;
    transition: all 0.5s ease;
}
#mt-chat-widget-container * { box-sizing: border-box; }

/* =========================================
   2. CHAT BUBBLE CORE (The Button)
   ========================================= */
#mt-chat-bubble {
    height: var(--mt-widget-size);
    min-width: var(--mt-widget-size);
    border-radius: calc(var(--mt-widget-size) / 2);
    display: flex; 
    align-items: center;
    justify-content: center;
    cursor: pointer; 
    box-shadow: 0 4px 15px rgba(0,0,0,0.2);
    transition: all 0.5s cubic-bezier(0.2, 0.8, 0.2, 1);
    position: relative;
    z-index: 20; 
    overflow: hidden; 
    padding: 0;
    background: linear-gradient(135deg, var(--mt-widget-grad-start), var(--mt-widget-grad-end));
}

#mt-chat-bubble:hover { 
    transform: translateY(-3px); 
    box-shadow: 0 8px 25px rgba(0,0,0,0.25); 
}

#mt-chat-bubble.hidden { 
    transform: scale(0); 
    opacity: 0; 
    pointer-events: none; 
}

/* =========================================
   3. AI MODE STYLES
   ========================================= */
/* Button Background for AI Mode */
.mt-ai-mode #mt-chat-bubble {
    background: linear-gradient(135deg, var(--mt-ai-blue), var(--mt-ai-purple));
    border: 1px solid rgba(255,255,255,0.1);
}

/* AI Halo Layers */
.ai-halo {
    position: absolute;
    inset: -3px; 
    border-radius: calc((var(--mt-widget-size) / 2) + 4px);
    z-index: 10;
    pointer-events: none;
    transition: all 0.5s ease;
    filter: blur(5px);
    opacity: 0.8;
}

.halo-1 {
    background: conic-gradient(
        from 0deg, 
        var(--mt-ai-blue), 
        var(--mt-ai-purple), 
        var(--mt-ai-cyan), 
        var(--mt-ai-purple), 
        var(--mt-ai-blue)
    );
    background-size: 200% 200%;
    animation: mt-move-colors 4s linear infinite; 
}

@keyframes mt-move-colors {
    0% { background-position: 0% 50%; }
    50% { background-position: 100% 50%; }
    100% { background-position: 0% 50%; }
}

@keyframes mt-spin-halo {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

/* =========================================
   4. CONTENT (ICON & TEXT)
   ========================================= */
.mt-bubble-icon {
    width: var(--mt-widget-size);
    height: var(--mt-widget-size);
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    position: relative;
    z-index: 22;
}

.mt-bubble-icon svg, .mt-bubble-icon img { 
    fill: #fff; 
    width: calc(var(--mt-widget-size) * 0.66) !important;
    height: calc(var(--mt-widget-size) * 0.66) !important;
    object-fit: contain; 
    display: block;
    filter: drop-shadow(0 2px 3px rgba(0,0,0,0.2));
}

.mt-bubble-text {
    color: #fff;
    font-weight: 700;
    font-size: 14px;
    white-space: nowrap;
    opacity: 1;
    max-width: 200px;
    padding-left: 20px;
    margin-right: -5px;
    transition: all 0.5s ease;
    position: relative;
    z-index: 22;
    text-shadow: 0 1px 2px rgba(0,0,0,0.1);
}

/* =========================================
   5. COLLAPSED STATE
   ========================================= */
#mt-chat-widget-container.collapsed #mt-chat-bubble {
    width: var(--mt-widget-size);
    border-radius: 50%;
}

#mt-chat-widget-container.collapsed .mt-bubble-text {
    opacity: 0;
    max-width: 0;
    padding-left: 0;
    margin: 0;
}

#mt-chat-widget-container.collapsed .ai-halo {
    border-radius: 50%;
    inset: -5px;
    animation: mt-spin-halo 3s linear infinite;
}

/* =========================================
   6. TRIGGER POPUP (REVISED)
   ========================================= */
#mt-chat-trigger-popup {
    position: absolute; 
    bottom: calc(var(--mt-widget-size) + 15px);
    width: 280px;
    background: #fff; 
    border-radius: 12px; 
    box-shadow: 0 5px 25px rgba(0,0,0,0.15);
    animation: mtSlideUp 0.4s ease; 
    transform-origin: bottom right;
    border: 1px solid rgba(0,0,0,0.05); 
    z-index: 999;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    padding: 0; /* Reset padding */
}
#mt-chat-trigger-popup.hidden { display: none; }

.mt-trigger-head {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 12px 15px;
    background: #f9f9f9;
    border-bottom: 1px solid #eee;
    position: relative;
}

.mt-trigger-avatar {
    position: relative;
    width: 36px;
    height: 36px;
    flex-shrink: 0;
    display: flex;
    justify-content: center;
    align-items: center;
}

.mt-trigger-avatar img {
    width: 100%;
    height: 100%;
    border-radius: 50%;
    object-fit: cover;
    border: 2px solid #fff;
    box-shadow: 0 2px 5px rgba(0,0,0,0.1);
    background: #fff;
    position: relative;
    z-index: 2;
}

/* AI Animation for Trigger Avatar */
.mt-trigger-avatar.mt-ai-animated-avatar img {
    background: linear-gradient(135deg, var(--mt-ai-blue), var(--mt-ai-purple));
    padding: 2px;
}
.mt-trigger-avatar.mt-ai-animated-avatar::before {
    content: ''; position: absolute; inset: -2px; border-radius: 50%;
    background: conic-gradient(from 0deg, var(--mt-ai-blue), var(--mt-ai-purple), var(--mt-ai-cyan), var(--mt-ai-purple), var(--mt-ai-blue));
    filter: blur(2px); z-index: 1; animation: mt-spin-halo 3s linear infinite;
}

.mt-trigger-name {
    font-weight: 700;
    font-size: 13px;
    color: #333;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    padding-left: 20px; /* Space for close button */
}

.mt-popup-content {
    padding: 15px;
    font-size: 13px;
    color: #444;
    line-height: 1.6;
}
.mt-popup-content p { margin: 0; }

#mt-close-trigger-popup {
    position: absolute; 
    top: 10px; 
    left: 8px; 
    background: none; 
    border: none; 
    color: #aaa; 
    cursor: pointer; 
    font-size: 18px; 
    padding: 0; 
    line-height: 1;
    display: flex; 
    align-items: center; 
    justify-content: center; 
    width: 24px; 
    height: 24px;
    transition: color 0.2s;
    z-index: 10;
}
#mt-close-trigger-popup:hover { color: #d63638; }

@keyframes mtSlideUp { from { opacity: 0; transform: translateY(10px); } to { opacity: 1; transform: translateY(0); } }

/* =========================================
   7. CHAT WINDOW & INTERNALS
   ========================================= */
#mt-chat-window {
    width: 380px; height: 600px; max-height: calc(100vh - 100px);
    background-color: var(--mt-chat-main-bg); border-radius: 12px;
    box-shadow: 0 10px 30px rgba(0,0,0,0.15); display: flex; flex-direction: column;
    position: absolute; bottom: 0; 
    
    /* Dynamic Positioning via Variables */
    left: var(--mt-window-left, auto);
    right: var(--mt-window-right, 0);
    transform-origin: var(--mt-window-origin, bottom right);
    
    overflow: hidden;
    transition: opacity 0.3s, transform 0.3s cubic-bezier(0.165, 0.84, 0.44, 1);
    border: 1px solid rgba(0,0,0,0.05);
}
#mt-chat-window.hidden { opacity: 0; transform: scale(0.9) translateY(20px); pointer-events: none; }

/* Header */
#mt-chat-header {
    background-color: var(--mt-chat-header-bg); color: var(--mt-chat-header-text);
    padding: 15px; display: flex; align-items: center; gap: 12px; flex-shrink: 0;
    box-shadow: 0 1px 3px rgba(0,0,0,0.1); z-index: 10;
}

/* HEADER AVATAR */
.mt-header-avatar { position: relative; display: flex; flex-shrink: 0; width: 40px; height: 40px; justify-content: center; align-items: center; }
.mt-header-avatar img { width: 100%; height: 100%; border-radius: 50%; border: 2px solid rgba(255,255,255,0.3); object-fit: cover; background: #fff; z-index: 2; position: relative; }

.mt-header-avatar.mt-ai-animated-avatar img,
.mt-chat-avatar.ai-avatar {
    background: linear-gradient(135deg, var(--mt-ai-blue), var(--mt-ai-purple)) !important;
    padding: 4px;
    box-sizing: border-box;
}

/* Header Status Dot (Online/Offline) */
.mt-header-status {
    position: absolute; bottom: 0; right: 0; width: 11px; height: 11px; border-radius: 50%; border: 2px solid #fff; z-index: 3;
}
.mt-header-status.online { background-color: #46b450; }
.mt-header-status.offline { background-color: #d63638; }

/* AI Halo Effect */
.mt-header-avatar.mt-ai-animated-avatar::before {
    content: ''; position: absolute; inset: -3px; border-radius: 50%;
    background: conic-gradient(from 0deg, var(--mt-ai-blue), var(--mt-ai-purple), var(--mt-ai-cyan), var(--mt-ai-purple), var(--mt-ai-blue));
    filter: blur(3px); z-index: 1; animation: mt-spin-halo 3s linear infinite;
}

.mt-header-details { flex-grow: 1; display: flex; flex-direction: column; overflow: hidden; }
#mt-chat-title { font-weight: 700; font-size: 15px; line-height: 1.2; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
#mt-chat-subtitle { font-size: 11px; opacity: 0.9; margin-top: 2px; font-weight: normal; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
#mt-close-chat { 
    background: transparent; border: none; color: #fff; cursor: pointer; 
    padding: 4px; border-radius: 50%; display: flex; align-items: center; justify-content: center;
    transition: background 0.2s; flex-shrink: 0;
}
#mt-close-chat:hover { background: rgba(255,255,255,0.1); }
#mt-close-chat span { font-size: 20px; }

/* Screens */
.mt-screen { display: none; flex-direction: column; height: 100%; width: 100%; background: var(--mt-chat-main-bg); flex: 1; overflow: hidden; }
.mt-screen.active { display: flex; }

/* Offline Screen */
#mt-offline-screen.active { display: flex !important; flex-direction: column; align-items: stretch; justify-content: center; }

/* Pre-Chat Form */
#mt-pre-chat-screen { padding: 30px; background: var(--mt-chat-main-bg); align-items: stretch; overflow-y: auto; }
#mt-pre-chat-screen h3 { margin: 0 0 15px; color: var(--mt-chat-admin-text-color); font-size: 18px; text-align: center; }
#mt-pre-chat-screen p { text-align: center; color: var(--mt-chat-footer-icon-color); font-size: 13px; margin-bottom: 25px; }

/* FORM & FLOATING LABELS */
.mt-form-group { margin-bottom: 20px; text-align: right; position: relative; }
.mt-form-group.floating-label input { padding: 22px 12px 8px; }
.mt-form-group.floating-label label {
    position: absolute; top: 50%; right: 12px; transform: translateY(-50%);
    color: #999; font-size: 14px; transition: all 0.2s ease; pointer-events: none; background: transparent;
}
.mt-form-group.floating-label input:focus + label,
.mt-form-group.floating-label input:not(:placeholder-shown) + label {
    top: 8px; transform: translateY(0); font-size: 11px; color: var(--mt-chat-accent); font-weight: 600;
}
.mt-form-group input, .mt-form-group select {
    width: 100%; padding: 12px; border: 1px solid var(--mt-chat-input-border-color);
    border-radius: 8px; font-size: 14px; background: #fff; outline: none;
    transition: border-color 0.2s; height: 48px; color: #333;
}
.mt-form-group input:focus, .mt-form-group select:focus, .mt-form-group textarea:focus { 
    border-color: var(--mt-chat-accent); box-shadow: 0 0 0 1px var(--mt-chat-accent);
}
.mt-form-group textarea {
    width: 100%; padding: 12px; border: 1px solid var(--mt-chat-input-border-color);
    border-radius: 8px; font-size: 14px; background: #fff; outline: none;
    transition: border-color 0.2s; resize: vertical; min-height: 80px; color: #333;
}

/* Error Box */
.mt-error-box {
    background-color: #ffebee; color: #c62828; border: 1px solid #ef9a9a; border-radius: 8px;
    padding: 10px; margin-bottom: 20px; font-size: 12px; text-align: center; font-weight: 500;
    display: flex; align-items: center; justify-content: center; gap: 5px; animation: mtShake 0.4s ease;
}
.mt-error-box.hidden { display: none; }
@keyframes mtShake { 0%, 100% { transform: translateX(0); } 25% { transform: translateX(-5px); } 75% { transform: translateX(5px); } }

#mt-start-chat-btn {
    width: 100%; padding: 12px; background: var(--mt-chat-accent); color: #fff; 
    border: none; border-radius: 8px; cursor: pointer; font-weight: bold; margin-top: 10px;
    font-size: 15px; transition: opacity 0.2s;
}
#mt-start-chat-btn:hover { opacity: 0.9; }

/* Chat Body */
#mt-chat-body { 
    flex: 1; padding: 15px; overflow-y: auto; background-color: var(--mt-chat-body-bg); 
    position: relative; scroll-behavior: smooth;
    background-image: var(--mt-chat-bg-pattern, none); background-size: 300px;
    overflow-x: hidden;
}
#mt-chat-body::before {
    content: ''; position: absolute; top: 0; left: 0; right: 0; bottom: 0;
    background-color: rgba(255,255,255,0.3); opacity: var(--mt-chat-bg-pattern-opacity, 0);
    z-index: 0; pointer-events: none;
}
#mt-chat-messages { position: relative; z-index: 1; display: flex; flex-direction: column; gap: 10px; padding-bottom: 10px; }

/* Message Bubbles */
.mt-message-wrapper { display: flex; align-items: flex-end; gap: 8px; max-width: 85%; position: relative; }
.mt-message-wrapper.user { align-self: flex-end; flex-direction: row-reverse; }
.mt-message-wrapper.assistant { align-self: flex-start; }
.mt-chat-avatar { width: 32px; height: 32px; border-radius: 50%; flex-shrink: 0; object-fit: cover; background: #fff; }

.mt-chat-message {
    padding: 10px 14px; border-radius: 18px; font-size: var(--mt-chat-font-size, 14px); 
    line-height: 1.5; word-wrap: break-word; position: relative; 
    box-shadow: 0 1px 2px rgba(0,0,0,0.05); min-width: 60px;
}
.mt-chat-message.user { 
    background-color: var(--mt-chat-user-bubble-bg); color: var(--mt-chat-user-text-color); border-bottom-left-radius: 2px; 
}
.mt-chat-message.assistant { 
    background-color: var(--mt-chat-admin-bubble-bg); color: var(--mt-chat-admin-text-color); border-bottom-right-radius: 2px; 
}

/* CHAT IMAGES AS THUMBNAILS (Fixed) */
.mt-chat-message img {
    width: 150px;
    height: 150px;
    object-fit: cover;
    border-radius: 8px;
    cursor: pointer;
    display: block;
    margin: 5px 0;
    background: #f0f0f0;
    transition: transform 0.2s;
}
.mt-chat-message img:hover {
    transform: scale(1.02);
}

/* --- Smart Link Styling --- */
.mt-chat-message a {
    color: inherit !important;
    font-weight: 800 !important;
    text-decoration: none !important;
    border-bottom: none !important;
}
.mt-chat-message a:hover {
    opacity: 0.8;
}

/* Info Card */
.mt-info-card {
    border: 1px solid #e0e0e0; border-radius: 8px; overflow: hidden;
    background: #fff; margin-top: 5px; box-shadow: 0 2px 5px rgba(0,0,0,0.05); max-width: 100%;
}
.mt-info-card strong { font-weight: 700; }

.mt-message-text-content { word-break: break-word; overflow-wrap: anywhere; white-space: pre-wrap; }
.mt-message-text-content strong { font-weight: 900 !important; color: inherit; }

/* Reply Button */
.mt-reply-btn { 
    position: absolute; top: 50%; transform: translateY(-50%); 
    background: #fff; border-radius: 50%; width: 26px; height: 26px; 
    display: flex; justify-content: center; align-items: center; 
    opacity: 0; cursor: pointer; box-shadow: 0 1px 3px rgba(0,0,0,0.2); 
    transition: opacity 0.2s; color: #555; z-index: 5;
}
.mt-message-wrapper:hover .mt-reply-btn { opacity: 1; }
.mt-message-wrapper.user .mt-reply-btn { right: auto; left: -35px; }
.mt-message-wrapper.assistant .mt-reply-btn { left: auto; right: -35px; }
.mt-reply-btn span { font-size: 16px; }

.mt-quoted-reply { 
    font-size: 12px; border-right: 3px solid var(--mt-chat-accent); 
    padding: 6px 8px; background: rgba(0,0,0,0.05); border-radius: 4px; 
    margin-bottom: 6px; max-width: 100%; overflow: hidden; 
    text-overflow: ellipsis; white-space: nowrap; cursor: pointer; text-align: right; direction: rtl;
}
.mt-chat-message.user .mt-quoted-reply { background: rgba(255,255,255,0.2); border-right-color: rgba(255,255,255,0.8); }
.mt-quoted-reply .quoted-author { font-weight: bold; display: block; margin-bottom: 2px; opacity: 0.8; }

.message-meta { display: flex; align-items: center; justify-content: flex-end; gap: 4px; margin-top: 4px; font-size: 10px; }
.message-meta span:first-child { color: var(--mt-chat-msg-time-color); }
.mt-chat-message.user .message-meta { justify-content: flex-start; } 
.message-status .material-icons-outlined { font-size: 14px; }

/* Product Cards */
.mt-product-cards-container { display: flex; gap: 10px; overflow-x: auto; padding: 5px; margin-top: 10px; max-width: 100%; scrollbar-width: thin; scrollbar-color: #ccc transparent; }
.mt-product-cards-container::-webkit-scrollbar { height: 4px; }
.mt-product-cards-container::-webkit-scrollbar-track { background: transparent; }
.mt-product-cards-container::-webkit-scrollbar-thumb { background: #ccc; border-radius: 4px; }
.mt-product-card { flex: 0 0 140px; background: #fff; border-radius: 8px; border: 1px solid #eee; overflow: hidden; text-decoration: none !important; color: #333; transition: transform 0.2s; display: flex; flex-direction: column; }
.mt-product-card:hover { transform: translateY(-2px); box-shadow: 0 4px 8px rgba(0,0,0,0.1); }
.mt-product-card-image {
    width: 100%;
    height: 130px;
    padding: 15px;
    box-sizing: border-box;
    background: #fff;
    overflow: hidden;
}

.mt-product-card-image img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    object-position: center;
    display: block;
}
.mt-product-card-details { padding: 8px; font-size: 12px; }
.mt-product-card-name { font-weight: bold; margin-bottom: 4px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; text-decoration: none; }
.mt-product-card-price { color: #d32f2f; font-weight: 700; text-decoration: none; display: block; }
.mt-product-cards-container.vertical { flex-direction: column; overflow-x: visible; }
.mt-product-cards-container.vertical .mt-product-card { flex: 0 0 auto; width: 100%; flex-direction: row; height: auto; align-items: center; }
.mt-product-cards-container.vertical .mt-product-card-image { width: 70px; height: 70px; flex-shrink: 0; border-left: 1px solid #eee; }
.mt-product-cards-container.vertical .mt-product-card-image img { height: 100%; object-fit: cover; }
.mt-product-cards-container.vertical .mt-product-card-details { flex-grow: 1; display: flex; flex-direction: column; justify-content: center; overflow: hidden; padding-right: 10px; }

/* Fallback Buttons */
.mt-fallback-buttons-container {
    display: flex;
    flex-direction: column;
    gap: 8px;
    margin-top: 10px;
}
.mt-fallback-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 8px 12px;
    border-radius: 8px;
    text-decoration: none !important;
    font-size: 13px;
    font-weight: 600;
    transition: all 0.2s;
    border: none;
    color: #fff !important;
}
.mt-fallback-btn svg {
    width: 18px;
    height: 18px;
    fill: currentColor;
}
.mt-btn-telegram {
    background-color: #229ED9;
}
.mt-btn-telegram:hover {
    background-color: #1d8dbf;
}
.mt-btn-whatsapp {
    background-color: #25D366;
}
.mt-btn-whatsapp:hover {
    background-color: #1ebd59;
}

/* 
   FOOTER - 2 ROW LAYOUT
*/
#mt-chat-footer { 
    padding: 10px 15px 15px; 
    background: var(--mt-chat-footer-bg); 
    border-top: 1px solid #eee; 
    position: relative; z-index: 5; flex-shrink: 0; 
}

#mt-reply-to-container { display: none; background: #f9f9f9; padding: 6px 10px; font-size: 12px; border-radius: 6px; margin-bottom: 10px; position: relative; border-right: 3px solid var(--mt-chat-accent); }
#mt-reply-to-author { font-weight: bold; color: var(--mt-chat-accent); margin-bottom: 2px; }
#mt-reply-to-text { color: #666; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
#mt-cancel-reply-btn { position: absolute; left: 8px; top: 50%; transform: translateY(-50%); background: none; border: none; cursor: pointer; font-size: 18px; color: #999; padding: 0; }

/* 
   FILE PREVIEW AREA (USER SIDE)
*/
#mt-file-preview-area {
    position: absolute;
    bottom: 100%;
    left: 0;
    width: 100%;
    background: #f5f5f5;
    border-top: 1px solid #e0e0e0;
    padding: 8px;
    display: flex;
    align-items: center;
    gap: 10px;
    z-index: 20;
    box-shadow: 0 -2px 5px rgba(0,0,0,0.03);
}
#mt-file-preview-area.hidden { display: none; }

.mt-preview-wrapper {
    position: relative;
    width: 70px;
    height: 70px;
    border-radius: 6px;
    overflow: hidden;
    flex-shrink: 0;
    border: 1px solid #ccc;
    background: #fff;
}

#mt-file-preview-img {
    width: 100% !important;
    height: 100% !important;
    object-fit: cover;
    display: block;
}

/* Upload Overlay */
.mt-upload-overlay {
    position: absolute;
    top: 0; left: 0; right: 0; bottom: 0;
    background: rgba(0,0,0,0.6);
    display: none;
    align-items: center;
    justify-content: center;
    z-index: 5;
}
.mt-preview-wrapper.uploading .mt-upload-overlay { display: flex; }

/* Typing Dots Animation */
.typing-dots { display: flex; gap: 3px; }
.typing-dots span { width: 4px; height: 4px; background: #fff; border-radius: 50%; animation: dotBlink 1.4s infinite both; }
.typing-dots span:nth-child(1) { animation-delay: 0s; }
.typing-dots span:nth-child(2) { animation-delay: 0.2s; }
.typing-dots span:nth-child(3) { animation-delay: 0.4s; }
@keyframes dotBlink { 0%, 100% { opacity: 0.2; transform: scale(0.8); } 50% { opacity: 1; transform: scale(1.2); } }

/* Success Icon */
.mt-upload-success-icon {
    position: absolute; top: 2px; right: 2px;
    background: #46b450; color: #fff; border: 1px solid #fff;
    border-radius: 50%; width: 18px; height: 18px;
    display: none; align-items: center; justify-content: center;
    z-index: 10;
}
.mt-upload-success-icon .material-icons-outlined { font-size: 12px; }
.mt-preview-wrapper.success .mt-upload-success-icon { display: flex; }

/* Remove Button */
#mt-remove-file-preview {
    position: absolute;
    top: 2px; 
    right: 2px; 
    background: #d63638;
    color: #fff;
    border: 1px solid #fff;
    border-radius: 50%;
    width: 18px;
    height: 18px;
    font-size: 14px;
    line-height: 1;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 2px 4px rgba(0,0,0,0.3);
    z-index: 5;
    padding: 0;
}
.mt-preview-wrapper.success ~ #mt-remove-file-preview { display: none; }

/* ROW 1: INPUT + SEND BUTTON */
.mt-footer-top {
    width: 100%; margin-bottom: 10px; position: relative;
}
#mt-chat-form { 
    display: flex; align-items: flex-end; gap: 8px; 
    background: transparent; border: none; padding: 0; width: 100%;
    position: relative; 
}

/* Textarea Styles */
#mt-chat-input { 
    flex-grow: 1; border: none; background: transparent; 
    padding: 8px 10px 8px 48px; 
    font-size: 14px; outline: none; font-family: inherit; min-width: 0; 
    color: #333; 
    line-height: 20px; 
    min-height: 40px; 
    max-height: 240px; 
    overflow-y: auto;
    resize: none;
    scrollbar-width: none;  
    -ms-overflow-style: none;
}
#mt-chat-input::-webkit-scrollbar { display: none; }
#mt-chat-input::placeholder { color: #aaa; }

/* Send Button - Absolute Positioned INSIDE Input Area */
#mt-send-btn { 
    position: absolute; 
    left: 6px; 
    bottom: 6px; 
    width: 33px; height: 33px; min-width: 33px;
    background-color: var(--mt-chat-accent) !important; 
    color: #fff !important; 
    border-radius: 12px; 
    display: flex; align-items: center; justify-content: center;
    border: none; cursor: pointer;
    box-shadow: 0 2px 5px rgba(0,0,0,0.15);
    transition: all 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275);
    animation: mtPopIn 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275);
    z-index: 10;
}
#mt-send-btn svg { 
    width: 18px; height: 18px; 
    transform: rotate(180deg); 
    fill: #fff;
    margin-right: -2px; 
}
@keyframes mtPopIn { from { transform: scale(0); opacity: 0; } to { transform: scale(1); opacity: 1; } }

/* ROW 2: ACTIONS + COPYRIGHT */
.mt-footer-bottom {
    display: flex; justify-content: space-between; align-items: center;
    border-top: 1px solid #f5f5f5; padding-top: 10px;
}

.mt-footer-actions-right { 
    display: flex; gap: 15px; align-items: center; justify-content: flex-start; height: 24px;
}

.mt-chat-action-btn { 
    background: transparent !important; border: none !important; cursor: pointer; 
    color: #999 !important; padding: 0 !important; margin: 0 !important; 
    display: inline-flex; align-items: center; justify-content: center; 
    transition: color 0.2s; width: auto; height: auto; box-shadow: none !important; 
}
.mt-chat-action-btn .material-icons-outlined { line-height: normal !important; display: flex; }
.mt-chat-action-btn:hover { color: #555 !important; background: none !important; }
.mt-chat-action-btn span { font-size: 20px !important; }

.mt-footer-copyright-left { display: flex; align-items: center; }

/* TOOLTIPS */
.mt-tooltip { position: relative; }
.mt-tooltip:hover::after {
    content: attr(aria-label);
    position: absolute; bottom: 100%; margin-bottom: 6px;
    left: 50%; transform: translateX(-50%);
    background: rgba(0,0,0,0.85); color: #fff; padding: 5px 10px;
    border-radius: 4px; font-size: 11px; white-space: nowrap; pointer-events: none;
    z-index: 100; opacity: 0; animation: mtTooltipFade 0.2s forwards;
}
.mt-tooltip:hover::before {
    content: ''; position: absolute; bottom: 100%;
    left: 50%; transform: translateX(-50%);
    border-width: 6px 6px 0 6px; border-style: solid;
    border-color: rgba(0,0,0,0.85) transparent transparent transparent;
    z-index: 100; opacity: 0; animation: mtTooltipFade 0.2s forwards;
}
@keyframes mtTooltipFade { from { opacity: 0; transform: translate(-50%, 5px); } to { opacity: 1; transform: translate(-50%, 0); } }

#mt-mic-btn.recording { color: #e74c3c !important; animation: pulse 1.5s infinite; }
@keyframes pulse { 0% { transform: scale(1); } 50% { transform: scale(1.1); } 100% { transform: scale(1); } }

/* Emoji Picker */
#mt-emoji-picker-container { position: absolute; bottom: 60px; left: 0; width: 100%; z-index: 100; box-shadow: 0 -5px 25px rgba(0,0,0,0.1); border-radius: 12px 12px 0 0; overflow: hidden; display: none; border: 1px solid #eee; border-bottom: none; }
#mt-emoji-picker-container.active { display: block; }
emoji-picker { width: 100%; height: 320px; --background: #fff; --emoji-size: 1.2rem; --num-columns: 8; --emoji-padding: 4px; }

/* Rating */
#mt-rating-screen { padding: 40px 20px; text-align: center; justify-content: center; background: var(--mt-chat-main-bg); }
.mt-star-rating { display: flex; justify-content: center; gap: 5px; margin: 20px 0; direction: ltr; }
.mt-star { font-size: 32px; cursor: pointer; color: #ddd; transition: color 0.2s; }
.mt-star.active { color: #f1c40f; }
#mt-rating-comment { width: 100%; border: 1px solid #ddd; padding: 10px; border-radius: 8px; margin-bottom: 15px; font-family: inherit; resize: vertical; background: #fff; color: #333; }
#mt-submit-rating-btn { background: var(--mt-chat-accent); color: #fff; border: none; padding: 10px 30px; border-radius: 20px; cursor: pointer; font-weight: bold; transition: opacity 0.2s; }
#mt-submit-rating-btn:hover { opacity: 0.9; }
#mt-reopen-chat-btn { background: #46b450; color: #fff; border: none; padding: 10px 30px; border-radius: 20px; cursor: pointer; font-weight: bold; margin-top: 15px; transition: opacity 0.2s; width: 100%; }
#mt-reopen-chat-btn:hover { opacity: 0.9; }

/* System Alert */
.mt-system-alert { background-color: #ffebee; color: #c62828; border: 1px solid #ef9a9a; border-radius: 8px; padding: 8px 15px; margin: 10px auto; font-size: 12px; text-align: center; max-width: 90%; font-weight: bold; box-shadow: 0 2px 4px rgba(0,0,0,0.05); }

/* Audio & Skeleton */
.mt-audio-player { width: 100%; min-width: 200px; margin-top: 5px; display: block; }
.mt-audio-player audio { width: 100%; height: 32px; border-radius: 16px; }
.mt-skeleton-loader { display: flex; flex-direction: column; gap: 12px; width: 100%; padding: 10px; }
.mt-skeleton-msg { display: flex; align-items: flex-end; gap: 8px; opacity: 0.7; }
.mt-skeleton-msg.own { flex-direction: row-reverse; }
.mt-skeleton-avatar { width: 32px; height: 32px; background: #ddd; border-radius: 50%; animation: mtSkeletonPulse 1.5s infinite; }
.mt-skeleton-bubble { height: 35px; background: #ddd; border-radius: 12px; animation: mtSkeletonPulse 1.5s infinite; width: 60%; }
.mt-skeleton-msg.own .mt-skeleton-bubble { width: 40%; background: #cfd8dc; }
@keyframes mtSkeletonPulse { 0% { opacity: 0.6; } 50% { opacity: 0.8; } 100% { opacity: 0.6; } }

/* Typing Indicator */
.typing-indicator-wrapper { margin-bottom: 10px; }
.mt-chat-message.typing { min-width: 50px; display: flex; align-items: center; justify-content: center; padding: 12px 15px; }
.typing-indicator { display: flex; align-items: center; gap: 4px; padding: 0; line-height: 1; }
.typing-indicator span { width: 6px; height: 6px; background-color: #888; border-radius: 50%; display: block; animation: mtTypingBounce 1.4s infinite ease-in-out both; }
.typing-indicator span:nth-child(1) { animation-delay: -0.32s; }
.typing-indicator span:nth-child(2) { animation-delay: -0.16s; }
@keyframes mtTypingBounce { 0%, 80%, 100% { transform: scale(0); opacity: 0.4; } 40% { transform: scale(1); opacity: 1; } }

/* --- REVISED MOBILE STYLES (Max-Width 768px) --- */
@media (max-width: 768px) {
    /* 
       Note: The widget CONTAINER (#mt-chat-widget-container) 
       positioning is now handled by PHP generated inline styles using CSS variables.
       We DO NOT force bottom:0 or right:0 here anymore.
    */

    /* Force the Chat WINDOW to be full screen when open */
    #mt-chat-window {
        position: fixed !important;
        inset: 0 !important; /* Top, Right, Bottom, Left = 0 */
        width: 100% !important;
        height: 100% !important;
        max-height: 100vh !important;
        border-radius: 0 !important;
        margin: 0 !important;
        transform: none !important; /* Disable open animation scaling on mobile */
        z-index: 99999999999999 !important;
    }
}