:root {
    --bg-color: #0f172a;
    --sidebar-bg: rgba(30, 41, 59, 0.7);
    --card-bg: rgba(30, 41, 59, 0.5);
    --text-primary: #f8fafc;
    --text-secondary: #94a3b8;
    --accent-color: #3b82f6;
    --accent-glow: rgba(59, 130, 246, 0.5);
    --neon-pink: #ec4899;
    --neon-purple: #8b5cf6;
    --border-color: rgba(255, 255, 255, 0.1);
    --glass-blur: blur(12px);
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    font-family: 'Outfit', sans-serif;
}

body {
    background-color: var(--bg-color);
    color: var(--text-primary);
    min-height: 100vh;
    overflow-x: hidden;
    /* Animated Gradient Background */
    background: radial-gradient(circle at 15% 50%, rgba(59, 130, 246, 0.15), transparent 25%),
                radial-gradient(circle at 85% 30%, rgba(139, 92, 246, 0.15), transparent 25%);
    background-color: var(--bg-color);
}

/* App Layout */
.app-container {
    display: flex;
    height: 100vh;
    overflow: hidden;
}

/* Sidebar */
.sidebar {
    width: 260px;
    background: var(--sidebar-bg);
    backdrop-filter: var(--glass-blur);
    border-right: 1px solid var(--border-color);
    padding: 2rem 1.5rem;
    display: flex;
    flex-direction: column;
    z-index: 10;
}

.logo {
    display: flex;
    align-items: center;
    gap: 1rem;
    font-size: 1.75rem;
    font-weight: 700;
    margin-bottom: 3rem;
    color: var(--text-primary);
}

.neon-text {
    background: linear-gradient(135deg, var(--accent-color), var(--neon-purple));
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    filter: drop-shadow(0 0 8px var(--accent-glow));
}

