/* Network topology map styles */

.network-page {
    height: calc(100vh - 160px);
    position: relative;
    overflow: hidden;
}

/* Cytoscape container */
.network-container {
    position: absolute;
    inset: 0;
    overflow: hidden;
}

.cytoscape-canvas {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
    background-color: #070b14;
    background-image:
        radial-gradient(circle at 1px 1px, rgba(99, 102, 241, 0.08) 1px, transparent 0);
    background-size: 28px 28px;
}

/* Scanline effect */
.network-container::before {
    content: '';
    position: absolute;
    inset: 0;
    background: repeating-linear-gradient(
        0deg,
        transparent,
        transparent 3px,
        rgba(0, 255, 120, 0.012) 3px,
        rgba(0, 255, 120, 0.012) 4px
    );
    pointer-events: none;
    z-index: 1;
}


/* ==================== LEGEND ==================== */

.network-legend {
    position: absolute;
    bottom: 16px;
    left: 16px;
    background: var(--bg-elevated);
    border: 1px solid var(--border);
    border-radius: 10px;
    padding: 10px 14px;
    font-size: 11px;
    color: var(--text-secondary);
    backdrop-filter: blur(10px);
    z-index: 5;
    pointer-events: none;
    min-width: 140px;
}

.legend-title {
    font-size: 10px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.6px;
    color: var(--text-muted);
    margin-bottom: 7px;
}

