/* =================================================================
   Phase 4: 3D Kubernetes Cluster Visualization
   Interactive cluster architecture diagram with animations
   ================================================================= */

/* ===== K8S VISUALIZATION CONTAINER ===== */

.k8s-visualization-section {
    position: relative;
    background: var(--bg-secondary);
    overflow: hidden;
    padding: 5rem 0;
}

.k8s-visualization-section::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: radial-gradient(circle at 30% 50%, var(--strategy-bg) 0%, transparent 60%),
                radial-gradient(circle at 70% 50%, var(--platform-bg) 0%, transparent 60%);
    opacity: 0.3;
    pointer-events: none;
}

.visualization-container {
    position: relative;
    max-width: 1400px;
    margin: 0 auto;
    padding: 0 2rem;
    z-index: 1;
}

/* ===== CLUSTER CANVAS ===== */

.cluster-canvas {
    width: 100%;
    height: 600px;
    position: relative;
    perspective: 1500px;
    margin: 3rem 0;
}

/* ===== CLUSTER ARCHITECTURE ===== */

.cluster-architecture {
    position: relative;
    width: 100%;
    height: 100%;
    transform-style: preserve-3d;
    transition: transform 1s cubic-bezier(0.4, 0, 0.2, 1);
}

.cluster-architecture:hover {
    transform: rotateY(5deg) rotateX(-5deg);
}

/* ===== CLUSTER LAYERS ===== */

.cluster-layer {
    position: absolute;
    width: 100%;
    display: flex;
    justify-content: center;
    gap: 2rem;
    transform-style: preserve-3d;
}

.cluster-layer.control-plane {
    top: 0;
    z-index: 3;
}

.cluster-layer.worker-nodes {
    top: 30%;
    z-index: 2;
}

.cluster-layer.services {
    top: 60%;
    z-index: 1;
}

/* ===== NODE COMPONENTS ===== */

.k8s-node {
    position: relative;
    width: 200px;
    height: 150px;
    background: var(--card-bg);
    border: 3px solid var(--border-primary);
    border-radius: 16px;
    padding: 1.5rem;
    transform-style: preserve-3d;
    transition: all 0.4s cubic-bezier(0.4, 0, 0.2, 1);
    cursor: pointer;
    animation: nodeFloat 6s ease-in-out infinite;
}

.k8s-node:nth-child(1) { animation-delay: 0s; }
.k8s-node:nth-child(2) { animation-delay: 0.5s; }
.k8s-node:nth-child(3) { animation-delay: 1s; }
.k8s-node:nth-child(4) { animation-delay: 1.5s; }

@keyframes nodeFloat {
    0%, 100% {
        transform: translateY(0) translateZ(0);
    }
    50% {
        transform: translateY(-10px) translateZ(10px);
    }
}

.k8s-node:hover {
    transform: translateY(-20px) translateZ(30px) scale(1.05);
    border-color: var(--accent-primary);
    box-shadow: 0 20px 60px rgba(245, 128, 78, 0.3);
    z-index: 10;
}

/* Node types */
.k8s-node.master {
    border-color: var(--strategy-accent);
    background: linear-gradient(135deg, var(--card-bg), var(--strategy-bg));
}

.k8s-node.worker {
    border-color: var(--platform-accent);
    background: linear-gradient(135deg, var(--card-bg), var(--platform-bg));
}

.k8s-node.service {
    border-color: var(--security-accent);
    background: linear-gradient(135deg, var(--card-bg), var(--security-bg));
}

/* ===== NODE HEADER ===== */

.node-header {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-bottom: 1rem;
    padding-bottom: 0.75rem;
    border-bottom: 2px solid var(--border-primary);
}

.node-icon {
    width: 40px;
    height: 40px;
    background: var(--bg-secondary);
    border-radius: 8px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 20px;
    color: var(--accent-primary);
    transition: all 0.3s ease;
}

.k8s-node.master .node-icon {
    color: var(--strategy-accent);
}

.k8s-node.worker .node-icon {
    color: var(--platform-accent);
}

.k8s-node.service .node-icon {
    color: var(--security-accent);
}

