/* VisionWorkspaceModule custom styles */
/* Google Font for Arabic readability: Cairo */
@import url('https://fonts.googleapis.com/css2?family=Cairo:wght@400;600;700&display=swap');
.demo-hello-world{ font-size: 30px; }
.demo-file-preview{ max-width: 300px; }

/* AI chat: icon and minimal overrides; wrapper inherits Rise chat styles */
.init-ai-chat-icon{
    width: 50px;
    height: 50px;
    background-color: #fff;
    z-index: 1100; /* above common layers */
    position: fixed;
    /* Place above the Rise chat icon (Rise ≈ bottom:20px,right:20px). 50px icon + ~10px gap => bottom:80px */
    bottom: 80px;
    right: 20px; /* align with Rise icon's right edge */
    box-shadow: 0 3px 4px 4px rgba(0,0,0,.1);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 0;
    cursor: pointer;
}
.init-ai-chat-icon.active{ background-color: #4e5e6a; color: #fff; }

/* Floating AI icon image size */
.init-ai-chat-icon .ai-logo-icon{
    width: 28px;
    height: 28px;
    object-fit: cover;
    border-radius: 6px;
    display: block;
}

/* Header switch link (reuse Rise header) */
.rise-chat-header .ai-switch{ font-size: 12px; color:#4e5e6a; cursor:pointer; opacity:.8; display:flex; align-items:center; }
.rise-chat-header .ai-switch:hover{ opacity:1; text-decoration: underline; }

/* Place AI chat wrapper same as Rise chat on desktop */
/* Shift AI chat window left so it aligns beside the launcher button and doesn't overlap it */
.rise-chat-wrapper.ai-chat{ right: 80px; }

/* Make AI avatars fit in circular frames like Rise */
.rise-chat-wrapper.ai-chat .avatar img{
    width: 100%;
    height: 100%;
    object-fit: cover;
    border-radius: 50%;
    display: block;
}

/* Slightly reduce bubble avatar visual size to match pattern */
.rise-chat-wrapper.ai-chat .chat-other .avatar,
.rise-chat-wrapper.ai-chat .chat-me .avatar{
    width: 32px;
    height: 32px;
}
.rise-chat-wrapper.ai-chat .chat-other .avatar { margin-top: 0; }

/* Add inner padding to chat body so avatar/bubbles don't touch borders */
.rise-chat-wrapper.ai-chat .rise-chat-body{
    padding: 12px 14px 12px 18px; /* top right bottom left */
}

/* Expand bubbles to use available width within AI chat (popup) */
.rise-chat-wrapper.ai-chat .chat-other,
.rise-chat-wrapper.ai-chat .chat-me{
    display: flex;
    align-items: flex-start; /* align bubble top with avatar top */
    margin-bottom: 16px; /* more space between messages */
}
.rise-chat-wrapper.ai-chat .chat-other{ gap: 12px; } /* consistent gap between avatar and bubble */
.rise-chat-wrapper.ai-chat .chat-me{ justify-content: flex-end; }
.rise-chat-wrapper.ai-chat .chat-other .chat-msg{
    /* avatar (32) + gap (~12) + right gutter (16) */
    max-width: calc(100% - 44px - 16px);
    margin-right: 12px; /* extra breathing space */
}
.rise-chat-wrapper.ai-chat .chat-me .chat-msg{
    /* right gutter so bubble never sticks to border */
    max-width: calc(100% - 16px);
    margin-right: 12px;
}

/* Avatar gap handled by flex gap above */
.rise-chat-wrapper.ai-chat .chat-other .avatar{ margin-right: 0; }

/* RTL support: if a bubble is RTL, align its text to the right inside the bubble */
.rise-chat-wrapper.ai-chat .chat-msg[dir="rtl"]{
    direction: rtl;
    text-align: right;
    font-family: 'Cairo', 'Noto Naskh Arabic', 'Noto Kufi Arabic', 'Amiri', 'Segoe UI', Arial, sans-serif;
    letter-spacing: 0.1px; /* small boost for legibility */
}

/* When typing Arabic, style the textarea accordingly */
#js-ai-chat-input.rtl-input{
    direction: rtl;
    text-align: right;
    font-family: 'Cairo', 'Noto Naskh Arabic', 'Noto Kufi Arabic', 'Amiri', 'Segoe UI', Arial, sans-serif;
}

/* Mobile adjustments */
@media (max-width: 576px){
    /* On mobile, keep the AI icon above the Rise icon too */
    .init-ai-chat-icon{ bottom: 110px; right: 20px; }
}

/* Modal mode: align and size chat neatly inside #ajaxModal */
#ajaxModal .rise-chat-wrapper.ai-chat.modal-mode{
    position: static;
    right: auto;
    bottom: auto;
    width: 100%;
    max-width: 100%;
    box-shadow: none;
    display: flex;
    flex-direction: column;
    height: 70vh; /* responsive vertical space */
}
#ajaxModal .rise-chat-wrapper.ai-chat.modal-mode .rise-chat-body{
    flex: 1 1 auto;
    overflow-y: auto;
    padding: 14px 18px; /* symmetric padding in modal */
}
#ajaxModal .rise-chat-wrapper.ai-chat.modal-mode .rise-chat-footer{
    border-top: 1px solid #eee;
}
#ajaxModal .rise-chat-wrapper.ai-chat.modal-mode .chat-message-textarea textarea{
    max-height: 180px;
}

