/* ===== CSS VARIABLES ===== */
:root {
    --year1: #29b6f6;
    --year1-dark: #0288d1;
    --year1-glow: rgba(41, 182, 246, 0.4);
    --year2: #66bb6a;
    --year2-dark: #2e7d32;
    --year2-glow: rgba(102, 187, 106, 0.4);
    --year3: #ab47bc;
    --year3-dark: #7b1fa2;
    --year3-glow: rgba(171, 71, 188, 0.4);
    --year4: #ff7043;
    --year4-dark: #d84315;
    --year4-glow: rgba(255, 112, 67, 0.4);
    --bg: #0c111b;
    --card: rgba(255, 255, 255, 0.035);
    --text: #e8eaed;
    --muted: #8a9099;
    --node-size: 105px;
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: 'Cairo', sans-serif;
    background: var(--bg);
    color: var(--text);
    overflow: hidden;
    height: 100vh;
    width: 100vw;
}

/* Subtle grid background */
body::before {
    content: '';
    position: fixed;
    inset: 0;
    background-image:
        radial-gradient(circle at 1px 1px, rgba(255, 255, 255, 0.03) 1px, transparent 0);
    background-size: 40px 40px;
    pointer-events: none;
    z-index: 0;
}

/* ===== ANIMATIONS ===== */
@keyframes fadeIn {
    from {
        opacity: 0;
        transform: translateY(15px) scale(0.9);
    }

    to {
        opacity: 1;
        transform: translateY(0) scale(1);
    }
}

.node {
    animation: fadeIn 0.5s ease forwards;
    opacity: 0;
}

/* ===== SCROLLBAR (hidden) ===== */
::-webkit-scrollbar {
    display: none;
}

body {
    -ms-overflow-style: none;
    scrollbar-width: none;
}


/* ===== VIEWPORT (pan & zoom container) ===== */
.viewport {
    position: fixed;
    inset: 0;
    overflow: hidden;
    cursor: grab;
    z-index: 1;
}

.viewport:active {
    cursor: grabbing;
}

.viewport-inner {
    position: absolute;
    top: 0;
    left: 0;
    transform-origin: 0 0;
    will-change: transform;
}

/* ===== HEADER ===== */
.header {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    z-index: 100;
    text-align: center;
    padding: 65px 20px 12px;
    background: linear-gradient(180deg, var(--bg) 60%, transparent);
    pointer-events: none;
}

