@import url('https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600&family=Merriweather:ital,wght@0,300;0,400;0,700;1,400&display=swap');

:root {
    --nexus-neon: #00ff99;
    --nexus-neon-glow: rgba(0, 255, 153, 0.3);
    --nexus-bg: #121214;
    --nexus-card: #1a1a1e;
    --nexus-text: #ffffff;
    --nexus-paper: #F9F9F9;
    --nexus-font-sans: 'Inter', sans-serif;
    --nexus-font-serif: 'Merriweather', serif;

    /* Global Selection Style Override */
    --nexus-selection: rgba(0, 255, 153, 0.25);

    /* Graph Nodes Theme Custom Properties (Dark Mode) */
    --nexus-graph-bg: radial-gradient(circle, #1a1a1a 0%, #121212 100%);
    --nexus-graph-link-secondary: rgba(255, 255, 255, 0.2);
    --nexus-graph-link-default: rgba(255, 255, 255, 0.1);
    
    --nexus-node-pill-bg: rgba(20, 20, 20, 0.95);
    
    --nexus-node-rule: #ff4646;
    --nexus-node-rule-bg: rgba(255, 70, 70, 0.1);
    --nexus-node-rule-text: #ff8b8b;
    
    --nexus-node-definition: #ffb03a;
    --nexus-node-definition-bg: rgba(255, 176, 58, 0.1);
    --nexus-node-definition-text: #ffd18c;
    
    --nexus-node-table: #d946ef;
    --nexus-node-table-bg: rgba(217, 70, 239, 0.1);
    --nexus-node-table-text: #f5d0fe;
    
    --nexus-node-section: #3b82f6;
    --nexus-node-section-bg: rgba(59, 130, 246, 0.1);
    --nexus-node-section-text: #93c5fd;
    
    --nexus-node-bridge: #06b6d4;
    --nexus-node-bridge-bg: rgba(6, 182, 212, 0.1);
    --nexus-node-bridge-text: #67e8f9;
    
    --nexus-node-current: var(--nexus-neon);
    --nexus-node-current-bg: rgba(0, 255, 153, 0.15);
    --nexus-node-current-text: #ffffff;
    
    --nexus-node-concept: #00d2c4;
    --nexus-node-concept-bg: rgba(0, 210, 196, 0.05);
    --nexus-node-concept-text: #e0e0e0;
}

::selection {
    background-color: var(--nexus-selection);
    color: inherit;
}


/* Global Semantic Theme Mapping */
--nexus-primary: var(--nexus-neon);
--nexus-primary-glow: var(--nexus-neon-glow);
--nexus-primary-hover: #00e688;

/* Standard Layout Tokens */
--radius-sm: 8px;
--radius-md: 12px;
--radius-lg: 16px;
--radius-xl: 20px;

/* Safe Area Insets with fallbacks */
--safe-area-inset-top: env(safe-area-inset-top, 0px);
--safe-area-inset-bottom: env(safe-area-inset-bottom, 0px);
--safe-area-inset-left: env(safe-area-inset-left, 0px);
--safe-area-inset-right: env(safe-area-inset-right, 0px);

/* Transitions */
--nexus-transition: 0.4s cubic-bezier(0.4, 0, 0.2, 1);
}

