:root {
    --red: #ff1a22;
    --green: #6abc28;
    --orange: #ff7b05;
    --purple: #752d7e;
    --white: #ffffff;
    --light-bg: #f5f7f9;
    --text-dark: #2d2d2d;
    --text-light: #5a5a5a;
    --border-color: #e0e0e0;
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    font-family: inherit;
}

body {
    background-color: var(--white);
    color: var(--text-dark);
    font-family: 'DM Sans', sans-serif;
    overflow: hidden;
    display: flex;
    flex-direction: column;
    height: 100vh;
    width: 100vw;
}

h1,
h2,
h3,
.node-title {
    font-family: 'Bricolage Grotesque', sans-serif;
    letter-spacing: -0.02em;
}

/* Background Elements - Subdued for Light Theme */
.glow {
    display: none;
}

.red-glow {
    background: var(--red);
    width: 400px;
    height: 400px;
    top: -100px;
    left: -100px;
}

.green-glow {
    background: var(--green);
    width: 500px;
    height: 500px;
    bottom: -200px;
    right: -100px;
}

.orange-glow {
    background: var(--orange);
    width: 350px;
    height: 350px;
    top: 40%;
    left: 30%;
}

.purple-glow {
    background: var(--purple);
    width: 600px;
    height: 600px;
    top: -200px;
    right: 20%;
}

/* Header - Light Theme */
.app-header {
    position: relative;
    z-index: 10;
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 1rem 3rem;
    background: var(--white);
    border-bottom: 2px solid var(--purple);
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.05);
}

.logo-container {
    height: 60px;
    display: flex;
    align-items: center;
}

.brand-logo {
    height: 100%;
    object-fit: contain;
}

.title-container {
    text-align: center;
}

.title-container h1 {
    font-size: 1.5rem;
    color: var(--purple);
    font-weight: 800;
}

.title-container p {
    font-size: 0.85rem;
    color: var(--text-light);
    font-weight: 500;
    text-transform: uppercase;
    letter-spacing: 1px;
    margin-top: 4px;
}

.btn {
    background: var(--white);
    border: 1px solid var(--purple);
    color: var(--purple);
    padding: 0.5rem 1.2rem;
    border-radius: 8px;
    cursor: pointer;
    font-family: 'DM Sans', sans-serif;
    font-weight: 600;
    transition: all 0.3s ease;
}

.btn:hover {
    background: var(--purple);
    color: var(--white);
    transform: translateY(-2px);
    box-shadow: 0 4px 10px rgba(117, 45, 126, 0.2);
}

.btn-primary {
    background: var(--purple);
    color: var(--white);
}

.btn-primary:hover {
    background: #5d2365;
}

/* Map Canvas Container */
.map-container {
    flex: 1;
    position: relative;
    overflow: hidden;
    cursor: grab;
    z-index: 5;
    background-color: var(--light-bg);
    /* Premium Dotted Grid Background */
    background-image:
        radial-gradient(rgba(117, 45, 126, 0.25) 1px, transparent 1px),
        radial-gradient(rgba(117, 45, 126, 0.25) 1px, transparent 1px),
        radial-gradient(circle at 15% 25%, rgba(255, 123, 5, 0.04) 0%, transparent 40%),
        radial-gradient(circle at 85% 75%, rgba(117, 45, 126, 0.05) 0%, transparent 40%);
    background-size:
        30px 30px,
        30px 30px,
        100% 100%,
        100% 100%;
    background-position:
        0 0,
        15px 15px,
        0 0,
        0 0;
}

.map-container:active {
    cursor: grabbing;
}

.canvas {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%) scale(1);
    transform-origin: 0 0;
    padding: 4rem;
    display: flex;
    justify-content: center;
    will-change: transform;
}

/* Org Chart Tree CSS */
.tree ul {
    padding-top: 40px;
    position: relative;
    transition: all 0.5s;
    display: flex;
    justify-content: center;
    gap: 40px;
}

.tree li {
    float: left;
    text-align: center;
    list-style-type: none;
    position: relative;
    padding: 40px 0px 0 0;
    transition: all 0.5s;
}

/* Connectors */
.tree li::before,
.tree li::after {
    content: '';
    position: absolute;
    top: 0;
    right: 50%;
    border-top: 2px solid #ccc;
    width: 50%;
    height: 40px;
    transition: all 0.4s ease;
}

.tree li::after {
    right: auto;
    left: 50%;
    border-left: 2px solid #ccc;
}

.tree li:only-child::after,
.tree li:only-child::before {
    display: none;
}

.tree li:only-child {
    padding-top: 0;
}

.tree li:first-child::before,
.tree li:last-child::after {
    border: 0 none;
}

.tree li:last-child::before {
    border-right: 2px solid #ccc;
    border-radius: 0 12px 0 0;
}

.tree li:first-child::after {
    border-radius: 12px 0 0 0;
}

.tree ul ul::before {
    content: '';
    position: absolute;
    top: 0;
    left: 50%;
    border-left: 2px solid #ccc;
    width: 0;
    height: 40px;
}

/* The Nodes - Light Theme */
.node-content {
    background: var(--white);
    border: 1px solid var(--border-color);
    border-top: 6px solid var(--node-color, var(--purple));
    border-radius: 12px;
    padding: 1.5rem;
    min-width: 280px;
    max-width: 320px;
    display: inline-block;
    vertical-align: top;
    position: relative;
    text-align: left;
    transition: all 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275);
    box-shadow: 0 8px 25px rgba(0, 0, 0, 0.06);
    cursor: pointer;
    overflow: hidden;
}

.node-content:hover {
    transform: translateY(-8px) scale(1.02);
    box-shadow: 0 15px 35px rgba(0, 0, 0, 0.12);
    border-color: #d0d0d0;
}