.header h1 {
    font-size: 2.4rem;
    font-weight: 900;
    background: linear-gradient(135deg, var(--year1), var(--year3), var(--year4));
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

.header .sub {
    font-size: 0.95rem;
    color: var(--muted);
    font-weight: 600;
}

.header .info {
    font-size: 0.78rem;
    color: var(--muted);
    opacity: 0.6;
    margin-top: 2px;
}

@media (min-width: 1025px) {
    .header .info {
        display: none;
    }
}

.right-sidebar {
    position: fixed;
    right: 0;
    top: 85px;
    bottom: 20px;
    display: flex;
    flex-direction: row-reverse;
    align-items: flex-start;
    pointer-events: none;
    z-index: 1000;
    transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

.right-sidebar.collapsed {
    transform: translateX(calc(100% - 36px));
}

.sidebar-toggle-btn {
    pointer-events: auto;
    background: rgba(12, 17, 27, 0.9);
    backdrop-filter: blur(12px);
    border: 1px solid rgba(255, 255, 255, 0.12);
    color: var(--text);
    width: 36px;
    height: 48px;
    border-radius: 8px 0 0 8px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    margin-top: 20px;
    box-shadow: -4px 4px 15px rgba(0, 0, 0, 0.3);
    border-right: none;
    transition: background 0.2s;
}

.sidebar-toggle-btn:hover {
    background: rgba(255, 255, 255, 0.1);
}

.sidebar-content-wrapper {
    display: flex;
    flex-direction: column;
    gap: 12px;
    max-height: calc(100vh - 100px);
    width: 280px;
    overflow-y: auto;
    margin-right: 15px;
    padding-left: 6px;
    padding-bottom: 20px;
    pointer-events: auto;
    scrollbar-width: thin;
    scrollbar-color: rgba(255, 255, 255, 0.2) transparent;
}

.sidebar-content-wrapper>* {
    flex-shrink: 0;
}

.sidebar-content-wrapper::-webkit-scrollbar {
    width: 6px;
}

.sidebar-content-wrapper::-webkit-scrollbar-track {
    background: transparent;
}

.sidebar-content-wrapper::-webkit-scrollbar-thumb {
    background: rgba(255, 255, 255, 0.2);
    border-radius: 4px;
}

.sidebar-content-wrapper::-webkit-scrollbar-thumb:hover {
    background: rgba(255, 255, 255, 0.4);
}




/* ===== RESPONSIVE DESIGN ===== */
@media (max-width: 1350px) {}

@media (max-width: 1024px) {
    .header h1 {
        font-size: 1.8rem;
    }

    .header .sub {
        font-size: 0.82rem;
    }

    .header .info {
        display: none;
    }

    .search-container {
        width: 220px;
        left: 15px;
    }

    .legend-bar {
        padding: 10px 14px;
    }

    .legend-text {
        font-size: 0.72rem;
    }

    .legend-text-ar {
        font-size: 0.62rem;
    }

    .legend-click-hint {
        display: none;
    }

    .right-sidebar {
        right: 10px;
        top: 75px;
    }

    .planner-controls-top {
        flex-direction: column;
    }
}

@media (max-width: 768px) {

    .header {
        padding: 100px 12px 10px;
    }

    .header h1 {
        font-size: 1.3rem;
    }

    .header .sub,
    .header .info {
        display: none;
    }

    .search-container {
        width: calc(100% - 24px) !important;
        left: 12px !important;
        right: 12px !important;
        top: 62px !important;
        max-width: none !important;
    }

    .right-sidebar {
        position: fixed;
        right: 0;
        top: 110px;
        bottom: 20px;
        flex-direction: row-reverse;
        align-items: flex-start;
        z-index: 1500;
        transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    }

    .right-sidebar.collapsed {
        transform: translateX(calc(100% - 36px));
    }

    .sidebar-content-wrapper {
        width: min(290px, 82vw);
        max-height: calc(100vh - 130px);
        background: rgba(12, 17, 27, 0.95);
        border: 1px solid rgba(255, 255, 255, 0.15);
        border-radius: 14px;
        padding: 12px;
        backdrop-filter: blur(16px);
        box-shadow: -8px 8px 30px rgba(0, 0, 0, 0.6);
        margin-right: 8px;
    }

    .legend-bar {
        display: block !important;
        padding: 10px;
    }

    .legend-grid {
        grid-template-columns: 1fr 1fr;
        gap: 6px;
    }

    .legend-text {
        font-size: 0.68rem;
    }

    .legend-text-ar {
        font-size: 0.6rem;
    }

    .zoom-controls {
        left: 12px;
        bottom: 12px;
        flex-direction: column;
        gap: 4px;
    }

    .zoom-btn {
        width: 36px;
        height: 36px;
        font-size: 0.95rem;
    }

    .zoom-level {
        font-size: 0.65rem;
        padding: 2px 6px;
        min-width: 38px;
    }

    .planner-container {
        padding: 10px;
    }

    .planner-header-banner h2 {
        font-size: 1.3rem;
    }

    .planner-controls-top {
        flex-direction: column;
        gap: 10px;
    }

    .planner-bottom-bar {
        flex-direction: column;
        gap: 10px;
    }

    .planner-table th,
    .planner-table td {
        padding: 8px 10px;
        font-size: 0.8rem;
    }

    #tab-planner {
        padding-top: 110px;
    }
}


/* ===== TREE CANVAS ===== */
.tree-canvas {
    position: relative;
    width: 5600px;
    height: 2500px;
    margin: 0 auto;
}

/* SVG arrows layer */
.tree-canvas svg.arrows {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
    z-index: 1;
}

/* ===== NODE ===== */
.node {
    position: absolute;
    z-index: 5;
    display: flex;
    flex-direction: column;
    align-items: center;
    cursor: pointer;
    transition: transform 0.25s ease, filter 0.25s ease;
}

.node:hover {
    transform: scale(1.1);
    z-index: 20;
}

.node .bubble {
    width: var(--node-size);
    height: var(--node-size);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    text-align: center;
    padding: 10px;
    font-size: 0.62rem;
    font-weight: 700;
    line-height: 1.35;
    color: #fff;
    border: 3px solid;
    transition: box-shadow 0.25s, transform 0.25s;
    text-shadow: 0 1px 4px rgba(0, 0, 0, 0.5);
    position: relative;
}

.node .code {
    font-size: 0.58rem;
    color: var(--muted);
    margin-top: 4px;
    text-align: center;
    font-weight: 600;
    direction: ltr;
}

.node .hrs {
    font-size: 0.52rem;
    color: var(--muted);
    opacity: 0.55;
    direction: ltr;
}

/* Year colors */
.y1 .bubble {
    background: linear-gradient(145deg, #4fc3f7, #0277bd);
    border-color: var(--year1-dark);
    box-shadow: 0 4px 25px var(--year1-glow);
}

.y2 .bubble {
    background: linear-gradient(145deg, #81c784, #1b5e20);
    border-color: var(--year2-dark);
    box-shadow: 0 4px 25px var(--year2-glow);
}

.y3 .bubble {
    background: linear-gradient(145deg, #ce93d8, #6a1b9a);
    border-color: var(--year3-dark);
    box-shadow: 0 4px 25px var(--year3-glow);
}

.y4 .bubble {
    background: linear-gradient(145deg, #ff8a65, #bf360c);
    border-color: var(--year4-dark);
    box-shadow: 0 4px 25px var(--year4-glow);
}

/* Elective styling removed dashed border to fix circle glitch */

.elective .bubble::after {
    content: '📋';
    position: absolute;
    top: -6px;
}