/**
 * @author   : M. R. Creighton
 * @link     : https://myopsagent.com
 * @version  : 3.7.0-ISOLATED-FIX
 * File Path : shared/assets/css/pages/ai-agents.css
 */

/* =========================================================
   1. ANIMATIONS ENGINE KEYS (UNCHANGED)
========================================================= */
@keyframes moaSlideInLeft {
    from { transform: translateX(-100%); opacity: 0; }
    to { transform: translateX(0); opacity: 1; }
}
@keyframes moaFadeInUp {
    from { transform: translateY(8px); opacity: 0; }
    to { transform: translateY(0); opacity: 1; }
}
@keyframes moaBeaconPulse {
    0% { transform: scale(0.95); box-shadow: 0 0 0 0 rgba(16, 185, 129, 0.7); }
    70% { transform: scale(1); box-shadow: 0 0 0 6px rgba(16, 185, 129, 0); }
    100% { transform: scale(0.95); box-shadow: 0 0 0 0 rgba(16, 185, 129, 0); }
}

/* =========================================================
   2. SYSTEM BOUNDARY OVERRIDES (STOPS OVERFLOW DEAD)
========================================================= */
.moa-floating-container {
    position: fixed !important;
    bottom: 20px !important;
    right: 20px !important;
    z-index: 10000 !important;
    font-family: 'Inter', system-ui, -apple-system, sans-serif;
}

.moa-fab-trigger {
    width: 68px;
    height: 68px;
    border-radius: 50%;
    border: none;
    background: transparent !important; /* Ensures no outer bounding circle rings show up */
    box-shadow: 0 8px 24px rgba(15, 23, 42, 0.16);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: transform 0.2s ease;
    padding: 0 !important;
}
.moa-fab-trigger img { width: 68px; height: 68px; border-radius: 50%; object-fit: cover; margin: 0 !important; }

/* The Viewport Box Isolation Layout */
.moa-drawer-window {
    position: fixed !important;
    bottom: 96px !important;
    right: 16px !important;
    left: 16px !important; /* Locks width inside mobile viewport edges explicitly */
    width: auto !important; /* Overrides any trailing 380px values coming from elsewhere */
    max-width: none !important;
    background: #ffffff;
    border: 1px solid #e2e8f0;
    border-radius: 16px;
    box-shadow: 0 16px 36px rgba(15, 23, 42, 0.12);
    overflow: hidden;
    transition: all 0.25s ease;
    box-sizing: border-box !important;
}

/* =========================================================
   3. CORE CHAT VIEWPORT ENVIRONMENT
========================================================= */
.moa-chat-shell {
    width: 100% !important;
    height: 65vh !important; 
    min-height: 400px;
    background: #ffffff;
    display: flex;
    position: relative;
    overflow: hidden;
    box-sizing: border-box !important;
    margin: 0 !important;
    padding: 0 !important;
}

