:root {
    --gemini-bg-dark: #131316;
    --gemini-bg-medium: #1E1E22;
    --gemini-bg-light: #2A2A2E;
    --gemini-accent-blue: #8AB4F8;
    --gemini-accent-green: #6DD5ED;
    --gemini-text-light: #E8EAED;
    --gemini-text-muted: #BDC1C6;
    --gemini-border: #3A3A3F;
    --gemini-red: #EA4335;
    --gemini-yellow: #F9AB00;
    --gemini-green: #34A853;

    --light-bg-dark: #FFFFFF;
    --light-bg-medium: #F0F2F5;
    --light-bg-light: #E8EAED;
    --light-accent-blue: #1A73E8;
    --light-accent-green: #0F9D58;
    --light-text-light: #202124;
    --light-text-muted: #5F6368;
    --light-border: #DADCE0;
    --light-red: #D93025;
    --light-yellow: #F9AB00;
    --light-green: #1E8E3E;

    --sidebar-expanded-width: 280px;
    --sidebar-collapsed-width: 70px;
     /* Grid layout tuning */
     --grid-gap: 1.5rem;
     /* Horizontal edge gutter: distance from sidebar inner edge to first card,
         and from last card to the right edge. Tweak this single value. */
     --grid-side-gutter: 0.75rem;
}

body.light-mode {
    --gemini-bg-dark: var(--light-bg-dark);
    --gemini-bg-medium: var(--light-bg-medium);
    --gemini-bg-light: var(--light-bg-light);
    --gemini-accent-blue: var(--light-accent-blue);
    --gemini-accent-green: var(--light-accent-green);
    --gemini-text-light: var(--light-text-light);
    --gemini-text-muted: var(--light-text-muted);
    --gemini-border: var(--light-border);
    --gemini-red: var(--light-red);
    --gemini-yellow: var(--light-yellow);
    --gemini-green: var(--light-green);
}

/* High priority z-index rules */
#notificationDropdown {
    z-index: 999999 !important;
    position: fixed !important; /* escape transformed ancestors */
}