.legend-section {
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.legend-divider {
    height: 1px;
    background: var(--border);
    margin: 7px 0;
}

.legend-item {
    display: flex;
    align-items: center;
    gap: 7px;
    white-space: nowrap;
}

.legend-dot {
    width: 9px;
    height: 9px;
    border-radius: 50%;
    flex-shrink: 0;
}

.legend-role {
    width: 9px;
    height: 9px;
    border-radius: 2px;
    flex-shrink: 0;
    border: 1.5px solid currentColor;
}

.legend-portal { background: rgba(99, 102, 241, 0.3); border-color: #6366f1; color: #6366f1; }
.legend-bridge { background: rgba(245, 158, 11, 0.3); border-color: #f59e0b; color: #f59e0b; }
.legend-relay  { background: rgba(139, 92, 246, 0.3); border-color: #8b5cf6; color: #8b5cf6; }

.legend-line {
    width: 22px;
    height: 0;
    flex-shrink: 0;
}

.legend-line-forward {
    border-top: 2px solid #fbbf24;
}

.legend-line-reverse {
    border-top: 2px dashed #818cf8;
}

/* ==================== BETA BADGE ==================== */

.beta-badge {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 1px 7px;
    border-radius: 999px;
    background: rgba(245, 158, 11, 0.13);
    border: 1px solid rgba(245, 158, 11, 0.35);
    color: #fbbf24;
    font-size: 10px;
    font-weight: 700;
    letter-spacing: 0.5px;
    vertical-align: middle;
}

/* ==================== FORM WARNING / HINT ==================== */

.form-warning {
    margin-top: 7px;
    padding: 8px 11px;
    border-radius: 7px;
    border: 1px solid rgba(245, 158, 11, 0.22);
    background: rgba(245, 158, 11, 0.07);
    color: #fcd34d;
    font-size: 11px;
    line-height: 1.45;
}

.form-warning strong {
    display: block;
    margin-bottom: 3px;
    color: #fbbf24;
}

/* ==================== EDGE INFO SUMMARY ==================== */

.info-summary {
    padding: 9px 11px;
    border-radius: var(--radius-sm);
    border: 1px solid rgba(99, 102, 241, 0.16);
    background: rgba(15, 23, 42, 0.5);
    margin-bottom: 2px;
    font-size: 12px;
}

.info-summary .beta-badge {
    margin-bottom: 6px;
    display: inline-block;
}

/* ==================== EMPTY STATE ==================== */

.network-empty {
    position: absolute;
    inset: 0;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 14px;
    color: var(--text-muted);
    pointer-events: none;
}

.network-empty i {
    font-size: 48px;
    opacity: 0.3;
}

.network-empty p {
    font-size: 14px;
    text-align: center;
    max-width: 280px;
    line-height: 1.5;
    margin: 0;
    opacity: 0.7;
}

/* ==================== NODE INFO MODAL ==================== */

.modal-card-sm {
    width: 360px;
}

.info-grid {
    display: flex;
    flex-direction: column;
    gap: 10px;
    padding-bottom: 4px;
}

.info-field { }

.info-label {
    display: flex;
    align-items: center;
    gap: 5px;
    font-size: 10px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    color: var(--text-muted);
    margin-bottom: 3px;
}

.info-label i { font-size: 12px; }

.info-value {
    font-size: 13px;
    color: var(--text-primary);
    font-family: 'JetBrains Mono', monospace;
    word-break: break-all;
}

.info-status {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 3px 10px;
    border-radius: 10px;
    font-size: 12px;
    font-weight: 500;
}

.info-status.online  { background: rgba(34, 197, 94, 0.12);  color: #22c55e; }
.info-status.offline { background: rgba(100, 116, 139, 0.15); color: #94a3b8; }
.info-status.pending { background: rgba(71, 85, 105, 0.2);    color: #94a3b8; }
.info-status.deployed{ background: rgba(59, 130, 246, 0.12);  color: #3b82f6; }
.info-status.error   { background: rgba(239, 68, 68, 0.12);   color: #ef4444; }
.info-status.syncing { background: rgba(234, 179, 8, 0.12);   color: #eab308; }

.info-role-badge {
    display: inline-block;
    margin-left: 6px;
    padding: 1px 6px;
    border-radius: 4px;
    font-size: 9px;
    font-weight: 700;
    letter-spacing: 0.5px;
    vertical-align: middle;
}
.info-role-badge.role-portal { background: rgba(99,102,241,0.2); color: #a5b4fc; border: 1px solid #6366f1; }
.info-role-badge.role-bridge { background: rgba(245,158,11,0.2); color: #fcd34d; border: 1px solid #f59e0b; }
.info-role-badge.role-relay  { background: rgba(139,92,246,0.2); color: #c4b5fd; border: 1px solid #8b5cf6; }

.info-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    margin-top: 14px;
    padding-top: 12px;
    border-top: 1px solid var(--border);
}

.info-loading {
    display: flex;
    align-items: center;
    gap: 8px;
    color: var(--text-muted);
    font-size: 12px;
    margin-top: 10px;
    padding: 8px 0;
}

/* ==================== MODAL ==================== */

.modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(8, 8, 10, 0.55);
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
    z-index: 1000;
    display: none;
    align-items: center;
    justify-content: center;
}

.modal-overlay.active {
    display: flex;
}

.modal-card {
    background: var(--glass-bg-strong, rgba(28, 28, 32, 0.78));
    border: 1px solid var(--glass-border-strong, rgba(255, 255, 255, 0.1));
    border-radius: var(--radius);
    width: 480px;
    max-width: 92vw;
    max-height: 85vh;
    overflow-y: auto;
    box-shadow: var(--glass-shadow-lg, 0 24px 64px rgba(0, 0, 0, 0.5));
    backdrop-filter: var(--glass-blur, blur(20px));
    -webkit-backdrop-filter: var(--glass-blur, blur(20px));
}

.modal-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 18px 22px 14px;
    border-bottom: 1px solid var(--glass-border, rgba(255, 255, 255, 0.06));
}

.modal-header h3 {
    margin: 0;
    font-size: 15px;
    font-weight: 600;
    color: var(--text-primary);
    display: flex;
    align-items: center;
    gap: 8px;
}

.modal-close {
    background: none;
    border: none;
    color: var(--text-secondary);
    cursor: pointer;
    padding: 4px 6px;
    border-radius: 6px;
    font-size: 16px;
    transition: color 0.15s;
}

.modal-close:hover { color: var(--text-primary); }

.modal-body {
    padding: 18px 22px 22px;
}

.form-group {
    margin-bottom: 14px;
    flex: 1;
}

.form-group label {
    display: block;
    font-size: 12px;
    font-weight: 500;
    color: var(--text-secondary);
    margin-bottom: 5px;
}

.form-row {
    display: flex;
    gap: 10px;
}

.form-input {
    width: 100%;
    padding: 8px 11px;
    background: var(--bg-tertiary);
    border: 1px solid var(--border);
    border-radius: 7px;
    color: var(--text-primary);
    font-size: 13px;
    font-family: inherit;
    transition: border-color 0.15s;
    box-sizing: border-box;
}

.form-input:focus {
    outline: none;
    border-color: var(--accent);
    box-shadow: 0 0 0 3px rgba(99, 102, 241, 0.15);
}

.form-input option {
    background: #1e1e2e;
    color: #e2e8f0;
}

.form-actions {
    display: flex;
    justify-content: flex-end;
    gap: 8px;
    margin-top: 18px;
    padding-top: 14px;
    border-top: 1px solid var(--border);
}

/* ==================== BUTTONS ==================== */

.btn {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    padding: 7px 13px;
    border-radius: 7px;
    font-size: 12px;
    font-weight: 500;
    cursor: pointer;
    border: 1px solid transparent;
    transition: all 0.15s;
    font-family: inherit;
    white-space: nowrap;
    text-decoration: none;
}

.btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

.btn-sm { padding: 5px 9px; font-size: 11px; }

.btn-primary {
    background: var(--accent);
    color: #fff;
    border-color: var(--accent);
}
.btn-primary:hover:not(:disabled) { background: #5558e6; }

.btn-outline {
    background: transparent;
    border-color: var(--border-light);
    color: var(--text-secondary);
}
.btn-outline:hover:not(:disabled) {
    background: rgba(255, 255, 255, 0.05);
    color: var(--text-primary);
}

.btn-success {
    background: rgba(34, 197, 94, 0.12);
    color: #22c55e;
    border-color: rgba(34, 197, 94, 0.3);
}
.btn-success:hover:not(:disabled) { background: rgba(34, 197, 94, 0.22); }

.btn-danger {
    background: rgba(239, 68, 68, 0.12);
    color: #ef4444;
    border-color: rgba(239, 68, 68, 0.3);
}
.btn-danger:hover:not(:disabled) { background: rgba(239, 68, 68, 0.22); }

/* Spin animation for loading icons */
@keyframes spin { to { transform: rotate(360deg); } }
.spin { animation: spin 0.7s linear infinite; display: inline-block; }

/* ==================== LOADING SPINNER ==================== */

.network-loading {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    color: var(--text-muted);
    font-size: 13px;
    display: flex;
    align-items: center;
    gap: 9px;
    pointer-events: none;
    z-index: 5;
}

.spinner {
    width: 18px;
    height: 18px;
    border: 2px solid var(--border);
    border-top-color: var(--accent);
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
}

/* ==================== MODE SWITCHER ==================== */

.mode-switcher {
    display: flex;
    gap: 6px;
    margin-bottom: 4px;
}

.mode-switcher .mode-btn {
    flex: 1;
    padding: 8px 12px;
    border: 1px solid var(--border);
    border-radius: 6px;
    background: var(--bg-secondary);
    color: var(--text-muted);
    font-size: 12px;
    cursor: pointer;
    transition: all 0.2s;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
}

.mode-switcher .mode-btn:hover {
    border-color: var(--accent);
    color: var(--text-primary);
}

.mode-switcher .mode-btn.active {
    background: var(--accent);
    border-color: var(--accent);
    color: #fff;
}

.mode-switcher-sm .mode-btn {
    padding: 5px 10px;
    font-size: 11px;
}

.form-hint {
    color: var(--text-muted);
    font-size: 11px;
    margin-top: 4px;
    line-height: 1.4;
}

/* ==================== FORM SECTIONS ==================== */

.form-section {
    border: 1px solid var(--glass-border, var(--border));
    border-radius: var(--radius-sm);
    padding: 12px;
    margin: 8px 0;
}

.form-section-title {
    color: var(--text-muted);
    font-size: 11px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    margin-bottom: 10px;
    display: flex;
    align-items: center;
    gap: 5px;
}

.form-details {
    margin: 8px 0;
}

.form-details summary {
    cursor: pointer;
    color: var(--text-muted);
    font-size: 12px;
    padding: 6px 0;
    user-select: none;
}

.form-details summary:hover {
    color: var(--text-primary);
}

.form-checkbox {
    display: flex;
    align-items: center;
    gap: 8px;
    cursor: pointer;
    font-size: 13px;
}

.form-checkbox input[type="checkbox"] {
    width: 16px;
    height: 16px;
    accent-color: var(--accent);
}

/* ==================== INFO MODE BADGE ==================== */

.info-mode-badge {
    display: inline-block;
    padding: 2px 8px;
    border-radius: 4px;
    font-size: 11px;
    font-weight: 600;
}

.info-mode-badge.reverse {
    background: rgba(99, 102, 241, 0.15);
    color: #818cf8;
}

.info-mode-badge.forward {
    background: rgba(245, 158, 11, 0.15);
    color: #fbbf24;
}

.modal-card-lg {
    max-width: 560px;
}

/* ==================== RESPONSIVE ==================== */

@media (max-width: 768px) {
    .network-page {
        height: calc(100vh - 140px);
    }

    .network-legend {
        bottom: auto;
        top: 8px;
        left: 8px;
        padding: 6px 10px;
    }

    .modal-card,
    .modal-card-sm {
        width: 96vw;
    }

    .form-row {
        flex-direction: column;
        gap: 0;
    }
}
