/* Base Styles */
body {
    font-family: 'FK Grotesk', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
    transition: background-color 0.3s ease, color 0.3s ease;
    background-color: #0f172a;
    color: #cbd5e1;
}

/* Panel Styles */
.panel {
    background-color: rgba(30, 41, 59, 0.8);
    backdrop-filter: blur(8px);
    padding: 1rem;
    border-radius: 0.5rem;
    box-shadow: 0 20px 25px -5px rgba(0, 0, 0, 0.1), 0 10px 10px -5px rgba(0, 0, 0, 0.04);
    border: 1px solid #334155;
    transition: all 0.3s ease;
}

body.light-mode .panel {
    background-color: rgba(255, 255, 255, 0.8);
    border-color: #cbd5e1;
    color: #1e293b;
}

/* Info Panel */
.info-panel {
    position: absolute;
    top: 0;
    right: 0;
    height: 100%;
    width: 100%;
    max-width: 28rem;
    background-color: rgba(30, 41, 59, 0.9);
    backdrop-filter: blur(8px);
    border-left: 1px solid #334155;
    box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.25);
    padding: 1.5rem;
    overflow-y: auto;
    transform: translateX(100%);
    transition: transform 0.4s cubic-bezier(0.4, 0, 0.2, 1);
    z-index: 40;
}

.info-panel.show {
    transform: translateX(0);
}

body.light-mode .info-panel {
    background-color: rgba(255, 255, 255, 0.9);
    border-color: #cbd5e1;
    color: #1e293b;
}

/* Info Panel Improvements */
.info-panel h2 {
    color: #ffffff;
    transition: color 0.3s ease;
}

body.light-mode .info-panel h2 {
    color: #1e293b;
}

.info-panel h3 {
    color: #ffffff;
    transition: color 0.3s ease;
}

body.light-mode .info-panel h3 {
    color: #1e293b;
}

.info-panel p {
    color: #cbd5e1;
    transition: color 0.3s ease;
}

body.light-mode .info-panel p {
    color: #475569;
}

.info-panel .text-slate-400 {
    color: #94a3b8;
    transition: color 0.3s ease;
}

body.light-mode .info-panel .text-slate-400 {
    color: #64748b;
}

.info-panel .bg-slate-900 {
    background-color: rgba(15, 23, 42, 0.5);
    transition: background-color 0.3s ease;
}

body.light-mode .info-panel .bg-slate-900 {
    background-color: rgba(248, 250, 252, 0.8);
}

.info-panel .bg-slate-700 {
    background-color: #334155;
    transition: background-color 0.3s ease;
}

body.light-mode .info-panel .bg-slate-700 {
    background-color: #e2e8f0;
    color: #1e293b !important;
}

.info-panel .bg-slate-800 {
    background-color: #1e293b;
    transition: background-color 0.3s ease;
}

body.light-mode .info-panel .bg-slate-800 {
    background-color: #f1f5f9;
    color: #475569 !important;
}

/* Fix text colors in light mode info panel */
body.light-mode .info-panel .text-white {
    color: #1e293b !important;
}

body.light-mode .info-panel .text-slate-300 {
    color: #334155 !important;
}

body.light-mode .info-panel .text-slate-400 {
    color: #475569 !important;
}

body.light-mode .info-panel .bg-slate-900\/50 {
    background-color: rgba(241, 245, 249, 0.8) !important;
}

/* Fix lists and other text elements in light mode */
body.light-mode .info-panel ul {
    color: #475569 !important;
}

body.light-mode .info-panel li {
    color: #475569 !important;
}

body.light-mode .info-panel .list-disc {
    color: #475569 !important;
}

body.light-mode .info-panel a {
    color: #0284c7 !important;
}

body.light-mode .info-panel a:hover {
    color: #0369a1 !important;
}

/* Fix tag styles in light mode */
body.light-mode .info-panel .bg-slate-800 {
    background-color: #e2e8f0 !important;
}

body.light-mode .info-panel .text-slate-400 {
    color: #475569 !important;
}

/* Close button styling */
#close-panel {
    color: #94a3b8;
    transition: color 0.3s ease;
}

#close-panel:hover {
    color: #ffffff;
}

body.light-mode #close-panel {
    color: #64748b;
}

body.light-mode #close-panel:hover {
    color: #1e293b;
}

/* Graph Elements */
.link {
    stroke-opacity: 0.5;
    transition: stroke-opacity 0.2s ease, stroke-width 0.2s ease, stroke 0.3s ease;
}

