/*
 * AI Enrichment plugin for GLPI — assistant chat widget styles.
 * Copyright (C) 2026 ReTech / UASK. GPL-3.0-or-later.
 */

.rta-root {
    --rta-primary: #206bc4;
    --rta-primary-d: #1a568f;
    position: fixed;
    right: 24px;
    bottom: 24px;
    z-index: 1035;
    font-size: 14px;
}

/* Launcher bubble */
.rta-launcher {
    width: 56px;
    height: 56px;
    border: 0;
    border-radius: 50%;
    background: var(--rta-primary);
    color: #fff;
    font-size: 26px;
    line-height: 1;
    cursor: pointer;
    box-shadow: 0 6px 20px rgba(0, 0, 0, .25);
    display: flex;
    align-items: center;
    justify-content: center;
    transition: transform .15s ease, background .15s ease;
}
.rta-launcher:hover { background: var(--rta-primary-d); transform: translateY(-2px); }
.rta-launcher.rta-open { transform: scale(.9); opacity: .85; }

/* Panel */
.rta-panel {
    position: absolute;
    right: 0;
    bottom: 72px;
    width: 380px;
    max-width: calc(100vw - 32px);
    height: 560px;
    max-height: calc(100vh - 120px);
    background: #fff;
    border-radius: 14px;
    box-shadow: 0 12px 40px rgba(0, 0, 0, .3);
    display: flex;
    flex-direction: column;
    overflow: hidden;
}
.rta-panel[hidden] { display: none; }

/* Maximized: fill the viewport */
.rta-panel.rta-maximized {
    position: fixed;
    right: 16px;
    bottom: 16px;
    top: 16px;
    left: 16px;
    width: auto !important;
    height: auto !important;
    max-width: none;
    max-height: none;
}

/* Drag handle (top-left corner) to resize */
.rta-resizer {
    position: absolute;
    top: 0;
    left: 0;
    width: 18px;
    height: 18px;
    cursor: nwse-resize;
    z-index: 6;
}
.rta-resizer::before {
    content: '';
    position: absolute;
    top: 5px; left: 5px;
    width: 8px; height: 8px;
    border-top: 2px solid rgba(255, 255, 255, .55);
    border-left: 2px solid rgba(255, 255, 255, .55);
    border-radius: 2px 0 0 0;
}
.rta-panel.rta-maximized .rta-resizer { display: none; }
body.rta-resizing { user-select: none; cursor: nwse-resize; }

.rta-head {
    background: var(--rta-primary);
    color: #fff;
    padding: 12px 14px;
    display: flex;
    align-items: center;
    gap: 8px;
}
.rta-title { font-weight: 600; flex: 1; }
.rta-head-actions { display: flex; gap: 2px; }
.rta-head button {
    background: transparent;
    border: 0;
    color: #fff;
    opacity: .8;
    cursor: pointer;
    font-size: 18px;
    padding: 2px 6px;
    border-radius: 6px;
}
.rta-head button:hover { opacity: 1; background: rgba(255, 255, 255, .15); }

