/* node-modal.css – модальное окно ноды (nodeModal.js): таблица нод и карта */

/* Флаг и числовые значения внутри модалки (на странице таблицы они же в newindex.css) */
.modal-overlay .country-flag-img {
    width: 20px;
    height: auto;
    border-radius: 2px;
    box-shadow: 0 1px 3px rgba(var(--black-rgb),0.3);
    vertical-align: middle;
    margin-right: 0.3rem;
}
.modal-overlay .perf-value,
.modal-overlay .stake-value,
.modal-overlay .as-value {
    font-weight: 500;
    color: var(--text);
}

/* ============================================================= */
/* ===== ШИРОКОЕ МОДАЛЬНОЕ ОКНО ===== */
/* ============================================================= */

.modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    height: 100dvh;
    background: rgba(var(--black-rgb), 0.85);
    backdrop-filter: blur(var(--blur-sm, 6px));
    display: none;
    align-items: center;
    justify-content: center;
    z-index: 10000;
    animation: fadeIn 0.25s ease;
    padding-top: env(safe-area-inset-top);
    padding-bottom: env(safe-area-inset-bottom);
    padding-left: env(safe-area-inset-left);
    padding-right: env(safe-area-inset-right);
    box-sizing: border-box;
}
.modal-overlay.active {
    display: flex;
}
@keyframes fadeIn {
    from { opacity: 0; transform: scale(0.97); }
    to { opacity: 1; transform: scale(1); }
}

.modal-box {
    background: var(--surface-elevated);
    border-radius: 24px;
    padding: 1.8rem 2.2rem 1.5rem;
    width: 94vw;
    max-width: 1400px;
    height: 92vh;
    max-height: 92vh;
    height: min(92vh, 92dvh);
    max-height: min(92vh, 92dvh);
    box-shadow: 0 30px 80px rgba(var(--black-rgb), 0.7);
    position: relative;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    border: 1px solid var(--glass-border);
}

/* ===== Кнопка закрытия ===== */
.modal-close {
    position: absolute;
    top: max(14px, env(safe-area-inset-top));
    right: max(20px, env(safe-area-inset-right));
    font-size: 2rem;
    cursor: pointer;
    color: var(--text);
    transition: color 0.2s, transform 0.2s, background 0.2s;
    background: rgba(var(--black-rgb), 0.4);
    border: 1px solid rgba(var(--white-rgb), 0.1);
    line-height: 1;
    z-index: 1001;
    width: 44px;
    height: 44px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    backdrop-filter: blur(4px);
}
.modal-close:hover {
    color: var(--text);
    transform: rotate(90deg);
    background: rgba(var(--black-rgb), 0.6);
}
.modal-close:active {
    transform: scale(0.9);
}

/* ===== Заголовок ===== */
.modal-header-center {
    text-align: center;
    padding-bottom: 0.8rem;
    border-bottom: 1px solid var(--glass-border);
    flex-shrink: 0;
}
.modal-moniker {
    font-size: 1.8rem;
    font-weight: 600;
    color: var(--text-dim);
    letter-spacing: 0.5px;
}
.modal-moniker-id {
    font-size: 1.2rem;
    color: var(--text-dimmer);
    font-weight: 400;
    margin-left: 0.8rem;
}