.link.highlighted {
    stroke-opacity: 1;
    stroke-width: 2.5px;
}

.link.faded {
    stroke-opacity: 0.1;
}

.link-label {
    font-family: 'FK Grotesk', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
    font-size: 10px;
    font-weight: 500;
    pointer-events: none;
    opacity: 0;
    transition: opacity 0.2s ease;
    text-shadow: 
        0 0 3px rgba(0, 0, 0, 0.8),
        0 0 5px rgba(0, 0, 0, 0.6),
        1px 1px 2px rgba(0, 0, 0, 0.9);
}

body.light-mode .link-label {
    text-shadow: 
        0 0 3px rgba(255, 255, 255, 0.9),
        0 0 5px rgba(255, 255, 255, 0.7),
        1px 1px 2px rgba(255, 255, 255, 1);
}

.node {
    transition: opacity 0.3s ease;
    cursor: pointer;
}

.node circle {
    stroke-width: 2px;
    transition: transform 0.2s ease, filter 0.2s ease, stroke 0.3s ease;
}

.node:hover circle {
    transform: scale(1.1);
    filter: drop-shadow(0 0 8px rgba(255, 255, 255, 0.3));
}

body.light-mode .node:hover circle {
    filter: drop-shadow(0 0 8px rgba(0, 0, 0, 0.2));
}

.node.faded {
    opacity: 0.2;
}

.node.search-highlighted circle {
    stroke-width: 3px;
    filter: drop-shadow(0 0 6px rgba(59, 130, 246, 0.6));
}

body.light-mode .node.search-highlighted circle {
    filter: drop-shadow(0 0 6px rgba(29, 78, 216, 0.8));
}

.node-label {
    font-size: 12px;
    pointer-events: none;
    text-anchor: middle;
    font-weight: 500;
    transition: fill 0.3s ease;
    fill: #e0e0e0;
}

body.light-mode .node-label {
    fill: #1e293b !important;
}

/* Graph Container */
#graph-container {
    cursor: grab;
    background-color: #0f172a;
    transition: background-color 0.3s ease;
}

body.light-mode #graph-container {
    background-color: #f8fafc;
}

#graph-container:active {
    cursor: grabbing;
}

/* Custom Checkbox */
.filter-checkbox {
    appearance: none;
    -webkit-appearance: none;
    background-color: transparent;
    width: 1.15em;
    height: 1.15em;
    border-radius: 0.25em;
    border: 2px solid #64748b;
    display: grid;
    place-content: center;
    cursor: pointer;
    transition: border-color 0.2s;
}

body.light-mode .filter-checkbox {
    border-color: #475569;
}

.filter-checkbox::before {
    content: "";
    width: 0.65em;
    height: 0.65em;
    transform: scale(0);
    transition: 120ms transform ease-in-out;
    box-shadow: inset 1em 1em var(--checkbox-color);
    border-radius: 0.15em;
}

.filter-checkbox:checked::before {
    transform: scale(1);
}

/* Search Input */
#search {
    background-color: #0f172a;
    border: 1px solid #475569;
    border-radius: 0.375rem;
    padding: 0.5rem 0.75rem;
    font-size: 0.875rem;
    width: 100%;
    color: #cbd5e1;
    transition: all 0.3s ease;
}

#search::placeholder {
    color: #64748b;
}

#search:focus {
    outline: none;
    box-shadow: 0 0 0 2px #0ea5e9;
    border-color: #0ea5e9;
}

body.light-mode #search {
    background-color: #f8fafc;
    border-color: #cbd5e1;
    color: #1e293b;
}

body.light-mode #search::placeholder {
    color: #94a3b8;
}

/* Year Slider */
#year-slider {
    width: 100%;
    height: 0.5rem;
    background-color: #334155;
    border-radius: 0.5rem;
    appearance: none;
    -webkit-appearance: none;
    cursor: pointer;
    transition: background-color 0.3s ease;
}

body.light-mode #year-slider {
    background-color: #cbd5e1;
}

#year-slider::-webkit-slider-thumb {
    -webkit-appearance: none;
    appearance: none;
    width: 20px;
    height: 20px;
    background: #3b82f6;
    cursor: pointer;
    border-radius: 50%;
    transition: background-color 0.3s ease;
}

#year-slider::-moz-range-thumb {
    width: 20px;
    height: 20px;
    background: #3b82f6;
    cursor: pointer;
    border-radius: 50%;
    border: none;
}

