/* ============================================================================
   Тема TorrServer: сетка карточек, окно раздачи и профили транскодирования.
   Каркас, панели, поля, кнопки, модальные окна и уведомления берет
   общий /css/style.css.
   ============================================================================ */

/* ----------------------------------------------------------------------------
   Сетка карточек раздач
   ---------------------------------------------------------------------------- */
.grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
    gap: 20px;
}

.card {
    position: relative;
    background: transparent;
    border: 1px solid transparent;
    border-radius: 8px;
    padding: 10px;
    overflow: hidden;
    cursor: pointer;
    transition: transform 0.6s ease, background-color 0.6s ease, border-color 0.6s ease, box-shadow 0.6s ease;
}

.card:hover {
    transform: scale(1.04);
    background: var(--silo-surface);
    border-color: var(--silo-border);
    box-shadow: 0 10px 28px rgba(0, 0, 0, 0.45);
}

.poster {
    position: relative;
    width: 100%;
    aspect-ratio: 2/3;
    background: var(--silo-bg-raised);
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 8px;
    overflow: hidden;
}

.poster img { width: 100%; height: 100%; object-fit: cover; }
.placeholder { color: var(--silo-amber); font-size: 14px; }

.card-badge {
    position: absolute;
    top: 8px;
    left: 8px;
    padding: 2px 10px;
    border-radius: 999px;
    font-size: 11px;
    font-weight: 600;
}