/* Main content fade-in after loading */
body {
    font-family: 'Inter', sans-serif;
    /* Fallback solid color */
    background-color: var(--gemini-bg-dark);
    /* Subtle black-grey gradient layers (no blue tint) */
    background-image:
        radial-gradient(800px 500px at 15% -10%, rgba(255, 255, 255, 0.045), rgba(255, 255, 255, 0) 60%),
        radial-gradient(700px 450px at 85% 110%, rgba(255, 255, 255, 0.035), rgba(255, 255, 255, 0) 60%),
        linear-gradient(180deg, var(--gemini-bg-dark) 0%, #0f0f12 100%);
    background-attachment: fixed, fixed, fixed;
    background-repeat: no-repeat;
    color: var(--gemini-text-light);
    position: relative;
    overflow-x: hidden;
    transition: background-color 0.3s ease, color 0.3s ease, background-image 0.3s ease;
    padding-top: 0;
}

/* Disable gradient in light mode for a clean solid background */
body.light-mode {
    background: var(--light-bg-dark) !important;
    background-image: none !important;
}

/* Simplified clean transition after loading */
.main-content,
.sidebar {
    opacity: 0;
    transition: opacity 1s ease-out;
}

/* Simple fade-in after loading */
body.loaded .main-content,
body.loaded .sidebar {
    opacity: 1;
}

/* Stagger the animations for different page elements */
body.loaded .sidebar {
    transition-delay: 0.1s;
}

body.loaded .main-content {
    transition-delay: 0.2s;
}

body.loaded .main-content header {
    opacity: 0;
    transform: translateY(-20px);
    animation: fadeInDown 0.6s ease-out 0.4s forwards;
}

body.loaded .university-card {
    animation-delay: 0.6s;
}

/* Additional entrance animations */
@keyframes fadeInDown {
    from {
        opacity: 0;
        transform: translateY(-20px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

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




/* Subtle background gradient for depth - even more subtle */
body::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: radial-gradient(circle at 15% 85%, rgba(138, 180, 248, 0.01) 0%, transparent 15%),
                radial-gradient(circle at 85% 15%, rgba(109, 213, 237, 0.01) 0%, transparent 15%);
    animation: backgroundSubtleShift 30s infinite alternate ease-in-out;
    z-index: 0;
    pointer-events: none;
}

/* Adjust background gradient for light mode if desired, or remove */
body.light-mode::before {
    background: radial-gradient(circle at 15% 85%, rgba(26, 115, 232, 0.02) 0%, transparent 15%), /* Light blue tint */
                radial-gradient(circle at 85% 15%, rgba(15, 157, 88, 0.02) 0%, transparent 15%); /* Light green tint */
}


@keyframes backgroundSubtleShift {
    0% { transform: scale(1); opacity: 1; }
    50% { transform: scale(1.005); opacity: 0.99; }
    100% { transform: scale(1); opacity: 1; }
}

/* Custom scrollbar for a sleek look */
::-webkit-scrollbar {
    width: 8px;
    height: 8px;
}
::-webkit-scrollbar-track {
    background: var(--gemini-bg-medium);
    border-radius: 10px;
}
::-webkit-scrollbar-thumb {
    background: var(--gemini-border);
    border-radius: 10px;
}
::-webkit-scrollbar-thumb:hover {
    background: var(--gemini-accent-blue);
}

/* Enhanced performance optimizations */
* {
    box-sizing: border-box;
}

/* Critical resource preloading and GPU acceleration */
body {
    will-change: auto;
    font-display: swap;
    text-rendering: optimizeLegibility;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

/* Enhanced GPU accelerated transitions with performance optimizations */
.transition-all-smooth {
    transition: transform 0.2s cubic-bezier(0.4, 0, 0.2, 1),
                opacity 0.2s cubic-bezier(0.4, 0, 0.2, 1),
                color 0.2s cubic-bezier(0.4, 0, 0.2, 1),
                background-color 0.2s cubic-bezier(0.4, 0, 0.2, 1);
    will-change: transform, opacity;
    backface-visibility: hidden;
    transform: translateZ(0);
}

/* Remove will-change when not hovering for better performance */
.transition-all-smooth:not(:hover):not(:focus) {
    will-change: auto;
}

/* Loading states and skeleton animations */
.loading-skeleton {
    background: linear-gradient(90deg, var(--gemini-bg-medium) 25%, var(--gemini-bg-light) 50%, var(--gemini-bg-medium) 75%);
    background-size: 200% 100%;
    animation: loading-shimmer 1.5s infinite;
}

@keyframes loading-shimmer {
    0% {
        background-position: -200% 0;
    }
    100% {
        background-position: 200% 0;
    }
}

/* Simple, clean loading screen transition */
.loading-screen {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: linear-gradient(135deg, var(--gemini-bg-dark) 0%, #0f0f12 100%);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 10000;
    transition: opacity 1s ease-out;
}

.loading-screen.hidden {
    opacity: 0;
    pointer-events: none;
}

.loading-container {
    text-align: center;
    animation: loadingPulse 2s ease-in-out infinite;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
}

.loading-logo {
    position: relative;
    margin-bottom: 2rem;
    display: flex;
    align-items: center;
    justify-content: center;
    width: 140px;
    height: 140px;
}

.logo-img {
    width: 60px;
    height: 60px;
    border-radius: 50%;
    animation: logoSpin 3s linear infinite;
    filter: drop-shadow(0 0 20px rgba(138, 180, 248, 0.3));
    position: relative;
    z-index: 2;
}

.loading-rings {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
}

.ring {
    position: absolute;
    border: 2px solid transparent;
    border-top: 2px solid var(--gemini-accent-blue);
    border-radius: 50%;
    animation: ringRotate 1.5s linear infinite;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
}

.ring-1 {
    width: 100px;
    height: 100px;
    animation-duration: 2s;
}

.ring-2 {
    width: 120px;
    height: 120px;
    animation-duration: 1.5s;
    animation-direction: reverse;
    border-top-color: var(--gemini-accent-green);
}

.ring-3 {
    width: 140px;
    height: 140px;
    animation-duration: 3s;
    border-top-color: rgba(138, 180, 248, 0.5);
}

.loading-text h2 {
    font-size: 2.5rem;
    font-weight: 700;
    color: var(--gemini-text-light);
    margin-bottom: 1rem;
    letter-spacing: 2px;
}

.loading-text .accent {
    color: var(--gemini-accent-blue);
    text-shadow: 0 0 20px rgba(138, 180, 248, 0.5);
}

.loading-message {
    margin: 1rem 0;
    min-height: 1.5rem;
}

.loading-message span {
    font-size: 1rem;
    color: var(--gemini-text-muted);
    font-weight: 400;
    transition: opacity 0.3s ease;
}

.loading-dots {
    display: inline-block;
    margin-left: 0.5rem;
}

.loading-dots span {
    display: inline-block;
    font-size: 2rem;
    color: var(--gemini-accent-blue);
    animation: loadingDots 1.5s infinite;
}

.loading-dots span:nth-child(2) {
    animation-delay: 0.2s;
}

.loading-dots span:nth-child(3) {
    animation-delay: 0.4s;
}

.loading-progress {
    width: 300px;
    height: 4px;
    background: var(--gemini-bg-medium);
    border-radius: 2px;
    margin: 2rem auto 0;
    overflow: hidden;
    position: relative;
    border: 1px solid rgba(138, 180, 248, 0.2);
}

.progress-bar {
    height: 100%;
    width: 0%;
    background: linear-gradient(90deg, var(--gemini-accent-blue), var(--gemini-accent-green), var(--gemini-accent-blue));
    background-size: 200% 100%;
    border-radius: 2px;
    transition: width 0.3s ease-out;
    box-shadow: 0 0 15px rgba(138, 180, 248, 0.6);
    animation: progressShimmer 2s ease-in-out infinite;
    position: relative;
}

.progress-bar::after {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: linear-gradient(90deg, transparent, rgba(255, 255, 255, 0.4), transparent);
    animation: progressGlow 1.5s ease-in-out infinite;
}

@keyframes logoSpin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

@keyframes ringRotate {
    0% { transform: translate(-50%, -50%) rotate(0deg); }
    100% { transform: translate(-50%, -50%) rotate(360deg); }
}

@keyframes loadingPulse {
    0%, 100% { transform: scale(1); opacity: 1; }
    50% { transform: scale(1.02); opacity: 0.9; }
}

@keyframes loadingDots {
    0%, 60%, 100% { transform: translateY(0); opacity: 0.4; }
    30% { transform: translateY(-10px); opacity: 1; }
}

@keyframes progressShimmer {
    0%, 100% {
        background-position: 0% 50%;
    }
    50% {
        background-position: 100% 50%;
    }
}

@keyframes progressGlow {
    0% {
        transform: translateX(-100%);
    }
    100% {
        transform: translateX(100%);
    }
}

/* Optimize image loading with attributes */
img {
    max-width: 100%;
    height: auto;
    display: block;
}

/* Optimize scrolling performance */
.university-card,
.modal-content {
    contain: layout style paint;
}
/* Avoid paint containment on sidebar to prevent visual clipping */
.sidebar {
    contain: layout;
}

/* Reduce layout thrashing */
.university-card {
    transform: translateZ(0);
    backface-visibility: hidden;
}

/* Optimize animations */
@media (prefers-reduced-motion: reduce) {
    *,
    *::before,
    *::after {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
    }
}

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

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

@keyframes scaleIn {
    from {
        opacity: 0;
        transform: scale(0.9);
    }
    to {
        opacity: 1;
        transform: scale(1);
    }
}

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

/* Apply animations to elements */
.university-card {
    animation: fadeInUp 0.3s ease-out forwards;
    animation-delay: calc(var(--animation-order, 0) * 0.05s);
}

.sidebar nav ul li {
    animation: slideInLeft 0.3s ease-out forwards;
    animation-delay: calc(var(--animation-order, 0) * 0.1s);
}

/* Hover animations */
.university-card:hover {
    transform: translateY(-2px);
    box-shadow: 0 8px 25px rgba(0, 0, 0, 0.15);
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

/* Fixed hover effect - no transform when collapsed */
.sidebar.expanded nav ul li a:hover,
.sidebar.expanded nav ul li button:hover {
    transform: translateX(4px);
    transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
}

.sidebar.collapsed nav ul li a:hover,
.sidebar.collapsed nav ul li button:hover {
    background-color: var(--gemini-bg-dark);
    transform: none; /* No movement when collapsed */
    transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
}

/* Overlay for popups/modals */
.overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.85); /* Slightly more opaque for full focus */
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 10001; /* Higher than sidebar (z-index: 50) */
    padding: 1rem; /* Add padding for mobile */
    opacity: 0;
    animation: overlayFadeIn 0.3s forwards ease-out;
}

@keyframes overlayFadeIn {
    to {
        opacity: 1;
    }
}

/* Desktop modal positioning - center between sidebar and right edge */
@media (min-width: 769px) {
    .overlay {
        left: var(--sidebar-collapsed-width);
        width: calc(100% - var(--sidebar-collapsed-width));
    }

    .sidebar.expanded ~ * .overlay {
        left: var(--sidebar-expanded-width);
        width: calc(100% - var(--sidebar-expanded-width));
    }
}
body.light-mode .overlay {
    background-color: rgba(0, 0, 0, 0.5); /* Lighter overlay for light mode */
}

/* Popup/Modal content styling */
.popup-content, .modal-content {
    background: linear-gradient(145deg, var(--gemini-bg-medium), var(--gemini-bg-dark));
    padding: 2rem;
    border-radius: 1.25rem;
    box-shadow:
        0 25px 50px rgba(0, 0, 0, 0.5),
        0 0 0 1px rgba(138, 180, 248, 0.1),
        inset 0 1px 0 rgba(255, 255, 255, 0.05);
    width: 100%;
    max-width: min(90vw, 800px); /* Responsive width based on viewport */
    max-height: calc(100vh - 2rem); /* Account for overlay padding */
    overflow-y: auto;
    position: relative;
    transform: translateY(30px) scale(0.95); /* Enhanced entry animation */
    opacity: 0;
    animation: modalSlideInFade 0.4s forwards cubic-bezier(0.4, 0, 0.2, 1);
    border: 1px solid rgba(138, 180, 248, 0.2);
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    backdrop-filter: blur(10px);
}

/* Large modal content (like comparison) */
.modal-content.max-w-6xl {
    max-width: min(90vw, 1200px); /* Responsive large width */
}

/* Mobile responsive adjustments */
@media (max-width: 768px) {
    .popup-content, .modal-content {
        padding: 1rem;
        margin: 0.5rem;
        max-height: calc(100vh - 1rem);
        border-radius: 0.5rem;
        max-width: calc(100vw - 1rem); /* Use almost full width on mobile */
    }

    .overlay {
        padding: 0.5rem;
    }

    /* Adjust grid layouts for mobile */
    .grid.grid-cols-1.md\\:grid-cols-2 {
        grid-template-columns: 1fr !important;
        gap: 1rem !important;
    }

    .grid.grid-cols-2 {
        grid-template-columns: 1fr !important;
        gap: 1rem !important;
    }

    /* Stack comparison table vertically on mobile */
    #comparisonContainer {
        grid-template-columns: 1fr !important;
    }

    /* Make input fields larger on mobile */
    input[type="text"], input[type="number"] {
        padding: 0.75rem !important;
        font-size: 1rem !important;
        min-height: 48px; /* Touch-friendly size */
    }

    /* Improve button sizing on mobile */
    .gemini-button {
        padding: 0.75rem 1.5rem !important;
        font-size: 1rem !important;
        min-height: 48px;
    }

    /* Better modal titles on mobile */
    .modal-content h3, .popup-content h3 {
        font-size: 1.5rem !important;
        margin-bottom: 1.5rem !important;
    }
}

body.light-mode .popup-content, body.light-mode .modal-content {
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.1); /* Lighter shadow for light mode */
}

@keyframes modalSlideInFade {
    to {
        transform: translateY(0) scale(1);
        opacity: 1;
    }
}

@keyframes slideInFade {
    to {
        transform: translateY(0);
        opacity: 1;
    }
}

/* Enhanced Gemini-style Buttons with Micro-interactions */
.gemini-button {
    padding: 0.75rem 1.5rem;
    border-radius: 0.5rem;
    font-weight: 500;
    font-size: 0.875rem;
    cursor: pointer;
    position: relative;
    overflow: hidden;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    text-decoration: none;
    border: none;
    min-height: 44px;
    white-space: nowrap;          /* keep label on one line */
    line-height: 1.1;             /* consistent vertical rhythm */
    gap: 8px;                     /* icon/text spacing */
    transition: all 0.25s cubic-bezier(0.4, 0, 0.2, 1);
    transform: translateY(0);
    will-change: transform, box-shadow;
    
    /* Default style */
    background: var(--gemini-bg-medium);
    color: var(--gemini-text-light);
    border: 1px solid var(--gemini-border);
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
}

.gemini-button:hover {
    transform: translateY(-1px);
    background: var(--gemini-bg-light);
    border-color: var(--gemini-accent-blue);
    color: var(--gemini-accent-blue);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
}

.gemini-button:active {
    transform: translateY(0);
    transition: all 0.1s ease;
}

.gemini-button.primary {
    background: linear-gradient(135deg, var(--gemini-accent-blue) 0%, rgba(138, 180, 248, 0.8) 100%);
    color: white;
    border: none;
    box-shadow: 0 2px 8px rgba(138, 180, 248, 0.2);
}

.gemini-button.primary:hover {
    background: linear-gradient(135deg, #9bc5ff 0%, var(--gemini-accent-blue) 100%);
    box-shadow: 0 6px 20px rgba(138, 180, 248, 0.3);
    color: white;
}

.gemini-button.secondary {
    background: transparent;
    color: var(--gemini-accent-blue);
    border: 1px solid var(--gemini-accent-blue);
    box-shadow: 0 2px 4px rgba(138, 180, 248, 0.1);
}

.gemini-button.secondary:hover {
    background: rgba(138, 180, 248, 0.1);
    color: var(--gemini-accent-blue);
    box-shadow: 0 4px 12px rgba(138, 180, 248, 0.15);
}

.gemini-button.danger {
    background: linear-gradient(135deg, var(--gemini-red) 0%, rgba(234, 67, 53, 0.8) 100%);
    color: white;
    border: none;
    box-shadow: 0 2px 8px rgba(234, 67, 53, 0.2);
}

.gemini-button.danger:hover {
    background: linear-gradient(135deg, #f56565 0%, var(--gemini-red) 100%);
    box-shadow: 0 6px 20px rgba(234, 67, 53, 0.3);
    color: white;
}

.gemini-button.success {
    background: linear-gradient(135deg, var(--gemini-green) 0%, rgba(52, 168, 83, 0.8) 100%);
    color: white;
    border: none;
    box-shadow: 0 2px 8px rgba(52, 168, 83, 0.2);
}

.gemini-button.success:hover {
    background: linear-gradient(135deg, #48bb78 0%, var(--gemini-green) 100%);
    box-shadow: 0 6px 20px rgba(52, 168, 83, 0.3);
    color: white;
}

/* Ripple effect */
.gemini-button::before {
    content: '';
    position: absolute;
    top: 50%;
    left: 50%;
    width: 0;
    height: 0;
    background: rgba(255, 255, 255, 0.2);
    border-radius: 50%;
    transform: translate(-50%, -50%);
    transition: width 0.3s ease, height 0.3s ease;
    z-index: 0;
}

.gemini-button:active::before {
    width: 300px;
    height: 300px;
}

.gemini-button > * {
    position: relative;
    z-index: 1;
}

/* Light Mode Button adjustments */
body.light-mode .gemini-button {
    background: var(--light-bg-medium);
    color: var(--light-text-light);
    border-color: var(--light-border);
}

body.light-mode .gemini-button:hover {
    background: var(--light-bg-light);
    color: var(--light-accent-blue);
    border-color: var(--light-accent-blue);
}

body.light-mode .gemini-button.primary {
    background: linear-gradient(135deg, var(--light-accent-blue) 0%, rgba(26, 115, 232, 0.8) 100%);
    color: white;
}

body.light-mode .gemini-button.primary:hover {
    background: linear-gradient(135deg, #4285f4 0%, var(--light-accent-blue) 100%);
}

body.light-mode .gemini-button.secondary {
    color: var(--light-accent-blue);
    border-color: var(--light-accent-blue);
}

body.light-mode .gemini-button.secondary:hover {
    background: rgba(26, 115, 232, 0.1);
}


/* Enhanced Form Input Styles */
input[type="text"], 
input[type="email"], 
input[type="password"], 
input[type="search"],
textarea, 
select {
    background: var(--gemini-bg-medium);
    border: 1px solid var(--gemini-border);
    color: var(--gemini-text-light);
    border-radius: 0.5rem;
    padding: 0.75rem 1rem;
    font-size: 0.875rem;
    line-height: 1.5;
    min-height: 44px;
    width: 100%;
    transition: all 0.25s cubic-bezier(0.4, 0, 0.2, 1);
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
}

input:focus, 
textarea:focus, 
select:focus {
    outline: none;
    border-color: var(--gemini-accent-blue);
    box-shadow: 
        0 0 0 3px rgba(138, 180, 248, 0.1),
        0 1px 3px rgba(0, 0, 0, 0.1);
    background: var(--gemini-bg-light);
    color: var(--gemini-text-light);
}

input::placeholder,
textarea::placeholder {
    color: var(--gemini-text-muted);
    opacity: 0.7;
}

/* Light mode form inputs */
body.light-mode input,
body.light-mode textarea,
body.light-mode select {
    background: white;
    border-color: var(--light-border);
    color: var(--light-text-light);
}

body.light-mode input:focus,
body.light-mode textarea:focus,
body.light-mode select:focus {
    border-color: var(--light-accent-blue);
    box-shadow: 
        0 0 0 3px rgba(26, 115, 232, 0.1),
        0 1px 3px rgba(0, 0, 0, 0.05);
    background: white;
}

/* Search bar specific styling */
#universitySearchInput {
    padding-left: 3rem;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' fill='none' viewBox='0 0 24 24' stroke='%23BDC1C6'%3E%3Cpath stroke-linecap='round' stroke-linejoin='round' stroke-width='2' d='M21 21l-6-6m2-5a7 7 0 11-14 0 7 7 0 0114 0z'%3E%3C/path%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: 1rem center;
    background-size: 1.25rem;
}
.test-option {
    background-color: var(--gemini-bg-light);
    color: var(--gemini-text-muted);
    padding: 0.5rem 1rem; /* px-4 py-2 */
    border-radius: 9999px; /* rounded-full */
    cursor: pointer;
    transition: all 0.2s ease-in-out;
    border: 1px solid transparent;
    font-size: 0.875rem; /* text-sm */
}
.test-option.selected {
    background-color: var(--gemini-accent-blue);
    color: var(--gemini-bg-dark); /* Dark text on accent blue for selected */
    font-weight: 600; /* font-semibold */
    border-color: var(--gemini-accent-blue);
}
/* Light Mode Test Options */
body.light-mode .test-option {
    background-color: var(--light-bg-light);
    color: var(--light-text-muted);
}
body.light-mode .test-option.selected {
    background-color: var(--light-accent-blue);
    color: #FFFFFF; /* White text on blue for light mode selected test option */
    border-color: var(--light-accent-blue);
}


/* University card styling with post-loading animations */
.university-card {
    background-color: var(--gemini-bg-medium);
    border-radius: 0.75rem;
    overflow: hidden;
    box-shadow: 0 1px 3px rgba(0,0,0,0.1);
    transition: transform 0.25s ease-out, 
                box-shadow 0.25s ease-out,
                border-color 0.2s ease-out;
    cursor: pointer;
    position: relative;
    border: 1px solid var(--gemini-border);
    opacity: 0;
    transform: translateY(20px) scale(0.98);
    will-change: transform, opacity;
    contain: layout style paint;
    /* Don't animate until page is loaded */
    animation: none;
}

/* Start university card animations only after loading is complete */
body.loaded .university-card {
    animation: universityCardEntrance 0.4s ease-out forwards;
}

/* Staggered animation delays only after loading */
body.loaded .university-card:nth-child(1) { animation-delay: 0.1s; }
body.loaded .university-card:nth-child(2) { animation-delay: 0.15s; }
body.loaded .university-card:nth-child(3) { animation-delay: 0.2s; }
body.loaded .university-card:nth-child(4) { animation-delay: 0.25s; }
body.loaded .university-card:nth-child(5) { animation-delay: 0.3s; }
body.loaded .university-card:nth-child(6) { animation-delay: 0.35s; }
body.loaded .university-card:nth-child(7) { animation-delay: 0.4s; }
body.loaded .university-card:nth-child(8) { animation-delay: 0.45s; }
body.loaded .university-card:nth-child(9) { animation-delay: 0.5s; }
body.loaded .university-card:nth-child(10) { animation-delay: 0.55s; }
body.loaded .university-card:nth-child(11) { animation-delay: 0.6s; }
body.loaded .university-card:nth-child(12) { animation-delay: 0.65s; }

/* For cards beyond 12 */
body.loaded .university-card:nth-child(n+13) { 
    animation-delay: 0.7s;
}

.university-card:hover {
    transform: translateY(-6px) scale(1.02);
    box-shadow: 0 12px 24px rgba(138, 180, 248, 0.15),
                0 6px 12px rgba(0, 0, 0, 0.1);
    border-color: var(--gemini-accent-blue);
}

.university-card:active {
    transform: translateY(-3px) scale(1.01);
    transition: transform 0.1s ease-out;
}

/* Mobile card adjustments */
@media (max-width: 768px) {
    .university-card:hover {
        transform: translateY(-4px) scale(1.01); /* Less aggressive hover on mobile */
    }

    /* Dashboard cards should also be single column on mobile */
    #favoritedUniversitiesList {
        grid-template-columns: 1fr !important;
        gap: 0.75rem;
        padding: 0 0.5rem;
    }
}

/* Light Mode University Card adjustments */
body.light-mode .university-card {
    background-color: var(--light-bg-medium);
    box-shadow: 0 1px 3px rgba(0,0,0,0.05); /* Lighter shadow */
    border: 1px solid var(--light-border);
}
body.light-mode .university-card:hover {
    box-shadow: 0 12px 28px rgba(26, 115, 232, 0.1), /* Light blue shadow */
                0 6px 16px rgba(0, 0, 0, 0.15);
    border-color: var(--light-accent-blue);
}

@keyframes universityCardEntrance {
    0% {
        opacity: 0;
        transform: translateY(20px) scale(0.98);
    }
    100% {
        opacity: 1;
        transform: translateY(0) scale(1);
    }
}

.university-card-image {
    width: 100%;
    height: 140px;
    object-fit: cover;
    border-bottom: 1px solid var(--gemini-border);
    transition: opacity 0.2s ease-out;
}

.university-card:hover .university-card-image {
    opacity: 0.95;
}

body.light-mode .university-card-image {
    border-bottom: 1px solid var(--light-border);
}

.university-card .rank-badge {
    position: absolute;
    top: 0.5rem; /* top-2 */
    right: 0.5rem; /* right-2 */
    background-color: var(--gemini-accent-green);
    color: var(--gemini-bg-dark); /* Dark text on green badge */
    font-weight: 700; /* font-bold */
    font-size: 0.75rem; /* text-xs */
    padding: 0.125rem 0.5rem; /* px-2 py-0.5 */
    border-radius: 9999px; /* rounded-full */
    transition: transform 0.2s ease-out;
}

.university-card:hover .rank-badge {
    transform: scale(1.05);
}

body.light-mode .university-card .rank-badge {
    color: #FFFFFF; /* White text on green badge for light mode */
    background-color: var(--light-accent-green);
}

.university-card h3 {
    font-size: 1rem; /* text-base */
    font-weight: 600; /* font-semibold */
    color: var(--gemini-text-light);
    margin-bottom: 0.25rem; /* mb-1 */
    transition: color 0.2s ease-out;
}

.university-card:hover h3 {
    color: var(--gemini-accent-blue);
}

.university-card p {
    color: var(--gemini-text-muted);
    font-size: 0.75rem; /* text-xs */
    transition: color 0.2s ease-out;
}

.university-card:hover p {
    color: var(--gemini-text-light);
}
.acceptance-bar {
    height: 0.375rem; /* h-1.5 */
    border-radius: 9999px; /* rounded-full */
    margin-top: 0.5rem; /* mt-2 */
    transition: opacity 0.2s ease-out;
}

.university-card:hover .acceptance-bar {
    opacity: 0.9;
}

.acceptance-bar.easy {
    background-color: var(--gemini-green);
}
.acceptance-bar.medium {
    background-color: var(--gemini-yellow);
}
.acceptance-bar.hard {
    background-color: var(--gemini-red);
}

/* Sidebar Container - Fixed positioning and backgrounds */
.sidebar {
    position: fixed;
    top: 0;
    left: 0;
    /* Ensure it always matches the visible viewport across devices */
    height: 100vh;              /* fallback */
    height: 100dvh;             /* modern browsers */
    max-height: 100dvh;
    overscroll-behavior: contain;
    -webkit-overflow-scrolling: touch;
    display: flex;
    flex-direction: column;
    /* Dark subtle gradient */
    background-color: var(--gemini-bg-medium); /* fallback */
    background-image: linear-gradient(180deg, rgba(255,255,255,0.03), rgba(255,255,255,0));
    width: var(--sidebar-collapsed-width);
    transition: width 0.25s cubic-bezier(0.25, 0.46, 0.45, 0.94);
    z-index: 50;
    /* Single vertical scrollbar, no horizontal */
    overflow-x: hidden;
    overflow-y: auto;           /* sidebar itself scrolls, page does not */
    border-right: 1px solid var(--gemini-border);
    will-change: width;
    transform: translateZ(0);
    backface-visibility: hidden;
    box-shadow: 2px 0 20px rgba(0, 0, 0, 0.1);
}

/* Light mode sidebar background */
body.light-mode .sidebar {
    background-color: var(--light-bg-medium);
    background-image: none; /* keep solid in light mode */
    box-shadow: 2px 0 20px rgba(0, 0, 0, 0.05);
}

/* Ensure inner containers don't create nested scrollbars */
.sidebar > * {
    overflow: visible;
}

/* Ensure nav never clips children */
.sidebar nav,
.sidebar nav ul li,
.sidebar nav ul li a,
.sidebar nav ul li button {
    overflow: visible;
}

/* Collapsed mode: give items full width and center icons */
.sidebar.collapsed nav ul li {
    width: 100% !important;
    margin-left: 0 !important;
    margin-right: 0 !important;
}

.sidebar.collapsed nav ul li a,
.sidebar.collapsed nav ul li button {
    justify-content: center !important;
    padding-left: 0.5rem !important;
    padding-right: 0.5rem !important;
    min-height: 40px;
}

/* Sidebar collapsed state (default) */
.sidebar.collapsed {
    width: var(--sidebar-collapsed-width);
}

/* Add safe inner padding so icons aren't against edges */
.sidebar.collapsed {
    padding-left: 8px !important;
    padding-right: 8px !important;
}

/* Sidebar expanded state with enhanced styling */
.sidebar.expanded {
    width: var(--sidebar-expanded-width);
    box-shadow: 4px 0 25px rgba(0, 0, 0, 0.15);
}

body.light-mode .sidebar.expanded {
    box-shadow: 4px 0 25px rgba(0, 0, 0, 0.08);
}

.sidebar nav ul li {
    display: flex;
    align-items: center;
    margin: 0.125rem 0.5rem;
    transition: all 0.3s ease;
    border-radius: 0.5rem;
    width: calc(100% - 1rem);
}

.sidebar nav ul li:nth-child(1) { --nav-index: 0; }
.sidebar nav ul li:nth-child(2) { --nav-index: 1; }
.sidebar nav ul li:nth-child(3) { --nav-index: 2; }
.sidebar nav ul li:nth-child(4) { --nav-index: 3; }
.sidebar nav ul li:nth-child(5) { --nav-index: 4; }
.sidebar nav ul li:nth-child(6) { --nav-index: 5; }
.sidebar nav ul li:nth-child(7) { --nav-index: 6; }
.sidebar nav ul li:nth-child(8) { --nav-index: 7; }
.sidebar nav ul li:nth-child(9) { --nav-index: 8; }

.sidebar nav ul li a,
.sidebar nav ul li button {
    display: flex;
    align-items: center;
    justify-content: flex-start;
    width: 100%;
    padding: 0.625rem 0.75rem;
    border-radius: 0.5rem;
    text-decoration: none;
    color: var(--gemini-text-light);
    transition: all 0.25s cubic-bezier(0.4, 0, 0.2, 1);
    position: relative;
    overflow: hidden;
    min-height: 44px;
    background: transparent;
    border: none;
    box-sizing: border-box;
}

/* Enhanced hover effects with glow */
.sidebar nav ul li:hover {
    background-color: var(--gemini-bg-light);
}

body.light-mode .sidebar nav ul li:hover {
    background-color: var(--light-bg-light);
}

.sidebar nav ul li a:hover,
.sidebar nav ul li button:hover {
    color: var(--gemini-accent-blue);
    transform: translateY(-1px);
}

body.light-mode .sidebar nav ul li a:hover,
body.light-mode .sidebar nav ul li button:hover {
    color: var(--light-accent-blue);
}

/* When sidebar is expanded, align to start */
.sidebar.expanded nav ul li a,
.sidebar.expanded nav ul li button {
    justify-content: flex-start;
    padding: 0.875rem;
    text-align: left;
}

/* When sidebar is collapsed, center everything */
.sidebar.collapsed nav ul li a,
.sidebar.collapsed nav ul li button {
    justify-content: center;
    padding: 0.875rem 0.5rem;
    text-align: center;
}

.sidebar nav ul li i {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 18px;
    height: 18px;
    font-size: 16px;
    margin-right: 0;
    flex-shrink: 0;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    position: relative;
    color: var(--gemini-text-muted);
}

.sidebar nav ul li:hover i {
    color: var(--gemini-accent-blue);
    transform: scale(1.05);
}

body.light-mode .sidebar nav ul li i {
    color: var(--light-text-muted);
}

body.light-mode .sidebar nav ul li:hover i {
    color: var(--light-accent-blue);
}

/* In expanded mode, icons should be aligned to left with margin */
.sidebar.expanded nav ul li i {
    margin-right: 12px;
    justify-content: flex-start;
}

/* In collapsed mode, icons should be centered */
.sidebar.collapsed nav ul li i {
    margin-right: 0;
    justify-content: center;
}

/* Icon pulse animation for active states */
.sidebar nav ul li.active i {
    animation: iconPulse 2s infinite;
}

@keyframes iconPulse {
    0%, 100% {
        transform: scale(1);
    }
    50% {
        transform: scale(1.05);
    }
}

.sidebar-text {
    opacity: 0;
    white-space: nowrap;
    transition: opacity 0.2s ease-out;
    font-size: 0.875rem;
    font-weight: 500;
    display: none;
    overflow: visible;
    text-overflow: clip;
    max-width: none;
    width: auto;
}

.sidebar.expanded .sidebar-text {
    opacity: 1;
    display: inline-block;
}

/* Enhanced Versiti branding with gradient effect */
.sidebar .text-xl.font-bold.tracking-wide.sidebar-text {
    display: none;
    opacity: 0;
    font-size: 1.4rem;
    margin-left: 0.75rem;
    transition: all 0.4s cubic-bezier(0.4, 0, 0.2, 1);
    background: linear-gradient(135deg, var(--gemini-text-light) 0%, var(--gemini-accent-blue) 100%);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    font-weight: 700;
    letter-spacing: -0.025em;
}

body.light-mode .sidebar .text-xl.font-bold.tracking-wide.sidebar-text {
    background: linear-gradient(135deg, var(--light-text-light) 0%, var(--light-accent-blue) 100%);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

.sidebar.expanded .text-xl.font-bold.tracking-wide.sidebar-text {
    display: inline !important;
    opacity: 1 !important;
    animation: brandingSlideIn 0.6s ease-out 0.2s both;
}

/* Mobile: also animate/show branding when the off-canvas sidebar opens */
.sidebar.mobile-visible .text-xl.font-bold.tracking-wide.sidebar-text {
    display: inline-block !important;
    opacity: 1 !important;
    animation: brandingSlideIn 0.6s ease-out 0.1s both;
}

/* Sidebar brand (mobile-only animated branding) */
.sidebar-brand {
    display: none;
    align-items: center;
    justify-content: center;
    padding: 12px 16px 8px;
    text-decoration: none;
    user-select: none;
    border-bottom: 1px solid rgba(255,255,255,0.08);
    margin-bottom: 0.5rem;
}

.sidebar-brand-text {
    background: linear-gradient(135deg, var(--gemini-text-light) 0%, var(--gemini-accent-blue) 100%);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    font-weight: 700;
    letter-spacing: -0.025em;
}

/* Entrance animation for mobile brand */
@keyframes sidebarBrandIn {
    from { 
        opacity: 0; 
        transform: translateY(-8px) scale(0.95); 
    }
    to { 
        opacity: 1; 
        transform: translateY(0) scale(1); 
    }
}

/* Show + animate when mobile sidebar is open */
@media (max-width: 768px) {
    .sidebar.mobile-visible .sidebar-brand {
        display: flex;
        animation: brandingSlideIn 0.6s ease-out 0.1s both;
    }

    @media (prefers-reduced-motion: reduce) {
        .sidebar.mobile-visible .sidebar-brand {
            animation: none;
        }
    }
}

/* Text animation keyframes */
@keyframes textSlideIn {
    from {
        opacity: 0;
        transform: translateX(-15px);
    }
    to {
        opacity: 1;
        transform: translateX(0);
    }
}

@keyframes brandingSlideIn {
    from {
        opacity: 0;
        transform: translateX(-20px) scale(0.9);
    }
    to {
        opacity: 1;
        transform: translateX(0) scale(1);
    }
}

/* Toggle button alignment */
.sidebar.collapsed .flex.items-center.mb-8 {
    justify-content: center;
    flex-direction: row;
    text-align: center;
}

.sidebar.expanded .flex.items-center.mb-8 {
    justify-content: flex-start;
    flex-direction: row;
    text-align: left;
}

/* Settings section styling - make consistent with nav items */
.sidebar .mt-auto {
    margin-top: auto;
    padding-top: 1rem;
}

.sidebar .mt-auto button {
    display: flex;
    align-items: center;
    justify-content: center;
    width: calc(100% - 1rem);
    padding: 0.625rem 0.75rem;
    margin: 0.125rem 0.5rem;
    border-radius: 0.5rem;
    background: transparent;
    border: none;
    color: var(--gemini-text-light);
    transition: all 0.25s cubic-bezier(0.4, 0, 0.2, 1);
    min-height: 44px;
    position: relative;
    overflow: hidden;
    box-sizing: border-box;
}

/* Hover effects consistent with nav items */
.sidebar .mt-auto button:hover {
    background-color: var(--gemini-bg-light);
    color: var(--gemini-accent-blue);
    transform: translateY(-1px);
}

body.light-mode .sidebar .mt-auto button:hover {
    background-color: var(--light-bg-light);
    color: var(--light-accent-blue);
}

/* When sidebar is expanded, align content to start */
.sidebar.expanded .mt-auto button {
    justify-content: flex-start;
    padding: 0.875rem;
    margin: 0.125rem 0.5rem;
}

/* When sidebar is collapsed, center everything */
.sidebar.collapsed .mt-auto button {
    justify-content: center;
    padding: 0.875rem 0.5rem;
}

/* Settings button icon styling - consistent with nav icons */
.sidebar .mt-auto button i {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 18px;
    height: 18px;
    font-size: 16px;
    margin-right: 0;
    flex-shrink: 0;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    color: var(--gemini-text-muted);
}

/* Icon hover effects */
.sidebar .mt-auto button:hover i {
    color: var(--gemini-accent-blue);
    transform: scale(1.05);
}

body.light-mode .sidebar .mt-auto button:hover i {
    color: var(--light-accent-blue);
}

/* When expanded, add margin to icon */
.sidebar.expanded .mt-auto button i {
    margin-right: 12px;
}

/* When collapsed, no margin */
.sidebar.collapsed .mt-auto button i {
    margin-right: 0;
}

@media (max-width: 768px) {
    body {
        padding-top: 0;
    }

    .sidebar {
        transform: translateX(-100%);
        width: min(260px, 80vw);
        z-index: 1500;
        box-shadow: 2px 0 20px rgba(0, 0, 0, 0.3);
        background-color: var(--gemini-bg-medium) !important;
        top: 0;
        height: 100vh;
        padding: 1rem 0.75rem;
    }

    .sidebar.mobile-visible {
        transform: translateX(0);
        width: min(260px, 80vw) !important;
    }

    .sidebar.mobile-visible .sidebar-text {
        opacity: 1 !important;
        display: inline-block !important;
        max-width: none;
        width: auto;
        overflow: visible;
    }

    .sidebar .text-xl.font-bold.tracking-wide.sidebar-text {
        display: inline-block !important;
        opacity: 1 !important;
        max-width: none;
        width: auto;
        overflow: visible;
    }

    .sidebar nav ul li {
        margin: 0.125rem 0.25rem 0.25rem 0.25rem;
        width: calc(100% - 0.5rem);
    }

    .sidebar nav ul li a,
    .sidebar nav ul li button {
        padding: 0.5rem;
        font-size: 0.875rem;
        line-height: 1.2;
        min-height: 44px;
        align-items: center;
        justify-content: flex-start;
    }

    .sidebar nav ul li .sidebar-text {
        white-space: nowrap;
        overflow: visible;
        text-overflow: clip;
        max-width: none;
        width: auto;
    }

    .sidebar nav ul li i {
        margin-right: 12px;
        width: 16px;
        height: 16px;
        font-size: 14px;
    }

    .main-content {
        margin-left: 0 !important;
        padding: 1rem;
    }

    /* Mobile overlay for sidebar */
    .sidebar-mobile-overlay {
        position: fixed;
        top: 0;
        left: 0;
        width: 100%;
        height: 100%;
        background-color: rgba(0, 0, 0, 0.6);
        z-index: 55;
        display: none;
        backdrop-filter: none !important;
    backdrop-filter: none !important;
    -webkit-backdrop-filter: none !important;
    }

    .sidebar-mobile-overlay.visible {
        display: block !important;
    }

    /* Completely remove all blur effects from any element */
    *, *::before, *::after {
        backdrop-filter: none !important;
        -webkit-backdrop-filter: none !important;
        filter: none !important;
        -webkit-filter: none !important;
        -moz-filter: none !important;
        -ms-filter: none !important;
        -o-filter: none !important;
    }

    /* Preserve transforms for other elements in main content */
    .main-content,
    #mainContent,
    main {
        margin-left: 0 !important;
        padding: 1rem !important;
    }

    /* STEP 5: Main content positioning - preserve normal layout */
    .main-content,
    #mainContent,
    main {
        margin-left: 0 !important;
        padding: 1rem !important;
        /* Allow transforms for other elements in main content */
    }

    /* STEP 6: Overlay */
    .sidebar-mobile-overlay {
        position: fixed !important;
        top: 0 !important;
        left: 0 !important;
        width: 100% !important;
        height: 100% !important;
        background-color: rgba(0, 0, 0, 0.6) !important;
        z-index: 55 !important;
        display: none !important;
    }

    .sidebar-mobile-overlay.visible {
        display: block !important;
    }

    /* STEP 7: Ensure header layout - keep things on the right */
    header {
        margin-bottom: 1rem !important;
        padding: 0.5rem 1rem;
        display: flex !important;
        align-items: center !important;
        justify-content: space-between !important;
        gap: 1rem;
        /* Allow transforms for header elements */
    }

    /* Mobile menu button - LEFT SIDE */
    #mobileSidebarToggle {
        flex-shrink: 0;
        order: 1; /* First item */
    }

    /* Title - CENTER */
    header h1 {
        font-size: 1.25rem !important;
        margin: 0 !important;
        text-align: center !important;
        flex: 1;
        order: 2; /* Second item */
        min-width: 0;
        overflow: hidden;
        text-overflow: ellipsis;
        white-space: nowrap;
    }

    /* Account/Notification section - RIGHT SIDE */
    header .flex.items-center.space-x-3,
    header > div:last-child,
    header [class*="space-x"] {
        flex-shrink: 0;
        order: 3; /* Third item - stays on right */
        margin-left: auto !important; /* Force to right side */
        display: flex !important;
        align-items: center !important;
        gap: 0.75rem !important;
    }

    /* STEP 8: Ensure dropdowns stay positioned correctly */
    #notificationDropdown,
    [id*="dropdown"],
    [class*="dropdown"] {
        position: fixed !important;
        top: 60px !important;
        right: 10px !important; /* Keep on right side */
        left: auto !important;
        width: calc(100vw - 20px) !important;
        max-width: 300px !important;
        z-index: 99999 !important;
        /* Allow transforms for dropdown animations */
    }

    /* STEP 9: Force expanded sidebar behavior on mobile */
    .sidebar.mobile-visible .sidebar-text {
        display: block !important;
        opacity: 1 !important;
        margin-left: 1rem !important;
    }

    .sidebar.mobile-visible nav ul li {
    justify-content: flex-start !important;
    padding: 0 1rem !important;
    display: flex !important;
    flex-direction: row !important;
    align-items: center !important;
    }

    .sidebar.mobile-visible nav ul li i {
        margin-right: 1rem !important;
        width: auto !important;
        height: auto !important;
        font-size: 1rem !important;
    }

    .sidebar.mobile-visible nav ul li a,
    .sidebar.mobile-visible nav ul li button {
        display: flex !important;
        flex-direction: row !important;
        align-items: center !important;
        white-space: nowrap !important; /* keep label on one line */
    }

    /* STEP 10: Browser-specific fixes for sidebar only */
    @supports (-webkit-backdrop-filter: blur(1px)) {
        .sidebar,
        .sidebar *,
        .sidebar-mobile-overlay {
            -webkit-backdrop-filter: none !important;
        }
    }

    @supports (backdrop-filter: blur(1px)) {
        .sidebar,
        .sidebar *,
        .sidebar-mobile-overlay {
            backdrop-filter: none !important;
        }
    }

    /* All other mobile styles remain the same */
    #sidebar-toggle-button {
        display: none;
    }

    #universityList {
        grid-template-columns: 1fr !important;
        gap: 0.75rem;
        padding: 0 0.5rem;
    }

    #favoritedUniversitiesList {
        grid-template-columns: 1fr !important;
        gap: 0.75rem;
        padding: 0 0.5rem;
    }

    .university-card {
        font-size: 0.875rem;
    }

    .university-card h3 {
        font-size: 0.875rem !important;
        line-height: 1.2;
        margin-bottom: 0.25rem;
    }

    .university-card p {
        font-size: 0.75rem !important;
        line-height: 1.1;
    }

    .university-card .rank-badge {
        font-size: 0.625rem !important;
        padding: 0.125rem 0.375rem !important;
    }

    .university-card-image {
        height: 100px !important;
    }

    .university-card .p-4 {
        padding: 0.75rem !important;
    }

    .university-card:hover {
        transform: translateY(-4px) scale(1.01) !important; /* Allow card hover transforms */
    }

    #topSearchBarContainer {
        position: relative;
        top: 0;
        left: 0 !important;
        width: 100% !important;
        margin: 1rem 0;
        padding: 0 1rem;
    }

    #topSearchBarContainer.visible {
        position: relative;
    }
}