/* Dual Range Slider - Apple Style */
.dual-range-slider {
    width: 100%;
    height: 4px;
    appearance: none;
    -webkit-appearance: none;
    cursor: pointer;
    background: transparent;
    pointer-events: none;
}

.dual-range-slider::-webkit-slider-thumb {
    -webkit-appearance: none;
    appearance: none;
    width: 18px;
    height: 18px;
    background: #ffffff;
    cursor: pointer;
    border-radius: 50%;
    pointer-events: all;
    position: relative;
    z-index: 3;
    border: 1px solid rgba(255, 255, 255, 0.2);
    box-shadow: 
        0 2px 8px rgba(0, 0, 0, 0.15),
        0 0 0 0 rgba(59, 130, 246, 0);
    transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
}

.dual-range-slider::-webkit-slider-thumb:hover {
    transform: scale(1.15);
    box-shadow: 
        0 4px 12px rgba(0, 0, 0, 0.2),
        0 0 0 4px rgba(59, 130, 246, 0.1);
}

.dual-range-slider::-webkit-slider-thumb:active {
    transform: scale(1.05);
    box-shadow: 
        0 2px 8px rgba(0, 0, 0, 0.15),
        0 0 0 6px rgba(59, 130, 246, 0.15);
}

.dual-range-slider::-moz-range-thumb {
    width: 18px;
    height: 18px;
    background: #ffffff;
    cursor: pointer;
    border-radius: 50%;
    border: 1px solid rgba(255, 255, 255, 0.2);
    pointer-events: all;
    box-shadow: 
        0 2px 8px rgba(0, 0, 0, 0.15),
        0 0 0 0 rgba(59, 130, 246, 0);
    transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
}

.dual-range-slider::-moz-range-thumb:hover {
    transform: scale(1.15);
    box-shadow: 
        0 4px 12px rgba(0, 0, 0, 0.2),
        0 0 0 4px rgba(59, 130, 246, 0.1);
}

.dual-range-slider::-moz-range-thumb:active {
    transform: scale(1.05);
    box-shadow: 
        0 2px 8px rgba(0, 0, 0, 0.15),
        0 0 0 6px rgba(59, 130, 246, 0.15);
}

/* Track container */
.dual-range-slider + .dual-range-slider + .relative {
    margin-top: 10px;
}

.dual-range-slider + .dual-range-slider + .relative > div {
    background-color: rgba(100, 116, 139, 0.2);
    height: 4px;
    border-radius: 2px;
}

#year-range-track {
    background: linear-gradient(90deg, #3b82f6 0%, #06b6d4 100%);
    height: 4px;
    border-radius: 2px;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

/* Light mode adjustments */
body.light-mode .dual-range-slider::-webkit-slider-thumb {
    background: #ffffff;
    border: 1px solid rgba(0, 0, 0, 0.08);
    box-shadow: 
        0 1px 4px rgba(0, 0, 0, 0.1),
        0 0 0 0 rgba(59, 130, 246, 0);
}

body.light-mode .dual-range-slider::-webkit-slider-thumb:hover {
    box-shadow: 
        0 2px 8px rgba(0, 0, 0, 0.15),
        0 0 0 4px rgba(59, 130, 246, 0.08);
}

body.light-mode .dual-range-slider::-webkit-slider-thumb:active {
    box-shadow: 
        0 1px 4px rgba(0, 0, 0, 0.1),
        0 0 0 6px rgba(59, 130, 246, 0.12);
}

body.light-mode .dual-range-slider::-moz-range-thumb {
    background: #ffffff;
    border: 1px solid rgba(0, 0, 0, 0.08);
    box-shadow: 
        0 1px 4px rgba(0, 0, 0, 0.1),
        0 0 0 0 rgba(59, 130, 246, 0);
}

body.light-mode .dual-range-slider::-moz-range-thumb:hover {
    box-shadow: 
        0 2px 8px rgba(0, 0, 0, 0.15),
        0 0 0 4px rgba(59, 130, 246, 0.08);
}

body.light-mode .dual-range-slider::-moz-range-thumb:active {
    box-shadow: 
        0 1px 4px rgba(0, 0, 0, 0.1),
        0 0 0 6px rgba(59, 130, 246, 0.12);
}

body.light-mode .dual-range-slider + .dual-range-slider + .relative > div {
    background-color: rgba(203, 213, 225, 0.5);
}

body.light-mode #year-range-track {
    background: linear-gradient(90deg, #2563eb 0%, #0891b2 100%);
}

/* Year range label styling */
#year-range-label {
    font-variant-numeric: tabular-nums;
    letter-spacing: -0.01em;
    font-weight: 500;
    color: #94a3b8;
    transition: color 0.3s ease;
}