.stat-0 { background: var(--silo-border-strong); color: var(--silo-text); }
.stat-1 { background: var(--silo-amber); color: #14171a; }
.stat-2 { background: var(--silo-teal); color: var(--silo-steel-bright); }
.stat-3 { background: var(--silo-teal-bright); color: #0d1210; }

.title {
    padding: 8px 0 2px;
    color: var(--silo-text);
    font-size: 14px;
    font-weight: 500;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.meta {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 6px;
    padding: 0;
    margin: 0;
    color: var(--silo-text-muted);
    font-size: 11px;
    white-space: nowrap;
}

.meta-item {
    display: inline-flex;
    align-items: center;
    gap: 3px;
    padding: 0;
    margin: 0;
    justify-self: start;
    overflow: hidden;
}

.meta-item img { width: 14px; height: 14px; opacity: 0.7; }
.meta-item em { font-style: normal; }

.grid-msg {
    grid-column: 1 / -1;
    color: var(--silo-text-muted);
    padding: 24px 0;
}

.grid-msg.error { color: var(--silo-danger); }

/* ----------------------------------------------------------------------------
   Меню карточки
   ---------------------------------------------------------------------------- */
.card-dots {
    position: absolute;
    top: 8px;
    right: 8px;
    width: 26px;
    height: 26px;
    border: none;
    border-radius: 6px;
    background: rgba(20, 23, 26, 0.7);
    color: var(--silo-steel-bright);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    opacity: 0;
    transition: opacity 0.25s ease, background-color 0.25s ease;
    z-index: 3;
}

.card:hover .card-dots,
.card.menu-open .card-dots { opacity: 1; }

.card-dots:hover { background: rgba(20, 23, 26, 0.9); }
.card-dots svg { width: 16px; height: 16px; fill: currentColor; }

.card-menu {
    position: absolute;
    inset: 0;
    background: var(--silo-bg-raised);
    transform: translateY(-101%);
    transition: transform 0.25s ease;
    display: flex;
    flex-direction: column;
    gap: 2px;
    padding: 8px;
    z-index: 2;
}

.card.menu-open .card-menu { transform: translateY(0); }

.card-menu-item {
    display: flex;
    align-items: center;
    gap: 8px;
    background: transparent;
    border: none;
    border-radius: 6px;
    padding: 6px 8px;
    color: var(--silo-text-muted);
    font-size: 12px;
    text-align: left;
    cursor: pointer;
    transition: color 0.2s ease, background-color 0.2s ease;
}

.card-menu-item:hover { background: var(--silo-surface); color: var(--silo-text); }
.card-menu-item img { width: 14px; height: 14px; opacity: 0.8; }
.card-menu-item.danger:hover { color: var(--silo-danger); }

/* ----------------------------------------------------------------------------
   Окно добавления и правки раздачи
   ---------------------------------------------------------------------------- */
.modal-add {
    max-width: 760px;
    width: 100%;
}

/* Тело окна добавления - две колонки, постер слева от полей */
.modal-body.add-body {
    display: flex;
    flex-direction: row;
    gap: 20px;
    align-items: flex-start;
}

.add-preview {
    flex: 0 0 260px;
    width: 260px;
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.add-preview-frame {
    position: relative;
    width: 100%;
    aspect-ratio: 2 / 3;
    background: var(--silo-surface);
    border: 1px solid var(--silo-border);
    border-radius: 8px;
    overflow: hidden;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
}

.add-preview-frame img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
}

.add-preview-empty {
    color: var(--silo-text-faint);
    font-size: 13px;
    text-align: center;
    padding: 12px;
}

.add-preview-label {
    color: var(--silo-text-muted);
    font-size: 12px;
    font-weight: 500;
    text-align: center;
}

.add-fields {
    flex: 1 1 auto;
    min-width: 0;
}

.edit-hash {
    margin-top: 10px;
    padding: 6px 8px;
    background: var(--silo-surface);
    border: 1px solid var(--silo-border);
    border-radius: 6px;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    min-width: 0;
}

.add-textarea {
    resize: vertical;
    min-height: 56px;
    font-family: inherit;
}

/* Настоящий input скрыт, роль кнопки играет сама зона загрузки */
.file-drop {
    position: relative;
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 12px 14px;
    margin-bottom: 12px;
    background: var(--silo-surface);
    border: 1px dashed var(--silo-border-strong);
    border-radius: 8px;
    cursor: pointer;
    transition: border-color 0.2s ease, background-color 0.2s ease;
}

.file-drop:hover,
.file-drop.dragging {
    border-color: var(--silo-amber);
    background: var(--silo-surface-hover);
}

.file-drop.has-file { border-style: solid; }

.file-drop input[type="file"] {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    border: 0;
}

.file-drop-icon {
    width: 20px;
    height: 20px;
    flex-shrink: 0;
    opacity: 0.85;
}

.file-drop-text {
    color: var(--silo-text-muted);
    font-size: 13px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    flex: 1 1 auto;
    min-width: 0;
}

.file-drop-name {
    color: var(--silo-steel-bright);
    font-size: 13px;
    font-weight: 500;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    flex: 1 1 auto;
    min-width: 0;
}

.file-drop-clear {
    flex-shrink: 0;
    background: transparent;
    border: none;
    color: var(--silo-text-muted);
    font-size: 18px;
    line-height: 1;
    cursor: pointer;
    padding: 2px 6px;
    border-radius: 4px;
}

.file-drop-clear:hover {
    background: var(--silo-bg-raised);
    color: var(--silo-danger);
}

/* ----------------------------------------------------------------------------
   Полоска постеров
   ---------------------------------------------------------------------------- */
.poster-block-head {
    display: flex;
    align-items: baseline;
    justify-content: space-between;
    gap: 8px;
    margin-bottom: 8px;
}

.poster-block-head > span:first-child {
    color: var(--silo-text-muted);
    font-size: 12px;
    font-weight: 500;
}

.poster-status {
    color: var(--silo-text-faint);
    font-size: 11px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.poster-strip {
    display: flex;
    gap: 10px;
    overflow-x: auto;
    padding-bottom: 6px;
    min-height: 132px;
    align-items: flex-start;
}

.poster-strip::-webkit-scrollbar { height: 6px; }
.poster-strip::-webkit-scrollbar-thumb {
    background: var(--silo-border-strong);
    border-radius: 3px;
}

.poster-item {
    flex: 0 0 auto;
    width: 92px;
    height: 138px;
    padding: 0;
    background: var(--silo-surface);
    border: 2px solid var(--silo-border);
    border-radius: 8px;
    overflow: hidden;
    cursor: pointer;
    transition: border-color 0.2s ease, transform 0.15s ease;
}

.poster-item:hover {
    border-color: var(--silo-amber);
    transform: translateY(-2px);
}

.poster-item.active {
    border-color: var(--silo-amber-bright);
    box-shadow: 0 0 0 1px var(--silo-amber-bright) inset;
}

.poster-item img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
}

.poster-item.broken { display: none; }

.poster-empty {
    color: var(--silo-text-faint);
    font-size: 12px;
    align-self: center;
}

/* ----------------------------------------------------------------------------
   Окно раздачи: вкладки файлов и кэша
   ---------------------------------------------------------------------------- */
.modal-info {
    max-width: 980px;
    width: 100%;
    height: min(720px, 90vh);
    display: flex;
    flex-direction: column;
}

.confirm-text {
    margin: 0;
    color: var(--silo-text-muted);
    font-size: 14px;
}

/* Тело формы: поля идут в столбик с равным шагом */
.modal-body {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.modal-sm { max-width: 380px; }
.modal-about { max-width: 560px; }

.info-header {
    display: flex;
    gap: 16px;
    padding: 16px 20px;
    border-bottom: 1px solid var(--silo-border);
    flex-shrink: 0;
}

.info-poster {
    width: 120px;
    height: 180px;
    object-fit: cover;
    border-radius: 8px;
    flex-shrink: 0;
}

.info-head-right {
    flex-grow: 1;
    display: flex;
    flex-direction: column;
    gap: 12px;
    min-width: 0;
    min-height: 180px;
}

.info-title-row {
    display: flex;
    align-items: center;
    gap: 8px;
}

.info-title-row h2 {
    margin: 0;
    flex-grow: 1;
    color: var(--silo-steel-bright);
    font-size: 18px;
    font-weight: 600;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.info-plaques {
    display: flex;
    gap: 6px;
    flex-wrap: nowrap;
}

.hash-row {
    display: flex;
    align-items: center;
    gap: 8px;
    min-width: 0;
}

.hash-label {
    color: var(--silo-text-muted);
    font-size: 11px;
    font-weight: 500;
    flex-shrink: 0;
}

.hash-value {
    color: var(--silo-text);
    font-family: ui-monospace, "SFMono-Regular", Menlo, monospace;
    font-size: 12px;
    word-break: break-all;
    min-width: 0;
}

.hash-row .hash-value { cursor: pointer; }
.hash-row .hash-value:hover { color: var(--silo-amber); }

.info-plaques-cache {
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.2s ease;
}

.info-plaques-cache.visible {
    opacity: 1;
    pointer-events: auto;
}

.plaque {
    flex: 1 1 0;
    min-width: 0;
    background: var(--silo-surface);
    border: 1px solid var(--silo-border);
    border-radius: 6px;
    padding: 6px 8px;
    display: flex;
    flex-direction: column;
    gap: 2px;
    align-items: center;
    text-align: center;
}

.plaque-label { color: var(--silo-text-muted); font-size: 10px; }

.plaque-value {
    color: var(--silo-text);
    font-size: 12px;
    font-weight: 600;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    max-width: 100%;
}

.info-tabs {
    display: flex;
    gap: 4px;
    padding: 0 20px;
    border-bottom: 1px solid var(--silo-border);
    flex-shrink: 0;
}

.info-tab {
    background: transparent;
    border: none;
    border-bottom: 2px solid transparent;
    color: var(--silo-text-muted);
    padding: 10px 14px;
    font-size: 13px;
    cursor: pointer;
    transition: color 0.2s ease;
}

.info-tab:hover { color: var(--silo-text); }
.info-tab.active { color: var(--silo-amber); border-bottom-color: var(--silo-amber); }

.info-body {
    display: flex;
    gap: 16px;
    padding: 16px 20px 20px;
    flex: 1 1 auto;
    min-height: 0;
    overflow: hidden;
    transition: opacity 0.18s ease;
}

.info-body-cache {
    flex-direction: column;
    gap: 12px;
}

.info-folders {
    width: 200px;
    flex-shrink: 0;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.info-folder {
    background: transparent;
    border: none;
    border-radius: 6px;
    color: var(--silo-text-muted);
    text-align: left;
    padding: 10px 12px;
    font-size: 13px;
    cursor: pointer;
    transition: background-color 0.2s ease, color 0.2s ease;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    min-height: 36px;
    display: flex;
    align-items: center;
    max-width: 100%;
}

.info-folder:hover { background: var(--silo-surface); color: var(--silo-text); }
.info-folder.selected { background: var(--silo-surface-hover); color: var(--silo-steel-bright); }

.info-files-wrap {
    flex-grow: 1;
    display: flex;
    flex-direction: column;
    gap: 10px;
    min-width: 0;
}

.media-only {
    display: flex;
    align-items: center;
    gap: 8px;
    color: var(--silo-text-muted);
    font-size: 12px;
    cursor: pointer;
}

.media-only input { cursor: pointer; }

.info-files {
    overflow-y: auto;
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.file-row {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 8px 10px;
    border-radius: 6px;
    transition: background-color 0.2s ease;
}

.file-row:hover { background: var(--silo-surface); }

/* Точка о просмотре: тот же цвет, что у кнопки Open, и та же высота строки,
   поэтому место под неё зарезервировано у всех строк - иначе кнопки съезжают */
.file-viewed {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: transparent;
    flex-shrink: 0;
}

.file-viewed.is-on { background: var(--silo-amber); }

/* Фильтр и кнопка массовой отметки в одной строке */
.info-files-tools {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    flex-wrap: wrap;
}

.file-main { flex-grow: 1; min-width: 0; }

.file-name {
    color: var(--silo-text);
    font-size: 13px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.file-sub {
    color: var(--silo-text-faint);
    font-size: 11px;
    margin-top: 2px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.file-actions {
    display: flex;
    align-items: center;
    gap: 6px;
    flex-shrink: 0;
}

.file-empty {
    color: var(--silo-text-faint);
    font-size: 13px;
    padding: 12px 0;
}

/* ----------------------------------------------------------------------------
   Карта кэша
   ---------------------------------------------------------------------------- */
.cache-toolbar {
    display: flex;
    align-items: center;
    gap: 8px;
    flex-shrink: 0;
}

.zoom-value {
    color: var(--silo-text-muted);
    font-size: 12px;
    font-family: "JetBrains Mono", monospace;
    min-width: 48px;
    text-align: center;
}

.cache-canvas-wrap {
    flex: 1 1 auto;
    overflow-y: auto;
    overflow-x: hidden;
    background: var(--silo-bg-raised);
    border: 1px solid var(--silo-border);
    border-radius: 6px;
    min-height: 220px;
    position: relative;
}

#cache-canvas { display: block; }

.cache-empty {
    position: absolute;
    inset: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--silo-text-muted);
    font-size: 13px;
    background: var(--silo-bg-raised);
}

/* ----------------------------------------------------------------------------
   Окна поддержки и о проекте
   ---------------------------------------------------------------------------- */
.donate-links {
    display: flex;
    flex-direction: column;
    gap: 8px;
    margin-top: 12px;
}

.donate-btn {
    text-decoration: none;
    text-align: center;
}

.about-body { gap: 16px; }

.about-brand {
    display: flex;
    align-items: center;
    gap: 14px;
    padding-bottom: 12px;
    border-bottom: 1px solid var(--silo-border);
}

.about-brand img { width: 48px; height: 48px; border-radius: 8px; }

.about-title {
    color: var(--silo-steel-bright);
    font-size: 18px;
    font-weight: 700;
}

.about-version {
    color: var(--silo-text-muted);
    font-size: 13px;
    font-family: "JetBrains Mono", monospace;
    margin-top: 2px;
}

.about-thanks {
    color: var(--silo-text);
    font-size: 13px;
    line-height: 1.6;
}

.about-section-title {
    color: var(--silo-text-faint);
    font-size: 11px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    margin-top: 8px;
}

.about-links {
    list-style: none;
    padding: 0;
    margin: 0;
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.about-links a {
    color: var(--silo-amber);
    text-decoration: none;
    font-size: 13px;
}

.about-links a:hover {
    color: var(--silo-amber-bright);
    text-decoration: underline;
}

.about-muted {
    color: var(--silo-text-faint);
    font-size: 13px;
}

.about-contributors {
    list-style: none;
    padding: 0;
    margin: 0;
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
}

.about-contributors li a {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 3px 10px 3px 3px;
    border: 1px solid var(--silo-border);
    border-radius: 999px;
    background: var(--silo-surface);
    color: var(--silo-text);
    text-decoration: none;
    font-size: 12px;
    transition: border-color 0.2s ease;
}

.about-contributors li a:hover { border-color: var(--silo-amber); }

/* ----------------------------------------------------------------------------
   Группы плагинов в сайдбаре
   ---------------------------------------------------------------------------- */
.plugin-group { margin-bottom: 4px; }

.plugin-group-name {
    color: var(--silo-text-faint);
    font-size: 10px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    padding: 6px 12px 2px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.about-contributors .uc-initials {
    width: 20px;
    height: 20px;
    border-radius: 50%;
    background: var(--silo-teal);
    color: var(--silo-steel-bright);
    font-size: 9px;
    font-weight: 700;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

/* ----------------------------------------------------------------------------
   Профили транскодирования и сведения о файле
   ---------------------------------------------------------------------------- */
.transcode-list {
    display: flex;
    flex-direction: column;
    gap: 8px;
    max-height: 60vh;
    overflow-y: auto;
}

.transcode-item {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    padding: 10px 12px;
    border: 1px solid var(--silo-border);
    border-radius: 8px;
    background: var(--silo-bg-raised);
}

.transcode-item:hover { border-color: var(--silo-border-strong); }

.transcode-main { min-width: 0; }

.transcode-name {
    color: var(--silo-text);
    font-weight: 600;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.transcode-star { color: var(--silo-amber); }

.transcode-sub {
    color: var(--silo-text-faint);
    font-size: 12px;
    margin-top: 2px;
}

.transcode-actions {
    display: flex;
    gap: 6px;
    flex-shrink: 0;
}

.transcode-empty {
    color: var(--silo-text-faint);
    padding: 12px 0;
    text-align: center;
}

.fileinfo-table {
    width: 100%;
    border-collapse: collapse;
    margin-bottom: 12px;
}

.fileinfo-table td {
    padding: 6px 8px;
    border-bottom: 1px solid var(--silo-border);
    vertical-align: top;
}

.fileinfo-table td:first-child {
    color: var(--silo-text-muted);
    white-space: nowrap;
    width: 40%;
}

.fileinfo-head {
    color: var(--silo-text-muted);
    font-size: 12px;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    margin: 12px 0 6px;
}

/* ----------------------------------------------------------------------------
   Мобильная адаптация
   ---------------------------------------------------------------------------- */
@media (max-width: 720px) {
    .modal-body.add-body { flex-direction: column; }

    .add-preview {
        flex: 0 0 auto;
        width: 100%;
        max-width: 220px;
        margin: 0 auto;
    }
}

@media (max-width: 767px) {
    .modal-add .modal-body { padding: 16px; }

    .poster-item {
        width: 78px;
        height: 117px;
    }

    .info-header {
        flex-direction: column;
        align-items: center;
        text-align: center;
    }

    .info-poster {
        width: 90px;
        height: 135px;
    }

    .info-plaques { flex-wrap: wrap; }
    .plaque { flex: 1 1 calc(50% - 3px); }

    .info-body { flex-direction: column; }

    .info-folders {
        width: 100%;
        max-height: 120px;
    }
}
