:root {
    /* Light Theme (Default) */
    --bg-color: #f0f2f5;
    --glass-bg: rgba(255, 255, 255, 0.65);
    --glass-border: rgba(255, 255, 255, 0.8);
    --text-primary: #1a202c;
    --text-secondary: #4a5568;
    --accent-color: #2ecc71; /* A clean, modern green */
    --accent-color-darker: #27ae60;
    --shadow-color: rgba(0, 0, 0, 0.07);
    --font-main: 'Poppins', sans-serif;
    --spotlight-color: rgba(46, 204, 113, 0.15);
}

body.dark-mode {
    --bg-color: #1a202c;
    --glass-bg: rgba(45, 55, 72, 0.5);
    --glass-border: rgba(255, 255, 255, 0.1);
    --text-primary: #edf2f7;
    --text-secondary: #a0aec0;
    --shadow-color: rgba(0, 0, 0, 0.2);
    --spotlight-color: rgba(46, 204, 113, 0.1);
}

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

@keyframes slideInLeft {
    from {
        opacity: 0;
        transform: translateX(-50px);
    }
    to {
        opacity: 1;
        transform: translateX(0);
    }
}

body {
    font-family: var(--font-main);
    line-height: 1.6;
    margin: 0;
    background-color: var(--bg-color);
    background-attachment: fixed;
    color: var(--text-primary);
    overflow-x: hidden; /* Prevents horizontal scroll from animations */
}

body::before {
    content: '';
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: radial-gradient(
        circle 300px at var(--cursor-x) var(--cursor-y),
        var(--spotlight-color), /* A more visible green spotlight */
        transparent 60%
    );
    z-index: -1;
    pointer-events: none;
    transition: background 0.1s ease;
}
.container {
    width: 90%;
    max-width: 960px;
    margin: auto;
    overflow: hidden;
    padding: 20px;
}
header {
    background: var(--glass-bg);
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
    border-bottom: 1px solid var(--glass-border);
    position: sticky;
    top: 0;
    z-index: 100;
    box-shadow: 0 2px 10px var(--shadow-color);
}
header nav {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 5px 0;
}
header .nav-right {
    display: flex;
    align-items: center;
    gap: 20px;
}

#menu-toggle {
    display: none; /* Hidden on desktop */
}
header #logo {
    font-size: clamp(1.8rem, 5vw, 2.2rem); /* Responsive font size */
    font-weight: 700;
    cursor: pointer;
    transition: transform 0.3s ease;
}

header #logo span {
    color: var(--accent-color);
    display: inline-block; /* Needed for transform */
    transition: transform 0.3s cubic-bezier(0.25, 0.8, 0.25, 1);
}

header #logo:hover span {
    transform: rotate(-10deg) scale(1.1);
}

header ul {
    list-style: none; 
    margin: 0;
    padding: 0;
    display: flex;
    gap: 20px;
}
header a {
    text-decoration: none;
    color: var(--text-primary);
    font-weight: 500;
    padding: 5px 10px;
    border-radius: 6px;
    transition: background-color 0.3s;
    font-weight: 500;
}
header a:hover {
    background-color: rgba(46, 204, 113, 0.1);
}
header ul.nav-open {
    display: flex;
}

main {
    padding: 20px 0;
}
.card {
    background: var(--glass-bg);
    padding: 20px;
    margin-bottom: 20px;
    border-radius: 12px;
    box-shadow: 0 8px 32px 0 var(--shadow-color);
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
    border: 1px solid var(--glass-border);
    animation: fadeInUp 0.5s ease-out forwards;
    opacity: 0; /* Start hidden for animation */
    animation-delay: var(--delay, 0ms);
}
.card h2, .card h3 {
    margin-top: 0;
    color: var(--text-primary);
    font-weight: 600;
    border-bottom: 2px solid var(--accent-color);
    padding-bottom: 8px;
    display: inline-block;
}
.notes-grid-layout {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(250px, 1fr));
    gap: 20px;
}
.note-card {
    background: var(--glass-bg);
    padding: 15px;
    border-radius: 12px;
    border: 1px solid var(--glass-border);
    cursor: pointer;
    transition: transform 0.2s ease, box-shadow 0.2s ease, background 0.2s ease;
    will-change: transform; /* Performance hint for the browser */
}
.note-card:hover {
    transform: translateY(-5px) scale(1.03);
    box-shadow: 0 10px 25px var(--shadow-color);
    background: var(--glass-bg);
}