.nav-links {
    list-style: none;
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.nav-links li {
    display: flex;
    align-items: center;
    gap: 1rem;
    padding: 1rem;
    border-radius: 12px;
    cursor: pointer;
    color: var(--text-secondary);
    transition: all 0.3s ease;
    font-weight: 500;
}

.nav-links li:hover {
    background: rgba(255, 255, 255, 0.05);
    color: var(--text-primary);
}

.nav-links li.active {
    background: linear-gradient(135deg, rgba(59, 130, 246, 0.2), rgba(139, 92, 246, 0.2));
    color: var(--text-primary);
    border: 1px solid rgba(139, 92, 246, 0.3);
    box-shadow: 0 0 15px rgba(139, 92, 246, 0.1);
}

.nav-links li i {
    font-size: 1.25rem;
    width: 24px;
    text-align: center;
}

/* Main Content */
.main-content {
    flex: 1;
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

.top-header {
    height: 80px;
    padding: 0 2.5rem;
    display: flex;
    align-items: center;
    justify-content: space-between;
    border-bottom: 1px solid var(--border-color);
    background: rgba(15, 23, 42, 0.8);
    backdrop-filter: var(--glass-blur);
    z-index: 5;
}

.search-bar {
    display: flex;
    align-items: center;
    background: var(--card-bg);
    padding: 0.75rem 1.5rem;
    border-radius: 20px;
    border: 1px solid var(--border-color);
    width: 300px;
    transition: all 0.3s ease;
    color: var(--text-primary);
}

.search-bar:focus-within {
    border-color: var(--accent-color);
    box-shadow: 0 0 10px var(--accent-glow);
}

.search-bar i {
    color: var(--text-secondary);
    margin-right: 0.75rem;
}

.search-bar input {
    background: transparent;
    border: none;
    color: var(--text-primary);
    outline: none;
    width: 100%;
    font-size: 0.95rem;
}

.user-profile .avatar {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    background: linear-gradient(135deg, var(--neon-purple), var(--neon-pink));
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.2rem;
    box-shadow: 0 0 15px rgba(236, 72, 153, 0.4);
    cursor: pointer;
}

.content-wrapper {
    flex: 1;
    padding: 2.5rem;
    overflow-y: auto;
    position: relative;
}

/* Views (Dashboard, Elementary, etc.) */
.view-section {
    display: none;
    animation: fadeIn 0.4s ease-out forwards;
}

.view-section.active {
    display: block;
}

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

h1.view-title {
    font-size: 2.5rem;
    font-weight: 700;
    margin-bottom: 0.5rem;
}

p.view-subtitle {
    color: var(--text-secondary);
    margin-bottom: 2.5rem;
    font-size: 1.1rem;
}

/* Cards & Grid */
.grid-cards {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
    gap: 1.5rem;
}

.card {
    background: var(--card-bg);
    border: 1px solid var(--border-color);
    border-radius: 16px;
    padding: 1.5rem;
    backdrop-filter: var(--glass-blur);
    transition: all 0.3s ease;
    cursor: pointer;
    position: relative;
    overflow: hidden;
}

.card::before {
    content: '';
    position: absolute;
    top: 0; left: 0; width: 100%; height: 100%;
    background: linear-gradient(135deg, rgba(255,255,255,0.05), transparent);
    opacity: 0;
    transition: opacity 0.3s ease;
}

.card:hover {
    transform: translateY(-5px);
    border-color: rgba(139, 92, 246, 0.5);
    box-shadow: 0 10px 25px rgba(0, 0, 0, 0.2), 0 0 15px rgba(139, 92, 246, 0.2);
}

.card:hover::before {
    opacity: 1;
}

.card-icon {
    width: 50px;
    height: 50px;
    border-radius: 12px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.5rem;
    margin-bottom: 1rem;
}

.icon-blue { background: rgba(59, 130, 246, 0.15); color: #60a5fa; }
.icon-purple { background: rgba(139, 92, 246, 0.15); color: #a78bfa; }
.icon-pink { background: rgba(236, 72, 153, 0.15); color: #f472b6; }
.icon-green { background: rgba(16, 185, 129, 0.15); color: #34d399; }

.card h3 {
    font-size: 1.25rem;
    margin-bottom: 0.5rem;
}

.card p {
    color: var(--text-secondary);
    font-size: 0.95rem;
    line-height: 1.5;
}

/* Utilities */
.math-display {
    padding: 1rem;
    background: rgba(0,0,0,0.2);
    border-radius: 8px;
    margin: 1rem 0;
    text-align: center;
    font-size: 1.2rem;
}

.btn {
    padding: 0.75rem 1.5rem;
    border-radius: 8px;
    border: none;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s ease;
}

.btn-primary {
    background: linear-gradient(135deg, var(--accent-color), var(--neon-purple));
    color: white;
    box-shadow: 0 4px 15px var(--accent-glow);
}

.btn-primary:hover {
    opacity: 0.9;
    transform: translateY(-2px);
}

/* Graph Container */
.graph-container {
    background: white; /* Function plot needs white/light bg usually, or we style it */
    border-radius: 12px;
    padding: 10px;
    margin-top: 1rem;
    overflow: hidden;
}

/* Scrollbar */
::-webkit-scrollbar {
    width: 8px;
}
::-webkit-scrollbar-track {
    background: rgba(0, 0, 0, 0.1);
}
::-webkit-scrollbar-thumb {
    background: rgba(255, 255, 255, 0.1);
    border-radius: 4px;
}
::-webkit-scrollbar-thumb:hover {
    background: rgba(255, 255, 255, 0.2);
}

/* --- Animazioni Giocose --- */
@keyframes bounceCustom {
    0%, 100% { transform: translateY(0); }
    50% { transform: translateY(-10px); }
}
.animate-bounce-custom {
    display: inline-block;
    animation: bounceCustom 1s infinite ease-in-out;
}

@keyframes floatUp {
    0% { transform: translateY(0) translateX(0); opacity: 1; }
    100% { transform: translateY(-20px) translateX(10px); opacity: 0; }
}
.animate-float {
    display: inline-block;
    animation: floatUp 2s infinite ease-in;
}

@keyframes seesaw {
    0%, 100% { transform: rotate(-10deg); }
    50% { transform: rotate(10deg); }
}
.animate-seesaw {
    display: inline-block;
    animation: seesaw 2s infinite ease-in-out;
    transform-origin: center bottom;
}

@keyframes spinSlow {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}
.animate-spin-slow {
    display: inline-block;
    animation: spinSlow 6s linear infinite;
}

@keyframes slideX {
    0%, 100% { transform: translateX(0); }
    50% { transform: translateX(20px); }
}
.animate-slide-x {
    display: inline-block;
    animation: slideX 2s infinite ease-in-out;
}

@keyframes rollercoaster {
    0% { transform: translate(0, 0) rotate(0deg); }
    25% { transform: translate(20px, -20px) rotate(-45deg); }
    50% { transform: translate(40px, 0) rotate(0deg); }
    75% { transform: translate(60px, 20px) rotate(45deg); }
    100% { transform: translate(80px, 0) rotate(0deg); }
}
.animate-rollercoaster {
    display: inline-block;
    animation: rollercoaster 3s infinite ease-in-out alternate;
}

@keyframes pulseCustom {
    0%, 100% { transform: scale(1); }
    50% { transform: scale(1.1); }
}
.animate-pulse-custom {
    display: inline-block;
    animation: pulseCustom 1.5s infinite ease-in-out;
}

/* --- Animazioni Esplicative --- */
@keyframes slideTogetherLeft {
    0% { transform: translateX(-50px); opacity: 0; }
    50%, 100% { transform: translateX(0); opacity: 1; }
}
@keyframes slideTogetherRight {
    0% { transform: translateX(50px); opacity: 0; }
    50%, 100% { transform: translateX(0); opacity: 1; }
}
.anim-merge-left { animation: slideTogetherLeft 2s ease-out infinite alternate; }
.anim-merge-right { animation: slideTogetherRight 2s ease-out infinite alternate; }

@keyframes flyAway {
    0%, 30% { transform: translateY(0) scale(1); opacity: 1; }
    80%, 100% { transform: translateY(-100px) scale(0.5); opacity: 0; }
}
.anim-fly-away { animation: flyAway 3s ease-in infinite; }

/* Balance Scale */
.balance-scale-container {
    display: flex;
    flex-direction: column;
    align-items: center;
    margin: 2rem 0;
}
.balance-beam {
    width: 200px;
    height: 10px;
    background: var(--accent-color);
    border-radius: 5px;
    position: relative;
    transition: transform 1s ease-in-out;
    animation: beamTilt 4s ease-in-out infinite alternate;
}
.balance-plate {
    position: absolute;
    top: 10px;
    width: 80px;
    height: 5px;
    background: rgba(255,255,255,0.2);
    border-radius: 0 0 10px 10px;
    display: flex;
    justify-content: center;
    gap: 5px;
}
.plate-left { left: 0; transform: translateX(-50%); }
.plate-right { right: 0; transform: translateX(50%); }
.balance-pivot {
    width: 0; 
    height: 0; 
    border-left: 20px solid transparent;
    border-right: 20px solid transparent;
    border-bottom: 30px solid var(--neon-purple);
}
.weight-block {
    background: var(--bg-color);
    border: 2px solid var(--neon-pink);
    padding: 5px;
    border-radius: 5px;
    font-weight: bold;
    color: white;
    margin-top: -30px;
}
@keyframes beamTilt {
    0%, 20% { transform: rotate(0deg); }
    40%, 60% { transform: rotate(-10deg); }
    80%, 100% { transform: rotate(0deg); }
}
@keyframes weightDisappear {
    0%, 30% { opacity: 1; transform: scale(1); }
    45%, 60% { opacity: 0; transform: scale(0); }
    80%, 100% { opacity: 0; transform: scale(0); }
}
.anim-weight-disappear { animation: weightDisappear 4s ease-in-out infinite alternate; }

/* Fraction Pie */
.fraction-pie {
    width: 120px;
    height: 120px;
    border-radius: 50%;
    margin: 0 auto;
    border: 2px solid rgba(255,255,255,0.2);
    animation: pieFill 4s ease-in-out infinite;
}
@keyframes pieFill {
    0%, 20% { background: conic-gradient(var(--neon-pink) 0deg 72deg, rgba(255,255,255,0.1) 72deg 360deg); }
    40%, 60% { background: conic-gradient(var(--neon-pink) 0deg 144deg, rgba(255,255,255,0.1) 144deg 360deg); }
    80%, 100% { background: conic-gradient(var(--neon-pink) 0deg 216deg, rgba(255,255,255,0.1) 216deg 360deg); }
}

@keyframes parabolaPath {
    0% { transform: translate(0, 0); opacity: 0; }
    10% { opacity: 1; }
    50% { transform: translate(50px, -60px); }
    90% { opacity: 1; }
    100% { transform: translate(100px, 0); opacity: 0; }
}
.anim-parabola {
    display: inline-block;
    animation: parabolaPath 3s infinite cubic-bezier(0.25, 1, 0.5, 1);
}
.parabola-container {
    position: relative;
    width: 150px;
    height: 80px;
    border-bottom: 2px dashed rgba(255,255,255,0.3);
    margin: 1rem auto;
}
.parabola-ball {
    position: absolute;
    bottom: -10px;
    left: 20px;
    font-size: 2rem;
}