/* Readiness indicator */
.rta-status { font-size: 12px; font-weight: 700; letter-spacing: .5px; display: inline-flex; align-items: center; gap: 6px; margin-right: 6px; }
.rta-ready { color: #cdeccf; }
.rta-working { color: #ffe6a3; }
.rta-caret { display: inline-block; width: 7px; height: 14px; background: currentColor; animation: rta-caretblink 1s steps(1) infinite; }
@keyframes rta-caretblink { 0%, 49% { opacity: 1; } 50%, 100% { opacity: 0; } }
.rta-spin { width: 12px; height: 12px; border: 2px solid rgba(255, 255, 255, .4); border-top-color: #fff; border-radius: 50%; animation: rta-spin .7s linear infinite; }
@keyframes rta-spin { to { transform: rotate(360deg); } }

/* Message list */
.rta-body {
    flex: 1;
    overflow-y: auto;
    padding: 14px;
    background: #f6f8fb;
    display: flex;
    flex-direction: column;
    gap: 10px;
}
.rta-msg { display: flex; }
.rta-msg.rta-user { justify-content: flex-end; }
.rta-bubble {
    max-width: 82%;
    padding: 9px 12px;
    border-radius: 14px;
    line-height: 1.45;
    white-space: normal;
    word-wrap: break-word;
    overflow-wrap: anywhere;
}
.rta-assistant .rta-bubble {
    background: #fff;
    color: #1b2536;
    border: 1px solid #e3e8ef;
    border-bottom-left-radius: 4px;
}
.rta-user .rta-bubble {
    background: var(--rta-primary);
    color: #fff;
    border-bottom-right-radius: 4px;
}
.rta-error .rta-bubble {
    background: #fce8e8;
    color: #a02020;
    border: 1px solid #f3c2c2;
}
.rta-bubble p:last-child { margin-bottom: 0; }
.rta-bubble ul { margin: 4px 0; padding-left: 18px; }
.rta-bubble pre {
    background: #0f172a;
    color: #e2e8f0;
    padding: 8px 10px;
    border-radius: 8px;
    overflow-x: auto;
    margin: 6px 0;
}
.rta-bubble code {
    background: rgba(0, 0, 0, .07);
    padding: 1px 4px;
    border-radius: 4px;
    font-size: .9em;
}
.rta-user .rta-bubble code { background: rgba(255, 255, 255, .2); }
.rta-bubble pre code { background: transparent; padding: 0; }
.rta-bubble a { color: inherit; text-decoration: underline; }

/* Typing indicator */
.rta-typing .rta-bubble { display: flex; gap: 4px; align-items: center; }
.rta-typing .rta-bubble span {
    width: 7px; height: 7px; border-radius: 50%;
    background: #9aa7b8; display: inline-block;
    animation: rta-blink 1.2s infinite both;
}
.rta-typing .rta-bubble span:nth-child(2) { animation-delay: .2s; }
.rta-typing .rta-bubble span:nth-child(3) { animation-delay: .4s; }
@keyframes rta-blink { 0%, 80%, 100% { opacity: .3; } 40% { opacity: 1; } }

/* Input */
.rta-input {
    display: flex;
    align-items: flex-end;
    gap: 8px;
    padding: 10px;
    border-top: 1px solid #e3e8ef;
    background: #fff;
}
.rta-input textarea {
    flex: 1;
    resize: none;
    border: 1px solid #d7dee8;
    border-radius: 10px;
    padding: 9px 12px;
    font: inherit;
    line-height: 1.4;
    max-height: 140px;
    outline: none;
}
.rta-input textarea:focus { border-color: var(--rta-primary); }
.rta-send {
    width: 40px;
    height: 40px;
    flex: 0 0 auto;
    border: 0;
    border-radius: 50%;
    background: var(--rta-primary);
    color: #fff;
    font-size: 18px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
}
.rta-send:hover { background: var(--rta-primary-d); }

/* Tool actions performed — a quiet footnote, not a console dump.
   Collapsed by default; the reply itself carries the answer. */
.rta-actions {
    background: transparent;
    border: 0;
    border-radius: 8px;
    padding: 0 2px;
    max-width: 92%;
    font-size: 11px;
}
.rta-actions summary {
    cursor: pointer;
    color: #93a1b5;
    font-weight: 500;
    list-style: none;
    padding: 1px 0;
}
.rta-actions summary::-webkit-details-marker { display: none; }
.rta-actions summary:hover { color: #5b6b80; }
.rta-actions[open] summary { margin-bottom: 4px; }
.rta-action { margin-top: 6px; }
.rta-action-cmd {
    font-family: ui-monospace, Menlo, Consolas, monospace;
    color: #0f3d63;
    word-break: break-all;
    margin-bottom: 2px;
}
.rta-action-res {
    background: #0f172a;
    color: #cbd5e1;
    padding: 6px 8px;
    border-radius: 6px;
    max-height: 180px;
    overflow: auto;
    white-space: pre-wrap;
    word-break: break-word;
    margin: 0;
}

/* Pending deletion confirmation */
.rta-pending {
    background: #fff7ed;
    border: 1px solid #fed7aa;
    border-radius: 12px;
    padding: 10px 12px;
    max-width: 92%;
}
.rta-pending-head { font-weight: 700; color: #b45309; margin-bottom: 6px; }
.rta-pending-cmd {
    font-family: ui-monospace, Menlo, Consolas, monospace;
    background: #1f2937;
    color: #fde68a;
    padding: 6px 8px;
    border-radius: 6px;
    white-space: pre-wrap;
    word-break: break-word;
    margin: 0 0 8px;
}
.rta-pending-actions { display: flex; gap: 8px; }
.rta-confirm-yes, .rta-confirm-no {
    border: 0; border-radius: 8px; padding: 6px 14px; cursor: pointer; font: inherit; font-weight: 600;
}
.rta-confirm-yes { background: #dc2626; color: #fff; }
.rta-confirm-yes:disabled { background: #f0a3a3; cursor: default; }
.rta-confirm-no { background: #e5e7eb; color: #374151; }
.rta-pending-out { margin: 8px 0 0; white-space: pre-wrap; word-break: break-word; color: #334155; }
.rta-pending.rta-done { background: #ecfdf5; border-color: #a7f3d0; }
.rta-pending.rta-cancelled { opacity: .7; }

/* Images in bubbles */
.rta-imgs { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 6px; }
.rta-img {
    max-width: 160px; max-height: 160px; border-radius: 8px; cursor: zoom-in;
    border: 1px solid rgba(0, 0, 0, .1); object-fit: cover;
}
.rta-user .rta-img { border-color: rgba(255, 255, 255, .3); }
.rta-bubble blockquote {
    margin: 4px 0; padding: 2px 0 2px 10px; border-left: 3px solid #b9c4d4;
    color: #5b6b80; font-style: italic;
}
.rta-user .rta-bubble blockquote { border-left-color: rgba(255, 255, 255, .5); color: #e8eefb; }

/* Lightbox */
.rta-lightbox {
    position: fixed; inset: 0; z-index: 1100; background: rgba(0, 0, 0, .8);
    display: flex; align-items: center; justify-content: center; cursor: zoom-out;
}
.rta-lightbox img { max-width: 92vw; max-height: 92vh; border-radius: 8px; }

/* Staged attachments strip */
.rta-attachments { display: flex; flex-wrap: wrap; gap: 6px; padding: 8px 10px 0; }
.rta-thumb { position: relative; width: 54px; height: 54px; }
.rta-thumb img { width: 100%; height: 100%; object-fit: cover; border-radius: 8px; border: 1px solid #d7dee8; }
.rta-thumb-x {
    position: absolute; top: -6px; right: -6px; width: 18px; height: 18px; line-height: 16px;
    border: 0; border-radius: 50%; background: #dc2626; color: #fff; cursor: pointer; font-size: 13px; padding: 0;
}
.rta-panel.rta-drag { outline: 3px dashed var(--rta-primary); outline-offset: -6px; }

/* Attach (paperclip) button */
.rta-attach {
    width: 36px; height: 40px; flex: 0 0 auto; border: 0; background: transparent;
    color: #7686a0; cursor: pointer; font-size: 18px;
}
.rta-attach:hover { color: var(--rta-primary); }

/* Floating "quote selection" button */
.rta-quote {
    position: absolute; z-index: 5; border: 0; border-radius: 8px; padding: 5px 10px;
    background: #1f2937; color: #fff; font: inherit; font-size: 12px; cursor: pointer;
    box-shadow: 0 3px 10px rgba(0, 0, 0, .3); white-space: nowrap;
}
.rta-quote:hover { background: #111827; }

@media (max-width: 480px) {
    .rta-root { right: 16px; bottom: 16px; }
    .rta-panel {
        width: calc(100vw - 24px);
        height: calc(100vh - 96px);
        right: -4px;
    }
}