.node-title {
    font-size: 1.15rem;
    font-weight: 700;
    margin-bottom: 0.8rem;
    color: var(--text-dark);
    display: flex;
    align-items: center;
    gap: 0.75rem;
    letter-spacing: -0.01em;
}

.node-title .dot {
    width: 12px;
    height: 12px;
    border-radius: 50%;
    background: var(--node-color, var(--purple));
    box-shadow: 0 0 8px rgba(0, 0, 0, 0.1);
}

.node-desc {
    font-size: 0.9rem;
    color: var(--text-light);
    line-height: 1.5;
    display: -webkit-box;
    -webkit-line-clamp: 4;
    line-clamp: 4;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

.node-toggle {
    margin-top: 1.2rem;
    background: var(--light-bg);
    border: 1px solid var(--border-color);
    color: var(--purple);
    padding: 0.4rem 0.8rem;
    border-radius: 6px;
    font-size: 0.75rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s;
    text-transform: uppercase;
    letter-spacing: 1px;
}

.node-toggle:hover {
    background: var(--purple);
    color: var(--white);
    border-color: var(--purple);
}

.hidden-children {
    display: none !important;
}

/* Modals & Overlays - Light Theme */
.modal-overlay,
.instructions-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.4);
    backdrop-filter: blur(4px);
    z-index: 100;
    display: flex;
    justify-content: center;
    align-items: center;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.3s ease;
}

.modal-overlay.active,
.instructions-overlay.active {
    opacity: 1;
    pointer-events: all;
}

.modal-content,
.instructions-box {
    background: var(--white);
    border-top: 8px solid var(--node-color, var(--purple));
    border-radius: 16px;
    padding: 2.5rem;
    width: 90%;
    max-width: 650px;
    position: relative;
    transform: translateY(20px);
    transition: transform 0.3s ease;
    box-shadow: 0 25px 60px rgba(0, 0, 0, 0.15);
}

.modal-overlay.active .modal-content,
.instructions-overlay.active .instructions-box {
    transform: translateY(0);
}

.close-btn {
    position: absolute;
    top: 1.5rem;
    right: 1.5rem;
    background: var(--light-bg);
    border: 1px solid var(--border-color);
    border-radius: 50%;
    width: 36px;
    height: 36px;
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--text-dark);
    font-size: 1.5rem;
    cursor: pointer;
    transition: all 0.2s;
}

.close-btn:hover {
    background: var(--red);
    color: var(--white);
    border-color: var(--red);
}

.modal-content h2,
.instructions-box h3 {
    margin-bottom: 1.5rem;
    color: var(--text-dark);
    font-size: 1.8rem;
    padding-right: 40px;
}

.modal-body {
    line-height: 1.7;
    color: var(--text-dark);
    font-size: 1rem;
    max-height: 60vh;
    overflow-y: auto;
    padding-right: 15px;
}

.modal-body strong {
    color: var(--purple);
    font-weight: 700;
}

.modal-body em {
    background: #fff3cd;
    padding: 2px 4px;
    border-radius: 4px;
    font-style: normal;
    color: #856404;
}

/* Custom Scrollbar */
.modal-body::-webkit-scrollbar {
    width: 8px;
}

.modal-body::-webkit-scrollbar-track {
    background: var(--light-bg);
    border-radius: 4px;
}

.modal-body::-webkit-scrollbar-thumb {
    background: #c0c0c0;
    border-radius: 4px;
}

.modal-body::-webkit-scrollbar-thumb:hover {
    background: var(--purple);
}

.badges {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    margin-bottom: 1rem;
}

.badge {
    padding: 6px 12px;
    border-radius: 6px;
    font-size: 0.75rem;
    font-weight: 700;
    background: var(--light-bg);
    border: 1px solid var(--border-color);
    color: var(--text-dark);
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

/* RESPONSIVE DESIGN (MOBILE & TABLET) */
@media screen and (max-width: 992px) {
    .app-header {
        flex-direction: column;
        gap: 1rem;
        padding: 1rem;
    }

    .title-container {
        width: 100%;
    }

    .title-container h1 {
        font-size: 1.2rem;
    }

    .title-container p {
        font-size: 0.75rem;
    }
}

@media screen and (max-width: 768px) {

    /* Menu / Header adjustments */
    .controls {
        position: absolute;
        bottom: -50px;
        right: 15px;
        z-index: 50;
    }

    .btn {
        font-size: 0.8rem;
        padding: 0.4rem 0.8rem;
    }

    /* Tree scale defaults per media */
    .tree ul {
        padding-top: 20px;
        gap: 20px;
    }

    .tree li {
        padding: 20px 0 0 0;
    }

    .tree li::before,
    .tree li::after,
    .tree ul ul::before {
        height: 20px;
    }

    /* Node mobile adjustments */
    .node-content {
        min-width: 220px;
        max-width: 260px;
        padding: 1rem;
    }

    .node-title {
        font-size: 1rem;
    }

    .node-desc {
        font-size: 0.8rem;
        line-height: 1.3;
        -webkit-line-clamp: 3;
        line-clamp: 3;
    }

    /* Modals Responsive */
    .modal-content,
    .instructions-box {
        padding: 1.5rem;
        width: 95%;
        border-top-width: 5px;
    }

    .modal-content h2,
    .instructions-box h3 {
        font-size: 1.3rem;
        margin-bottom: 1rem;
    }

    .modal-body {
        font-size: 0.9rem;
        line-height: 1.5;
    }

    .close-btn {
        top: 1rem;
        right: 1rem;
        width: 30px;
        height: 30px;
        font-size: 1.2rem;
    }
}