/* Make chat messages span the full width in modal mode */
#ajaxModal .rise-chat-wrapper.ai-chat.modal-mode .chat-other,
#ajaxModal .rise-chat-wrapper.ai-chat.modal-mode .chat-me{
    display: flex;
    align-items: flex-start;
    margin-bottom: 18px; /* a touch more space in modal */
}
#ajaxModal .rise-chat-wrapper.ai-chat.modal-mode .chat-other{ gap: 12px; }
#ajaxModal .rise-chat-wrapper.ai-chat.modal-mode .chat-me{
    justify-content: flex-end;
}
#ajaxModal .rise-chat-wrapper.ai-chat.modal-mode .chat-other .chat-msg{
    /* avatar (32) + gap (~12) + right gutter (16) */
    max-width: calc(100% - 44px - 16px);
    margin-right: 12px;
}
#ajaxModal .rise-chat-wrapper.ai-chat.modal-mode .chat-me .chat-msg{
    max-width: calc(100% - 16px);
    margin-right: 12px;
}

/* Avatar gap handled by flex gap in modal */
#ajaxModal .rise-chat-wrapper.ai-chat.modal-mode .chat-other .avatar{ margin-right: 0; }

/* Header alignment: center title, keep back/close/max usable */
.rise-chat-wrapper.ai-chat .rise-chat-header{ position: relative; display:flex; align-items:center; }
.rise-chat-wrapper.ai-chat .rise-chat-header .chat-title{
    position: absolute;
    left: 50%;
    transform: translateX(-50%);
    text-align: center;
    width: 60%;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
.rise-chat-wrapper.ai-chat .rise-chat-header .chat-back,
.rise-chat-wrapper.ai-chat .rise-chat-header .chat-bars{ z-index: 1; }

/* Size and center the back control */
.rise-chat-wrapper.ai-chat .rise-chat-header .chat-back{
    width: 40px;
    min-width: 40px;
    display: flex;
    align-items: center;
    justify-content: center;
}

/* Right-side controls container (maximize, close) */
.rise-chat-wrapper.ai-chat .rise-chat-header .chat-bars{
    margin-left: auto;
    display: flex;
    align-items: center;
    gap: 8px;
    padding-right: 6px;
}
.rise-chat-wrapper.ai-chat .rise-chat-header .chat-bars span{
    width: 32px;
    height: 32px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border-radius: 4px;
    cursor: pointer;
}
.rise-chat-wrapper.ai-chat .rise-chat-header .chat-bars span:hover{
    background: rgba(0,0,0,0.05);
}
.rise-chat-wrapper.ai-chat .rise-chat-header .chat-bars i.icon-16,
.rise-chat-wrapper.ai-chat .rise-chat-header .chat-back i.icon-16{
    line-height: 1;
    vertical-align: middle;
}