/* Tablet breakpoint - 2 columns */
@media (min-width: 481px) and (max-width: 1024px) {
    #universityList {
        grid-template-columns: repeat(2, 1fr) !important;
        gap: 1rem;
        padding: 0 1rem;
    }

    #favoritedUniversitiesList {
        grid-template-columns: repeat(2, 1fr) !important;
        gap: 1rem;
        padding: 0 1rem;
    }
}

/* Desktop breakpoint - 3+ columns */
@media (min-width: 1025px) {
    #universityList {
    grid-template-columns: repeat(auto-fit, minmax(280px, 1fr)) !important;
    gap: var(--grid-gap);
    padding-left: 0; padding-right: 0;
    margin-left: var(--grid-side-gutter); margin-right: var(--grid-side-gutter);
    justify-content: center;
    }

    #favoritedUniversitiesList {
    grid-template-columns: repeat(auto-fit, minmax(280px, 1fr)) !important;
    gap: var(--grid-gap);
    padding-left: 0; padding-right: 0;
    margin-left: var(--grid-side-gutter); margin-right: var(--grid-side-gutter);
    justify-content: center;
    }

    /* Reduce outer content gutters equally on desktop */
    .main-content { padding-left: 0 !important; padding-right: 0 !important; }
}

/* Wide desktop: center grid and show exactly 4 columns on mid-wide, 5 on ultra-wide */
@media (min-width: 1440px) and (max-width: 1799px) {
    #universityList {
    /* 4 responsive columns; edge gaps via symmetric margins */
    grid-template-columns: repeat(4, minmax(280px, 1fr)) !important;
    gap: var(--grid-gap);
    padding-left: 0; padding-right: 0;
    margin-left: var(--grid-side-gutter); margin-right: var(--grid-side-gutter);
    }

    #favoritedUniversitiesList {
    grid-template-columns: repeat(4, minmax(280px, 1fr)) !important;
    gap: var(--grid-gap);
    padding-left: 0; padding-right: 0;
    margin-left: var(--grid-side-gutter); margin-right: var(--grid-side-gutter);
    }
}

