/**
 * Section 5: Distributed Systems Styles
 * Teal/Cyan theme with cluster visualizations
 */

/* Distributed Systems Color Palette */
:root {
    --distributed-primary: #14b8a6;
    --distributed-secondary: #0d9488;
    --distributed-accent: #06b6d4;
    --distributed-light: #5eead4;
    --distributed-dark: #0f766e;
    --node-color: #f0fdfa;
    --edge-color: #99f6e4;
}

/* Override primary colors for this section */
body {
    --primary: var(--distributed-primary);
    --primary-light: var(--distributed-light);
    --accent-purple: var(--distributed-accent);
}

/* SQL Syntax Highlighting - Distributed Keywords */
.sql-keyword {
    color: var(--distributed-primary);
    font-weight: 600;
}

.sql-block {
    background: linear-gradient(135deg, #f0fdfa 0%, #f0fdf4 100%);
    border-left: 3px solid var(--distributed-primary);
    padding: 1rem;
    border-radius: 8px;
    overflow-x: auto;
    margin: 1.5rem 0;
}

/* Python/Code blocks */
.python-block,
.code-block {
    background: #f8fafc;
    border-left: 3px solid var(--distributed-accent);
    padding: 1rem;
    border-radius: 8px;
    overflow-x: auto;
    margin: 1.5rem 0;
}

/* Cluster Visualization Elements */
.cluster-diagram {
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 2rem;
    margin: 2rem 0;
    padding: 2rem;
    background: linear-gradient(135deg, #f0fdfa 0%, #ffffff 100%);
    border-radius: 12px;
}

.cluster-node {
    width: 80px;
    height: 80px;
    background: var(--distributed-primary);
    color: white;
    border-radius: 12px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 600;
    box-shadow: 0 4px 6px rgba(20, 184, 166, 0.2);
    position: relative;
    transition: all 0.3s;
}

.cluster-node:hover {
    transform: translateY(-4px);
    box-shadow: 0 8px 12px rgba(20, 184, 166, 0.3);
}

.cluster-node.replica {
    background: var(--distributed-accent);
}

.cluster-node.leader {
    background: var(--distributed-dark);
    border: 3px solid var(--distributed-light);
}

/* Data Flow Arrows */
.data-flow {
    display: inline-block;
    width: 40px;
    height: 2px;
    background: var(--distributed-accent);
    position: relative;
    margin: 0 1rem;
}

.data-flow::after {
    content: '▶';
    position: absolute;
    right: -8px;
    top: -7px;
    color: var(--distributed-accent);
    font-size: 14px;
}

.data-flow.animated {
    background: linear-gradient(90deg,
            transparent 0%,
            var(--distributed-accent) 50%,
            transparent 100%);
    background-size: 200% 100%;
    animation: dataFlow 2s linear infinite;
}

@keyframes dataFlow {
    0% {
        background-position: -100% 0;
    }

    100% {
        background-position: 100% 0;
    }
}

/* Enhanced Tables for Distributed Systems */
table {
    margin: 1.5rem auto;
    font-size: 14px;
}

/* Tables with node status */
tr.node-healthy {
    background: rgba(20, 184, 166, 0.05);
}

tr.node-failed {
    background: rgba(239, 68, 68, 0.05);
    opacity: 0.7;
}

/* Consensus States */
.state-follower {
    color: #64748b;
    font-weight: 500;
}

.state-candidate {
    color: var(--distributed-accent);
    font-weight: 600;
}

.state-leader {
    color: var(--distributed-dark);
    font-weight: 700;
}

/* Quorum Visualization */
.quorum-box {
    display: inline-flex;
    gap: 0.5rem;
    padding: 0.5rem;
    border: 2px dashed var(--distributed-primary);
    border-radius: 8px;
    background: var(--node-color);
}

.quorum-node {
    width: 30px;
    height: 30px;
    border-radius: 50%;
    background: var(--distributed-primary);
}

.quorum-node.inactive {
    background: #e2e8f0;
}

/* CAP Theorem Triangle */
.cap-triangle {
    width: 200px;
    height: 200px;
    margin: 2rem auto;
    position: relative;
}

.cap-vertex {
    position: absolute;
    width: 60px;
    height: 60px;
    background: var(--distributed-primary);
    color: white;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 700;
}

.cap-vertex.consistency {
    top: 0;
    left: 50%;
    transform: translateX(-50%);
}

.cap-vertex.availability {
    bottom: 0;
    left: 0;
}

.cap-vertex.partition {
    bottom: 0;
    right: 0;
}

/* Ring Visualization for Consistent Hashing */
.hash-ring {
    width: 250px;
    height: 250px;
    border: 3px solid var(--distributed-primary);
    border-radius: 50%;
    position: relative;
    margin: 2rem auto;
}

.hash-ring-node {
    position: absolute;
    width: 40px;
    height: 40px;
    background: var(--distributed-primary);
    color: white;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 12px;
    font-weight: 600;
}

/* Phase Indicators */
.phase-indicator {
    display: inline-block;
    padding: 0.25rem 0.75rem;
    background: var(--distributed-primary);
    color: white;
    border-radius: 999px;
    font-size: 0.85rem;
    font-weight: 600;
    margin-right: 0.5rem;
}

/* Comparison Tables */
.comparison-table {
    width: 100%;
    margin: 2rem 0;
}

.comparison-table th {
    background: linear-gradient(180deg, var(--distributed-light) 0%, var(--distributed-primary) 100%);
    color: white;
}

.comparison-table .better {
    background: rgba(20, 184, 166, 0.1);
    color: var(--distributed-dark);
    font-weight: 600;
}

.comparison-table .worse {
    background: rgba(239, 68, 68, 0.1);
    color: #dc2626;
}

/* Side-by-side layout adjustments */
.side-by-side {
    border: 1px solid var(--edge-color);
    border-radius: 12px;
    padding: 1rem;
    background: linear-gradient(135deg, #ffffff 0%, var(--node-color) 100%);
}

.side-by-side>div {
    padding: 1rem;
}

.side-by-side>div:first-child {
    border-right: 2px dashed var(--edge-color);
}

/* Slide mode adjustments */
body.slides-mode .cluster-diagram {
    transform: scale(1.2);
}

body.slides-mode .hash-ring {
    transform: scale(1.3);
}

/* Navigation subsections */
.nav-subsection {
    margin-left: 0;
    padding-left: 0;
    border-left: none;
    margin-top: 0rem;
}

.nav-subsection h4 {
    font-size: 0.65rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--text-secondary);
    margin: 0.3rem 0 0.15rem 0;
    padding-left: 2rem;
}

.nav-subsection .nav-link {
    font-size: 0.875rem;
    padding: 0.25rem 1.5rem 0.25rem 3rem;
    line-height: 1.3;
}

/* Responsive Design */
@media (max-width: 768px) {
    .cluster-diagram {
        flex-direction: column;
        gap: 1rem;
    }

    .hash-ring {
        width: 180px;
        height: 180px;
    }
}