/* ==========================================================================
   CSS VARIABLES & GLOBAL DESIGN SYSTEM
   ========================================================================== */
:root {
    /* Color System (Futuristic Slate & Neon) */
    --bg-primary: #090d16;
    --bg-secondary: #0f1524;
    --bg-card: rgba(17, 25, 44, 0.7);
    --border-color: rgba(255, 255, 255, 0.07);
    --border-active: rgba(139, 92, 246, 0.4);
    
    --accent-sales: #0ea5e9;        /* Electric Teal */
    --accent-profit: #10b981;       /* Mint Emerald */
    --accent-purple: #8b5cf6;       /* Royal Purple */
    --accent-danger: #f43f5e;       /* Coral Red */
    --accent-amber: #f59e0b;        /* Soft Amber */
    
    --text-main: #f3f4f6;
    --text-muted: #9ca3af;
    --text-inactive: #6b7280;
    
    /* Shadows and Glows */
    --shadow-premium: 0 10px 30px rgba(0, 0, 0, 0.4);
    --shadow-inset: inset 0 1px 1px rgba(255, 255, 255, 0.05);
    --glow-purple: 0 0 20px rgba(139, 92, 246, 0.25);
    --glow-sales: 0 0 20px rgba(14, 165, 233, 0.25);
    --glow-profit: 0 0 20px rgba(16, 185, 129, 0.25);
    
    /* Layout Constants */
    --sidebar-width: 280px;
    --header-height: 80px;
    --border-radius-lg: 16px;
    --border-radius-md: 10px;
    --border-radius-sm: 6px;
    --transition-smooth: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

/* Base Reset & Styling */
* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

body {
    font-family: 'Inter', sans-serif;
    background-color: var(--bg-primary);
    color: var(--text-main);
    height: 100vh;
    overflow: hidden;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

h1, h2, h3, h4 {
    font-family: 'Outfit', sans-serif;
    font-weight: 600;
    letter-spacing: -0.02em;
}

/* Scrollbar Customization */
::-webkit-scrollbar {
    width: 6px;
    height: 6px;
}

::-webkit-scrollbar-track {
    background: var(--bg-primary);
}

::-webkit-scrollbar-thumb {
    background: rgba(255, 255, 255, 0.1);
    border-radius: var(--border-radius-sm);
}

::-webkit-scrollbar-thumb:hover {
    background: var(--accent-purple);
}

/* ==========================================================================
   LAYOUT STRUCTURE (CONTAINERS)
   ========================================================================== */
.app-container {
    display: flex;
    height: 100vh;
    width: 100vw;
    overflow: hidden;
}

/* Sidebar Navigation */
.sidebar {
    width: var(--sidebar-width);
    background-color: var(--bg-secondary);
    border-right: 1px solid var(--border-color);
    padding: 30px 24px;
    display: flex;
    flex-direction: column;
    z-index: 10;
}

.logo-area {
    display: flex;
    flex-direction: column;
    gap: 10px;
    margin-bottom: 35px;
}

.logo-wrapper {
    display: flex;
    align-items: center;
    gap: 12px;
}

.logo {
    width: 40px;
    height: 40px;
    object-fit: cover;
    transition: transform 0.2s ease, border-color 0.2s ease;
    filter: drop-shadow(0 0 0 #8b5cf6)
            drop-shadow(0 0 1px #8b5cf6)
            drop-shadow(0 0 1px #8b5cf6);
}

.logo:hover {
    transform: scale(1.08);
    border-color: var(--accent-sales);
}

.logo-area h1 {
    font-size: 19px;
    font-weight: 700;
    color: #fff;
}

.user-identity {
    font-size: 11px;
    font-weight: 600;
    color: var(--text-muted);
    border-left: 2px solid var(--accent-purple);
    padding-left: 8px;
    line-height: 1.4;
    margin-top: 4px;
}

.student-id {
    font-size: 9.5px;
    font-family: monospace;
    color: var(--accent-sales);
    display: block;
    margin-top: 1px;
}

.nav-menu {
    display: flex;
    flex-direction: column;
    gap: 10px;
    flex: 1;
}

.nav-item {
    display: flex;
    align-items: center;
    gap: 14px;
    background: transparent;
    border: 1px solid transparent;
    color: var(--text-inactive);
    padding: 14px 18px;
    border-radius: var(--border-radius-md);
    cursor: pointer;
    font-size: 14px;
    font-weight: 500;
    text-align: left;
    transition: var(--transition-smooth);
}

.nav-item:hover {
    color: var(--text-main);
    background: rgba(255, 255, 255, 0.03);
    padding-left: 22px;
}

.nav-item.active {
    color: #fff;
    background: linear-gradient(135deg, rgba(139, 92, 246, 0.15), rgba(14, 165, 233, 0.15));
    border-color: var(--border-active);
    box-shadow: var(--shadow-inset), var(--glow-purple);
}

.nav-icon {
    font-size: 18px;
    transition: var(--transition-smooth);
}

.nav-item.active .nav-icon {
    transform: scale(1.15);
}

.sidebar-footer {
    border-top: 1px solid var(--border-color);
    padding-top: 20px;
    font-size: 11px;
    color: var(--text-inactive);
    line-height: 1.6;
}

.copyright-text {
    color: var(--text-muted);
    font-size: 10.5px;
    opacity: 0.65;
    margin-top: 4px;
    letter-spacing: 0.02em;
    font-weight: 500;
}

/* Main Workspace */
.main-content {
    flex: 1;
    display: flex;
    flex-direction: column;
    height: 100vh;
    overflow-y: auto;
    padding: 32px 40px;
}

/* Header Dashboard */
.main-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    border-bottom: 1px solid var(--border-color);
    padding-bottom: 24px;
    margin-bottom: 32px;
    flex-shrink: 0;
}

.header-title h2 {
    font-size: 26px;
    font-weight: 700;
    color: #fff;
    margin-bottom: 6px;
}

.header-title p {
    font-size: 13px;
}

.header-controls {
    display: flex;
    align-items: center;
    gap: 16px;
}

.year-filter-wrapper {
    display: flex;
    align-items: center;
    gap: 8px;
    background: rgba(255, 255, 255, 0.03);
    border: 1px solid var(--border-color);
    padding: 6px 14px;
    border-radius: 20px;
    font-size: 12px;
    font-weight: 500;
    transition: var(--transition-smooth);
}

.year-filter-wrapper:focus-within {
    border-color: var(--accent-purple);
    box-shadow: var(--glow-purple);
}

.filter-label {
    color: var(--text-muted);
    font-weight: 600;
}

.premium-select {
    background: transparent;
    border: none;
    color: var(--accent-purple);
    font-weight: 600;
    font-family: 'Inter', sans-serif;
    outline: none;
    cursor: pointer;
    padding-right: 4px;
}

.premium-select option {
    background: #090d16;
    color: #fff;
}

/* Filter Badge */
.filter-badge {
    display: flex;
    align-items: center;
    gap: 8px;
    background: linear-gradient(135deg, rgba(16, 185, 129, 0.15), rgba(14, 165, 233, 0.15));
    border: 1px solid var(--accent-profit);
    color: var(--text-main);
    padding: 6px 14px;
    border-radius: 20px;
    font-size: 12px;
    font-weight: 600;
    box-shadow: 0 0 15px rgba(16, 185, 129, 0.15);
}

.filter-badge.hidden {
    display: none !important;
}

.clear-btn {
    background: transparent;
    border: none;
    color: var(--text-muted);
    font-size: 16px;
    font-weight: bold;
    cursor: pointer;
    line-height: 1;
    padding: 0 2px;
    transition: var(--transition-smooth);
}

.clear-btn:hover {
    color: var(--accent-danger);
    transform: scale(1.2);
}

/* ==========================================================================
   TAB VISIBILITY MANAGEMENT
   ========================================================================== */
.dashboard-tab {
    display: none;
    flex-direction: column;
}

.dashboard-tab.active {
    display: flex;
}

/* ==========================================================================
   KPI CARDS GRID
   ========================================================================== */
.kpi-grid {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 24px;
    margin-bottom: 32px;
    flex-shrink: 0;
}

.kpi-card {
    background-color: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: var(--border-radius-lg);
    padding: 24px;
    backdrop-filter: blur(12px);
    box-shadow: var(--shadow-premium), var(--shadow-inset);
    transition: var(--transition-smooth);
    display: flex;
    flex-direction: column;
    position: relative;
    overflow: hidden;
}

.kpi-card::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 4px;
    background: transparent;
    transition: var(--transition-smooth);
}

#kpi-sales::before { background: var(--accent-sales); }
#kpi-profit::before { background: var(--accent-profit); }
#kpi-orders::before { background: var(--accent-purple); }
#kpi-discount::before { background: var(--accent-amber); }

.kpi-card:hover {
    transform: translateY(-5px);
    box-shadow: 0 15px 35px rgba(0, 0, 0, 0.5), var(--shadow-inset);
    border-color: rgba(255, 255, 255, 0.15);
}

#kpi-sales:hover { box-shadow: 0 15px 35px rgba(0, 0, 0, 0.5), var(--glow-sales); }
#kpi-profit:hover { box-shadow: 0 15px 35px rgba(0, 0, 0, 0.5), var(--glow-profit); }

.kpi-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 12px;
}

.kpi-title {
    font-size: 13px;
    font-weight: 500;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

.kpi-icon {
    font-size: 18px;
    padding: 6px;
    background: rgba(255, 255, 255, 0.03);
    border-radius: var(--border-radius-sm);
}

.kpi-value {
    font-family: 'Outfit', sans-serif;
    font-size: 28px;
    font-weight: 700;
    color: #fff;
    margin-bottom: 6px;
}

.kpi-change {
    font-size: 12px;
    font-weight: 500;
    margin-bottom: 16px;
}

.kpi-sparkline {
    height: 40px;
    width: 100%;
    margin-top: auto;
}

/* Utilities for texts */
.text-success { color: var(--accent-profit); }
.text-danger { color: var(--accent-danger); }
.text-muted { color: var(--text-muted); }

/* ==========================================================================
   CHARTS GRID & CONTAINER CARDS
   ========================================================================== */
.charts-grid-two {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 24px;
    margin-bottom: 32px;
}

.glass-card {
    background-color: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: var(--border-radius-lg);
    box-shadow: var(--shadow-premium), var(--shadow-inset);
    backdrop-filter: blur(12px);
}

.chart-card {
    padding: 26px;
    display: flex;
    flex-direction: column;
    height: 490px;
    transition: border-color 0.3s ease;
}

.chart-card:hover {
    border-color: rgba(255, 255, 255, 0.12);
}

.chart-card-header {
    margin-bottom: 20px;
    flex-shrink: 0;
}

.chart-card-header h3 {
    font-size: 18px;
    font-weight: 600;
    color: #fff;
    margin-bottom: 4px;
}

.chart-card-header p {
    font-size: 12px;
}

.chart-container {
    flex: 1;
    width: 100%;
    height: 100%;
    position: relative;
    overflow: hidden;
}

/* ==========================================================================
   TAB 2: RADIAL TREE EXCLUSIVE CONTROLS & LAYOUT
   ========================================================================== */
.tab-controls-bar {
    padding: 20px 28px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 20px;
    margin-bottom: 24px;
    flex-shrink: 0;
    flex-wrap: wrap;
}

.control-group {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.control-label {
    font-size: 11px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--text-muted);
}

.slider-wrapper {
    display: flex;
    align-items: center;
    gap: 12px;
}

/* Premium Range Input */
input[type="range"] {
    -webkit-appearance: none;
    width: 180px;
    height: 6px;
    background: rgba(255, 255, 255, 0.1);
    border-radius: 3px;
    outline: none;
}

input[type="range"]::-webkit-slider-thumb {
    -webkit-appearance: none;
    width: 16px;
    height: 16px;
    background: var(--accent-purple);
    border-radius: 50%;
    cursor: pointer;
    box-shadow: 0 0 10px rgba(139, 92, 246, 0.5);
    transition: var(--transition-smooth);
}

input[type="range"]::-webkit-slider-thumb:hover {
    transform: scale(1.2);
    background: #fff;
}

.badge {
    background: rgba(139, 92, 246, 0.15);
    border: 1px solid var(--accent-purple);
    color: var(--accent-purple);
    padding: 4px 10px;
    border-radius: 12px;
    font-size: 12px;
    font-weight: 700;
    min-width: 35px;
    text-align: center;
}

/* Search Box */
.search-group {
    flex: 1;
    max-width: 480px;
}

.search-box {
    display: flex;
    align-items: center;
    background: rgba(0, 0, 0, 0.2);
    border: 1px solid var(--border-color);
    border-radius: var(--border-radius-md);
    padding: 4px 8px;
    position: relative;
    transition: var(--transition-smooth);
}

.search-box:focus-within {
    border-color: var(--accent-purple);
    box-shadow: var(--glow-purple);
}

.search-box input {
    background: transparent;
    border: none;
    color: #fff;
    padding: 8px 12px;
    outline: none;
    font-size: 13px;
    flex: 1;
}

.search-box input::placeholder {
    color: var(--text-inactive);
}

.action-btn {
    background: var(--accent-purple);
    border: none;
    color: #fff;
    font-weight: 600;
    padding: 8px 16px;
    border-radius: var(--border-radius-sm);
    cursor: pointer;
    font-size: 12px;
    transition: var(--transition-smooth);
}

.action-btn:hover {
    background: #9b72ff;
    box-shadow: var(--glow-purple);
}

/* Legend for Tree */
.legend {
    display: flex;
    gap: 16px;
    align-items: center;
    height: 100%;
}

.legend-item {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 12px;
    font-weight: 500;
}

.dot {
    width: 10px;
    height: 10px;
    border-radius: 50%;
    display: inline-block;
}

.dot.profitable {
    background-color: var(--accent-profit);
    box-shadow: 0 0 8px var(--accent-profit);
}

.dot.unprofitable {
    background-color: var(--accent-danger);
    box-shadow: 0 0 8px var(--accent-danger);
}

/* Workspace Tree Container */
.radial-tree-workspace {
    flex: 1;
    height: calc(100vh - 240px);
    position: relative;
    padding: 16px;
    overflow: hidden;
}

.workspace-tip {
    position: absolute;
    top: 16px;
    left: 20px;
    background: rgba(11, 15, 25, 0.8);
    border: 1px solid var(--border-color);
    padding: 8px 16px;
    border-radius: 20px;
    font-size: 11px;
    color: var(--text-muted);
    z-index: 5;
    pointer-events: none;
}

.chart-container-full {
    width: 100%;
    height: 100%;
    position: relative;
}

/* Search Alerts */
.search-alert {
    position: absolute;
    bottom: 24px;
    left: 50%;
    transform: translateX(-50%);
    background: rgba(244, 63, 94, 0.15);
    border: 1px solid var(--accent-danger);
    color: #fca5a5;
    padding: 12px 24px;
    border-radius: 30px;
    font-size: 12px;
    font-weight: 600;
    box-shadow: 0 8px 25px rgba(0,0,0,0.4);
    z-index: 100;
    animation: bounce 1s infinite alternate;
}

.search-alert.hidden {
    display: none !important;
}

/* ==========================================================================
   TAB 4: LOGISTICS SPECIFIC ITEMS
   ========================================================================== */
.logistics-metrics-content {
    display: flex;
    flex-direction: column;
    gap: 28px;
    justify-content: center;
    height: 100%;
}

.metric-list-item {
    display: flex;
    align-items: center;
    gap: 20px;
    padding: 12px 0;
}

.metric-list-item:not(:last-child) {
    border-bottom: 1px solid rgba(255, 255, 255, 0.04);
}

.m-icon {
    font-size: 28px;
    width: 54px;
    height: 54px;
    background: rgba(255, 255, 255, 0.03);
    border: 1px solid var(--border-color);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

.m-details {
    flex: 1;
    display: grid;
    grid-template-columns: 2fr 3fr 1fr;
    align-items: center;
    gap: 16px;
}

.m-details h4 {
    font-size: 14px;
    color: #fff;
    font-weight: 600;
}

.m-details .text-muted {
    font-size: 11px;
}

.m-value-bar {
    background: rgba(255, 255, 255, 0.05);
    height: 8px;
    width: 100%;
    border-radius: 4px;
    overflow: hidden;
}

.bar-fill {
    background: var(--accent-sales);
    height: 100%;
    border-radius: 4px;
    box-shadow: 0 0 10px rgba(14, 165, 233, 0.5);
    transition: width 1.2s cubic-bezier(0.4, 0, 0.2, 1);
}

.bar-fill.secondary {
    background: var(--accent-purple);
    box-shadow: 0 0 10px rgba(139, 92, 246, 0.5);
}

.bar-fill.alert {
    background: var(--accent-amber);
    box-shadow: 0 0 10px rgba(245, 158, 11, 0.5);
}

.m-value {
    font-family: 'Outfit', sans-serif;
    font-size: 16px;
    font-weight: 700;
    text-align: right;
    color: #fff;
}

/* ==========================================================================
   D3 CHART SVG INTERNAL STYLING
   ========================================================================== */
/* Axes and grids */
.axis-label {
    fill: var(--text-muted);
    font-size: 11px;
    font-weight: 500;
    font-family: 'Inter', sans-serif;
}

.axis path,
.axis line {
    stroke: rgba(255, 255, 255, 0.1);
}

.axis text {
    fill: var(--text-inactive);
    font-size: 10px;
    font-family: 'Inter', sans-serif;
}

.grid-line line {
    stroke: rgba(255, 255, 255, 0.03);
}

/* Line / Area Charts */
.trend-line-sales {
    stroke: var(--accent-sales);
    stroke-width: 3px;
    fill: none;
    filter: drop-shadow(0 0 8px rgba(14, 165, 233, 0.5));
}

.trend-line-profit {
    stroke: var(--accent-profit);
    stroke-width: 3px;
    fill: none;
    filter: drop-shadow(0 0 8px rgba(16, 185, 129, 0.5));
}

.trend-area-sales {
    fill: url(#gradient-sales);
    opacity: 0.12;
}

.trend-area-profit {
    fill: url(#gradient-profit);
    opacity: 0.12;
}

/* Tree Nodes and Links */
.tree-node-link {
    fill: none;
    stroke: rgba(255, 255, 255, 0.18);
    stroke-width: 1.5px;
}

.tree-node-link.highlighted {
    stroke: var(--accent-purple);
    stroke-width: 3px;
    opacity: 0.9;
    filter: drop-shadow(0 0 4px rgba(139, 92, 246, 0.6));
}

.tree-node-link.dimmed {
    opacity: 0.12;
}

.tree-node circle {
    stroke-width: 2px;
    cursor: default;
}

.tree-node.node-collapsed circle {
    stroke: #fff;
    stroke-width: 2.5px;
}

.tree-node text {
    font-family: 'Inter', sans-serif;
    font-size: 9px;
    fill: var(--text-muted);
    pointer-events: none;
    text-shadow: 0 1px 2px rgba(0,0,0,0.8);
}

.tree-node:hover text {
    fill: #fff;
    font-weight: 500;
}

.tree-node.node-highlighted circle {
    stroke: #fff !important;
    stroke-width: 3px !important;
    filter: drop-shadow(0 0 10px var(--accent-purple)) !important;
}

.tree-node.node-highlighted text {
    fill: #fff !important;
    font-weight: bold !important;
    font-size: 11px !important;
}

/* Choropleth Map States */
.state-path {
    stroke: rgba(0, 0, 0, 0.3);
    stroke-width: 1px;
    cursor: pointer;
    transition: fill 0.2s, stroke 0.2s, stroke-width 0.2s;
}

.state-path:hover {
    stroke: #fff;
    stroke-width: 1.5px;
    filter: drop-shadow(0 0 10px rgba(255,255,255,0.15));
}

.state-path.selected {
    stroke: var(--accent-profit);
    stroke-width: 2.5px;
}

/* Donut Slices */
.donut-slice {
    stroke: var(--bg-secondary);
    stroke-width: 3px;
    cursor: pointer;
    transition: filter 0.3s, transform 0.3s;
}

.donut-slice:hover {
    filter: drop-shadow(0 0 12px var(--slice-color));
}

/* Ridgeline Area Charts */
.ridgeline-area {
    opacity: 0.75;
    stroke: #fff;
    stroke-width: 1.5px;
}

/* ==========================================================================
   PREMIUM FLOATING TOOLTIP
   ========================================================================== */
.tooltip, #tooltip, .chart-tooltip {
    position: absolute;
    display: none;
    background: rgba(9, 13, 24, 0.95);
    border: 1px solid rgba(255, 255, 255, 0.12);
    border-radius: var(--border-radius-md);
    color: #fff;
    padding: 14px 18px;
    font-size: 12.5px;
    line-height: 1.5;
    pointer-events: none;
    z-index: 9999;
    box-shadow: 0 15px 35px rgba(0, 0, 0, 0.6), inset 0 1px 0 rgba(255, 255, 255, 0.1);
    backdrop-filter: blur(8px);
    min-width: 180px;
    max-width: 320px;
}

.tooltip-header {
    font-family: 'Outfit', sans-serif;
    font-weight: 700;
    font-size: 14px;
    margin-bottom: 8px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.08);
    padding-bottom: 6px;
    color: var(--accent-sales);
}

.tooltip-row {
    display: flex;
    justify-content: space-between;
    gap: 16px;
    margin-bottom: 4px;
}

.tooltip-label {
    color: var(--text-muted);
}

.tooltip-value {
    font-weight: 600;
    text-align: right;
}

/* ==========================================================================
   ANIMATIONS & KEYFRAMES
   ========================================================================== */
@keyframes fadeIn {
    from { opacity: 0; transform: translateY(10px); }
    to { opacity: 1; transform: translateY(0); }
}

@keyframes pulsing {
    0% { transform: scale(0.9); box-shadow: 0 0 0 0 rgba(16, 185, 129, 0.7); }
    70% { transform: scale(1.1); box-shadow: 0 0 0 8px rgba(16, 185, 129, 0); }
    100% { transform: scale(0.9); box-shadow: 0 0 0 0 rgba(16, 185, 129, 0); }
}

@keyframes nodePulse {
    0% { box-shadow: 0 0 0 0 rgba(139, 92, 246, 0.8); r: 6px; }
    100% { box-shadow: 0 0 0 10px rgba(139, 92, 246, 0); r: 10px; }
}

@keyframes rotateSlow {
    from { transform: rotate(0deg); }
    to { transform: rotate(360deg); }
}

@keyframes bounce {
    from { transform: translate(-50%, 0); }
    to { transform: translate(-50%, -6px); }
}

/* Category Bar Chart Styles */
.category-bar {
    transition: filter 0.2s, opacity 0.2s;
    cursor: pointer;
}
.category-bar:hover {
    filter: brightness(1.2) drop-shadow(0 0 6px rgba(255, 255, 255, 0.25));
}
