/* Behsaz AI Chat — dedicated stylesheet (Phase 3A) */

/*#region AI Conversation Sidebar */
.Ai-Assistant-Shell {
    display: flex;
    flex-direction: row;
    position: relative;
    min-height: 0;
    flex: 1 1 auto;
}

.Ai-ConversationSidebar {
    width: 280px;
    min-width: 240px;
    max-width: 320px;
    border-inline-end: 1px solid var(--Theme-BorderColor, #d7dde5);
    background: var(--Theme-PanelBackground, #f7f9fc);
    display: flex;
    flex-direction: column;
    gap: 8px;
    padding: 10px;
    box-sizing: border-box;
}

.Ai-ConversationSidebar-Header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
}

.Ai-ConversationSidebar-Title {
    font-weight: 600;
    font-size: 14px;
}

.Ai-ConversationSidebar-Search {
    display: flex;
    gap: 6px;
    align-items: center;
}

.Ai-ConversationSidebar-SearchInput {
    flex: 1 1 auto;
    min-width: 0;
    padding: 6px 8px;
    border: 1px solid var(--Theme-BorderColor, #d7dde5);
    border-radius: 6px;
    background: var(--Theme-InputBackground, #fff);
}

.Ai-ConversationSidebar-List {
    flex: 1 1 auto;
    overflow: auto;
    display: flex;
    flex-direction: column;
    gap: 4px;
    min-height: 120px;
}

.Ai-ConversationSidebar-Item {
    border: 1px solid transparent;
    border-radius: 8px;
    padding: 4px;
    background: transparent;
}

.Ai-ConversationSidebar-Item-Selected {
    border-color: var(--Theme-AccentColor, #2f6fed);
    background: rgba(47, 111, 237, 0.08);
}

.Ai-ConversationSidebar-ItemButton {
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    width: 100%;
    border: none;
    background: transparent;
    text-align: start;
    cursor: pointer;
    padding: 6px 8px;
}

.Ai-ConversationSidebar-ItemTitle {
    font-size: 13px;
    font-weight: 500;
    line-height: 1.35;
}

.Ai-ConversationSidebar-ItemMeta {
    font-size: 11px;
    opacity: 0.7;
    margin-top: 2px;
}

.Ai-ConversationSidebar-ItemActions {
    display: flex;
    gap: 2px;
    justify-content: flex-end;
    opacity: 0;
    transition: opacity 120ms ease;
}

.Ai-ConversationSidebar-Item:hover .Ai-ConversationSidebar-ItemActions,
.Ai-ConversationSidebar-Item-Selected .Ai-ConversationSidebar-ItemActions {
    opacity: 1;
}

.Ai-ConversationSidebar-Empty {
    padding: 12px 8px;
    opacity: 0.7;
    font-size: 12px;
}

.Ai-ConversationSidebar-RenameInput {
    width: 100%;
    box-sizing: border-box;
    padding: 6px 8px;
    border: 1px solid var(--Theme-BorderColor, #d7dde5);
    border-radius: 6px;
}

.Ai-ConversationDrawer-Toggle,
.Ai-ConversationDrawer-Backdrop {
    display: none;
}

.IsMobileSize .Ai-ConversationDrawer-Toggle {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    align-self: flex-start;
    margin: 6px 8px 0;
    padding: 5px 9px;
    border: 1px solid var(--Theme-BorderColor, #d7dde5);
    border-radius: 7px;
    background: var(--Theme-PanelBackground, #f7f9fc);
    color: inherit;
    cursor: pointer;
    transition: background-color 150ms ease, transform 120ms ease;
}

.IsMobileSize .Ai-ConversationDrawer-Toggle:active {
    transform: scale(0.98);
}

.IsMobileSize .Ai-ConversationDrawer-Backdrop {
    display: block;
    position: absolute;
    inset: 0;
    z-index: 40;
    border: 0;
    background: rgba(10, 18, 30, 0.28);
    animation: AiChat-FadeIn 160ms ease both;
}

.IsMobileSize .Ai-ConversationSidebar {
    position: absolute;
    inset-block: 0;
    inset-inline-start: 0;
    z-index: 41;
    width: min(86vw, 320px);
    min-width: 0;
    box-shadow: 0 12px 32px rgba(10, 18, 30, 0.2);
    animation: AiChat-DrawerIn 200ms ease-out both;
}

.Ai-AgentTabShell > .TLayoutGroupContent > .Ai-AgentViewRoot {
    flex: 1 1 auto;
    min-height: 0;
    min-width: 0;
}

/* Keep execution steps on the visual LEFT (former TDockPanel used direction:ltr). */
.Ai-SessionRow,
.Ai-SessionRow > .TLayoutGroupContent {
    direction: ltr;
}

.Ai-SessionRow > .TLayoutGroupContent > .Ai-StepsColumn {
    order: 0;
}

.Ai-SessionRow > .TLayoutGroupContent > .Ai-ChatColumnHost {
    order: 1;
}

[dir="rtl"] .Ai-ChatColumn,
[dir="rtl"] .Ai-AgentPanel {
    direction: rtl;
}
/*#endregion*/

/*#region Durable AI memory manager */
.Ai-MemoryManager {
    gap: 8px;
    padding: 8px;
    box-sizing: border-box;
}

.Ai-MemoryManager-Help,
.Ai-MemoryManager-Empty {
    color: var(--Theme-ForegroundColor-Light, #666);
    font-size: 12px;
    line-height: 1.6;
}

.Ai-MemoryManager-Item {
    display: flex;
    flex-direction: column;
    gap: 4px;
    min-width: 0;
    padding-block: 4px;
}

.Ai-MemoryManager-Content {
    line-height: 1.6;
    overflow-wrap: anywhere;
}

.Ai-MemoryManager-Meta {
    direction: ltr;
    unicode-bidi: isolate;
    color: var(--Theme-ForegroundColor-Light, #777);
    font-size: 11px;
}
/*#endregion*/

/*#region Calm AI motion and state transitions */
.Ai-AgentViewRoot {
    --Ai-Motion-Fast: 120ms;
    --Ai-Motion-Normal: 180ms;
    --Ai-Motion-Slow: 260ms;
}

.Ai-AgentViewRoot .Ai-Thinking-Block {
    min-height: 1.5em;
    background: linear-gradient(90deg, currentColor 20%, var(--Theme-AccentColor, #3978d6) 48%, currentColor 76%);
    background-size: 220% 100%;
    background-clip: text;
    -webkit-background-clip: text;
    color: transparent;
    animation: AiChat-ThinkingShimmer 1.8s ease-in-out infinite;
}

.Ai-AgentViewRoot .Ai-Input-ConversationBtn,
.Ai-AgentViewRoot .Ai-Suggestion-Chip,
.Ai-AgentViewRoot .Ai-Question-Choice-Button,
.Ai-AgentViewRoot .Ai-Input-AttachmentChip,
.Ai-AgentViewRoot .Ai-ExecutionPlan-Step,
.Ai-ConversationSidebar-Item {
    transition: transform var(--Ai-Motion-Fast) ease,
        opacity var(--Ai-Motion-Normal) ease,
        background-color var(--Ai-Motion-Normal) ease,
        border-color var(--Ai-Motion-Normal) ease,
        box-shadow var(--Ai-Motion-Normal) ease;
}

.Ai-AgentViewRoot .Ai-Suggestion-Chip:hover,
.Ai-AgentViewRoot .Ai-Question-Choice-Button:hover {
    transform: translateY(-1px);
}

.Ai-AgentViewRoot .Ai-Suggestion-Chip:active,
.Ai-AgentViewRoot .Ai-Question-Choice-Button:active,
.Ai-AgentViewRoot .Ai-Input-ConversationBtn:active {
    transform: scale(.98);
}

.Ai-AgentViewRoot .Ai-Input-AttachmentChip.is-uploading {
    opacity: .78;
    animation: AiChat-UploadBreath 1.5s ease-in-out infinite;
}

.Ai-AgentViewRoot .Ai-Input-AttachmentChip.is-ready {
    opacity: 1;
}

.Ai-AgentViewRoot .Ai-Input-AttachmentChip.is-failed {
    animation: AiChat-FailureEmphasis 240ms ease-out 1;
}

.Ai-AgentViewRoot .Ai-Input-AttachmentProgress {
    position: relative;
    width: 54px;
    height: 3px;
    overflow: hidden;
    border-radius: 999px;
    background: rgba(47, 111, 237, .14);
}

.Ai-AgentViewRoot .Ai-Input-AttachmentProgressFill {
    position: absolute;
    inset-block: 0;
    inset-inline-start: 0;
    border-radius: inherit;
    background: var(--Theme-AccentColor, #2f6fed);
    transition: width var(--Ai-Motion-Normal) ease-out;
}

.Ai-AgentViewRoot .Ai-Input-AttachmentProgressText {
    min-width: 3.4em;
    font-size: 11px;
    opacity: .72;
}

.Ai-AgentViewRoot button:focus-visible,
.Ai-ConversationSidebar button:focus-visible,
.Ai-ConversationSidebar input:focus-visible,
.Ai-ConversationDrawer-Toggle:focus-visible {
    outline: 2px solid var(--Theme-AccentColor, #2f6fed);
    outline-offset: 2px;
}

.Ai-AgentViewRoot .Ai-ExecutionPlan-BarFill {
    transition: width var(--Ai-Motion-Slow) ease-out;
}

.Ai-AgentViewRoot .Ai-Recovery-Banner {
    margin: 6px 12px;
    padding: 8px 10px;
    border: 1px solid rgba(194, 120, 18, .35);
    border-radius: 8px;
    background: rgba(245, 166, 35, .1);
    animation: AiChat-FadeIn var(--Ai-Motion-Normal) ease both;
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 8px;
}

.Ai-AgentViewRoot .Ai-Recovery-Body {
    min-width: 0;
    flex: 1 1 auto;
}

.Ai-AgentViewRoot .Ai-Recovery-Goal,
.Ai-AgentViewRoot .Ai-Recovery-Warning {
    margin-top: 4px;
    font-size: .92em;
    opacity: .92;
}

.Ai-AgentViewRoot .Ai-Recovery-Actions {
    display: flex;
    flex: 0 0 auto;
    flex-wrap: wrap;
    gap: 6px;
}

.Ai-AgentViewRoot .Ai-Recovery-ReviewButton {
    flex: 0 0 auto;
    border: 1px solid currentColor;
    border-radius: 6px;
    padding: 4px 8px;
    background: transparent;
    color: inherit;
    cursor: pointer;
    transition: background-color var(--Ai-Motion-Fast) ease, transform var(--Ai-Motion-Fast) ease;
}

.Ai-AgentViewRoot .Ai-Recovery-ReviewButton:active {
    transform: scale(.98);
}

.Ai-AgentViewRoot .Ai-Input-ConversationBtn.is-listening .Ai-Conversation-Wave {
    animation-duration: 1.25s;
    animation-timing-function: ease-in-out;
}

.Ai-AgentViewRoot .Ai-Input-ConversationBtn.is-voice-thinking .Ai-Conversation-Wave {
    animation-duration: 1.8s;
    opacity: .45;
}

.Ai-AgentViewRoot .Ai-Input-ConversationBtn.is-speaking .Ai-Conversation-Wave {
    animation-duration: .72s;
}

.Ai-AgentViewRoot .Ai-Input-ConversationBtn.is-voice-error .Ai-Conversation-Wave,
.Ai-AgentViewRoot .Ai-Input-ConversationBtn.is-voice-unsupported .Ai-Conversation-Wave {
    animation: none;
    opacity: .25;
}

@keyframes AiChat-ThinkingShimmer {
    0%, 100% { background-position: 110% 0; }
    50% { background-position: -10% 0; }
}

@keyframes AiChat-UploadBreath {
    0%, 100% { opacity: .65; }
    50% { opacity: .9; }
}

@keyframes AiChat-FailureEmphasis {
    0% { transform: translateY(0); }
    45% { transform: translateY(-2px); }
    100% { transform: translateY(0); }
}

@keyframes AiChat-FadeIn {
    from { opacity: 0; }
    to { opacity: 1; }
}

@keyframes AiChat-DrawerIn {
    from { opacity: 0; transform: translateX(-12px); }
    to { opacity: 1; transform: translateX(0); }
}

[dir="rtl"] .IsMobileSize .Ai-ConversationSidebar {
    animation-name: AiChat-DrawerInRtl;
}

@keyframes AiChat-DrawerInRtl {
    from { opacity: 0; transform: translateX(12px); }
    to { opacity: 1; transform: translateX(0); }
}

@media (prefers-reduced-motion: reduce) {
    .Ai-AgentViewRoot .Ai-Thinking-Block,
    .Ai-AgentViewRoot .Ai-Conversation-Wave,
    .Ai-AgentViewRoot .Ai-Input-AttachmentChip,
    .Ai-AgentViewRoot .Ai-ExecutionPlan-BarFill,
    .Ai-AgentViewRoot .Ai-ExecutionPlan-Step,
    .Ai-AgentViewRoot .Ai-Suggestion-Chip,
    .Ai-AgentViewRoot .Ai-Recovery-ReviewButton,
    .Ai-AgentViewRoot .Ai-Question-Choice-Button,
    .Ai-ConversationSidebar-Item,
    .Ai-ConversationDrawer-Backdrop,
    .IsMobileSize .Ai-ConversationSidebar,
    .IsMobileSize .Ai-ConversationDrawer-Toggle {
        animation: none !important;
        transition-duration: 1ms !important;
    }
}
/*#endregion*/

/*#region AI Message paging */
.Ai-Messages-LoadingOlder {
    text-align: center;
    font-size: 12px;
    opacity: 0.7;
    padding: 8px 12px;
    flex: 0 0 auto;
}
/*#endregion*/

/*#region AI Composer attachments */
.Ai-Input-Attachments {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    padding: 8px 12px 0;
    box-sizing: border-box;
}

.Ai-Input-AttachmentChip {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    max-width: 100%;
    padding: 4px 8px 4px 4px;
    border-radius: 8px;
    border: 1px solid var(--Theme-BorderColor, #d7dde5);
    background: var(--Theme-PanelBackground, #f7f9fc);
    box-sizing: border-box;
}

.Ai-Input-AttachmentChip.is-uploading {
    opacity: 0.85;
}

.Ai-Input-AttachmentChip.is-failed {
    border-color: #d9534f;
    background: rgba(217, 83, 79, 0.08);
}

.Ai-Input-AttachmentChip.is-ready {
    border-color: var(--Theme-AccentColor, #2f6fed);
}

.Ai-Input-AttachmentThumb {
    width: 36px;
    height: 36px;
    object-fit: cover;
    border-radius: 6px;
    flex: 0 0 auto;
}

.Ai-Input-AttachmentIcon {
    width: 24px;
    height: 24px;
    flex: 0 0 auto;
}

.Ai-Input-AttachmentName {
    font-size: 12px;
    max-width: 160px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.Ai-Input-AttachmentSize {
    font-size: 11px;
    opacity: 0.65;
    flex: 0 0 auto;
}

.Ai-Input-AttachmentProgress,
.Ai-Input-AttachmentError {
    font-size: 11px;
    opacity: 0.75;
}

.Ai-Input-AttachmentError {
    color: #c0392b;
    max-width: 120px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.IsMobileSize .Ai-Input-AttachmentName {
    max-width: 100px;
}

[dir="rtl"] .Ai-Input-AttachmentChip {
    padding: 4px 4px 4px 8px;
}
/*#endregion*/

/*#region AI message history attachments (Phase 3C) */
.Ai-Message-Attachments {
    display: flex;
    flex-direction: column;
    gap: 8px;
    margin-bottom: 6px;
}

.Ai-Message-Attachment {
    display: flex;
    align-items: center;
    gap: 8px;
    max-width: 100%;
    box-sizing: border-box;
}

.Ai-Message-Attachment-Image {
    cursor: pointer;
}

.Ai-Message-Attachment-Thumb {
    width: 72px;
    height: 72px;
    object-fit: cover;
    border-radius: 8px;
    flex: 0 0 auto;
}

.Ai-Message-Attachment-Name {
    font-size: 12px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    max-width: 220px;
}

.Ai-Message-Attachment-File {
    font-size: 13px;
    color: var(--Theme-AccentColor, #2f6fed);
    text-decoration: none;
    word-break: break-all;
}

.Ai-Message-Attachment-File:hover {
    text-decoration: underline;
}

.Ai-Message-Attachment-Audio {
    flex-direction: column;
    align-items: flex-start;
}

.Ai-Message-Attachment-AudioPlayer {
    width: 100%;
    max-width: 280px;
}
/*#endregion*/

/*#region AI composer compact start */
.Ai-AgentViewRoot .Ai-Input-Text {
    min-height: 36px;
    max-height: 200px;
    height: 36px;
}
/*#endregion*/
