/* Enable scrolling */
body.domain-synergy-page {
    overflow-y: auto !important;
    overflow-x: hidden;
    height: auto;
    min-height: 100vh;
    background: var(--bg-dark, #0a0a0f);
}

body.domain-synergy-page #app {
    height: auto;
    min-height: 100vh;
}

/* ═══════════════════════════════════════════════════
   LAYOUT
   ═══════════════════════════════════════════════════ */

.app-container {
    max-width: 1200px;
    margin: 0 auto;
    padding: 20px;
}

/* Header */
.header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 20px 0;
    border-bottom: 1px solid var(--border-color, #3a3a42);
    margin-bottom: 24px;
}

.back-link {
    color: var(--text-secondary, #A09A92);
    text-decoration: none;
    font-size: 14px;
    transition: color 0.2s;
}

.back-link:hover {
    color: var(--accent-primary, #6366f1);
}

.header h1 {
    font-size: 24px;
    font-weight: 700;
    background: linear-gradient(135deg, var(--accent-primary, #6366f1), var(--accent-secondary, #8b5cf6));
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    margin: 0;
}

.header-actions {
    display: flex;
    gap: 16px;
}

.nav-link {
    color: var(--text-secondary, #A09A92);
    text-decoration: none;
    font-size: 14px;
    padding: 8px 16px;
    border-radius: 8px;
    transition: all 0.2s;
}

.nav-link:hover {
    color: var(--text-primary, #E8E6E3);
    background: var(--bg-elevated, #1a1a24);
}

/* ═══════════════════════════════════════════════════
   STATS ROW
   ═══════════════════════════════════════════════════ */

.stats-row {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 12px;
    margin-bottom: 24px;
}

.stat-card {
    background: var(--bg-card, #12121a);
    border-radius: 16px;
    padding: 20px;
    text-align: center;
}

.stat-value {
    display: block;
    font-size: 28px;
    font-weight: 700;
    color: var(--accent-primary, #6366f1);
}

.stat-label {
    font-size: 13px;
    color: var(--text-secondary, #A09A92);
    margin-top: 4px;
}

/* ═══════════════════════════════════════════════════
   MAIN GRID
   ═══════════════════════════════════════════════════ */

.synergy-grid {
    display: grid;
    grid-template-columns: 1fr 340px;
    gap: 20px;
    align-items: start;
}

/* ═══════════════════════════════════════════════════
   NETWORK CARD
   ═══════════════════════════════════════════════════ */

.network-card {
    background: var(--bg-card, #12121a);
    border-radius: 16px;
    overflow: hidden;
}

.card-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 16px 20px;
    border-bottom: 1px solid var(--border-color, #3a3a42);
}

.card-header h2 {
    font-size: 16px;
    font-weight: 600;
    color: var(--text-primary, #E8E6E3);
    margin: 0;
}

.reset-btn {
    background: var(--bg-elevated, #1a1a24);
    border: 1px solid var(--border-color, #3a3a42);
    color: var(--text-secondary, #A09A92);
    padding: 6px 14px;
    border-radius: 8px;
    cursor: pointer;
    font-size: 13px;
    transition: all 0.2s;
}

.reset-btn:hover {
    border-color: var(--accent-primary, #6366f1);
    color: var(--text-primary, #E8E6E3);
}

.network-area {
    height: 500px;
    position: relative;
    background: radial-gradient(ellipse at center,
        rgba(99, 102, 241, 0.03) 0%,
        transparent 70%);
}

#network-graph {
    display: block;
    width: 100%;
    height: 100%;
}

.network-legend {
    display: flex;
    gap: 20px;
    padding: 12px 20px;
    border-top: 1px solid var(--border-color, #3a3a42);
}

.legend-item {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 12px;
    color: var(--text-secondary, #A09A92);
}

.legend-dot {
    width: 20px;
    height: 3px;
    border-radius: 2px;
}

.legend-dot.primary { background: #818cf8; }
.legend-dot.secondary { background: #fbbf24; }
.legend-dot.inverse { background: #f87171; }
.legend-dot.tertiary { background: #a78bfa; }

/* ═══════════════════════════════════════════════════
   D3 SVG ELEMENTS
   ═══════════════════════════════════════════════════ */

.link {
    transition: stroke-opacity 0.3s;
}

.link.primary { stroke: #818cf8; stroke-opacity: 0.5; }
.link.secondary { stroke: #fbbf24; stroke-opacity: 0.4; }
.link.inverse { stroke: #f87171; stroke-opacity: 0.4; stroke-dasharray: 5 5; }
.link.tertiary { stroke: #a78bfa; stroke-opacity: 0.25; stroke-dasharray: 3 6; }

.link.highlighted { stroke-opacity: 0.9; }
.link.faded { stroke-opacity: 0.06; }

.node { cursor: pointer; transition: opacity 0.3s; }
.node circle { transition: all 0.2s; }
.node:hover circle { stroke-width: 3; filter: drop-shadow(0 0 8px rgba(99, 102, 241, 0.4)); }
.node.active circle { stroke-width: 3; stroke: #fff !important; filter: drop-shadow(0 0 12px rgba(99, 102, 241, 0.5)); }
.node.faded { opacity: 0.12; }

/* ═══════════════════════════════════════════════════
   SIDEBAR
   ═══════════════════════════════════════════════════ */

.sidebar {
    display: flex;
    flex-direction: column;
    gap: 16px;
}

.card {
    background: var(--bg-card, #12121a);
    border-radius: 16px;
    padding: 20px;
}

.card-title {
    font-size: 15px;
    font-weight: 600;
    color: var(--text-primary, #E8E6E3);
    margin: 0 0 16px 0;
}

/* ═══════════════════════════════════════════════════
   TRIADS
   ═══════════════════════════════════════════════════ */

.triad-list {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.triad-card {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px;
    background: var(--bg-elevated, #1a1a24);
    border: 1px solid transparent;
    border-radius: 12px;
    cursor: pointer;
    transition: all 0.2s;
}

.triad-card:hover {
    border-color: var(--border-color, #3a3a42);
    background: var(--bg-secondary, #232328);
}

.triad-card.active {
    border-color: var(--accent-primary, #6366f1);
    background: rgba(99, 102, 241, 0.08);
}

.triad-icon {
    font-size: 1.5rem;
    flex-shrink: 0;
}

.triad-info {
    flex: 1;
    min-width: 0;
}

.triad-name {
    font-size: 14px;
    font-weight: 500;
    color: var(--text-primary, #E8E6E3);
    margin-bottom: 6px;
}

.triad-domains {
    display: flex;
    flex-wrap: wrap;
    gap: 4px;
}

.tag {
    background: rgba(255, 255, 255, 0.06);
    padding: 2px 8px;
    border-radius: 6px;
    font-size: 11px;
    color: var(--text-secondary, #A09A92);
}

/* ═══════════════════════════════════════════════════
   DOMAIN DETAIL
   ═══════════════════════════════════════════════════ */

.domain-detail {
    display: none;
}

.domain-detail.active {
    display: block;
}

.detail-header {
    display: flex;
    align-items: center;
    gap: 12px;
    margin-bottom: 12px;
}

.detail-icon {
    font-size: 2rem;
    width: 48px;
    height: 48px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--bg-elevated, #1a1a24);
    border-radius: 12px;
    flex-shrink: 0;
}

.detail-name {
    font-size: 16px;
    font-weight: 600;
    color: var(--text-primary, #E8E6E3);
}

.detail-category {
    font-size: 13px;
    color: var(--text-secondary, #A09A92);
}

.detail-description {
    font-size: 14px;
    color: var(--text-secondary, #A09A92);
    line-height: 1.6;
    margin: 0 0 16px 0;
}

/* Score */
.detail-score-section {
    margin-bottom: 16px;
    padding: 12px;
    background: var(--bg-elevated, #1a1a24);
    border-radius: 10px;
}

.detail-score-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 8px;
}

.detail-score-label {
    font-size: 12px;
    color: var(--text-muted, #6B665E);
}

.detail-score-value {
    font-size: 18px;
    font-weight: 700;
    color: var(--accent-primary, #6366f1);
}

.detail-score-bar {
    height: 6px;
    background: rgba(255, 255, 255, 0.06);
    border-radius: 3px;
    overflow: hidden;
}

.detail-score-fill {
    height: 100%;
    border-radius: 3px;
    transition: width 0.5s ease;
}

/* Section titles */
.detail-section-title {
    font-size: 12px;
    font-weight: 500;
    color: var(--text-muted, #6B665E);
    text-transform: uppercase;
    letter-spacing: 0.5px;
    margin: 16px 0 10px 0;
}

/* Connections */
.connection-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 8px 10px;
    background: var(--bg-elevated, #1a1a24);
    border-radius: 8px;
    margin-bottom: 4px;
}

.connection-name {
    font-size: 13px;
    color: var(--text-primary, #E8E6E3);
}

.connection-type {
    font-size: 10px;
    padding: 2px 8px;
    border-radius: 10px;
    text-transform: uppercase;
    font-weight: 500;
}

.connection-type.primary { background: rgba(129, 140, 248, 0.15); color: #818cf8; }
.connection-type.secondary { background: rgba(251, 191, 36, 0.15); color: #fbbf24; }
.connection-type.inverse { background: rgba(248, 113, 113, 0.15); color: #f87171; }
.connection-type.tertiary { background: rgba(167, 139, 250, 0.15); color: #a78bfa; }

/* Cascade */
.cascade-preview {
    display: none;
}

.cascade-row {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 6px 0;
    font-size: 13px;
    color: var(--text-secondary, #A09A92);
}

.cascade-arrow {
    color: var(--accent-primary, #6366f1);
}

.cascade-factor {
    margin-left: auto;
    color: #4ade80;
    font-weight: 600;
    font-size: 12px;
}

/* Placeholder */
.placeholder-card {
    text-align: center;
    padding: 40px 20px;
    color: var(--text-muted, #6B665E);
}

.placeholder-icon {
    font-size: 2rem;
    margin-bottom: 12px;
    opacity: 0.4;
}

.placeholder-card p {
    font-size: 14px;
    line-height: 1.5;
    margin: 0;
}

.empty-text {
    font-size: 13px;
    color: var(--text-muted, #6B665E);
    margin: 0;
}

/* ═══════════════════════════════════════════════════
   RESPONSIVE
   ═══════════════════════════════════════════════════ */

@media (max-width: 1024px) {
    .synergy-grid {
        grid-template-columns: 1fr;
    }

    .network-area {
        height: 400px;
    }
}

@media (max-width: 768px) {
    .app-container {
        padding: 16px;
    }

    .header {
        flex-direction: column;
        gap: 12px;
        text-align: center;
    }

    .stats-row {
        grid-template-columns: repeat(3, 1fr);
        gap: 8px;
    }

    .stat-card {
        padding: 14px;
    }

    .stat-value {
        font-size: 22px;
    }

    .network-area {
        height: 320px;
    }

    .network-legend {
        flex-wrap: wrap;
        gap: 12px;
        justify-content: center;
    }
}

@media (max-width: 480px) {
    .header h1 {
        font-size: 20px;
    }

    .header-actions {
        display: none;
    }
}