@media (min-width: 1800px) {
    #universityList {
    /* 5 responsive columns; edge gaps via symmetric margins */
    grid-template-columns: repeat(5, minmax(280px, 1fr)) !important;
    gap: var(--grid-gap);
    padding-left: 0; padding-right: 0;
    margin-left: var(--grid-side-gutter); margin-right: var(--grid-side-gutter);
    }

    #favoritedUniversitiesList {
    grid-template-columns: repeat(5, minmax(280px, 1fr)) !important;
    gap: var(--grid-gap);
    padding-left: 0; padding-right: 0;
    margin-left: var(--grid-side-gutter); margin-right: var(--grid-side-gutter);
    }
}

/* Light Mode Sidebar */
body.light-mode .sidebar {
    background-color: var(--light-bg-medium);
    border-right: 1px solid var(--light-border);
}

/* Expanded Sidebar */
.sidebar.expanded {
    width: var(--sidebar-expanded-width);
}

/* Sidebar Navigation */
.sidebar nav {
    flex-grow: 1; /* Take up remaining space */
    display: flex;
    flex-direction: column;
    justify-content: flex-start;
    align-items: stretch;
    padding-top: 1rem;
}

.sidebar nav ul {
    list-style: none;
    padding: 0;
    margin: 0;
}

.sidebar nav ul li {
    display: flex;
    align-items: center;
    justify-content: flex-start;
    height: 48px; /* Consistent height */
    padding: 0 1rem;
    transition: background-color 0.2s ease, padding 0.3s ease, justify-content 0.3s ease;
    cursor: pointer;
}

