/* ============================================================
   Neural Spending Map — Dedicated Styles
   ============================================================ */

/* --- Flow animation for SVG bezier lines --- */
@keyframes neuralFlow {
    0% { stroke-dashoffset: 24; }
    100% { stroke-dashoffset: 0; }
}

@keyframes neuralFlowReverse {
    0% { stroke-dashoffset: 0; }
    100% { stroke-dashoffset: 24; }
}

@keyframes nodePulse {
    0%, 100% { transform: scale(1); opacity: 0.7; }
    50% { transform: scale(1.15); opacity: 1; }
}

@keyframes fadeSlideUp {
    from { opacity: 0; transform: translateY(12px); }
    to { opacity: 1; transform: translateY(0); }
}

/* --- Neural Map Container --- */
.nsm-container {
    position: relative;
    width: 100%;
    min-height: 400px;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
}

/* --- SVG Canvas overlay --- */
.nsm-svg {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
    z-index: 1;
}

/* --- Flow paths --- */
.nsm-flow-path {
    fill: none;
    stroke-linecap: round;
    stroke-dasharray: 8 16;
    animation: neuralFlow 1.5s linear infinite;
    transition: opacity 0.3s ease, stroke-width 0.3s ease;
}
.nsm-flow-path.dimmed {
    opacity: 0.06 !important;
}
.nsm-flow-path.highlighted {
    stroke-width: 3px !important;
    opacity: 0.9 !important;
    stroke-dasharray: 4 8;
    animation-duration: 0.8s;
}

/* --- Column Nodes --- */
.nsm-node {
    position: relative;
    z-index: 5;
    padding: 5px;
    border-radius: 4px;
    background: transparent;
    cursor: pointer;
    transition: all 0.25s ease;
    animation: fadeSlideUp 0.4s ease both;
}
.nsm-node:hover, .nsm-node.active {
    transform: translateY(-1px);
}
.nsm-node.dimmed {
    opacity: 0.25;
    transform: scale(0.97);
}

/* --- Central Processing Nodes --- */
.nsm-center-node {
    width: 28px;
    height: 28px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    animation: nodePulse 3s ease-in-out infinite;
    transition: all 0.3s ease;
    cursor: pointer;
    z-index: 5;
    position: relative;
    box-shadow: 0 0 12px rgba(0,0,0,0.3);
}
.nsm-center-node.dimmed {
    opacity: 0.15;
    animation: none;
}
.nsm-center-node.active {
    animation: none;
    transform: scale(1.3);
    opacity: 1;
    box-shadow: 0 0 20px currentColor;
}

/* --- Tooltip/Popup --- */
.nsm-tooltip {
    position: fixed;
    z-index: 100;
    background: rgba(3, 7, 18, 0.97);
    border: 1px solid rgba(255,255,255,0.1);
    border-radius: 4px;
    padding: 5px;
    max-width: 280px;
    max-height: 300px;
    overflow-y: auto;
    box-shadow: 0 16px 48px rgba(0,0,0,0.6);
    animation: fadeSlideUp 0.2s ease;
    backdrop-filter: blur(12px);
}
.nsm-tooltip-close {
    position: absolute;
    top: 6px;
    right: 8px;
    color: #6b7280;
    cursor: pointer;
    font-size: 14px;
    line-height: 1;
}

/* --- Stats Cards --- */
.nsm-stat-card {
    background: rgba(15, 23, 42, 0.6);
    border: 1px solid rgba(255,255,255,0.08);
    border-radius: 4px;
    padding: 5px;
    transition: all 0.25s ease;
    animation: fadeSlideUp 0.5s ease both;
}
.nsm-stat-card:hover {
    border-color: rgba(253, 224, 33, 0.2);
    transform: translateY(-2px);
}

/* --- Period Filter Bar --- */
.nsm-filter-bar {
    display: flex;
    align-items: center;
    gap: 5px;
    flex-wrap: wrap;
}

.nsm-filter-btn {
    padding: 4px 6px;
    border-radius: 4px;
    font-size: 8px;
    font-weight: 800;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    border: 1px solid rgba(255,255,255,0.08);
    background: transparent;
    color: #9ca3af;
    cursor: pointer;
    transition: all 0.2s ease;
    white-space: nowrap;
}
.nsm-filter-btn:hover {
    background: rgba(255,255,255,0.05);
    color: #e5e7eb;
}
.nsm-filter-btn.active {
    background: #FDE021;
    color: #030712;
    border-color: #FDE021;
}

/* --- 2-column layout --- */
.nsm-columns {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 80px;
    align-items: start;
    min-height: 350px;
    position: relative;
}

.nsm-col-left {
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    gap: 5px;
    padding: 5px 0;
}
.nsm-col-right {
    display: flex;
    flex-direction: column;
    align-items: flex-end;
    gap: 5px;
    padding: 5px 0;
}

/* --- Column headers --- */
.nsm-col-header {
    font-size: 8px;
    font-weight: 900;
    text-transform: uppercase;
    letter-spacing: 1.5px;
    color: #4b5563;
    margin-bottom: 4px;
    text-align: center;
}

/* --- Scrollbar minimal --- */
.nsm-tooltip::-webkit-scrollbar { width: 3px; }
.nsm-tooltip::-webkit-scrollbar-thumb { background: rgba(255,255,255,0.1); border-radius: 3px; }
.nsm-container::-webkit-scrollbar { height: 3px; }
.nsm-container::-webkit-scrollbar-thumb { background: rgba(255,255,255,0.1); border-radius: 3px; }

/* --- Responsive mobile: scale down to fit screen width without horizontal scroll --- */
@media (max-width: 768px) {
    .nsm-columns {
        min-width: 100% !important;
        width: 100% !important;
        gap: 20px !important;
    }
    .nsm-node {
        padding: 4px 2px !important;
        border-radius: 4px !important;
    }
    .nsm-stat-card {
        padding: 5px !important;
        border-radius: 4px !important;
    }
    .nsm-filter-bar {
        gap: 5px !important;
    }
    .nsm-filter-btn {
        padding: 4px 6px !important;
        border-radius: 4px !important;
        font-size: 8px !important;
    }
    /* Reduce text sizes within nodes */
    .nsm-node div, 
    .nsm-node span {
        font-size: 8px !important;
    }
    .nsm-node .text-\[9px\] {
        font-size: 6px !important;
    }
}
