/* Полигон видимости — вид на /research. Наследует HUD-переменные из shortener.css. */

/* Атрибут hidden должен побеждать display:grid обоих видов (иначе не прячутся) */
#view-links[hidden], #view-polygon[hidden] { display: none !important; }

/* Тумблер видов в шапке */
.view-switch { display: flex; border: 1px solid var(--hud-line); align-self: center; margin: 0 0.6rem; }
.vswitch {
    display: inline-flex; align-items: center; gap: 0.4rem;
    background: transparent; border: none; border-right: 1px solid var(--hud-line);
    color: var(--hud-muted); font-family: inherit; font-size: 0.62rem;
    letter-spacing: 1px; text-transform: uppercase; padding: 0.45rem 0.8rem; cursor: pointer;
}
.vswitch:last-child { border-right: none; }
.vswitch.active { background: rgba(63, 211, 255, 0.14); color: var(--hud-cyan); }
@media (hover: hover) { .vswitch:hover { color: var(--hud-cyan); } }

/* Плитки полигона в шапке (рядом с #tiles) */
.pg-htiles { grid-template-columns: 1.25fr repeat(4, 1fr); }
.tile.pg-state .tile-value { letter-spacing: 1px; }
.tile.danger { border-left-color: var(--hud-red); }
.tile.danger .tile-value { color: var(--hud-red); text-shadow: 0 0 14px rgba(255, 84, 112, 0.35); }
.tile.ok { border-left-color: #3ad29a; }
.tile.ok .tile-value { color: #3ad29a; }

/* Сетка полигона: слева типы(коротко)+поток, справа длинная таблица источников */
.pg-layout {
    flex: 1; min-height: 0; display: grid; gap: 0.75rem; padding: 0.75rem;
    grid-template-columns: 1fr 1.05fr;
    grid-template-rows: auto minmax(0, 1fr);
    grid-template-areas:
        "cats    sources"
        "feed    sources";
}
.pg-area-cats    { grid-area: cats; }
.pg-area-sources { grid-area: sources; min-height: 0; }
.pg-area-feed    { grid-area: feed; min-height: 0; }
.pg-area-sources .table-wrap, .pg-area-feed { overflow-y: auto; min-height: 0; }
.pg-area-sources { display: flex; flex-direction: column; }
.pg-area-sources .table-wrap { flex: 1; }
@media (max-width: 900px) {
    .pg-layout { grid-template-columns: 1fr; grid-template-rows: none;
        grid-template-areas: "cats" "sources" "feed"; }
    .pg-area-sources .table-wrap { max-height: 320px; }
    .pg-area-feed { max-height: 300px; }
}

/* Категории — плотные чипсы */
.pg-cats { display: flex; flex-wrap: wrap; gap: 0.45rem; padding: 0.55rem 0.8rem 0.8rem; }
.pg-cat {
    display: flex; align-items: center; gap: 0.45rem;
    border: 1px solid var(--hud-line); border-left-width: 3px; padding: 0.3rem 0.55rem;
    background: rgba(63, 211, 255, 0.04);
}
.pg-cat-count { font-size: 0.9rem; font-weight: 700; color: var(--hud-text); }
.pg-cat-label { font-size: 0.58rem; color: var(--hud-muted); }

/* Таблица источников */
.pg-ip { font-family: ui-monospace, monospace; color: var(--hud-text); }
.pg-live { margin-left: 0.35rem; color: var(--hud-red); }
.pg-row { cursor: pointer; }
.pg-row.is-active { background: rgba(255, 84, 112, 0.08) !important; }
.pg-tools { color: var(--hud-muted); font-size: 0.6rem; }
.pg-when { color: var(--hud-muted); font-size: 0.62rem; white-space: nowrap; }
#pg-attackers td { padding: 0.3rem 0.5rem; }

/* Бейдж категории */
.pg-badge {
    display: inline-block; max-width: 180px; font-size: 0.55rem; letter-spacing: 0.3px;
    padding: 0.1rem 0.38rem; border: 1px solid currentColor; border-radius: 2px;
    white-space: nowrap; overflow: hidden; text-overflow: ellipsis; vertical-align: middle;
}

/* Поток событий */
.pg-feed { list-style: none; margin: 0; padding: 0.35rem 0.55rem 0.7rem; }
.pg-ev {
    display: flex; align-items: baseline; gap: 0.45rem; flex-wrap: wrap;
    padding: 0.26rem 0.35rem; border-bottom: 1px solid rgba(63, 211, 255, 0.08);
    font-size: 0.64rem; border-left: 2px solid transparent;
}
.pg-ev-time { color: var(--hud-muted); font-family: ui-monospace, monospace; font-size: 0.58rem; }
.pg-ev-ip { color: var(--hud-cyan); font-family: ui-monospace, monospace; }
.pg-ev-detail { color: var(--hud-text); word-break: break-all; flex: 1; }
.pg-ev-tool { color: var(--hud-gold); font-size: 0.56rem; }
.pg-ev-count { color: var(--hud-cyan); font-weight: 700; font-size: 0.6rem; }

/* Цвета по severity */
.sev-crit { color: var(--hud-red); border-left-color: var(--hud-red); }
.sev-high { color: #ff8a3d; border-left-color: #ff8a3d; }
.sev-med  { color: var(--hud-gold); border-left-color: var(--hud-gold); }
.sev-low  { color: var(--hud-cyan); border-left-color: var(--hud-cyan); }
.sev-info { color: var(--hud-muted); border-left-color: var(--hud-muted); }
.pg-cat.sev-crit .pg-cat-count { color: var(--hud-red); }
.pg-cat.sev-high .pg-cat-count { color: #ff8a3d; }

/* Пульс всей панели, когда идёт скан */
#view-polygon[data-state="under_attack"] .pg-htiles .tile.pg-state { animation: pgpulse 1.1s infinite; }
@keyframes pgpulse { 0%,100% { box-shadow: 0 0 0 0 rgba(255,84,112,0.6);} 50% { box-shadow: 0 0 0 6px rgba(255,84,112,0);} }

/* Модалка (детали по IP / как проверить) */
.pg-modal {
    position: fixed; inset: 0; background: rgba(2, 5, 10, 0.78);
    display: flex; align-items: center; justify-content: center; z-index: 2200; padding: 1rem;
}
.pg-modal-card {
    background: var(--hud-bg); border: 1px solid var(--hud-cyan-dim);
    width: min(680px, 96vw); max-height: 80vh; display: flex; flex-direction: column;
    box-shadow: 0 0 40px rgba(63, 211, 255, 0.15);
}
.pg-modal-head { display: flex; align-items: center; justify-content: space-between; padding: 0.6rem 1rem; border-bottom: 1px solid var(--hud-line); }
.pg-modal-head h3 { margin: 0; font-size: 0.85rem; color: var(--hud-cyan); font-family: ui-monospace, monospace; letter-spacing: 1px; }
.pg-modal-body { overflow-y: auto; padding: 0.4rem 0; }

/* Отпечаток клиента в детали по IP */
.pg-fp { border: 1px solid var(--hud-line); border-left: 3px solid var(--hud-cyan); padding: 0.5rem 0.7rem; margin: 0.4rem 1rem 0.2rem; background: rgba(63, 211, 255, 0.04); }
.pg-fp-sum { color: var(--hud-cyan); font-size: 0.75rem; letter-spacing: 0.3px; }
.pg-fp-risks { list-style: none; margin: 0.35rem 0 0; padding: 0; }
.pg-fp-risks li { color: var(--hud-gold); font-size: 0.62rem; padding: 0.1rem 0; display: flex; flex-direction: column; }
.pg-fp-cve { color: var(--hud-muted); font-size: 0.55rem; font-family: ui-monospace, monospace; padding-left: 1rem; }
.pg-fp-ua { color: var(--hud-muted); font-size: 0.56rem; font-family: ui-monospace, monospace; margin-top: 0.3rem; word-break: break-all; }

/* Как проверить (в модалке) */
.pg-howto-hint { font-size: 0.62rem; color: var(--hud-muted); padding: 0.4rem 1rem 0; margin: 0; }
.pg-howto { list-style: none; margin: 0; padding: 0.5rem 1rem 0.9rem; display: flex; flex-direction: column; gap: 0.5rem; }
.pg-cmd { display: grid; grid-template-columns: 1fr auto; align-items: center; gap: 0.25rem 0.5rem; }
.pg-cmd-name { grid-column: 1 / -1; font-size: 0.54rem; color: var(--hud-muted); text-transform: uppercase; letter-spacing: 0.5px; }
.pg-cmd code {
    font-family: ui-monospace, monospace; font-size: 0.64rem; color: var(--hud-cyan);
    background: rgba(63, 211, 255, 0.06); border: 1px solid var(--hud-line);
    padding: 0.35rem 0.5rem; overflow-x: auto; white-space: nowrap;
}
.pg-copy { background: transparent; border: 1px solid var(--hud-line); color: var(--hud-muted); cursor: pointer; padding: 0.35rem 0.5rem; }
@media (hover: hover) { .pg-copy:hover { color: var(--hud-cyan); border-color: var(--hud-cyan); } }