.sidebar nav ul li:hover {
    background-color: var(--gemini-bg-light);
}
/* Light Mode Sidebar List Items */
body.light-mode .sidebar nav ul li:hover {
    background-color: var(--light-bg-light);
}


/* Collapsed Sidebar - Center Icons */
.sidebar.collapsed nav ul li {
    justify-content: center; /* Center icons horizontally */
    padding: 0;           /* Remove padding */
}

.sidebar.collapsed nav ul li a,
.sidebar.collapsed nav ul li button {
    width: 100% !important;
    text-align: center;
}

.sidebar.collapsed nav ul li i,
.sidebar.collapsed nav ul li svg {
    display: flex;
    justify-content: center;
    align-items: center;
    margin: 0; /* Ensure no margin in collapsed state */
    font-size: 1.0rem; /* Adjust size for collapsed view */
    width: 20px; /* Fixed width to prevent cropping */
    height: 20px; /* Fixed height to prevent cropping */
    text-align: center;
    flex-shrink: 0; /* Prevent shrinking */
}

/* Ensure icons are centered and not clipped */
.sidebar.collapsed nav ul li a i,
.sidebar.collapsed nav ul li button i {
    display: inline-block;
    margin: 0 !important;
}

/* Sidebar Text (Expanded Only) */
.sidebar-text {
    margin-left: 1rem;
    opacity: 1;
    white-space: nowrap;
    transition: opacity 0.3s ease, margin 0.3s ease, color 0.3s ease; /* Added color transition */
    color: var(--gemini-text-light);
}