body.light-mode #year-range-label {
    color: #64748b;
}

/* Timeline container refinements */
#timeline-container label {
    margin-bottom: 12px;
    font-weight: 500;
    font-size: 0.8125rem;
    letter-spacing: -0.01em;
}

#timeline-container .flex.justify-between.text-xs {
    margin-top: 8px;
    font-variant-numeric: tabular-nums;
    font-size: 0.6875rem;
    opacity: 0.6;
}

body.light-mode #year-range-track {
    background: linear-gradient(90deg, #1d4ed8, #0891b2);
}

/* Text Elements */
h3 {
    color: #ffffff;
    transition: color 0.3s ease;
}

body.light-mode h3 {
    color: #1e293b;
}

label {
    color: #ffffff;
    transition: color 0.3s ease;
}

body.light-mode label {
    color: #1e293b;
}

.legend-text {
    color: #cbd5e1;
    transition: color 0.3s ease;
}

body.light-mode .legend-text {
    color: #374151;
}

/* Footer */
#footer {
    background-color: rgba(30, 41, 59, 0.8);
    backdrop-filter: blur(8px);
    color: #64748b;
    transition: all 0.3s ease;
}

body.light-mode #footer {
    background-color: rgba(248, 250, 252, 0.8);
    color: #374151;
}

#stats {
    color: #64748b;
    transition: color 0.3s ease;
}

body.light-mode #stats {
    color: #6b7280;
}

/* Loading Screen */
#loading {
    background-color: #0f172a;
    transition: background-color 0.3s ease;
}

body.light-mode #loading {
    background-color: #f8fafc;
}

body.light-mode #loading p {
    color: #6b7280;
}

/* Light Mode Global */
body.light-mode {
    background-color: #f8fafc;
    color: #1e293b;
}

/* Theme Toggle Button */
#theme-toggle {
    transition: all 0.3s ease;
    position: relative;
    overflow: hidden;
}

#theme-toggle:hover {
    transform: scale(1.05);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
}

body.light-mode #theme-toggle:hover {
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.08);
}

#theme-toggle::before {
    content: '';
    position: absolute;
    top: 50%;
    left: 50%;
    width: 0;
    height: 0;
    background: radial-gradient(circle, rgba(59, 130, 246, 0.1) 0%, transparent 70%);
    border-radius: 50%;
    transform: translate(-50%, -50%);
    transition: all 0.3s ease;
}

#theme-toggle:active::before {
    width: 100px;
    height: 100px;
}

/* Improved button ripple effect */
.button-ripple {
    position: relative;
    overflow: hidden;
}

.button-ripple:active::after {
    content: '';
    position: absolute;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.2);
    transform: scale(0);
    animation: ripple 0.3s linear;
    top: 50%;
    left: 50%;
    width: 20px;
    height: 20px;
    margin-left: -10px;
    margin-top: -10px;
}

@keyframes ripple {
    to {
        transform: scale(4);
        opacity: 0;
    }
}

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

.fade-in {
    animation: fadeIn 0.5s ease-out;
}

/* MathJax Styling */
.MathJax {
    color: inherit !important;
}

.MathJax_Display {
    color: inherit !important;
}

body.light-mode .MathJax {
    color: #1e293b !important;
}

body.light-mode .MathJax_Display {
    color: #1e293b !important;
}

/* Ensure MathJax inherits text color properly */
.info-panel .MathJax {
    color: inherit !important;
}

.info-panel .text-slate-400 .MathJax {
    color: #94a3b8 !important;
}

body.light-mode .info-panel .text-slate-400 .MathJax {
    color: #64748b !important;
}

.info-panel .text-slate-300 .MathJax {
    color: #cbd5e1 !important;
}

body.light-mode .info-panel .text-slate-300 .MathJax {
    color: #475569 !important;
}

/* SVG Icons Color */
body.light-mode svg {
    color: #374151;
}

/* Make sure all text elements transition smoothly */
* {
    transition: color 0.3s ease, background-color 0.3s ease, border-color 0.3s ease;
}

/* Info Panel Content Animation */
.info-panel .flex.flex-col {
    opacity: 0;
    transform: translateY(10px);
    transition: opacity 0.3s ease 0.1s, transform 0.3s ease 0.1s;
}

.info-panel.show .flex.flex-col {
    opacity: 1;
    transform: translateY(0);
}