.moa-main-chat-viewport {
    flex: 1;
    display: flex;
    flex-direction: column;
    padding: 14px;
    overflow: hidden;
    position: relative;
    background: radial-gradient(circle at 90% 10%, #f8fafc 0%, #ffffff 100%);
    box-sizing: border-box !important;
}

/* =========================================================
   4. DRAWER HISTORICAL LOGS PANEL
========================================================= */
.moa-history-sidebar {
    position: absolute;
    top: 0;
    left: 0;
    bottom: 0;
    width: 100% !important; /* Completely matches container panel width on screens */
    background: #f8fafc;
    border-right: 1px solid #e2e8f0;
    z-index: 110;
    display: flex;
    flex-direction: column;
    transform: translateX(-100%);
    transition: transform 0.3s cubic-bezier(0.16, 1, 0.3, 1);
    box-sizing: border-box !important;
}

.moa-history-sidebar.sidebar-open {
    transform: translateX(0);
}

.moa-sidebar-header {
    padding: 14px 16px;
    border-bottom: 1px solid #e2e8f0;
    display: flex;
    align-items: center;
    justify-content: space-between;
    background: #ffffff;
    flex-shrink: 0;
}
.moa-sidebar-header h6 {
    margin: 0;
    font-weight: 700;
    font-size: 0.88rem;
    color: #0f172a;
}

.moa-sidebar-scroll-body {
    flex: 1;
    overflow-y: auto;
    padding: 16px;
    -webkit-overflow-scrolling: touch;
}

.moa-sidebar-section-label {
    font-size: 0.72rem;
    font-weight: 700;
    text-transform: uppercase;
    color: #94a3b8;
    letter-spacing: 0.05em;
    margin-bottom: 8px;
}

.moa-sidebar-item {
    padding: 10px 12px;
    border-radius: 8px;
    font-size: 0.82rem;
    color: #475569;
    cursor: pointer;
    display: flex;
    align-items: center;
    transition: all 0.2s ease;
    margin-bottom: 4px;
    background: transparent;
}
.moa-sidebar-item:hover { background: #f1f5f9; color: #0f172a; }
.moa-sidebar-item.active { background: #e2e8f0; color: #2563eb; font-weight: 600; }
.moa-sidebar-item.item-dense { padding: 6px 12px; font-size: 0.78rem; }

.moa-sidebar-footer {
    padding: 12px;
    border-top: 1px solid #e2e8f0;
    background: #ffffff;
}

/* =========================================================
   5. CHAT HEADER UTILITIES
========================================================= */
.moa-chat-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding-bottom: 12px;
    margin-bottom: 12px;
    border-bottom: 1px solid #f1f5f9;
    flex-shrink: 0;
}
.moa-chat-header-left { display: flex; align-items: center; gap: 4px; }

.moa-avatar-wrapper { position: relative; margin-right: 8px; }
.moa-online-beacon {
    position: absolute;
    bottom: 2px;
    right: 2px;
    width: 10px;
    height: 10px;
    background: #10b981;
    border: 2px solid #ffffff;
    border-radius: 50%;
    animation: moaBeaconPulse 2s infinite;
}

.moa-status-tracker-pill {
    background: #f1f5f9;
    color: #64748b;
    font-size: 0.7rem;
    padding: 2px 6px;
    border-radius: 20px;
    font-weight: 600;
}

.moa-chat-header-right { display: flex; gap: 6px; }
.moa-header-action-btn {
    background: #ffffff;
    border: 1px solid #e2e8f0;
    border-radius: 8px;
    padding: 6px 10px;
    font-size: 0.8rem;
    font-weight: 600;
    color: #475569;
    cursor: pointer;
}
.moa-header-action-btn.primary-intent { background: #2563eb; color: #ffffff; border-color: #2563eb; }

/* =========================================================
   6. LOG HISTORY BULLET ENGINE
========================================================= */
.moa-chat-log {
    flex: 1;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
    gap: 12px;
    margin-bottom: 12px;
    -webkit-overflow-scrolling: touch;
}

.moa-message-row { display: flex; width: 100%; }
.moa-message-row.user { justify-content: flex-end; }

.agent-message, .user-message {
    padding: 10px 14px;
    border-radius: 14px;
    max-width: 88%;
    font-size: 0.86rem;
    line-height: 1.45;
    box-shadow: 0 4px 12px rgba(15, 23, 42, 0.01);
    word-break: break-word;
}
.agent-message { background: #ffffff; color: #111827; border: 1px solid #e2e8f0; border-top-left-radius: 4px; }
.user-message { background: #2563eb; color: #ffffff; border-top-right-radius: 4px; }

/* Input configurations wrappers */
.moa-chat-input-row {
    display: flex;
    gap: 8px;
    align-items: center;
    background: #ffffff;
    border: 1px solid #cbd5e1;
    padding: 4px 4px 4px 12px;
    border-radius: 12px;
    flex-shrink: 0;
}
.moa-chat-input-row textarea {
    flex: 1;
    border: none;
    outline: none;
    resize: none;
    font-size: 0.92rem;
    color: #0f172a;
    background: transparent;
    height: 24px;
    padding: 4px 0;
}

.moa-submit-matrix-btn {
    background: #2563eb;
    color: #ffffff;
    border: none;
    width: 34px;
    height: 34px;
    border-radius: 8px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
}

.moa-sidebar-action-btn { background: rgba(37, 99, 235, 0.06); border: 1px dashed rgba(37, 99, 235, 0.3); color: #2563eb; font-weight: 600; padding: 8px; border-radius: 8px; font-size: 0.8rem; cursor: pointer; }
.moa-sidebar-danger-btn { background: transparent; border: 1px solid #fca5a5; color: #dc3545; padding: 8px; border-radius: 8px; font-size: 0.8rem; font-weight: 600; cursor: pointer; }
.moa-icon-close-btn { background: transparent; border: none; color: #94a3b8; cursor: pointer; }

/* =========================================================
   7. TABLET & MONITOR DESKTOP BREAKPOINTS
========================================================= */
@media (min-width: 576px) {
    .moa-drawer-window {
        left: auto !important;
        width: 380px !important;
        right: 20px !important;
    }
    .moa-chat-shell {
        height: 560px !important;
    }
    .moa-history-sidebar {
        width: 280px !important;
    }
}