/*
 * Виджет «Мониторинг серверов» на сайте.
 *
 * Вёрстка портирована из референса (box-monitoring/box-center-online/
 * block-monitor-progress), классы переименованы под проект в префикс msm-,
 * цвета берём из токенов root.css: --bg, --panel, --border, --accent.
 * Внешних шрифтов и картинок нет — только SVG модуля и кэш карт.
 */

.msm-widget {
    display: grid;
    gap: 12px;
    color: var(--text);
    font-size: 12px;
    line-height: 1.4;
}

/* ---------- Шапка и общая полоса онлайна ---------- */
.msm-head {
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    padding: 10px 12px;
    background: var(--panel);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    box-shadow: 0 0 10px rgb(0 0 0 / 50%);
}

.msm-head-main {
    display: flex;
    align-items: baseline;
    gap: 8px;
    min-width: 0;
}

.msm-title {
    font-size: 13px;
    font-weight: 700;
    letter-spacing: -.01em;
    white-space: nowrap;
}

.msm-updated {
    color: var(--muted);
    font-size: 10px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.msm-head-side {
    display: flex;
    align-items: center;
    gap: 10px;
    flex: 0 0 auto;
}

.msm-total {
    font-family: ui-monospace, Consolas, monospace;
    font-size: 12px;
    white-space: nowrap;
}

.msm-total-percent {
    font-size: 12px;
    font-weight: 700;
}

.msm-refresh {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 26px;
    height: 26px;
    padding: 0;
    border: 0;
    border-radius: 6px;
    background: transparent;
    cursor: pointer;
}

.msm-refresh svg {
    width: 18px;
    height: 18px;
    fill: var(--muted);
    transition: fill .2s;
}

.msm-refresh:hover svg {
    fill: var(--accent);
}

.msm-refresh.msm-busy svg {
    animation: msm-spin 1s linear infinite;
}

@keyframes msm-spin {
    to { transform: rotate(360deg); }
}

.msm-progress {
    height: 8px;
    border: 1px solid var(--border);
    border-radius: 6px;
    background: var(--bg-soft);
    overflow: hidden;
}

.msm-progress-bar {
    width: 0;
    height: 100%;
    border-radius: 6px;
    transition: width .5s ease, background .5s ease;
}

/* ---------- Список карточек ---------- */
.msm-list {
    display: grid;
    gap: 5px;
    grid-template-columns: repeat(auto-fill, minmax(290px, 1fr));
}

.msm-card {
    position: relative;
    height: 80px;
    border: 1px solid var(--border);
    border-radius: 6px;
    background: var(--panel);
    box-shadow: 0 0 10px rgb(0 0 0 / 50%);
    overflow: hidden;
}

.msm-card-bg {
    position: absolute;
    inset: 0;
    background-size: cover;
    background-position: center;
    opacity: .3;
}

/* Затемнение картинки под текстом: справа карточка уходит в фон панели. */
.msm-card::before {
    content: "";
    position: absolute;
    inset: 0;
    z-index: 1;
    background: linear-gradient(90deg, rgb(10 10 10 / 35%) 0%, rgb(10 10 10 / 72%) 55%, var(--panel) 100%);
}

.msm-card-body {
    position: relative;
    z-index: 2;
    height: 100%;
    padding: 10px 46px 14px 12px;
}

.msm-map {
    position: absolute;
    top: 10px;
    left: 12px;
    max-width: 55%;
    color: rgb(238 240 244 / 78%);
    font-size: 11px;
    letter-spacing: .04em;
    text-transform: uppercase;
    text-shadow: 0 1px 2px rgb(0 0 0 / 70%);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

/* Вертикальная полоса заполнения — как box-online-proccent в референсе. */
.msm-gauge {
    position: absolute;
    top: 50%;
    right: 46px;
    transform: translateY(-50%);
    display: flex;
    align-items: center;
    gap: 5px;
}

.msm-gauge-val {
    writing-mode: vertical-rl;
    transform: rotate(180deg);
    color: rgb(238 240 244 / 75%);
    font-size: 10px;
    user-select: none;
}

.msm-gauge-track {
    position: relative;
    width: 6px;
    height: 50px;
    border-radius: 6px;
    background: var(--bg-soft);
    overflow: hidden;
}

.msm-gauge-bar {
    position: absolute;
    left: 0;
    bottom: 0;
    width: 100%;
    height: 0;
    border-radius: 6px;
    transition: height .6s ease, background .6s ease;
}

.msm-meta {
    position: absolute;
    left: 12px;
    bottom: 12px;
    display: flex;
    align-items: baseline;
    gap: 10px;
    max-width: calc(100% - 62px);
}

.msm-players {
    display: inline-flex;
    align-items: center;
    height: 18px;
    padding: 0 8px;
    border-radius: 6px;
    background: hsl(143deg 72% 75% / 10%);
    color: #90edb3;
    font-size: 10.5px;
    white-space: nowrap;
}

.msm-card-off .msm-players {
    background: rgb(143 154 163 / 12%);
    color: var(--muted);
}

.msm-name {
    color: rgb(238 240 244 / 85%);
    font-size: 11px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.msm-actions {
    position: absolute;
    top: 10px;
    right: 10px;
    bottom: 14px;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: space-between;
    gap: 6px;
}

.msm-play,
.msm-copy,
.msm-players-btn {
    display: inline-flex;
    padding: 0;
    border: 0;
    background: transparent;
    cursor: pointer;
    text-decoration: none;
}

.msm-play svg,
.msm-copy svg,
.msm-players-btn svg {
    width: 16px;
    height: 16px;
    fill: var(--muted);
    transition: fill .2s;
}

.msm-play:hover svg,
.msm-copy:hover svg,
.msm-players-btn:hover svg {
    fill: var(--accent);
}

.msm-off-label {
    color: var(--muted);
    font-size: 9.5px;
    letter-spacing: .06em;
    text-transform: uppercase;
    white-space: nowrap;
}

.msm-card-off {
    border-style: dashed;
}

.msm-card-off::before {
    background: linear-gradient(90deg, rgb(10 10 10 / 60%) 0%, var(--panel) 100%);
}

.msm-card-off .msm-card-bg {
    opacity: .12;
}

/* ---------- Нижняя полоска заполнения на всю ширину карточки ---------- */
.msm-card-strip {
    position: absolute;
    left: 0;
    right: 0;
    bottom: 0;
    height: 3px;
    background: rgb(0 0 0 / 35%);
    z-index: 3;
    overflow: hidden;
}

.msm-card-strip-fill {
    height: 100%;
    width: 0;
    border-radius: 0 3px 3px 0;
    transition: width .6s ease, background .6s ease;
}

.msm-card-off .msm-card-strip {
    background: rgb(255 255 255 / 6%);
}

.msm-stub {
    grid-column: 1 / -1;
    padding: 18px 14px;
    text-align: center;
    color: var(--muted);
    font-size: 11.5px;
    background: var(--panel);
    border: 1px dashed var(--border);
    border-radius: 6px;
}

/* ---------- Модалка со списком игроков ---------- */
.msm-modal {
    position: fixed;
    inset: 0;
    z-index: 9999;
    display: flex;
    align-items: center;
    justify-content: center;
}

.msm-modal[hidden] {
    display: none;
}

.msm-modal-backdrop {
    position: absolute;
    inset: 0;
    background: rgb(0 0 0 / 66%);
    backdrop-filter: blur(3px);
}

.msm-modal-box {
    position: relative;
    z-index: 1;
    display: flex;
    flex-direction: column;
    width: min(760px, 94vw);
    max-height: 86vh;
    background: var(--panel);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    box-shadow: 0 20px 60px rgb(0 0 0 / 60%);
    overflow: hidden;
}

.msm-modal-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
    padding: 12px 14px;
    border-bottom: 1px solid var(--border);
}

.msm-modal-title {
    font-size: 12.5px;
    font-weight: 600;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.msm-modal-x {
    padding: 0 4px;
    border: 0;
    background: transparent;
    color: var(--muted);
    font-size: 20px;
    line-height: 1;
    cursor: pointer;
}

.msm-modal-x:hover {
    color: var(--text);
}

.msm-modal-body {
    padding: 12px 14px 14px;
    overflow: auto;
}

/* Шапка модалки: карта + Присоединиться + адрес */
.msm-m-head {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 0 0 12px;
    border-bottom: 1px solid var(--border);
    margin-bottom: 10px;
}

.msm-m-map {
    padding: 2px 8px;
    border: 1px solid var(--border);
    border-radius: 4px;
    font-size: 10.5px;
    letter-spacing: .04em;
    text-transform: uppercase;
    color: var(--muted);
}

.msm-m-join {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 6px 12px;
    border-radius: 6px;
    background: #f08a24;
    color: #fff;
    font-size: 11.5px;
    font-weight: 600;
    text-decoration: none;
}

.msm-m-join svg {
    width: 14px;
    height: 14px;
    fill: #fff;
}

.msm-m-addr {
    margin-left: auto;
    font-family: ui-monospace, Consolas, monospace;
    font-size: 11px;
    color: var(--muted);
}

/* Счёт T : CT */
.msm-m-score {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
    margin: 6px 0 12px;
    font-size: 22px;
    font-weight: 700;
}

.msm-m-score-side {
    min-width: 28px;
    text-align: center;
}

.msm-m-score-sep {
    color: var(--muted);
    font-weight: 400;
}

/* Две колонки: Террористы / Спецназ */
.msm-m-cols {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 12px;
}

.msm-m-col {
    border: 1px solid var(--border);
    border-radius: 6px;
    overflow: hidden;
    background: rgb(255 255 255 / 2%);
}

.msm-m-col-head {
    padding: 6px 10px;
    font-size: 11px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: .04em;
    background: rgb(255 255 255 / 3%);
    border-bottom: 1px solid var(--border);
}

.msm-p-row {
    display: grid;
    grid-template-columns: 14px 1fr auto auto;
    gap: 8px;
    padding: 6px 10px;
    font-size: 11.5px;
    border-bottom: 1px solid rgb(255 255 255 / 4%);
}

.msm-p-row:last-child {
    border-bottom: 0;
}

.msm-p-dash {
    color: var(--muted);
}

.msm-p-name {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.msm-p-score {
    color: #e0a53a;
    font-weight: 600;
    min-width: 22px;
    text-align: right;
}

.msm-p-time {
    color: var(--muted);
    min-width: 42px;
    text-align: right;
}

.msm-m-empty {
    padding: 10px;
    color: var(--muted);
    font-size: 11px;
    text-align: center;
}

/* Наблюдатели */
.msm-m-spec {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-top: 12px;
    padding: 8px 10px;
    border: 1px solid var(--border);
    border-radius: 6px;
    font-size: 11.5px;
}

.msm-m-spec-head {
    font-weight: 600;
}

.msm-m-spec-count {
    color: var(--muted);
}

.msm-m-spec-list {
    margin-top: 6px;
    border: 1px solid var(--border);
    border-radius: 6px;
    overflow: hidden;
}

@media (max-width: 560px) {
    .msm-list {
        grid-template-columns: 1fr;
    }

    .msm-title {
        font-size: 12px;
    }

    .msm-name {
        max-width: 130px;
    }

    .msm-m-cols {
        grid-template-columns: 1fr;
    }
}



















.msm-card {
    position: relative;
    height: 80px;
    border: 1px solid var(--border);
    border-radius: 6px;
    background: var(--panel);
    box-shadow: 0 0 10px rgb(0 0 0 / 50%);
    overflow: hidden;
    /* Резервируем 4px снизу, чтобы контент и кнопки не заходили под полоску. */
}

.msm-card-body {
    position: relative;
    z-index: 2;
    height: 100%;
    /* Снизу 4px заняты полоской, ещё 8px — отступ контента от полоски. */
    padding: 10px 46px 16px 12px;
}

/* Полоска онлайна: во всю ширину карточки, поверх фона, под кнопками. */
.msm-online-bar {
    position: absolute;
    left: 0;
    right: 0;
    bottom: 0;
    height: 4px;
    background: rgb(255 255 255 / 6%);
    z-index: 3;         /* выше фона и градиента ::before, но ниже .msm-actions (там z-index 2, но .msm-actions находится внутри .msm-card-body с z-index 2 → визуально кнопки перекрывают полоску, если заходят на неё) */
    pointer-events: none;
}

.msm-online-bar-fill {
    height: 100%;
    width: 0;
    transition: width .6s ease, background .6s ease;
}