.sidebar.collapsed .sidebar-text {
    display: none; /* Fully hide text in collapsed mode */
}

/* Sidebar Header (UniQuest 2.0 and toggle) */
.sidebar .flex.items-center.mb-8 {
    transition: justify-content 0.3s ease; /* Smooth transition for alignment */
}
.sidebar.collapsed .flex.items-center.mb-8 {
    justify-content: center; /* Center icon when collapsed */
}
.sidebar .flex.items-center.mb-8 .fa-bars {
    transition: margin-right 0.3s ease;
}
.sidebar.collapsed .flex.items-center.mb-8 .fa-bars {
    margin-right: 0; /* Remove margin when collapsed */
    margin-bottom: 0.5rem; /* Add bottom margin when stacked */
}

.sidebar.expanded .flex.items-center.mb-8 .fa-bars {
    margin-right: 0.5rem; /* Restore margin when expanded */
    margin-bottom: 0; /* Remove bottom margin when side by side */
}


/* Settings & Logout Section */
.sidebar-footer {
    display: flex;
    flex-direction: column;
    padding: 1rem;
}

.sidebar-footer button {
    display: flex;
    align-items: center;
    justify-content: flex-start;
    gap: 0.75rem;
    padding: 0.5rem 1rem;
    border-radius: 0.5rem;
    background: transparent;
    border: none;
    color: var(--gemini-text-light);
    transition: background-color 0.2s ease, color 0.2s ease; /* Added color transition */
    cursor: pointer;
}

.sidebar-footer button:hover {
    background-color: var(--gemini-bg-light);
}
/* Light Mode Sidebar Footer Buttons */
body.light-mode .sidebar-footer button {
    color: var(--light-text-light);
}
body.light-mode .sidebar-footer button:hover {
    background-color: var(--light-bg-light);
    color: var(--light-text-light);
}


.sidebar.collapsed .sidebar-footer button {
    justify-content: center;
    padding: 0.5rem 0; /* Slim padding */
}

.sidebar.collapsed .sidebar-footer button span {
    display: none; /* Hide text */
}

.main-content {
    margin-left: 0; /* rely on flex layout so grid gutters control edges */
    transition: margin-left 0.2s ease-out;
    flex-grow: 1;
    will-change: margin-left; /* Optimize for GPU acceleration */
}
.main-content.sidebar-expanded-margin {
    margin-left: 0; /* no extra shift when sidebar expands */
}

/* Neutralize Tailwind container so page content spans full width inside main-content */
#page-content.container {
    max-width: none !important;
    margin-left: 0 !important;
    margin-right: 0 !important;
    padding-left: 0 !important;
    padding-right: 0 !important;
}


/* Search Bar: floating overlay with smooth open/close animation */
#topSearchBarContainer {
    position: fixed;                 /* floating overlay */
    left: 50%;                       /* center horizontally */
    top: 80px;                       /* JS will set exact top under the title */
    transform: translateX(-50%) translateY(-12px) scale(0.95);
    width: calc(100vw - 2rem);
    max-width: 42rem;                /* ~max-w-2xl */
    margin: 0 auto;                  /* visual center */
    padding: 0 0;                    /* container padding not needed */
    z-index: 100000;                 /* above cards and content */
    /* Keep in DOM for close animation */
    opacity: 0;
    visibility: hidden;
    pointer-events: none;            /* prevent stray events when hidden */
    transition: opacity 280ms cubic-bezier(0.4, 0, 0.2, 1), 
                transform 280ms cubic-bezier(0.4, 0, 0.2, 1);
}

/* Toast notifications: ensure they sit above everything and never get hidden */
#toastContainer {
    position: fixed !important;
    top: 16px; left: 50%; right: auto; transform: translateX(-50%);
    z-index: 1000002 !important; /* above search (100000) */
    display: flex; flex-direction: column; gap: 8px;
    pointer-events: none; /* only toasts receive events */
}
#toastContainer > div {
    pointer-events: auto;
}
#topSearchBarContainer.visible {   /* shown when toggled */
    opacity: 1;
    visibility: visible;
    transform: translateX(-50%) translateY(0) scale(1);
    pointer-events: auto;
}
#topSearchBarContainer .relative { position: relative; }
#topSearchBarContainer input {
    height: 48px;                    /* consistent touch target */
    padding-left: 3rem;              /* space for the search icon */
    width: 100%;
    border-radius: 9999px;           /* pill */
    background: var(--gemini-bg-medium);
    color: var(--gemini-text-light);
    border: 1px solid var(--gemini-border);
    box-shadow: 
        0 10px 32px rgba(0,0,0,0.4),
        0 4px 16px rgba(138, 180, 248, 0.12),
        inset 0 1px 0 rgba(255,255,255,0.05);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    position: relative;
    overflow: hidden;
}

#topSearchBarContainer input::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: linear-gradient(135deg, rgba(255,255,255,0.1) 0%, transparent 100%);
    pointer-events: none;
}

#topSearchBarContainer input:focus {
    outline: none;
    border-color: var(--gemini-accent-blue);
    box-shadow: 
        0 16px 40px rgba(0,0,0,0.5),
        0 8px 24px rgba(138, 180, 248, 0.25),
        0 0 0 1px var(--gemini-accent-blue),
        inset 0 1px 0 rgba(255,255,255,0.1);
    transform: translateY(-1px);
    background: var(--gemini-bg-light);
}

#topSearchBarContainer input:hover {
    border-color: rgba(138, 180, 248, 0.5);
    box-shadow: 
        0 12px 36px rgba(0,0,0,0.45),
        0 6px 20px rgba(138, 180, 248, 0.18),
        inset 0 1px 0 rgba(255,255,255,0.08);
}
#topSearchBarContainer .fa-search {
    position: absolute;
    left: 1rem;                      /* ~left-4 */
    top: 50%;
    transform: translateY(-50%);
    color: var(--gemini-text-muted);
    pointer-events: none;
    transition: all 0.3s ease;
    font-size: 1rem;
}

#topSearchBarContainer input:focus ~ .fa-search,
#topSearchBarContainer input:hover ~ .fa-search {
    color: var(--gemini-accent-blue);
    transform: translateY(-50%) scale(1.1);
}

/* Mobile: hide sidebar by default; only show when mobile-visible */
@media (max-width: 768px) {
    .sidebar { display: none; }
    .sidebar.mobile-visible { display: flex; }
}

/* Mobile search bar adjustments */
@media (max-width: 768px) {
    /* Mobile: collapse height when hidden for proper layout, animate open/close */
    #topSearchBarContainer {
        position: relative;
        top: 0;
        left: 0 !important;
        width: 100% !important;
        margin: 1rem 0;
        padding: 0 1rem;
        max-height: 0;
        overflow: hidden;
        opacity: 0;
        transform: translateY(-8px) scale(0.98);
        visibility: hidden;
        pointer-events: none;
        transition: opacity 200ms ease, transform 200ms ease, max-height 200ms ease;
    }

    #topSearchBarContainer.visible {
        position: relative;
        max-height: 80px; /* enough for the input */
        opacity: 1;
        transform: translateY(0) scale(1);
        visibility: visible;
        pointer-events: auto;
    }

    /* Ensure the text doesn't overlap the icon on small screens */
    #topSearchBarContainer input {
        padding-left: 3.75rem !important; /* ensure text never sits under the icon */
        font-size: 0.95rem;
        line-height: 1.25rem;
    }
    #topSearchBarContainer .fa-search {
        left: 0.75rem; /* give extra breathing room */
        font-size: 1rem;
        z-index: 1;
    }
}

/* Header Icons */
.header-icon-button {
    color: var(--gemini-text-muted);
    transition: color 0.2s ease, background-color 0.2s ease;
    padding: 0.5rem;
    border-radius: 50%;
}
.header-icon-button:hover {
    background-color: var(--gemini-bg-light);
    color: var(--gemini-text-light);
}
/* Light Mode Header Icons */
body.light-mode .header-icon-button {
    color: var(--light-text-muted);
}
body.light-mode .header-icon-button:hover {
    background-color: var(--light-bg-light);
    color: var(--light-text-light);
}

/* Desktop header improvements */
@media (min-width: 769px) {
    header {
        display: flex;
        align-items: center;
        justify-content: center;
        position: relative;
    }

    header h1 {
        position: absolute;
        left: 50%;
        transform: translateX(-50%);
        margin: 0;
        text-align: center;
    }

    header .flex.items-center.space-x-3 {
        margin-left: auto;
    }

    /* Ensure proper spacing for larger screens */
    .popup-content, .modal-content {
        min-width: 600px;
    }

    /* Better grid layouts on desktop */
    .grid.grid-cols-1.md\\:grid-cols-2 {
        grid-template-columns: repeat(2, 1fr);
        gap: 1.5rem;
    }

    .grid.grid-cols-2 {
        gap: 1.5rem;
    }
}

/* Gemini Toggle Switch (Assuming its part of settings or general UI) */
.gemini-toggle-switch {
    position: relative;
    display: inline-block;
    width: 48px; /* Slightly wider */
    height: 24px; /* Taller */
}