/* ===== Детали (2 колонки) ===== */
.modal-body-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 0.8rem 2rem;
    padding: 0.8rem 0 0.5rem 0;
    flex-shrink: 0;
}
.modal-field {
    display: flex;
    align-items: center;
    padding: 0.2rem 0;
    border-bottom: 1px solid rgba(var(--surface-elevated-rgb), 0.3);
}
.modal-field:last-child {
    border-bottom: none;
}
.modal-field .label {
    color: var(--text-dim);
    font-weight: 400;
    font-size: 0.75rem;
    min-width: 110px;
    flex-shrink: 0;
    text-transform: uppercase;
    letter-spacing: 0.3px;
}
.modal-field .value {
    color: var(--text);
    font-weight: 500;
    font-size: 0.85rem;
    word-break: break-all;
    flex: 1;
}
.modal-field .value.identity-full {
    font-family: 'Courier New', monospace;
    font-size: 0.75rem;
    background: var(--surface);
    padding: 0.1rem 0.5rem;
    border-radius: 6px;
    word-break: break-all;
}
.saturation-bar-wrapper {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    flex: 1;
}
.saturation-bar-track {
    flex: 1;
    height: 6px;
    background: var(--glass-border);
    border-radius: var(--radius-sm);
    overflow: hidden;
    min-width: 60px;
}
.saturation-bar-fill {
    height: 100%;
    border-radius: var(--radius-sm);
    transition: width 0.6s ease;
    background: linear-gradient(90deg, var(--accent-alt), var(--warning), var(--danger));
}
.saturation-label {
    font-weight: 600;
    font-size: 0.8rem;
    min-width: 45px;
    text-align: right;
    color: var(--text);
}
.modal-badge {
    display: inline-block;
    padding: 0.05rem 0.6rem;
    border-radius: 20px;
    font-size: 0.7rem;
    font-weight: 600;
    text-transform: uppercase;
}
.modal-badge.active {
    background: rgba(var(--accent-alt-rgb), 0.15);
    color: var(--accent-alt);
}
.modal-badge.inactive {
    background: rgba(var(--danger-rgb), 0.15);
    color: var(--danger);
}
.modal-badge.dp-yes {
    background: rgba(var(--accent-2-rgb), 0.15);
    color: var(--accent-2);
}
.modal-badge.dp-no {
    background: var(--surface-elevated);
    color: var(--text-dimmer);
}

/* ===== Графики: Reliability + Performance (2 колонки) ===== */
.modal-charts-row {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 1rem;
    flex: 0 1 auto;
    min-height: 0;
    margin-top: 0.3rem;
}

/* ===== Блок Rewards (отдельная строка) ===== */
.modal-rewards-section {
    flex-shrink: 0;
    margin-top: 0.3rem;
    display: flex;
    flex-direction: column;
    gap: 0.2rem;
}
.modal-rewards-section .modal-chart-box {
    min-height: 100px;
    max-height: 160px;
}

/* ===== Общий контейнер графика ===== */
.modal-chart-box {
    background: var(--surface);
    border-radius: 14px;
    padding: 0.5rem 0.6rem 0.3rem;
    border: 1px solid var(--glass-border);
    display: flex;
    flex-direction: column;
    min-height: 0;
    flex: 1;
}
.modal-chart-box h4 {
    color: var(--text-dim);
    font-weight: 400;
    font-size: 0.65rem;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    margin-bottom: 0.15rem;
    flex-shrink: 0;
    text-align: center;
}
.modal-chart-box .chart-container {
    flex: 1;
    min-height: 0;
    position: relative;
}
.modal-chart-box .chart-container canvas {
    width: 100% !important;
    height: 100% !important;
    max-height: 100%;
}

/* ===== Rewards: заголовок и статистика ===== */
.rewards-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
}
.rewards-header h4 {
    color: var(--text-dim);
    font-weight: 400;
    font-size: 0.65rem;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    margin: 0;
}
.rewards-period-buttons {
    display: flex;
    gap: 0.3rem;
}
.rewards-period-btn {
    background: var(--surface-elevated);
    border: 1px solid var(--glass-border);
    color: var(--text-dim);
    padding: 0.05rem 0.5rem;
    border-radius: var(--radius-md);
    cursor: pointer;
    font-size: 0.55rem;
    transition: all 0.2s;
}
.rewards-period-btn:hover {
    background: var(--glass-border);
    color: var(--text);
}
.rewards-period-btn.active {
    background: #3b82f6;
    border-color: #3b82f6;
    color: var(--text);
}
.rewards-stats {
    display: flex;
    gap: 1rem;
    justify-content: center;
    flex-wrap: wrap;
    padding: 0.1rem 0;
}
.rewards-stat-item {
    display: flex;
    align-items: baseline;
    gap: 0.3rem;
}
.rewards-stat-label {
    font-size: 0.5rem;
    color: var(--text-dim);
    text-transform: uppercase;
    letter-spacing: 0.3px;
}
.rewards-stat-value {
    font-size: 0.75rem;
    font-weight: 600;
}
.rewards-stat-value.total { color: var(--text); }
.rewards-stat-value.operator { color: var(--accent-alt); }
.rewards-stat-value.delegators { color: var(--accent-2); }

