:root {
    --bg-color: #0f172a;
    --card-bg: rgba(30, 41, 59, 0.6);
    --text-primary: #f1f5f9;
    --text-secondary: #94a3b8;
    --accent: #38bdf8;
    --success: #10b981;
    --warning: #f59e0b;
    --danger: #ef4444;
    --border-color: rgba(148, 163, 184, 0.1);
    --font-family: 'Inter', sans-serif;
}

* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

body {
    font-family: var(--font-family);
    background-color: var(--bg-color);
    color: var(--text-primary);
    overflow-x: hidden;
    height: 100vh;
    /* Attempt to fit on one screen */
    display: flex;
    flex-direction: column;
}

.background-shapes {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: -1;
}

.shape {
    position: absolute;
    filter: blur(90px);
    opacity: 0.3;
    border-radius: 50%;
}

.shape-1 {
    width: 600px;
    height: 600px;
    background: var(--accent);
    top: -20%;
    left: -10%;
}

.shape-2 {
    width: 500px;
    height: 500px;
    background: #6366f1;
    bottom: -20%;
    right: -10%;
}

.container-fluid {
    max-width: 1400px;
    margin: 0 auto;
    padding: 1rem 2rem;
    display: flex;
    flex-direction: column;
    height: 100%;
    justify-content: space-between;
}

.main-header {
    text-align: center;
    margin-bottom: 1rem;
}

.main-header h4 {
    font-size: 1.5rem;
    font-weight: 700;
    color: #fff;
}

.subtitle {
    color: var(--text-secondary);
    font-size: 0.9rem;
}

/* Chain Section New Layout */

.chain-section {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 2rem;
    flex-grow: 1;
    justify-content: center;
}

.chain-container {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 1rem;
    padding: 2rem;
    width: 100%;
}

.location-group {
    background: rgba(255, 255, 255, 0.03);
    border-radius: 1.5rem;
    padding: 2rem;
    position: relative;
    display: flex;
    flex-direction: column;
    align-items: center;
    border: 1px dashed rgba(255, 255, 255, 0.1);
    transition: all 0.3s;
}

.location-group:hover {
    background: rgba(255, 255, 255, 0.05);
    border-color: rgba(255, 255, 255, 0.2);
}

.location-group.cloud {
    border-color: rgba(56, 189, 248, 0.3);
}

.location-group.hq {
    border-style: solid;
    border-color: rgba(16, 185, 129, 0.3);
}

.location-label {
    margin-bottom: 2rem;
    display: flex;
    align-items: center;
    gap: 0.5rem;
    color: var(--text-secondary);
    font-weight: 600;
    text-transform: uppercase;
    font-size: 0.8rem;
    letter-spacing: 0.05em;
    width: 100%;
    justify-content: center;
}

.location-label .lucide {
    width: 16px;
    height: 16px;
}

.nodes-row {
    display: flex;
    align-items: center;
    position: relative;
}

/* Connection between locations */
.internet-connection {
    display: flex;
    align-items: center;
    color: var(--text-secondary);
    padding: 0 1rem;
    position: relative;
    min-width: 60px;
    justify-content: center;
}

.internet-connection .connection-line {
    position: absolute;
    width: 100%;
    height: 2px;
    background: var(--border-color);
    background: repeating-linear-gradient(90deg, var(--border-color) 0, var(--border-color) 6px, transparent 6px, transparent 12px);
    z-index: 1;
}

.internet-connection .connection-icon {
    background: var(--bg-color);
    z-index: 2;
    padding: 0 5px;
}

/* Nodes */
.chain-node {
    position: relative;
    display: flex;
    flex-direction: column;
    align-items: center;
    cursor: pointer;
    transition: transform 0.3s cubic-bezier(0.34, 1.56, 0.64, 1);
    z-index: 10;
}

.chain-node:hover {
    transform: scale(1.15);
}

.icon-circle {
    width: 64px;
    height: 64px;
    background: rgba(15, 23, 42, 0.8);
    border: 2px solid var(--border-color);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    margin-bottom: 0.5rem;
    transition: all 0.3s;
    box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.5);
}

.chain-node .lucide {
    width: 24px;
    height: 24px;
    color: var(--text-secondary);
}

.label {
    font-size: 0.85rem;
    font-weight: 600;
    color: var(--text-secondary);
}

/* Managed State */
.chain-node.managed .icon-circle {
    border-color: var(--success);
    box-shadow: 0 0 15px rgba(16, 185, 129, 0.2);
}

.chain-node.managed .lucide {
    color: var(--success);
}

.chain-node.managed .status-indicator {
    background: var(--success);
}

/* Unmanaged State */
.chain-node.unmanaged .icon-circle {
    border-color: var(--warning);
    box-shadow: 0 0 15px rgba(245, 158, 11, 0.2);
}

.chain-node.unmanaged .lucide {
    color: var(--warning);
}