/* Features Section */
.features-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
    gap: 20px;
    margin-top: 20px;
}
.feature-card {
    background: var(--glass-bg);
    padding: 20px;
    border-radius: 10px;
    border: 1px solid var(--glass-border);
    text-align: center;
    transition: transform 0.3s ease, box-shadow 0.3s ease;
}
.feature-card:hover {
    transform: translateY(-5px);
    box-shadow: 0 8px 20px var(--shadow-color);
}
.feature-card h3 {
    border-bottom: none;
    font-size: 1.2em;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
}
.feature-card p {
    font-size: 0.9em;
    color: var(--text-secondary);
}
.feature-button {
    background: none;
    border: 1px solid var(--accent-color);
    color: var(--accent-color);
    padding: 8px 16px;
    border-radius: 6px;
    cursor: pointer;
    transition: background-color 0.3s, color 0.3s;
}
.feature-button:hover {
    background-color: var(--accent-color);
    color: #fff;
}

.note-card:hover {
    transform: translateY(-5px) scale(1.03);
    box-shadow: 0 10px 25px var(--shadow-color);
    background: var(--glass-bg);
}
.star-rating {
    color: #facc15;
    font-size: 1.2em;
}
.review {
    border-top: 1px solid var(--glass-border);
    padding-top: 10px;
    margin-top: 15px;
}
.review p {
    margin: 5px 0;
}

/* Form Styling */
.search-filters label, form label {
    display: block;
    margin-bottom: 5px;
    font-weight: bold;
    color: var(--text-secondary);
}
form input[type="text"], form textarea, form input[type="file"] {
    width: 100%;
    padding: 12px;
    margin-bottom: 15px;
    border-radius: 6px;
    border: 1px solid var(--glass-border);
    box-sizing: border-box;
    background-color: var(--glass-bg);
    color: var(--text-primary);
    font-size: 1em;
    font-family: var(--font-main);
    transition: border-color 0.3s ease, background-color 0.3s ease, box-shadow 0.3s ease;
}
form input:focus, form textarea:focus {
    outline: none;
    border-color: var(--accent-color);
    background-color: var(--glass-bg);
    box-shadow: 0 0 0 3px rgba(46, 204, 113, 0.2);
}
form input[type="file"] {
    padding: 5px;
}
form input::placeholder, form textarea::placeholder {
    color: var(--text-secondary);
}
form button {
    display: block;
    width: 100%;
    padding: 12px;
    border: none;
    background: var(--accent-color);
    color: #fff;
    cursor: pointer;
    border-radius: 8px;
    font-size: 1em;
    font-weight: bold;
    font-family: var(--font-main);
    text-transform: uppercase;
    letter-spacing: 1px;
    transition: background-color 0.3s ease, box-shadow 0.3s ease, transform 0.1s ease;
}
form button:hover {
    background: var(--accent-color-darker); /* Darker green on hover */
    box-shadow: 0 7px 14px rgba(46, 204, 113, 0.3);
}
form button:active {
    transform: scale(0.98);
    transition: transform 0.05s ease;
}

/* Interactive Star Rating Styles */
.rating {
    display: flex;
    flex-direction: row-reverse;
    justify-content: flex-end;
    margin-bottom: 10px;
}
.rating > input { display:none; }
.rating > label {
    position: relative;
    width: 1.1em;
    font-size: 2.2rem;
    color: #ccc; /* Default star color */
    cursor: pointer;
    transition: color 0.2s ease-in-out;
}
.rating > label:hover,
.rating > label:hover ~ label,
.rating > input:checked ~ label {
    color: #facc15; /* Gold color for selected/hovered stars */
}

#review-form textarea {
    height: 80px;
    resize: vertical;
}
footer {
    text-align: center;
    padding: 20px;
    margin-top: 20px;
    background: none;
    color: var(--text-secondary);
}

/* Chart Styles */
.charts-container {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 20px;
    margin-top: 20px;
}

.chart-wrapper { position: relative; }

.hidden {
    display: none;
}

/* Search Page Filters */
.search-filters {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 15px;
}

.filter-group {
    display: flex;
    flex-direction: column;
}

/* Profile/Auth Page Styles */
.auth-container {
    display: flex;
    align-items: flex-start;
    gap: 30px;
}

.auth-container > .card {
    flex: 1;
}

.auth-separator {
    display: flex;
    align-items: center;
    justify-content: center;
    flex-direction: column;
    height: 200px; /* Adjust as needed */
    align-self: center;
    gap: 10px;
    color: var(--text-secondary);
    font-weight: 600;
}

.auth-separator .line {
    width: 1px;
    height: 100%;
    background-color: var(--glass-border);
}