/* Global Glassmorphism with Fallback */
.glass-panel {
    background: rgba(20, 20, 20, 0.85);
    /* Darker fallback for readability */
    border: 1px solid rgba(255, 255, 255, 0.05);
    border-radius: var(--radius-xl);
    padding: 1.5rem;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

@supports (backdrop-filter: blur(10px)) {
    .glass-panel {
        background: rgba(255, 255, 255, 0.03);
        backdrop-filter: blur(10px);
    }
}

/* Unified Enterprise Component Constraints */
.btn-nexus {
    font-family: var(--nexus-font-sans);
    font-weight: 600;
    border-radius: var(--radius-md);
    transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    border: none;
    text-decoration: none;
}

.btn-nexus-primary {
    background: var(--nexus-neon);
    color: #000000;
}

.btn-nexus-secondary {
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid rgba(255, 255, 255, 0.1);
    color: #ffffff;
}

.btn-nexus:hover {
    transform: translateY(-2px);
    filter: brightness(1.1);
}

.btn-nexus-primary:hover {
    box-shadow: 0 4px 15px var(--nexus-primary-glow);
}

.btn-nexus-secondary:hover {
    box-shadow: 0 4px 15px rgba(255, 255, 255, 0.05);
}


.theme-light {
    --nexus-bg: #f4f1ea;
    --nexus-card: #ffffff;
    --nexus-text: #2d2a26;
    --nexus-selection: rgba(16, 185, 129, 0.18);

    /* Graph Nodes Theme Custom Properties (Light Mode) */
    --nexus-graph-bg: radial-gradient(circle, #ffffff 0%, #e8e4da 100%);
    --nexus-graph-link-secondary: rgba(0, 0, 0, 0.15);
    --nexus-graph-link-default: rgba(0, 0, 0, 0.08);
    
    --nexus-node-pill-bg: #fbfafa;
    
    --nexus-node-rule: #dc2626;
    --nexus-node-rule-bg: rgba(220, 38, 38, 0.05);
    --nexus-node-rule-text: #991b1b;
    
    --nexus-node-definition: #d97706;
    --nexus-node-definition-bg: rgba(217, 119, 6, 0.05);
    --nexus-node-definition-text: #92400e;
    
    --nexus-node-table: #c084fc;
    --nexus-node-table-bg: rgba(192, 132, 252, 0.05);
    --nexus-node-table-text: #6b21a8;
    
    --nexus-node-section: #2563eb;
    --nexus-node-section-bg: rgba(37, 99, 235, 0.05);
    --nexus-node-section-text: #1e3a8a;
    
    --nexus-node-bridge: #0891b2;
    --nexus-node-bridge-bg: rgba(8, 145, 178, 0.05);
    --nexus-node-bridge-text: #155e75;
    
    --nexus-node-current: #10b981;
    --nexus-node-current-bg: rgba(16, 185, 129, 0.08);
    --nexus-node-current-text: #064e3b;
    
    --nexus-node-concept: #0d9488;
    --nexus-node-concept-bg: rgba(13, 148, 136, 0.03);
    --nexus-node-concept-text: #115e59;
    
    --nexus-accent: #10b981;
}
.theme-light .knowledge-graph-container svg {
    background: radial-gradient(circle, #ffffff 0%, #e8e4da 100%) !important;
}

.theme-light .graph-controls {
    background: rgba(254, 254, 253, 0.4) !important;
    border: 1px solid rgba(0, 0, 0, 0.08) !important;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.04) !important;
}

.theme-light .zoom-btn {
    background: rgba(0, 0, 0, 0.02) !important;
    border: 1px solid rgba(0, 0, 0, 0.06) !important;
    color: #78716c !important;
}

.theme-light .zoom-btn:hover {
    background: rgba(16, 185, 129, 0.05) !important;
    color: #10b981 !important;
    border-color: #10b981 !important;
}

.theme-light .loading-state {
    color: #292524 !important;
    background: rgba(254, 254, 254, 0.85) !important;
    border: 1px solid rgba(0, 0, 0, 0.05) !important;
    box-shadow: 0 20px 40px rgba(0, 0, 0, 0.05) !important;
}

.theme-light .neon-pulse {
    color: #10b981 !important;
    filter: none !important;
    animation: robot-pulse-light 2s infinite ease-in-out !important;
}

.theme-light .scan-line {
    background: #10b981 !important;
    box-shadow: 0 0 10px rgba(16, 185, 129, 0.5) !important;
}

.theme-light .nexus-node-active {
    stroke: #10b981 !important;
    filter: drop-shadow(0 0 8px rgba(16, 185, 129, 0.2)) !important;
}

@keyframes robot-pulse-light {
    0% { transform: scale(1); }
    50% { transform: scale(1.05); }
    100% { transform: scale(1); }
}

.theme-light ::-webkit-scrollbar-thumb {
    background: rgba(0, 0, 0, 0.1);
}

.theme-light ::-webkit-scrollbar-thumb:hover {
    background: rgba(0, 0, 0, 0.2);
}

.theme-light .glass-panel {
    background: rgba(255, 255, 255, 0.85);
    border: 1px solid rgba(0, 0, 0, 0.05);
}

@supports (backdrop-filter: blur(10px)) {
    .theme-light .glass-panel {
        background: rgba(255, 255, 255, 0.7);
        backdrop-filter: blur(10px);
    }
}

.theme-light .btn-nexus-secondary {
    background: rgba(0, 0, 0, 0.04);
    border: 1px solid rgba(0, 0, 0, 0.08);
    color: #292524;
}

.theme-light .btn-nexus-secondary:hover {
    background: rgba(0, 0, 0, 0.08);
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.05);
}



* {
    box-sizing: border-box;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

body {
    background-color: var(--nexus-bg);
    color: var(--nexus-text);
    font-family: var(--nexus-font-sans);
    margin: 0;
    padding: 0;

    /* Handle Notches */
    padding-top: var(--safe-area-inset-top);
    padding-bottom: var(--safe-area-inset-bottom);
    padding-left: var(--safe-area-inset-left);
    padding-right: var(--safe-area-inset-right);

    min-height: 100vh;
    overflow-x: hidden;
}

/* Modern Scrollbars */
::-webkit-scrollbar {
    width: 6px;
    height: 6px;
}

::-webkit-scrollbar-track {
    background: transparent;
}

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

::-webkit-scrollbar-thumb:hover {
    background: rgba(255, 255, 255, 0.2);
}


/* Platform Specific Tweaks */
.platform-mobile .nexus-btn {
    min-height: var(--touch-target-size);
    min-width: var(--touch-target-size);
    font-size: 1.1rem;
    padding: 12px 24px;
}

.platform-desktop .nexus-btn {
    min-height: 36px;
    font-size: 0.9rem;
    padding: 8px 16px;
}

/* D3.js Touch Optimization */
svg {
    touch-action: none;
}

h1:focus {
    outline: none;
}

.blazor-error-boundary {
    background: #b32121;
    padding: 1rem;
    color: white;
    margin: 1rem;
    border-radius: 8px;
}

/* Preloader Styles */
#app-preloader,
.app-preloader {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: radial-gradient(circle at center, #1a1a1a 0%, var(--nexus-bg) 100%);
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    z-index: 9999;
    transition: opacity 0.8s ease, visibility 0.8s;
}

#app-preloader.loaded {
    opacity: 0;
    visibility: hidden;
}

.preloader-spinner {
    width: 80px;
    height: 80px;
    border: 3px solid rgba(0, 255, 153, 0.1);
    border-top: 3px solid var(--nexus-neon);
    border-radius: 50%;
    animation: spin 1s cubic-bezier(0.4, 0, 0.2, 1) infinite;
    filter: drop-shadow(0 0 10px var(--nexus-neon));
    margin-bottom: 20px;
}

.preloader-text {
    color: var(--nexus-neon);
    font-family: var(--nexus-font-sans);
    letter-spacing: 4px;
    text-transform: uppercase;
    font-size: 0.8rem;
    font-weight: 500;
    animation: pulse 2s infinite;
}

@keyframes spin {
    0% {
        transform: rotate(0deg);
    }

    100% {
        transform: rotate(360deg);
    }
}

@keyframes pulse {

    0%,
    100% {
        opacity: 1;
        transform: scale(1);
    }

    50% {
        opacity: 0.5;
        transform: scale(0.95);
    }
}