.chain-node.unmanaged .status-indicator {
    background: var(--warning);
    animation: pulse 2s infinite;
}

.status-indicator {
    width: 10px;
    height: 10px;
    border-radius: 50%;
    position: absolute;
    top: 0;
    right: 0;
}

@keyframes pulse {
    0% {
        transform: scale(1);
        opacity: 1;
    }

    50% {
        transform: scale(1.5);
        opacity: 0.5;
    }

    100% {
        transform: scale(1);
        opacity: 1;
    }
}

.risk-badge {
    position: absolute;
    top: -20px;
    background: var(--danger);
    color: white;
    font-size: 0.65rem;
    font-weight: bold;
    padding: 2px 6px;
    border-radius: 4px;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.3);
}

/* Links within groups */
.chain-link {
    width: 40px;
    height: 2px;
    background: var(--border-color);
    margin: 0 10px;
}

/* Node Attachment (Apps, Printers) */
.node-attachment {
    position: absolute;
}

.node-attachment.top-right {
    top: -90px;
    right: 0;
}

.node-attachment.bottom-right {
    bottom: -90px;
    right: 0;
}

/* Mini Nodes */
.chain-node.mini-node .icon-circle.small {
    width: 48px;
    height: 48px;
}

.chain-node.mini-node .label {
    font-size: 0.75rem;
}

.chain-node.mini-node .risk-badge {
    top: -15px;
    font-size: 0.6rem;
}

/* Connectors for attachments */
.node-attachment::before {
    content: '';
    position: absolute;
    width: 2px;
    height: 40px;
    background: var(--border-color);
    left: 50%;
    transform: translateX(-50%);
}

.node-attachment.top-right::before {
    bottom: -40px;
}

.node-attachment.bottom-right::before {
    top: -40px;
}

/* Details Panel */
.details-panel {
    width: 100%;
    max-width: 800px;
    min-height: 180px;
    padding: 1.5rem;
    border-radius: 1rem;
    transition: all 0.3s;
    border: 1px solid var(--accent);
    box-shadow: 0 0 30px rgba(56, 189, 248, 0.05);
}

.glass-panel {
    background: var(--card-bg);
    backdrop-filter: blur(12px);
    border: 1px solid var(--border-color);
    border-radius: 1rem;
}

.panel-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 1rem;
    border-bottom: 1px solid var(--border-color);
    padding-bottom: 0.5rem;
}

.panel-header h2 {
    font-size: 1.25rem;
    color: #fff;
}

.status-pill {
    padding: 0.25rem 0.75rem;
    border-radius: 1rem;
    font-size: 0.75rem;
    font-weight: 700;
    text-transform: uppercase;
}

.status-pill.managed {
    background: rgba(16, 185, 129, 0.2);
    color: var(--success);
}

.status-pill.risk {
    background: rgba(239, 68, 68, 0.2);
    color: var(--danger);
}

.status-pill.neutral {
    background: rgba(255, 255, 255, 0.1);
    color: var(--text-secondary);
}

.panel-body p {
    font-size: 0.95rem;
    color: var(--text-secondary);
    margin-bottom: 1rem;
}

.panel-extra h4 {
    color: var(--text-primary);
    margin-bottom: 0.5rem;
    font-size: 0.9rem;
}

.panel-extra ul {
    padding-left: 1.2rem;
    color: var(--text-secondary);
    font-size: 0.9rem;
}

/* Grid Layout for Bottom Info */
.grid-layout {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 1.5rem;
    margin-top: 2rem;
    margin-bottom: 1rem;
}

.info-card {
    padding: 1.25rem;
}