.gemini-toggle-switch input {
    opacity: 0;
    width: 0;
    height: 0;
}

.gemini-toggle-switch .slider {
    position: absolute;
    cursor: pointer;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background-color: var(--gemini-border); /* Off state color */
    -webkit-transition: .4s;
    transition: .4s;
    border-radius: 24px; /* Make it pill-shaped */
}
body.light-mode .gemini-toggle-switch .slider {
    background-color: var(--light-border); /* Off state color for light mode */
}

.gemini-toggle-switch .slider:before {
    position: absolute;
    content: "";
    height: 18px; /* Smaller circle */
    width: 18px; /* Smaller circle */
    left: 3px; /* Adjust for padding */
    bottom: 3px; /* Adjust for padding */
    background-color: var(--gemini-text-light); /* Knob color */
    -webkit-transition: .4s;
    transition: .4s;
    border-radius: 50%; /* Make it circular */
}
body.light-mode .gemini-toggle-switch .slider:before {
    background-color: #FFFFFF; /* White knob for light mode */
}


.gemini-toggle-switch input:checked + .slider {
    background-color: var(--gemini-accent-blue); /* On state color */
}
body.light-mode .gemini-toggle-switch input:checked + .slider {
    background-color: var(--light-accent-blue); /* On state color for light mode */
}

.gemini-toggle-switch input:focus + .slider {
    box-shadow: 0 0 1px var(--gemini-accent-blue);
}
body.light-mode .gemini-toggle-switch input:focus + .slider {
    box-shadow: 0 0 1px var(--light-accent-blue);
}

.gemini-toggle-switch input:checked + .slider:before {
    -webkit-transform: translateX(24px); /* Move knob to the right */
    -ms-transform: translateX(24px);
    transform: translateX(24px);
}

/* Specific styling for Versiti text in sidebar */
.sidebar .text-xl.font-bold.tracking-wide.sidebar-text {
    color: var(--gemini-text-light); /* Ensure it follows theme */
    white-space: nowrap;
    font-size: 1.25rem; /* Slightly larger for better visibility */
    font-weight: 700; /* Make it bolder */
}
body.light-mode .sidebar .text-xl.font-bold.tracking-wide.sidebar-text {
    color: var(--light-text-light);
}
.sidebar .text-xl.font-bold.tracking-wide.sidebar-text span[class*="text-"] {
    color: var(--gemini-accent-blue); /* Specific blue part for "siti" */
}
body.light-mode .sidebar .text-xl.font-bold.tracking-wide.sidebar-text span[class*="text-"] {
    color: var(--light-accent-blue);
}

/* Styling for input fields (advanced filters, search bar) */
input[type="text"], input[type="number"] {
    background-color: var(--gemini-bg-medium);
    color: var(--gemini-text-light);
    border: 1px solid var(--gemini-border);
    transition: background-color 0.3s ease, color 0.3s ease, border-color 0.3s ease;
}
input[type="text"]::placeholder, input[type="number"]::placeholder {
    color: var(--gemini-text-muted);
}
input[type="text"]:focus, input[type="number"]:focus {
    border-color: var(--gemini-accent-blue);
    box-shadow: 0 0 0 1px var(--gemini-accent-blue);
}
/* Light Mode Input Fields */
body.light-mode input[type="text"], body.light-mode input[type="number"] {
    background-color: var(--light-bg-medium);
    color: var(--light-text-light);
    border: 1px solid var(--light-border);
}
body.light-mode input[type="text"]::placeholder, body.light-mode input[type="number"]::placeholder {
    color: var(--light-text-muted);
}
body.light-mode input[type="text"]:focus, body.light-mode input[type="number"]:focus {
    border-color: var(--light-accent-blue);
    box-shadow: 0 0 0 1px var(--light-accent-blue);
}


/* General text colors for consistency */
.text-white {
    color: var(--gemini-text-light); /* Use var for dynamic white */
}
.text-\[var\(--gemini-text-light\)\] {
    color: var(--gemini-text-light);
}
.text-\[var\(--gemini-text-muted\)\] {
    color: var(--gemini-text-muted);
}
.text-\[var\(--gemini-accent-blue\)\] {
    color: var(--gemini-accent-blue);
}
.text-\[var\(--gemini-red-error\)\] {
    color: var(--gemini-red); /* Assuming --gemini-red is the error color */
}

/* Ensure these explicit Tailwind-like classes also adapt to light mode */
body.light-mode .text-white {
    color: var(--light-text-light); /* White text in dark mode becomes light-text-light in light mode */
}
body.light-mode .text-\[var\(--gemini-text-light\)\] {
    color: var(--light-text-light);
}
body.light-mode .text-\[var\(--gemini-text-muted\)\] {
    color: var(--light-text-muted);
}
body.light-mode .text-\[var\(--gemini-accent-blue\)\] {
    color: var(--light-accent-blue);
}
body.light-mode .text-\[var\(--gemini-red-error\)\] {
    color: var(--light-red);
}


/* Fix for sidebar text margin in expanded state - it was implicitly handled by `sidebar-text` class */
/* Ensure elements inside sidebar links apply these colors correctly */
/* Ensure elements inside sidebar links apply colors correctly without double hover effect */
.sidebar nav ul li a,
.sidebar nav ul li button {
    color: var(--gemini-text-light);
    display: flex;
    align-items: center;
    width: 100%;
    height: 100%;
    padding: 0; /* Keep padding only on li */
    background-color: transparent; /* Prevent hover flash */
    text-decoration: none;
    border: none;
}

.sidebar nav ul li {
    border-radius: 0.5rem; /* Match Settings button rounded edges */
    margin: 0.5rem; /* Add slight side margin so radius is visible */
}
.sidebar nav ul li:hover {
    background-color: var(--gemini-bg-light);
}


.sidebar nav ul li a:hover,
.sidebar nav ul li button:hover {
    /* Avoid double background highlight */
    background-color: transparent;
    color: var(--gemini-accent-blue);
}

.sidebar nav ul li a i,
.sidebar nav ul li button i {
    color: var(--gemini-text-muted);
    transition: color 0.2s ease;
}

.sidebar nav ul li:hover a i,
.sidebar nav ul li:hover button i {
    color: var(--gemini-accent-blue);
}

body.light-mode .sidebar nav ul li a,
body.light-mode .sidebar nav ul li button {
    color: var(--light-text-light);
    background-color: transparent;
}

body.light-mode .sidebar nav ul li:hover {
    background-color: var(--light-bg-light);
}

body.light-mode .sidebar nav ul li a:hover,
body.light-mode .sidebar nav ul li button:hover {
    background-color: transparent;
    color: var(--light-accent-blue);
}

body.light-mode .sidebar nav ul li a i,
body.light-mode .sidebar nav ul li button i {
    color: var(--light-text-muted);
}
body.light-mode .sidebar nav ul li:hover a i,
body.light-mode .sidebar nav ul li:hover button i {
    color: var(--light-accent-blue);
}
/* Enhanced Sidebar Separator with animation */
.sidebar-separator {
    height: 2px;
    width: calc(100% - 2rem);
    margin: 1.5rem 1rem;
    background: linear-gradient(90deg, transparent 0%, var(--gemini-accent-blue) 50%, transparent 100%);
    opacity: 0.4;
    border-radius: 9999px;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    position: relative;
    overflow: hidden;
}

.sidebar-separator::before {
    content: '';
    position: absolute;
    top: 0;
    left: -100%;
    width: 100%;
    height: 100%;
    background: linear-gradient(90deg, transparent, rgba(138, 180, 248, 0.6), transparent);
    animation: shimmer 3s infinite;
}

@keyframes shimmer {
    0% {
        left: -100%;
    }
    100% {
        left: 100%;
    }
}

body.light-mode .sidebar-separator {
    background: linear-gradient(90deg, transparent 0%, var(--light-accent-blue) 50%, transparent 100%);
}

body.light-mode .sidebar-separator::before {
    background: linear-gradient(90deg, transparent, rgba(26, 115, 232, 0.4), transparent);
}

.sidebar.collapsed .sidebar-separator {
    width: calc(100% - 1rem);
    margin: 1.5rem 0.5rem;
    opacity: 0.3;
}


/* TARGETED MOBILE BLUR FIX - Only affects sidebar, preserves other layouts */

@media (max-width: 768px) {
/* STEP 1: Global blur removal but preserve transforms for other elements */
* {
backdrop-filter: none !important;
-webkit-backdrop-filter: none !important;
filter: none !important;
-webkit-filter: none !important;
-moz-filter: none !important;
-ms-filter: none !important;
-o-filter: none !important;
}

/* STEP 2: Remove transforms ONLY from sidebar-related elements */
.sidebar,
.sidebar *,
.sidebar-mobile-overlay {
transform: none !important;
-webkit-transform: none !important;
-moz-transform: none !important;
-ms-transform: none !important;
-o-transform: none !important;
will-change: auto !important;
contain: none !important;
isolation: auto !important;
mix-blend-mode: normal !important;
-webkit-backface-visibility: visible !important;
backface-visibility: visible !important;
perspective: none !important;
-webkit-perspective: none !important;
transform-style: flat !important;
-webkit-transform-style: flat !important;
}

/* STEP 3: Sidebar positioning using margin-left (no blur) */
.sidebar {
position: fixed !important;
top: 0 !important;
left: 0 !important;
height: 100vh !important;
width: min(280px, 80vw) !important;
background-color: var(--gemini-bg-medium) !important;
z-index: 60 !important;
box-shadow: 2px 0 10px rgba(0, 0, 0, 0.3) !important;

/* Use margin-left for positioning (no transform = no blur) */
margin-left: -100% !important;
transition: margin-left 0.3s ease !important;
}

/* STEP 4: Show sidebar when visible */
.sidebar.mobile-visible {
margin-left: 0 !important;
}

/* STEP 5: Main content positioning - preserve normal layout */
.main-content,
#mainContent,
main {
margin-left: 0 !important;
padding: 1rem !important;
/* Allow transforms for other elements in main content */
}

/* STEP 6: Overlay */
.sidebar-mobile-overlay {
position: fixed !important;
top: 0 !important;
left: 0 !important;
width: 100% !important;
height: 100% !important;
background-color: rgba(0, 0, 0, 0.6) !important;
z-index: 55 !important;
display: none !important;
}

.sidebar-mobile-overlay.visible {
display: block !important;
}

/* STEP 7: Preserve header layout - keep things on the right */
header {
margin-bottom: 1rem !important;
padding: 0.5rem 1rem;
display: flex !important;
align-items: center !important;
justify-content: space-between !important;
gap: 1rem;
/* Allow transforms for header elements */
}

/* Mobile menu button - LEFT SIDE */
#mobileSidebarToggle {
flex-shrink: 0;
order: 1; /* First item */
}