/* ===== Кнопки действий ===== */
.modal-actions-row {
    display: flex;
    justify-content: center;
    gap: 1rem;
    padding: 0.6rem 0 0.1rem 0;
    border-top: 1px solid var(--glass-border);
    flex-shrink: 0;
    flex-wrap: wrap;
}
.modal-action-btn {
    padding: 0.4rem 1.5rem;
    border: none;
    border-radius: var(--radius-md);
    font-size: 0.8rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s;
    color: var(--text);
    display: inline-flex;
    align-items: center;
    gap: 0.4rem;
}
.modal-action-btn.btn-explorer {
    background: #3b82f6;
}
.modal-action-btn.btn-explorer:hover {
    background: #2563eb;
    transform: translateY(-2px);
}
.modal-action-btn.btn-spectre {
    background: #8b5cf6;
}
.modal-action-btn.btn-spectre:hover {
    background: #7c3aed;
    transform: translateY(-2px);
}
.modal-action-btn.btn-delegate-modal {
    background: #22c55e;
}
.modal-action-btn.btn-delegate-modal:hover {
    background: #16a34a;
    transform: translateY(-2px);
}

/* ===== Модальное окно на мобильных (≤768px) ===== */
@media (max-width: 768px) {
    .modal-box {
        width: 98vw;
        padding: 0.6rem 0.6rem 0.4rem;
        height: 96vh;
        height: min(96vh, 96dvh);
        max-height: min(96vh, 96dvh);
        border-radius: var(--radius-md);
    }
    .modal-body-grid {
        grid-template-columns: 1fr;
        gap: 0.2rem;
        padding: 0.3rem 0 0.2rem 0;
    }
    .modal-charts-row {
        grid-template-columns: 1fr;
        gap: 0.4rem;
    }
    .modal-rewards-section .modal-chart-box {
        min-height: 80px;
        max-height: 120px;
    }
    .modal-chart-box {
        padding: 0.3rem 0.4rem 0.2rem;
    }
    .modal-chart-box h4 {
        font-size: 0.55rem;
    }
    .modal-close {
        top: max(8px, env(safe-area-inset-top));
        right: max(8px, env(safe-area-inset-right));
        font-size: 1.4rem;
        width: 34px;
        height: 34px;
        background: rgba(var(--black-rgb), 0.6);
        border: 1px solid rgba(var(--white-rgb), 0.15);
    }
    .modal-actions-row {
        gap: 0.4rem;
        padding: 0.3rem 0 0.1rem 0;
    }
    .modal-action-btn {
        padding: 0.25rem 0.8rem;
        font-size: 0.65rem;
        flex: 1;
        min-width: 60px;
        justify-content: center;
    }
    .modal-action-btn.btn-delegate-modal {
        display: none !important;
    }
    .modal-moniker {
        font-size: 1.1rem;
    }
    .modal-moniker-id {
        font-size: 0.8rem;
    }
    .modal-field .label {
        min-width: 60px;
        font-size: 0.6rem;
    }
    .modal-field .value {
        font-size: 0.65rem;
    }
    .rewards-header h4 {
        font-size: 0.55rem;
    }
    .rewards-period-btn {
        font-size: 0.5rem;
        padding: 0.05rem 0.4rem;
    }
    .rewards-stat-value {
        font-size: 0.65rem;
    }
    .rewards-stat-label {
        font-size: 0.45rem;
    }
}

/* ===== Адаптив для планшетов (769–1024px) ===== */
@media (max-width: 1024px) and (min-width: 769px) {
    .modal-box {
        width: 96vw;
        padding: 1.2rem 1.2rem 1rem;
        height: 94vh;
        height: min(94vh, 94dvh);
        max-height: min(94vh, 94dvh);
    }
    .modal-body-grid {
        gap: 0.5rem 1.5rem;
        padding: 0.5rem 0 0.3rem 0;
    }
    .modal-field .label {
        min-width: 90px;
        font-size: 0.7rem;
    }
    .modal-field .value {
        font-size: 0.8rem;
    }
    .modal-chart-box {
        padding: 0.4rem 0.5rem 0.2rem;
    }
    .modal-rewards-section .modal-chart-box {
        min-height: 100px;
        max-height: 140px;
    }
}

/* ===== Адаптив для широких экранов (≥1600px) ===== */
@media (min-width: 1600px) {
    .modal-box {
        max-width: 1500px;
        padding: 2rem 2.5rem 1.5rem;
    }
    .modal-body-grid {
        gap: 1rem 3rem;
        padding: 1rem 0 0.5rem 0;
    }
    .modal-field .label {
        min-width: 160px;
        font-size: 0.85rem;
    }
    .modal-field .value {
        font-size: 0.95rem;
    }
    .modal-rewards-section .modal-chart-box {
        min-height: 140px;
        max-height: 200px;
    }
}