.k8s-node:hover .node-icon {
    transform: rotate(360deg) scale(1.2);
}

.node-title {
    font-size: 1rem;
    font-weight: 700;
    color: var(--text-primary);
}

/* ===== NODE CONTENT ===== */

.node-content {
    font-size: 0.85rem;
    color: var(--text-secondary);
    line-height: 1.5;
}

.node-status {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    margin-top: 0.5rem;
    padding: 4px 10px;
    background: var(--platform-bg);
    color: var(--platform-accent);
    border-radius: 8px;
    font-size: 0.75rem;
    font-weight: 600;
}

.status-indicator {
    width: 8px;
    height: 8px;
    background: var(--platform-accent);
    border-radius: 50%;
    animation: statusPulse 2s ease-in-out infinite;
}

@keyframes statusPulse {
    0%, 100% {
        opacity: 1;
        box-shadow: 0 0 0 0 var(--platform-accent);
    }
    50% {
        opacity: 0.7;
        box-shadow: 0 0 0 4px rgba(16, 185, 129, 0.3);
    }
}

/* ===== CONNECTION LINES ===== */

.cluster-connections {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
    z-index: 0;
}

.connection-line {
    position: absolute;
    height: 2px;
    background: linear-gradient(90deg,
        var(--accent-primary),
        transparent
    );
    transform-origin: left center;
    opacity: 0.4;
    animation: connectionFlow 3s linear infinite;
}

@keyframes connectionFlow {
    0% {
        background-position: 0% 50%;
    }
    100% {
        background-position: 200% 50%;
    }
}

/* ===== POD CONTAINERS ===== */

.pod-container {
    display: flex;
    gap: 0.5rem;
    margin-top: 0.75rem;
}

.pod {
    width: 12px;
    height: 12px;
    background: var(--accent-primary);
    border-radius: 3px;
    transition: all 0.3s ease;
}

.k8s-node:hover .pod {
    transform: scale(1.2);
    box-shadow: 0 0 8px var(--accent-primary);
}

.pod:nth-child(1) { background: var(--strategy-accent); }
.pod:nth-child(2) { background: var(--platform-accent); }
.pod:nth-child(3) { background: var(--security-accent); }

/* ===== METRICS OVERLAY ===== */

.node-metrics {
    position: absolute;
    bottom: 1rem;
    right: 1rem;
    display: flex;
    gap: 0.75rem;
    opacity: 0;
    transform: translateY(10px);
    transition: all 0.3s ease;
}

.k8s-node:hover .node-metrics {
    opacity: 1;
    transform: translateY(0);
}

.metric-badge {
    background: var(--bg-secondary);
    padding: 4px 8px;
    border-radius: 6px;
    font-size: 0.7rem;
    font-weight: 600;
    color: var(--text-secondary);
    display: flex;
    align-items: center;
    gap: 4px;
}

.metric-badge i {
    font-size: 10px;
}

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

.cluster-legend {
    display: flex;
    justify-content: center;
    gap: 3rem;
    margin-top: 3rem;
    padding: 2rem;
    background: var(--card-bg);
    border-radius: 16px;
    border: 2px solid var(--border-primary);
}

.legend-item {
    display: flex;
    align-items: center;
    gap: 12px;
}

.legend-color {
    width: 40px;
    height: 40px;
    border-radius: 8px;
    border: 3px solid;
}

.legend-color.master {
    background: var(--strategy-bg);
    border-color: var(--strategy-accent);
}

.legend-color.worker {
    background: var(--platform-bg);
    border-color: var(--platform-accent);
}

.legend-color.service {
    background: var(--security-bg);
    border-color: var(--security-accent);
}

.legend-text {
    font-weight: 600;
    color: var(--text-primary);
}

.legend-description {
    font-size: 0.85rem;
    color: var(--text-secondary);
    margin-top: 0.25rem;
}

/* ===== INTERACTIVE CONTROLS ===== */

.visualization-controls {
    display: flex;
    justify-content: center;
    gap: 1rem;
    margin-bottom: 2rem;
}

