/* ═══════════════════════════════════════════════════════════════════════════
   LLM Assistant — Floating Chat Widget
   ═══════════════════════════════════════════════════════════════════════════ */

/* ── Floating Action Button ─────────────────────────────────────────────── */

.llm-fab {
    position: fixed;
    bottom: 24px;
    right: 24px;
    z-index: 1090;
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 11px 18px 11px 14px;
    background: linear-gradient(135deg, #2563eb 0%, #1d4ed8 100%);
    color: #fff;
    border: none;
    border-radius: 50px;
    font-size: 0.875rem;
    font-weight: 600;
    cursor: pointer;
    box-shadow: 0 4px 16px rgba(37, 99, 235, 0.45);
    transition: transform 0.18s ease, box-shadow 0.18s ease, background 0.18s ease;
    outline: none;
}

.llm-fab:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 22px rgba(37, 99, 235, 0.55);
    background: linear-gradient(135deg, #1d4ed8 0%, #1e40af 100%);
}

.llm-fab:active {
    transform: translateY(0);
}

.llm-fab-badge {
    position: absolute;
    top: -4px;
    right: -4px;
    width: 12px;
    height: 12px;
    background: #ef4444;
    border-radius: 50%;
    font-size: 0;
    border: 2px solid #fff;
    animation: llm-pulse 1.4s infinite;
}

@keyframes llm-pulse {
    0%, 100% { opacity: 1; transform: scale(1); }
    50%       { opacity: 0.6; transform: scale(1.3); }
}

/* ── Chat Panel ──────────────────────────────────────────────────────────── */

.llm-panel {
    position: fixed;
    bottom: 88px;
    right: 24px;
    z-index: 1089;
    width: 480px;
    max-width: calc(100vw - 32px);
    height: 660px;
    max-height: calc(100vh - 110px);
    background: #fff;
    border-radius: 16px;
    box-shadow: 0 8px 40px rgba(0, 0, 0, 0.18), 0 2px 8px rgba(0, 0, 0, 0.08);
    display: flex;
    flex-direction: column;
    overflow: hidden;
    transition: opacity 0.2s ease, transform 0.2s ease;
    border: 1px solid rgba(0,0,0,0.08);
}

.llm-panel--closed {
    opacity: 0;
    transform: translateY(12px) scale(0.97);
    pointer-events: none;
}

.llm-panel--open {
    opacity: 1;
    transform: translateY(0) scale(1);
    pointer-events: all;
}

/* ── Header ──────────────────────────────────────────────────────────────── */

.llm-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 12px 14px;
    background: linear-gradient(135deg, #1e40af 0%, #2563eb 100%);
    color: #fff;
    flex-shrink: 0;
}

.llm-header-info {
    display: flex;
    align-items: center;
    gap: 10px;
}

.llm-header-avatar {
    width: 34px;
    height: 34px;
    background: rgba(255,255,255,0.18);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

.llm-header-title {
    font-size: 0.9rem;
    font-weight: 700;
    line-height: 1.2;
}

.llm-header-subtitle {
    font-size: 0.72rem;
    opacity: 0.8;
    margin-top: 1px;
}

.llm-header-actions {
    display: flex;
    gap: 4px;
}

.llm-icon-btn {
    background: rgba(255,255,255,0.15);
    border: none;
    border-radius: 6px;
    color: #fff;
    width: 28px;
    height: 28px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: background 0.15s;
    padding: 0;
}

.llm-icon-btn:hover {
    background: rgba(255,255,255,0.28);
}

/* ── Messages ────────────────────────────────────────────────────────────── */

.llm-messages {
    flex: 1;
    overflow-y: auto;
    padding: 14px 12px;
    display: flex;
    flex-direction: column;
    gap: 10px;
    scroll-behavior: smooth;
}

.llm-messages::-webkit-scrollbar { width: 4px; }
.llm-messages::-webkit-scrollbar-track { background: transparent; }
.llm-messages::-webkit-scrollbar-thumb { background: #d1d5db; border-radius: 4px; }

.llm-msg {
    display: flex;
    max-width: 88%;
}

.llm-msg--user {
    align-self: flex-end;
    flex-direction: row-reverse;
}

.llm-msg--assistant {
    align-self: flex-start;
}

.llm-msg-bubble {
    padding: 9px 13px;
    border-radius: 14px;
    font-size: 0.845rem;
    line-height: 1.5;
    word-break: break-word;
}

.llm-msg--user .llm-msg-bubble {
    background: linear-gradient(135deg, #2563eb, #1d4ed8);
    color: #fff;
    border-bottom-right-radius: 4px;
}

.llm-msg--assistant .llm-msg-bubble {
    background: #f1f5f9;
    color: #1e293b;
    border-bottom-left-radius: 4px;
}

.llm-msg--error .llm-msg-bubble {
    background: #fef2f2;
    color: #b91c1c;
    border: 1px solid #fecaca;
}

.llm-intro-list {
    margin: 6px 0 0 0;
    padding-left: 18px;
    font-size: 0.83rem;
}

.llm-intro-list li {
    margin-bottom: 3px;
}

/* ── Typing indicator ────────────────────────────────────────────────────── */

.llm-typing .llm-msg-bubble {
    display: flex;
    align-items: center;
    gap: 4px;
    padding: 11px 14px;
    min-width: 52px;
}

.llm-dot {
    width: 7px;
    height: 7px;
    background: #94a3b8;
    border-radius: 50%;
    animation: llm-bounce 1.2s infinite;
}

.llm-dot:nth-child(2) { animation-delay: 0.2s; }
.llm-dot:nth-child(3) { animation-delay: 0.4s; }

@keyframes llm-bounce {
    0%, 80%, 100% { transform: translateY(0); opacity: 0.5; }
    40%           { transform: translateY(-6px); opacity: 1; }
}

/* ── Progress bubble ─────────────────────────────────────────────────────── */

.llm-msg--progress .llm-msg-bubble {
    background: linear-gradient(135deg, #eff6ff 0%, #f0fdf4 100%);
    border: 1px solid #bfdbfe;
    color: #1e40af;
    font-size: 13px;
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 8px 14px;
    border-radius: 12px;
    min-width: 180px;
    animation: llm-progress-pulse 2s ease-in-out infinite;
}

.llm-msg--progress .llm-progress-icon {
    font-size: 15px;
    flex-shrink: 0;
}

.llm-msg--progress .llm-progress-text {
    flex: 1;
}

@keyframes llm-progress-pulse {
    0%, 100% { opacity: 1; }
    50%       { opacity: 0.7; }
}

/* ── File Preview ────────────────────────────────────────────────────────── */

.llm-file-preview {
    display: flex;
    align-items: flex-start;
    gap: 6px;
    margin: 0 12px 4px;
    padding: 7px 10px;
    background: #eff6ff;
    border: 1px solid #bfdbfe;
    border-radius: 8px;
    font-size: 0.8rem;
    color: #1e40af;
    flex-shrink: 0;
}

.llm-file-list {
    flex: 1;
    display: flex;
    flex-wrap: wrap;
    gap: 5px;
    min-width: 0;
}

.llm-file-chip {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    background: #dbeafe;
    border: 1px solid #93c5fd;
    border-radius: 20px;
    padding: 2px 8px 2px 10px;
    font-size: 0.78rem;
    color: #1e40af;
    max-width: 100%;
    word-break: break-all;
}

.llm-file-chip-remove {
    background: none;
    border: none;
    color: #6b7280;
    cursor: pointer;
    padding: 0;
    font-size: 0.75rem;
    line-height: 1;
    flex-shrink: 0;
    margin-left: 2px;
}

.llm-file-chip-remove:hover { color: #ef4444; }

.llm-file-remove {
    background: none;
    border: none;
    color: #9ca3af;
    cursor: pointer;
    padding: 0;
    font-size: 0.85rem;
    line-height: 1;
    flex-shrink: 0;
    align-self: flex-start;
    margin-top: 1px;
}

.llm-file-remove:hover { color: #ef4444; }

/* ── Input Area ──────────────────────────────────────────────────────────── */

.llm-input-area {
    display: flex;
    align-items: flex-end;
    gap: 6px;
    padding: 10px 12px;
    border-top: 1px solid #e5e7eb;
    flex-shrink: 0;
    background: #fafafa;
}

.llm-attach-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 34px;
    height: 34px;
    border-radius: 8px;
    color: #6b7280;
    cursor: pointer;
    flex-shrink: 0;
    transition: background 0.15s, color 0.15s;
    margin-bottom: 1px;
}

.llm-attach-btn:hover {
    background: #e5e7eb;
    color: #2563eb;
}

.llm-textarea {
    flex: 1;
    resize: none;
    border: 1px solid #d1d5db;
    border-radius: 10px;
    padding: 7px 11px;
    font-size: 0.855rem;
    line-height: 1.45;
    font-family: inherit;
    color: #1e293b;
    background: #fff;
    outline: none;
    transition: border-color 0.15s;
    min-height: 36px;
    max-height: 120px;
    overflow-y: auto;
}

.llm-textarea:focus {
    border-color: #2563eb;
    box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.1);
}

.llm-textarea:disabled {
    background: #f9fafb;
    color: #9ca3af;
}

.llm-send-btn {
    width: 34px;
    height: 34px;
    border-radius: 8px;
    background: #2563eb;
    color: #fff;
    border: none;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    flex-shrink: 0;
    transition: background 0.15s, transform 0.1s;
    margin-bottom: 1px;
}

.llm-send-btn:hover:not(:disabled) {
    background: #1d4ed8;
    transform: translateY(-1px);
}

.llm-send-btn:disabled {
    background: #9ca3af;
    cursor: not-allowed;
    transform: none;
}

/* ── Drag & Drop ─────────────────────────────────────────────────────────── */

.llm-panel--dragover {
    outline: 3px dashed #2563eb;
    outline-offset: -4px;
}

.llm-drop-overlay {
    position: absolute;
    inset: 0;
    z-index: 20;
    background: rgba(37, 99, 235, 0.08);
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 10px;
    border-radius: 16px;
    pointer-events: none;
    opacity: 0;
    transition: opacity 0.15s ease;
}

.llm-panel--dragover .llm-drop-overlay {
    opacity: 1;
    pointer-events: all;
}

.llm-drop-overlay-icon {
    font-size: 2.5rem;
    line-height: 1;
}

.llm-drop-overlay-text {
    font-size: 0.95rem;
    font-weight: 600;
    color: #1d4ed8;
}

.llm-drop-overlay-hint {
    font-size: 0.77rem;
    color: #6b7280;
}

/* Globalny drop indicator (gdy panel zamknięty) */
.llm-global-drop-banner {
    position: fixed;
    bottom: 88px;
    right: 24px;
    z-index: 1091;
    background: linear-gradient(135deg, #2563eb, #1d4ed8);
    color: #fff;
    border-radius: 14px;
    padding: 14px 20px;
    font-size: 0.9rem;
    font-weight: 600;
    display: flex;
    align-items: center;
    gap: 10px;
    box-shadow: 0 4px 20px rgba(37, 99, 235, 0.45);
    opacity: 0;
    transform: translateY(8px);
    transition: opacity 0.18s ease, transform 0.18s ease;
    pointer-events: none;
}

.llm-global-drop-banner.llm-drop-active {
    opacity: 1;
    transform: translateY(0);
}

/* ── Highlight effect (po wypełnieniu pola przez AI) ─────────────────────── */

.llm-highlight {
    animation: llm-field-flash 1.8s ease forwards;
}

@keyframes llm-field-flash {
    0%   { box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.6); background-color: #eff6ff; }
    60%  { box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.3); background-color: #eff6ff; }
    100% { box-shadow: none; background-color: inherit; }
}

/* ── History Overlay Panel ───────────────────────────────────────────────── */

.llm-history-overlay {
    position: absolute;
    inset: 0;
    background: #fff;
    border-radius: 16px;
    display: flex;
    flex-direction: column;
    z-index: 10;
    overflow: hidden;
}

.llm-history-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 12px 14px;
    background: linear-gradient(135deg, #1e40af 0%, #2563eb 100%);
    color: #fff;
    font-size: 0.9rem;
    font-weight: 700;
    flex-shrink: 0;
}

.llm-history-list {
    flex: 1;
    overflow-y: auto;
    padding: 8px 0;
}

.llm-history-list::-webkit-scrollbar { width: 4px; }
.llm-history-list::-webkit-scrollbar-track { background: transparent; }
.llm-history-list::-webkit-scrollbar-thumb { background: #d1d5db; border-radius: 4px; }

.llm-history-loading,
.llm-history-empty {
    padding: 24px 16px;
    text-align: center;
    color: #9ca3af;
    font-size: 0.85rem;
}

.llm-history-item {
    padding: 10px 14px;
    cursor: pointer;
    border-bottom: 1px solid #f1f5f9;
    transition: background 0.12s;
}

.llm-history-item:hover {
    background: #eff6ff;
}

.llm-history-item:last-child {
    border-bottom: none;
}

.llm-history-item-title {
    font-size: 0.855rem;
    font-weight: 600;
    color: #1e293b;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    margin-bottom: 3px;
}

.llm-history-item-meta {
    display: flex;
    gap: 10px;
    font-size: 0.73rem;
    color: #94a3b8;
    margin-bottom: 3px;
}

.llm-history-item-preview {
    font-size: 0.77rem;
    color: #64748b;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

/* ── Rating Bar ──────────────────────────────────────────────────────────── */

.llm-rating-bar {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 8px 12px;
    background: #fefce8;
    border-top: 1px solid #fde68a;
    flex-shrink: 0;
}

.llm-rating-label {
    font-size: 0.78rem;
    color: #78350f;
    white-space: nowrap;
}

.llm-rating-stars {
    display: flex;
    gap: 2px;
}

.llm-rating-stars button {
    background: none;
    border: none;
    font-size: 1.2rem;
    color: #d97706;
    cursor: pointer;
    padding: 0 1px;
    line-height: 1;
    opacity: 0.45;
    transition: opacity 0.12s, transform 0.1s;
}

.llm-rating-stars button:hover,
.llm-rating-stars button:hover ~ button {
    opacity: 1;
}

.llm-rating-stars:hover button {
    opacity: 0.45;
}

.llm-rating-stars button:hover {
    opacity: 1;
    transform: scale(1.2);
}

.llm-rating-skip {
    background: none;
    border: none;
    font-size: 0.72rem;
    color: #9ca3af;
    cursor: pointer;
    margin-left: auto;
    padding: 2px 4px;
    white-space: nowrap;
}

.llm-rating-skip:hover {
    color: #6b7280;
    text-decoration: underline;
}

/* ── Mobile responsive ───────────────────────────────────────────────────── */

@media (max-width: 480px) {
    .llm-panel {
        bottom: 0;
        right: 0;
        left: 0;
        width: 100%;
        max-width: 100%;
        border-radius: 16px 16px 0 0;
        height: 70vh;
    }

    .llm-fab {
        bottom: 16px;
        right: 16px;
    }

    .llm-fab-label {
        display: none;
    }

    .llm-fab {
        padding: 12px;
        border-radius: 50%;
        width: 52px;
        height: 52px;
        justify-content: center;
    }
}