.info-card h3 {
    font-size: 1rem;
    color: var(--accent);
    margin-bottom: 0.75rem;
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.info-card .lucide {
    width: 18px;
    height: 18px;
}

.sm-text {
    font-size: 0.85rem;
    color: var(--text-secondary);
    margin-bottom: 0.5rem;
}

.compact-list {
    list-style: none;
    font-size: 0.85rem;
    color: var(--text-secondary);
}

.compact-list li {
    margin-bottom: 0.4rem;
    padding-left: 0.5rem;
    border-left: 2px solid var(--border-color);
}

footer {
    text-align: center;
    font-size: 0.75rem;
    color: rgba(255, 255, 255, 0.2);
    padding-bottom: 1rem;
}

/* Responsive */
@media (max-width: 1024px) {
    body {
        height: auto;
        overflow-y: auto;
    }

    .grid-layout {
        grid-template-columns: 1fr;
    }

    .chain-container {
        flex-direction: column;
        gap: 2rem;
    }

    .internet-connection {
        transform: rotate(90deg);
        min-width: 0;
        min-height: 40px;
    }

    .node-attachment {
        position: relative;
        top: auto;
        right: auto;
        bottom: auto;
        margin-top: 1rem;
    }

    .node-attachment::before {
        display: none;
    }

    .nodes-row {
        flex-wrap: wrap;
        justify-content: center;
        gap: 1rem;
    }
}

/* CSS for Column-Based Refactored Layout */
/* Clean slate for the structure changes */

.node-column {
    display: flex;
    flex-direction: column;
    align-items: center;
    position: relative;
    min-width: 120px;
}

.nodes-row {
    display: flex;
    align-items: flex-start;
    /* Align tops of columns */
    justify-content: center;
    gap: 0;
    /* Gaps handled by links */
}

/* Vertical connector from row 1 to row 2 */
.branch-line-vertical {
    width: 2px;
    height: 30px;
    background: var(--border-color);
    margin: 0.5rem 0;
}

/* Ensure horizontal link is centered vertically relative to the TOP nodes */
/* The top nodes are the first children of .node-column */
.chain-link {
    width: 40px;
    height: 2px;
    background: var(--border-color);
    margin: 0 10px;
    /* Push it down to align with the middle of the first circle (64px height + approx margin) */
    /* Circle is 64px, so center is at 32px. */
    margin-top: 36px;
    /* 32px + border correction */
    align-self: flex-start;
    /* Don't stretch */
}

/* Location Header */
.location-top-bar {
    width: 100%;
    border-bottom: 1px solid rgba(255, 255, 255, 0.05);
    margin-bottom: 1.5rem;
    padding-bottom: 0.5rem;
}

.location-group {
    padding-bottom: 2rem;
}

/* Mini Node adjustments */
.chain-node.mini-node .icon-circle.small {
    width: 48px;
    height: 48px;
    box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.3);
}

.chain-node.mini-node .label {
    font-size: 0.75rem;
    margin-top: 5px;
}

/* Deprecated / Reset styles */
.nodes-grid,
.nodes-row.secondary {
    display: none !important;
}

/* Clean up old absolute positioning mess */
.node-attachment,
.node-attachment::before {
    display: none;
}

/* Mobile Overrides */
@media (max-width: 1024px) {
    .nodes-row {
        flex-wrap: wrap;
    }

    .node-column {
        flex-direction: column;
        width: 100%;
        margin-bottom: 2rem;
    }

    .chain-link {
        display: none;
    }
}

/* Risk Banner Styles */
.risk-banner {
    margin-top: 1.5rem;
    padding: 1.5rem;
    display: flex;
    align-items: flex-start;
    gap: 1.5rem;
    border: 1px solid var(--danger);
    background: rgba(239, 68, 68, 0.1);
    /* Red tint */
}

.risk-icon-container {
    background: rgba(239, 68, 68, 0.2);
    padding: 1rem;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

.risk-icon-container .lucide {
    color: var(--danger);
    width: 32px;
    height: 32px;
}

.risk-content h3 {
    color: var(--danger);
    margin-bottom: 0.5rem;
    font-size: 1.1rem;
    font-weight: 700;
}

.risk-content p {
    color: var(--text-secondary);
    font-size: 0.95rem;
    line-height: 1.5;
}

.risk-content strong {
    color: var(--text-primary);
}

@media (max-width: 768px) {
    .risk-banner {
        flex-direction: column;
        align-items: center;
        text-align: center;
    }
}

/* Network Flow Animation */

/* Base animation keyframes */
@keyframes flow {
    0% {
        background-position: 0 0;
    }

    100% {
        background-position: 20px 0;
    }
}

@keyframes flow-vertical {
    0% {
        background-position: 0 0;
    }

    100% {
        background-position: 0 20px;
    }
}

/* Apply to horizontal links */
.chain-link,
.connection-line {
    /* Create a dashed line pattern with gradient */
    background: repeating-linear-gradient(90deg,
            rgba(56, 189, 248, 0.5) 0,
            rgba(56, 189, 248, 0.5) 10px,
            transparent 10px,
            transparent 20px);
    background-size: 200% 100%;
    /* Ensure space for animation */
    animation: flow 1s linear infinite;
    opacity: 0.8;
}

/* Apply to vertical branches */
.branch-line-vertical {
    background: repeating-linear-gradient(180deg,
            rgba(56, 189, 248, 0.5) 0,
            rgba(56, 189, 248, 0.5) 6px,
            transparent 6px,
            transparent 12px);
    background-size: 100% 200%;
    animation: flow-vertical 1s linear infinite;
    width: 2px;
}

/* Enhancing the Network Node to pulsate as the 'Source' */
.chain-node[data-node="network"] .icon-circle {
    box-shadow: 0 0 20px rgba(56, 189, 248, 0.4);
    border-color: var(--accent);
    animation: pulse-border 2s infinite;
}

@keyframes pulse-border {
    0% {
        box-shadow: 0 0 0 0 rgba(56, 189, 248, 0.7);
    }

    70% {
        box-shadow: 0 0 0 10px rgba(56, 189, 248, 0);
    }

    100% {
        box-shadow: 0 0 0 0 rgba(56, 189, 248, 0);
    }
}