/*CC- #3044 / #3047: stránka AI asistenta s vláknami — zdieľaná CORE a zákaznícka zóna */
/*CC- #3044: farby výhradne cez DX premenné — stránka musí fungovať aj v tmavých témach */
.aic-layout { display: grid; grid-template-columns: 320px 1fr; gap: 12px; height: calc(100vh - 150px); min-height: 480px; }
.aic-panel { border: 1px solid var(--dx-color-border, #dee2e6); border-radius: 8px; padding: 10px; display: flex; flex-direction: column; min-height: 0; }
.aic-threads-tools { display: flex; flex-direction: column; gap: 8px; margin-bottom: 8px; }
.aic-threads-row { display: flex; align-items: center; gap: 4px; }
.aic-threads-row #aicNewButton { flex: 1 1 auto; }
.aic-threads-list { flex: 1 1 auto; min-height: 0; }
.aic-threads-footer { font-size: 0.75rem; text-align: center; padding-top: 6px; display: flex; flex-direction: column; align-items: center; gap: 2px; }
.aic-threads-count { opacity: 0.6; }
.aic-thread-group { font-size: 0.75rem; font-weight: 600; text-transform: uppercase; letter-spacing: 0.03em; opacity: 0.6; }
.aic-thread { display: flex; align-items: center; gap: 4px; }
.aic-thread-info { flex: 1 1 auto; min-width: 0; }
.aic-thread-title { font-weight: 500; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.aic-thread-pin { font-size: 0.7rem; margin-right: 5px; color: var(--dx-color-primary); }
.aic-thread-meta { font-size: 0.75rem; opacity: 0.6; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.aic-thread-active .aic-thread-title { color: var(--dx-color-primary); }
.aic-thread-ended .aic-thread-title { opacity: 0.7; }
/*CC- #3101: akcie riadku len pri prejdení myšou alebo na aktívnom vlákne — titulok má viac miesta.
  Na dotykových zariadeniach (bez hover) ostávajú viditeľné vždy. */
.aic-thread-actions { display: flex; flex: 0 0 auto; }
@media (hover: hover) {
    .aic-thread-actions { display: none; }
    .dx-list-item:hover .aic-thread-actions, .aic-thread-active .aic-thread-actions { display: flex; }
}
.aic-header { display: flex; align-items: center; gap: 8px; margin-bottom: 8px; min-height: 36px; }
.aic-header-title { flex: 1 1 auto; min-width: 0; }
.aic-header-title .aic-title { font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.aic-header-title .aic-meta { font-size: 0.75rem; opacity: 0.6; }
.aic-chat { flex: 1 1 auto; min-height: 0; }

/*CC- #3101: zbalený ľavý panel — úzky pruh s tlačidlami, chat má celú šírku */
.aic-layout.aic-collapsed { grid-template-columns: 52px 1fr; }
.aic-collapsed .aic-panel-threads { padding: 8px 4px; align-items: center; }
.aic-collapsed .aic-threads-row { flex-direction: column; }
.aic-collapsed #aicSearch, .aic-collapsed .aic-threads-list, .aic-collapsed .aic-threads-footer { display: none; }

/*CC- #3101: vstup správy ako v DX demo. Téma ENVI-PAK (ThemeBuilder) farbí pozadie každého .dx-toolbar —
  riadok s tlačidlom Odoslať potom vyzeral ako vstupné pole a placeholder ako jeho popis. */
.aic-chat .dx-chat-textarea-toolbar { background: transparent; }
.aic-chat .dx-chat-messagebox {
    position: relative;
    border-top: 1px solid var(--dx-color-border, #dee2e6);
    background: color-mix(in srgb, var(--dx-color-primary) 4%, transparent);
}
.aic-chat .dx-chat-messagebox-textarea-container .dx-chat-textarea { cursor: text; }
/*CC- Pole od dvoch riadkov, rastie s textom do 30 % výšky okna, potom sa posúva (DX autoResize nastavuje výšku inline) */
.aic-chat .dx-chat-textarea .dx-texteditor-input { min-height: 44px; max-height: 30vh !important; }
.aic-counter { display: none; position: absolute; right: 18px; bottom: 2px; font-size: 0.7rem; opacity: 0.7; pointer-events: none; }
.aic-counter.aic-counter-visible { display: block; }
.aic-counter.dx-color-danger { opacity: 1; }

/*CC- #3101: akcie pod odpoveďou AI — Kopírovať + hodnotenie (ai-chat-feedback.js) v jednom riadku */
.aic-msg-actions { display: flex; justify-content: flex-end; align-items: center; gap: 2px; margin-top: 4px; }
.aic-msg-actions .ai-feedback { margin-top: 0 !important; }

/*CC- #3101: galéria „Moje prílohy" */
.aic-gallery { display: flex; flex-direction: column; height: 100%; min-height: 0; }
.aic-gallery-body { flex: 1 1 auto; min-height: 0; overflow-y: auto; padding: 10px 2px; }
.aic-gallery-footer { display: flex; align-items: center; justify-content: space-between; font-size: 0.75rem; padding-top: 6px; }
.aic-gallery-footer #aicGalleryCount { opacity: 0.6; }
.aic-gallery-empty { text-align: center; opacity: 0.6; padding: 40px 0; }
.aic-gallery-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(170px, 1fr)); gap: 12px; }
.aic-gallery-tile { border: 1px solid var(--dx-color-border, #dee2e6); border-radius: 8px; overflow: hidden; display: flex; flex-direction: column; }
.aic-gallery-thumb { height: 130px; display: flex; align-items: center; justify-content: center; background: color-mix(in srgb, var(--dx-color-border) 30%, transparent); }
.aic-gallery-thumb img { max-width: 100%; max-height: 100%; object-fit: contain; cursor: pointer; }
.aic-gallery-caption { padding: 6px 8px 0 8px; min-width: 0; }
.aic-gallery-name { font-weight: 500; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.aic-gallery-meta { font-size: 0.75rem; opacity: 0.6; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.aic-gallery-actions { display: flex; justify-content: flex-end; flex: 0 0 auto; }
.aic-gallery-files { display: flex; flex-direction: column; }
.aic-gallery-file { display: flex; align-items: center; gap: 10px; padding: 6px 4px; border-bottom: 1px solid var(--dx-color-border, #dee2e6); }
.aic-gallery-file-icon { font-size: 1.3rem; opacity: 0.6; width: 24px; text-align: center; }
.aic-gallery-file-info { flex: 1 1 auto; min-width: 0; }

/*CC- #3101: plávajúci AI asistent (CORE _Layout) — vpravo medzi hlavičkou (57 px) a pätičkou (34 px), pevná šírka,
  prekrýva obsah bez backdropu. Zatvorený je mimo obrazovky a skrytý (visibility) — nedá sa doň tabovať. */
.ai-float-panel {
    position: fixed; top: 65px; right: 12px; bottom: 42px; width: 420px; max-width: calc(100vw - 24px);
    z-index: 1040; display: flex; flex-direction: column; padding: 10px;
    background: var(--dx-color-main-bg, #fff); color: var(--dx-color-text, #333);
    border: 1px solid var(--dx-color-border, #dee2e6); border-radius: 10px;
    box-shadow: 0 8px 28px rgba(0, 0, 0, 0.18);
    transform: translateX(calc(100% + 24px)); visibility: hidden;
    transition: transform 0.25s ease, visibility 0s linear 0.25s;
}
.ai-float-panel.open { transform: none; visibility: visible; transition: transform 0.25s ease, width 0.2s ease; }
/*CC- #3101: história konverzácií v paneli — rozbalená rozšíri panel na 760 px, zoznam vlákien je vľavo */
.ai-float-panel:not(.aic-collapsed) { width: 760px; }
.ai-float-body { flex: 1 1 auto; min-height: 0; display: flex; gap: 10px; }
.ai-float-threads {
    flex: 0 0 300px; min-width: 0; display: flex; flex-direction: column; gap: 6px;
    padding-right: 10px; border-right: 1px solid var(--dx-color-border, #dee2e6);
}
.ai-float-panel.aic-collapsed .ai-float-threads { display: none; }
.ai-float-chat { flex: 1 1 auto; min-width: 0; min-height: 0; display: flex; flex-direction: column; }
.ai-float-header { display: flex; align-items: center; gap: 4px; margin-bottom: 6px; }
/*CC- #3118: na úzkej obrazovke sa skracuje názov vlákna, nie tlačidlá (inak si orežú ikonu) */
.ai-float-header > .dx-button, .ai-float-header > .ai-float-link, .ai-float-header > .ai-float-icon { flex: 0 0 auto; }
.ai-float-header .aic-header-title { margin-left: 4px; }
.ai-float-icon { color: var(--dx-color-primary); font-size: 1.1rem; }
.ai-float-link { color: var(--dx-color-link, var(--dx-color-primary)); padding: 0 8px; }
.ai-float-flow { margin-bottom: 8px; }
.ai-float-flow .dx-buttongroup { width: 100%; }
.ai-float-flow .dx-buttongroup-item { flex: 1 1 0; }
#btnAiAssistant.active { color: var(--dx-color-primary); border-color: var(--dx-color-primary); }

/*CC- #3118: zákaznícka zóna — panel ako „bublina" nad robotom vpravo dole (#aiChatLauncher: right 20px,
  bottom 76px, 52 px). Zóna má vysokú fixnú hlavičku aj pätičku — výška podľa okna, najviac 640 px. */
.ai-float-panel.ai-float-cz { top: auto; right: 20px; bottom: 140px; height: min(640px, calc(100vh - 260px)); min-height: 360px; z-index: 1036; }
.ai-float-partner { margin-bottom: 8px; }
.ai-float-empty { padding: 24px 8px; text-align: center; opacity: 0.7; }
#aiChatLauncher.active { box-shadow: 0 0 0 4px color-mix(in srgb, var(--dx-color-primary, #84bd00) 35%, transparent); }
@media (max-width: 900px) {
    .ai-float-threads { flex-basis: 42%; }
}
@media (max-width: 576px) {
    /*CC- #3118: left+right 0 namiesto 100vw — 100vw zahŕňa aj zvislý posuvník a panel by trčal doľava */
    .ai-float-panel, .ai-float-panel:not(.aic-collapsed) { top: 57px; left: 0; right: 0; bottom: 0; width: auto; max-width: none; border-radius: 0; }
    /*CC- #3118: zóna na mobile — celá obrazovka nad hlavičkou aj pätičkou (zavrie sa krížikom) */
    .ai-float-panel.ai-float-cz, .ai-float-panel.ai-float-cz:not(.aic-collapsed) { top: 0; left: 0; right: 0; bottom: 0; width: auto; height: auto; min-height: 0; z-index: 1050; }
}

@media (max-width: 900px) {
    .aic-layout, .aic-layout.aic-collapsed { grid-template-columns: 1fr; height: auto; }
    .aic-panel-threads { max-height: 320px; }
    .aic-collapsed .aic-panel-threads { max-height: none; }
    .aic-collapsed .aic-threads-row { flex-direction: row; }
    .aic-panel-chat { height: 70vh; }
}