.forgot-password {
    display: block;
    text-align: right;
    margin: -10px 0 15px 0;
    font-size: 0.9em;
}

#sign-in-card {
    animation: slideInLeft 0.6s ease-out forwards;
    animation-delay: 0.2s;
    opacity: 0;
}

/* Leaderboard Styles */
#leaderboard-list {
    list-style: none;
    padding: 0;
    display: flex;
    flex-direction: column;
    gap: 10px;
}
#leaderboard-list li {
    display: flex;
    justify-content: space-between; 
    align-items: center;
    padding: 12px 15px;
    border-radius: 8px;
    background: var(--glass-bg);
    transition: background 0.3s, transform 0.2s;
    border: 1px solid transparent;
}
#leaderboard-list li:hover {
    background: var(--glass-bg);
    transform: scale(1.02);
}
.leaderboard-user {
    display: flex;
    align-items: center;
    gap: 15px;
}
.leaderboard-rank {
    font-size: 1.1em;
    font-weight: 700;
    color: var(--accent-color);
    width: 24px;
    text-align: center;
}
.leaderboard-avatar {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    background-color: var(--accent-color);
    color: #fff;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 600;
    font-size: 0.9em;
}
.leaderboard-name {
    font-weight: 600;
}
.leaderboard-count {
    font-weight: 500;
    color: var(--text-secondary);
    font-size: 0.9em;
}

/* Special styles for top 3 */
#leaderboard-list li:nth-child(1) {
    background: linear-gradient(135deg, rgba(255, 215, 0, 0.2), rgba(255, 215, 0, 0.05));
    border-color: rgba(255, 215, 0, 0.4);
}
#leaderboard-list li:nth-child(2) {
    background: linear-gradient(135deg, rgba(192, 192, 192, 0.2), rgba(192, 192, 192, 0.05));
    border-color: rgba(192, 192, 192, 0.4);
}
#leaderboard-list li:nth-child(3) {
    background: linear-gradient(135deg, rgba(205, 127, 50, 0.2), rgba(205, 127, 50, 0.05));
    border-color: rgba(205, 127, 50, 0.4);
}

/* Dashboard Styles */
.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
    gap: 20px;
}
.stat-card {
    background: var(--glass-bg);
    padding: 20px;
    border-radius: 10px;
    border: 1px solid var(--glass-border);
    text-align: center;
}
.stat-card h3 {
    margin: 0 0 10px 0;
    font-size: 1em;
    color: var(--text-secondary);
    border: none;
    font-weight: 500;
}
.stat-card .stat-number {
    font-size: 2.5em;
    font-weight: 700;
    color: var(--accent-color);
    margin: 0;
}
.stat-card .stat-text {
    font-size: 1.2em;
    font-weight: 600;
    color: var(--text-primary);
    margin: 0;
    line-height: 1.2;
}

/* --- Theme Toggle Switch --- */
.theme-switch-wrapper {
    display: flex;
    align-items: center;
    margin-left: 20px; /* Add some space from the nav links */
}
.theme-switch {
    display: inline-block;
    height: 28px;
    position: relative;
    width: 55px;
}
.theme-switch input {
    opacity: 0;
    width: 0;
    height: 0;
}
.slider {
    position: absolute;
    cursor: pointer;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background-color: #ccc;
    transition: .4s;
    border-radius: 28px;
}
.slider:before {
    position: absolute;
    content: "☀️";
    height: 20px;
    width: 20px;
    left: 4px;
    bottom: 4px;
    background-color: white;
    transition: .4s;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 14px;
}
input:checked + .slider {
    background-color: var(--accent-color);
}
input:checked + .slider:before {
    transform: translateX(27px);
    content: "🌙";
}

/* Responsive Design */
@media (max-width: 768px) {
    header nav {
        flex-direction: column;
        gap: 10px;
        align-items: flex-start;
    }
    header ul {
        flex-direction: column;
        width: 100%;
        gap: 5px;
    }
    header nav {
        flex-direction: row;
        flex-wrap: wrap;
        justify-content: space-between;
    }
    .theme-switch-wrapper {
        margin-left: 0;
        margin-top: 10px;
        width: 100%;
        justify-content: flex-end;
    }
    .charts-container {
        grid-template-columns: 1fr;
    }
    .auth-container {
        flex-direction: column;
        gap: 0;
    }
    .auth-separator {
        flex-direction: row;
        height: auto;
        width: 100%;
        margin: 20px 0;
    }
    .auth-separator .line {
        height: 1px;
        flex: 1;
    }
}

@media (max-width: 480px) {
    .container {
        width: 95%;
        padding: 10px;
    }
}