/* ===========================
   Flasker AI Signal Panel v0.5
   Stable: left+right layout, no width property, no reflow animations
   =========================== */

:root {
    --fsp-bg:          rgba(9, 9, 9, 0.95);
    --fsp-border:      rgba(255, 255, 255, 0.055);
    --fsp-border-sub:  rgba(255, 255, 255, 0.035);

    /* Низько-контрастний текст */
    --fsp-text:        #545454;
    --fsp-text-mid:    #404040;
    --fsp-text-dim:    #2c2c2c;
    --fsp-text-hi:     #909090;

    /* Кольорові акценти тільки для тегів */
    --fsp-match:   #3d7ca8;
    --fsp-trend:   #7a5f26;
    --fsp-hint:    #3a3a3a;
    --fsp-rare:    #5c3e80;
    --fsp-link:    #2a5e4a;
    --fsp-dot-on:  #3aeb85;
    --fsp-dot-off: #252525;

    --fsp-font: -apple-system, BlinkMacSystemFont, 'Segoe UI', 'Inter', Arial, sans-serif;
    --fsp-mono: 'Consolas', 'SF Mono', monospace;
}

/* ── Панель: left+right:0, без width ──────────────────────────
   Позиція встановлюється з JS через panel.style.left
   Не використовуємо width взагалі → нуль стрибків                */
#fsp-panel {
    position: fixed;
    top: 0;
    right: 0;
    bottom: 0;
    left: 80vw; /* fallback, одразу замінюється JS */

    background: var(--fsp-bg);
    border-left: 1px solid var(--fsp-border);
    z-index: 9990;
    font-family: var(--fsp-font);
    font-size: 12px;
    color: var(--fsp-text);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    pointer-events: none;
    display: none; /* прихований до init, без opacity flash */
    flex-direction: column;
    overflow: hidden;
}

/* Показуємо тільки після calcLeft() */
#fsp-panel.fsp-ready {
    display: flex;
}

/* Анімація першої появи — тільки opacity, без width/transform */
#fsp-panel.fsp-ready {
    animation: fsp-panel-in 0.5s ease forwards;
}

@keyframes fsp-panel-in {
    from { opacity: 0; }
    to   { opacity: 1; }
}

#fsp-panel.fsp-hidden {
    display: none;
}

/* ── Scroll-контейнер ──────────────────────────────────────── */
.fsp-inner {
    display: flex;
    flex-direction: column;
    height: 100%;
    padding: 18px 14px;
    overflow-y: auto;
    scrollbar-width: none;
}
.fsp-inner::-webkit-scrollbar { display: none; }

/* ── Хедер ─────────────────────────────────────────────────── */
.fsp-header {
    display: flex;
    align-items: center;
    gap: 7px;
    margin-bottom: 14px;
    padding-bottom: 10px;
    border-bottom: 1px solid var(--fsp-border);
    flex-shrink: 0;
}

.fsp-dot {
    width: 6px;
    height: 6px;
    border-radius: 50%;
    background: var(--fsp-dot-off);
    flex-shrink: 0;
    transition: background 0.6s ease, box-shadow 0.6s ease;
}

.fsp-state-thinking .fsp-dot {
    background: var(--fsp-dot-on);
    animation: fsp-pulse 1.6s ease-in-out infinite;
}
.fsp-state-result .fsp-dot,
.fsp-state-refinement .fsp-dot {
    background: var(--fsp-dot-on);
    box-shadow: 0 0 7px rgba(58,235,133,0.2);
}

@keyframes fsp-pulse {
    0%,100% { box-shadow: 0 0 0 0 rgba(58,235,133,0.15); }
    50%     { box-shadow: 0 0 0 5px rgba(58,235,133,0); opacity: 0.5; }
}

.fsp-label {
    font-size: 9px;
    letter-spacing: 0.2em;
    color: var(--fsp-text-dim);
    text-transform: uppercase;
}
.fsp-label-ver {
    margin-left: auto;
    font-size: 8px;
    color: var(--fsp-text-dim);
    opacity: 0.4;
}

/* ── 3 блоки ───────────────────────────────────────────────── */
.fsp-block {
    flex: 1;
    min-height: 0;
    display: flex;
    flex-direction: column;
    padding: 10px 0;
    border-bottom: 1px solid var(--fsp-border-sub);
    overflow: hidden;
}
.fsp-block:last-child { border-bottom: none; }

.fsp-block-label {
    font-size: 8px;
    letter-spacing: 0.18em;
    color: var(--fsp-text-dim);
    text-transform: uppercase;
    margin-bottom: 9px;
    flex-shrink: 0;
}

/* ── Block A: Reasoning ────────────────────────────────────── */
.fsp-reasoning {
    flex: 1;
    overflow: hidden;
    display: flex;
    flex-direction: column;
    gap: 5px;
    position: relative;
}