.viz-control-btn {
    background: var(--card-bg);
    border: 2px solid var(--border-primary);
    color: var(--text-primary);
    padding: 12px 24px;
    border-radius: 12px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s ease;
    display: flex;
    align-items: center;
    gap: 8px;
}

.viz-control-btn:hover {
    border-color: var(--accent-primary);
    color: var(--accent-primary);
    transform: translateY(-2px);
}

.viz-control-btn.active {
    background: var(--accent-primary);
    border-color: var(--accent-primary);
    color: white;
    box-shadow: 0 4px 12px rgba(245, 128, 78, 0.3);
}

.viz-control-btn i {
    font-size: 18px;
}

/* ===== DEPLOYMENT FLOW ANIMATION ===== */

.deployment-flow {
    position: absolute;
    width: 20px;
    height: 20px;
    background: var(--accent-primary);
    border-radius: 50%;
    opacity: 0;
    animation: deployFlow 4s ease-in-out infinite;
}

@keyframes deployFlow {
    0% {
        opacity: 0;
        transform: translate(0, 0) scale(0.5);
    }
    25% {
        opacity: 1;
        transform: translate(100px, 50px) scale(1);
    }
    50% {
        opacity: 0.8;
        transform: translate(200px, 100px) scale(0.8);
    }
    75% {
        opacity: 0.5;
        transform: translate(300px, 150px) scale(0.6);
    }
    100% {
        opacity: 0;
        transform: translate(400px, 200px) scale(0.3);
    }
}

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

@media (max-width: 1200px) {
    .cluster-canvas {
        height: 500px;
    }

    .k8s-node {
        width: 180px;
        height: 140px;
        padding: 1.25rem;
    }

    .cluster-layer {
        gap: 1.5rem;
    }
}

@media (max-width: 768px) {
    .cluster-canvas {
        height: auto;
        perspective: none;
    }

    .cluster-architecture {
        display: flex;
        flex-direction: column;
        gap: 2rem;
        transform: none !important;
    }

    .cluster-layer {
        position: static;
        flex-direction: column;
        align-items: center;
        gap: 1rem;
    }

    .k8s-node {
        width: 100%;
        max-width: 300px;
        animation: none;
    }

    .k8s-node:hover {
        transform: translateY(-8px) scale(1.02);
    }

    .cluster-legend {
        flex-direction: column;
        gap: 1.5rem;
    }

    .visualization-controls {
        flex-wrap: wrap;
    }

    .viz-control-btn {
        flex: 1;
        min-width: 140px;
        justify-content: center;
    }
}

@media (max-width: 480px) {
    .k8s-node {
        padding: 1rem;
    }

    .node-icon {
        width: 32px;
        height: 32px;
        font-size: 16px;
    }

    .node-title {
        font-size: 0.9rem;
    }

    .node-content {
        font-size: 0.8rem;
    }
}

/* ===== DARK THEME ADJUSTMENTS ===== */

[data-theme="dark"] .k8s-node {
    background: rgba(30, 41, 59, 0.6);
    border-color: rgba(255, 255, 255, 0.1);
}

[data-theme="dark"] .k8s-node.master {
    background: linear-gradient(135deg, rgba(30, 41, 59, 0.6), var(--strategy-bg));
}

[data-theme="dark"] .k8s-node.worker {
    background: linear-gradient(135deg, rgba(30, 41, 59, 0.6), var(--platform-bg));
}

[data-theme="dark"] .k8s-node.service {
    background: linear-gradient(135deg, rgba(30, 41, 59, 0.6), var(--security-bg));
}

[data-theme="dark"] .node-icon {
    background: rgba(15, 23, 42, 0.8);
}

[data-theme="dark"] .cluster-legend {
    background: rgba(30, 41, 59, 0.6);
    border-color: rgba(255, 255, 255, 0.1);
}

[data-theme="dark"] .viz-control-btn {
    background: rgba(30, 41, 59, 0.6);
    border-color: rgba(255, 255, 255, 0.1);
}

[data-theme="dark"] .metric-badge {
    background: rgba(15, 23, 42, 0.8);
}