/* Title - CENTER */
header h1 {
font-size: 1.25rem !important;
margin: 0 !important;
text-align: center !important;
flex: 1;
order: 2; /* Second item */
min-width: 0;
overflow: hidden;
text-overflow: ellipsis;
white-space: nowrap;
}

/* Account/Notification section - RIGHT SIDE */
header .flex.items-center.space-x-3,
header > div:last-child,
header [class*="space-x"] {
flex-shrink: 0;
order: 3; /* Third item - stays on right */
margin-left: auto !important; /* Force to right side */
display: flex !important;
align-items: center !important;
gap: 0.75rem !important;
}

/* STEP 8: Ensure dropdowns stay positioned correctly */
#notificationDropdown,
[id*="dropdown"],
[class*="dropdown"] {
position: fixed !important;
top: 60px !important;
right: 10px !important; /* Keep on right side */
left: auto !important;
width: calc(100vw - 20px) !important;
max-width: 300px !important;
z-index: 99999 !important;
/* Allow transforms for dropdown animations */
}

/* STEP 9: Force expanded sidebar behavior on mobile */
.sidebar.mobile-visible .sidebar-text {
display: block !important;
opacity: 1 !important;
margin-left: 1rem !important;
}

.sidebar.mobile-visible nav ul li {
justify-content: flex-start !important;
padding: 0 1rem !important;
}

.sidebar.mobile-visible nav ul li i {
margin-right: 1rem !important;
width: auto !important;
height: auto !important;
font-size: 1rem !important;
}

/* STEP 10: Browser-specific fixes for sidebar only */
@supports (-webkit-backdrop-filter: blur(1px)) {
.sidebar,
.sidebar *,
.sidebar-mobile-overlay {
-webkit-backdrop-filter: none !important;
backdrop-filter: none !important;
}
}

@supports (backdrop-filter: blur(1px)) {
.sidebar,
.sidebar *,
.sidebar-mobile-overlay {
backdrop-filter: none !important;
}
}

/* All other mobile styles remain the same */
#sidebar-toggle-button {
display: none;
}

#universityList {
grid-template-columns: 1fr !important;
gap: 0.75rem;
padding: 0 0.5rem;
}

#favoritedUniversitiesList {
grid-template-columns: 1fr !important;
gap: 0.75rem;
padding: 0 0.5rem;
}

.university-card {
font-size: 0.875rem;
}

.university-card h3 {
font-size: 0.875rem !important;
line-height: 1.2;
margin-bottom: 0.25rem;
}

.university-card p {
font-size: 0.75rem !important;
line-height: 1.1;
}

.university-card .rank-badge {
font-size: 0.625rem !important;
padding: 0.125rem 0.375rem !important;
}

.university-card-image {
height: 100px !important;
}

.university-card .p-4 {
padding: 0.75rem !important;
}

.university-card:hover {
transform: translateY(-4px) scale(1.01) !important; /* Allow card hover transforms */
}

/* Duplicate mobile block (targeted fix): keep in sync with above for smooth animation */
#topSearchBarContainer {
position: relative;
top: 0;
left: 0 !important;
width: 100% !important;
margin: 1rem 0;
padding: 0 1rem;
max-height: 0;
overflow: hidden;
opacity: 0;
transform: translateY(-8px) scale(0.98);
visibility: hidden;
pointer-events: none;
transition: opacity 200ms ease, transform 200ms ease, max-height 200ms ease;
}

#topSearchBarContainer.visible {
position: relative;
max-height: 80px;
opacity: 1;
transform: translateY(0) scale(1);
visibility: visible;
pointer-events: auto;
}
}

/* Fix for random messageBox appearing */
#messageBox.hidden {
    display: none !important;
    visibility: hidden !important;
    opacity: 0 !important;
    pointer-events: none !important;
    z-index: -9999 !important;
}

#messageBox.hidden * {
    display: none !important;
    opacity: 0 !important;
}

/* Sidebar logo styling */
.sidebar-logo {
    transition: all 0.3s ease;
    border-radius: 4px;
    flex-shrink: 0;
}

.sidebar.collapsed .sidebar-logo {
    width: 24px;
    height: 24px;
    margin-right: 0;
}

.sidebar.expanded .sidebar-logo {
    width: 32px;
    height: 32px;
    margin-right: 8px;
}

/* Main title logo styling */
.main-logo {
    display: inline-block;
    transition: all 0.3s ease;
    border-radius: 4px;
    flex-shrink: 0;
    opacity: 0; /* hidden by default (matches collapsed initial state) */
    transform: scale(0.9);
}

/* Hide main logo when sidebar is collapsed */
.sidebar.collapsed ~ .main-content .main-logo {
    opacity: 0;
    transform: scale(0.8);
    pointer-events: none;
}

/* Show main logo when sidebar is expanded */
.sidebar.expanded ~ .main-content .main-logo {
    opacity: 1;
    transform: scale(1);
}

/* =========================== */
/* PERFORMANCE OPTIMIZATIONS   */
/* =========================== */

/* Reduce layout thrashing with containment */
.university-card,
.modal-content,
.sidebar,
.loading-screen {
    contain: layout style paint;
}

/* Optimize animations for 60fps */
@media (hover: hover) {
    .university-card,
    .gemini-button,
    .sidebar nav ul li {
        will-change: transform;
    }
    
    .university-card:not(:hover):not(:focus),
    .gemini-button:not(:hover):not(:focus),
    .sidebar nav ul li:not(:hover):not(:focus) {
        will-change: auto;
    }
}

/* Optimize scrolling performance */
.main-content,
#universityList {
    overflow-anchor: none;
    scroll-behavior: smooth;
}

/* GPU layer optimization */
.university-card,
.gemini-button,
.loading-screen {
    transform: translateZ(0);
    backface-visibility: hidden;
}

/* =========================== */
/* VISUAL ENHANCEMENTS         */
/* =========================== */

/* Enhanced shadows and depth */
.university-card {
    box-shadow: 
        0 1px 3px rgba(0, 0, 0, 0.12),
        0 1px 2px rgba(0, 0, 0, 0.24);
}

.university-card:hover {
    box-shadow: 
        0 14px 28px rgba(0, 0, 0, 0.25),
        0 10px 10px rgba(0, 0, 0, 0.22),
        0 0 0 1px rgba(138, 180, 248, 0.1) !important;
}

/* Enhanced focus indicators for accessibility */
button:focus-visible,
input:focus-visible,
textarea:focus-visible,
select:focus-visible,
.university-card:focus-visible {
    outline: 2px solid var(--gemini-accent-blue);
    outline-offset: 2px;
}

/* Smooth theme transitions */
* {
    transition-property: background-color, border-color, color, fill, stroke;
    transition-timing-function: cubic-bezier(0.4, 0, 0.2, 1);
    transition-duration: 200ms;
}

/* High contrast mode support */
@media (prefers-contrast: high) {
    :root {
        --gemini-border: #666;
        --gemini-text-muted: #ccc;
    }
    
    .university-card {
        border-width: 2px;
    }
    
    .gemini-button {
        border-width: 2px;
    }
}

/* Print styles */
@media print {
    .sidebar,
    .loading-screen,
    button,
    .modal-content {
        display: none !important;
    }
    
    .main-content {
        margin-left: 0 !important;
        width: 100% !important;
    }
    
    .university-card {
        break-inside: avoid;
        margin-bottom: 1rem;
    }
}

/* Sidebar fit on short screens: avoid needing to scroll the sidebar itself */
@media (max-height: 900px) {
    .sidebar .flex.items-center.mb-8 { margin-bottom: 0.75rem !important; }
    .sidebar .sidebar-brand { padding: 8px 16px 6px !important; margin-bottom: 0.25rem !important; }
    .sidebar nav ul li { margin: 0.1rem 0.35rem !important; }
    .sidebar nav ul li a,
    .sidebar nav ul li button { padding: 0.5rem 0.6rem !important; min-height: 40px !important; }
}

@media (max-height: 780px) {
    .sidebar .text-xl.font-bold.tracking-wide.sidebar-text { font-size: 1rem !important; }
    .sidebar .sidebar-brand-text { font-size: 1rem !important; }
    .sidebar nav ul li a,
    .sidebar nav ul li button { font-size: 0.85rem !important; min-height: 38px !important; }
    .sidebar nav ul li i { font-size: 0.9rem !important; margin-right: 10px !important; }
}

@media (max-height: 680px) {
    #sidebar-toggle-button { margin-bottom: 0.5rem !important; }
    .sidebar .sidebar-brand { padding: 6px 16px 4px !important; margin-bottom: 0.15rem !important; }
    .sidebar nav ul li { margin: 0.05rem 0.3rem !important; }
    .sidebar nav ul li a,
    .sidebar nav ul li button { padding: 0.4rem 0.55rem !important; min-height: 34px !important; }
    .sidebar .mt-auto { padding-top: 0.25rem !important; }
}

@media (max-height: 620px) {
    .sidebar .sidebar-brand-text { font-size: 0.95rem !important; }
    .sidebar .mt-auto button { padding: 0.4rem 0.5rem !important; font-size: 0.85rem !important; }
    .sidebar .mt-auto button i { font-size: 0.95rem !important; }
}
/* Reserve space for fixed sidebar on desktop so content never sits underneath */
@media (min-width: 1025px) {
    .main-content {
        margin-left: var(--sidebar-collapsed-width) !important;
    }
    .main-content.sidebar-expanded-margin {
        margin-left: var(--sidebar-expanded-width) !important;
    }
}

@media (max-height: 550px) {
    .sidebar .sidebar-brand { padding: 4px 16px 2px !important; margin-bottom: 0.1rem !important; }
    .sidebar nav ul li { margin: 0.02rem 0.25rem !important; }
    .sidebar nav ul li a,
    .sidebar nav ul li button { padding: 0.35rem 0.5rem !important; min-height: 32px !important; font-size: 0.8rem !important; }
    .sidebar .mt-auto { padding-top: 0.15rem !important; }
    .sidebar .mt-auto button { padding: 0.35rem 0.45rem !important; font-size: 0.8rem !important; }
}