/* Fade-маска знизу */
.fsp-reasoning::after {
    content: '';
    position: absolute;
    bottom: 0; left: 0; right: 0;
    height: 20px;
    background: linear-gradient(transparent, var(--fsp-bg));
    pointer-events: none;
}

.fsp-reason-line {
    font-size: 11px;
    color: var(--fsp-text-mid);
    letter-spacing: 0.02em;
    line-height: 1.5;
    flex-shrink: 0;
    /* НЕ використовуємо max-width — уникаємо reflow! */
    opacity: 0;
    transform: translateY(4px);
    animation: fsp-line-in 0.35s ease forwards;
}
@keyframes fsp-line-in {
    to { opacity: 1; transform: translateY(0); }
}

/* "Переосмислення": старий рядок лише фейдиться, новий фейдиться поверх */
.fsp-reason-line.fsp-fade-out {
    animation: fsp-fade-out 0.4s ease forwards;
}
@keyframes fsp-fade-out {
    to { opacity: 0; }
}

/* Підказка статусу */
.fsp-status-text {
    font-size: 10.5px;
    color: var(--fsp-text-dim);
    margin-top: 6px;
    font-style: italic;
    flex-shrink: 0;
    min-height: 14px;
    transition: opacity 0.4s ease;
}
.fsp-shimmer {
    background: linear-gradient(90deg, #282828 25%, #484848 50%, #282828 75%);
    background-size: 200% 100%;
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    animation: fsp-shimmer 2s linear infinite;
}
@keyframes fsp-shimmer {
    0%   { background-position: 200% center; }
    100% { background-position: -200% center; }
}

/* ── Block B: Signals ──────────────────────────────────────── */
.fsp-signals-wrap {
    flex: 1;
    overflow: hidden;
    position: relative;
    display: flex;
    flex-direction: column;
    justify-content: flex-end;
}
/* Fade зверху — ефект "проявлення" знизу */
.fsp-signals-wrap::before {
    content: '';
    position: absolute;
    top: 0; left: 0; right: 0;
    height: 28px;
    background: linear-gradient(var(--fsp-bg), transparent);
    z-index: 1;
    pointer-events: none;
}

.fsp-signals {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.fsp-signal-row {
    display: flex;
    flex-direction: column;
    gap: 1px;
    padding-bottom: 7px;
    border-bottom: 1px solid var(--fsp-border-sub);
    /* Scroll-up reveal — тільки transform+opacity, без layout */
    opacity: 0;
    transform: translateY(6px);
    animation: fsp-scrollup 0.45s ease forwards;
}
.fsp-signal-row:last-child { border-bottom: none; }

@keyframes fsp-scrollup {
    to { opacity: 1; transform: translateY(0); }
}

.fsp-signal-row.fsp-stale {
    opacity: 0.1;
    transition: opacity 0.7s ease;
}

.fsp-signal-tag {
    font-size: 8px;
    letter-spacing: 0.1em;
    font-family: var(--fsp-mono);
    font-weight: 500;
}
.fsp-signal-tag.match { color: var(--fsp-match); }
.fsp-signal-tag.trend { color: var(--fsp-trend); }
.fsp-signal-tag.hint  { color: var(--fsp-hint); }
.fsp-signal-tag.rare  { color: var(--fsp-rare); }

.fsp-signal-text {
    font-size: 12px;
    color: var(--fsp-text);
    line-height: 1.45;
}
.fsp-glow { color: var(--fsp-text-hi); }

.fsp-link-hint {
    font-size: 10px;
    color: var(--fsp-link);
    border-bottom: 1px solid rgba(42,94,74,0.2);
    margin-top: 2px;
    display: inline-block;
    opacity: 0.7;
}

.fsp-updated-badge {
    font-size: 8px;
    color: var(--fsp-dot-on);
    margin-left: 5px;
    opacity: 0.5;
}

/* ── Block C: Confidence bars ──────────────────────────────── */
.fsp-confidence {
    flex: 1;
    display: flex;
    flex-direction: column;
    gap: 7px;
    justify-content: center;
}
.fsp-conf-row { display: flex; flex-direction: column; gap: 3px; }
.fsp-conf-label {
    font-size: 9.5px;
    color: var(--fsp-text-dim);
    letter-spacing: 0.03em;
}
.fsp-conf-bar-wrap {
    height: 1px;
    background: rgba(255,255,255,0.04);
    border-radius: 1px;
    overflow: visible;
    position: relative;
}
.fsp-conf-bar {
    height: 1px;
    background: rgba(255,255,255,0.18);
    border-radius: 1px;
    width: 0%;
    transition: width 1.1s cubic-bezier(0.16, 1, 0.3, 1);
    /* transition-delay встановлюється inline */
}
