/* CSS Styles */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

:root {
    --primary-blue: #4F46E5;
    --secondary-blue: #6366F1;
    --light-blue: #818CF8;
    --primary-purple: #7C3AED;
    --secondary-purple: #8B5CF6;
    --light-purple: #A78BFA;
    --dark-bg: #1a1a2e;
    --darker-bg: #16213e;
    --card-bg: #2a2d47;
    --text-light: #ffffff;
    --text-gray: #e2e8f0;
    --text-muted: #94a3b8;
    --success-green: #10B981;
    --error-red: #EF4444;
    --accent-gradient: linear-gradient(135deg, var(--primary-blue), var(--primary-purple));
    --card-gradient: linear-gradient(145deg, var(--card-bg), rgba(124, 58, 237, 0.1));
    --border-color: rgba(129, 140, 248, 0.3);
}

body {
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    background: linear-gradient(135deg, var(--dark-bg) 0%, var(--darker-bg) 100%);
    color: var(--text-light);
    min-height: 100vh;
    overflow-x: hidden;
    scroll-behavior: smooth;
    line-height: 1.6;
}

/* Animated background particles */
.particles {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: -1;
    pointer-events: none;
}

.particle {
    position: absolute;
    width: 3px;
    height: 3px;
    background: var(--light-blue);
    border-radius: 50%;
    animation: float 8s ease-in-out infinite;
    opacity: 0.4;
}

.star {
    position: absolute;
    width: 2px;
    height: 2px;
    background: #ffffff;
    border-radius: 50%;
    animation: twinkle 4s ease-in-out infinite;
    opacity: 0.6;
}

@keyframes float {
    0%, 100% { transform: translateY(0px) rotate(0deg); }
    50% { transform: translateY(-30px) rotate(180deg); }
}

@keyframes twinkle {
    0%, 100% { opacity: 0.3; transform: scale(1); }
    50% { opacity: 0.8; transform: scale(1.2); }
}

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

@keyframes fadeIn {
    from { opacity: 0; }
    to { opacity: 1; }
}

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

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

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

@keyframes spin {
    to { transform: rotate(360deg); }
}

.particle.large {
    width: 4px;
    height: 4px;
    opacity: 0.3;
}

.particle.slow {
    animation-duration: 12s;
}

.particle.fast {
    animation-duration: 5s;
}

.star.bright {
    opacity: 0.8;
    animation-duration: 2s;
}

.star.dim {
    opacity: 0.2;
    animation-duration: 6s;
}

/* Enhanced float animation - update your existing one */
@keyframes float {
    0%, 100% { 
        transform: translateY(0px) rotate(0deg);
        opacity: 0.4;
    }
    25% { 
        transform: translateY(-15px) rotate(45deg);
        opacity: 0.6;
    }
    50% { 
        transform: translateY(-30px) rotate(180deg);
        opacity: 0.4;
    }
    75% { 
        transform: translateY(-15px) rotate(270deg);
        opacity: 0.2;
    }
}

/* Enhanced twinkle animation - update your existing one */
@keyframes twinkle {
    0%, 100% { 
        opacity: 0.3; 
        transform: scale(1);
    }
    25% {
        opacity: 0.6;
        transform: scale(1.1);
    }
    50% { 
        opacity: 0.8; 
        transform: scale(1.2);
    }
    75% {
        opacity: 0.5;
        transform: scale(1.05);
    }
}

/* Additional particle effects - these are completely missing */
@keyframes drift {
    0%, 100% { 
        transform: translateX(0px) translateY(0px);
    }
    25% { 
        transform: translateX(10px) translateY(-5px);
    }
    50% { 
        transform: translateX(-5px) translateY(-10px);
    }
    75% { 
        transform: translateX(-10px) translateY(-5px);
    }
}

@keyframes shimmer {
    0%, 100% { 
        box-shadow: 0 0 5px rgba(129, 140, 248, 0.3);
    }
    50% { 
        box-shadow: 0 0 15px rgba(129, 140, 248, 0.6);
    }
}

@keyframes shootingStarPath {
    0% {
        opacity: 0;
        transform: translateX(0px) translateY(0px) scale(0);
    }
    10% {
        opacity: 1;
        transform: translateX(50px) translateY(-20px) scale(1);
    }
    90% {
        opacity: 1;
        transform: translateX(400px) translateY(-150px) scale(1);
    }
    100% {
        opacity: 0;
        transform: translateX(500px) translateY(-200px) scale(0);
    }
}

/* Header */
.header {
    background: rgba(42, 45, 71, 0.95);
    backdrop-filter: blur(20px);
    border-bottom: 1px solid var(--border-color);
    padding: 1rem 0;
    position: sticky;
    top: 0;
    z-index: 100;
}

.nav-container {
    max-width: 1200px;
    margin: 0 auto;
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0 2rem;
}

.logo {
    font-size: 2rem;
    font-weight: bold;
    background: var(--accent-gradient);
    -webkit-background-clip: text;
    background-clip: text;
    -webkit-text-fill-color: transparent;
    cursor: pointer;
    transition: transform 0.3s ease;
}

.logo:hover {
    transform: scale(1.05);
}

.nav-menu {
    display: flex;
    gap: 2rem;
    list-style: none;
}

.nav-item {
    cursor: pointer;
    padding: 0.5rem 1rem;
    border-radius: 8px;
    transition: all 0.3s ease;
    border: 1px solid transparent;
    color: var(--text-light);
}

.nav-item:hover {
    background: var(--card-gradient);
    border-color: var(--primary-blue);
    transform: translateY(-2px);
}

/* Main Container */
.container {
    max-width: 1200px;
    margin: 0 auto;
    padding: 2rem;
    min-height: calc(100vh - 140px);
}

/* Home Page */
.home-page {
    text-align: center;
    padding: 4rem 0;
}

.hero-title {
    font-size: 3.5rem;
    font-weight: bold;
    margin-bottom: 1rem;
    background: var(--accent-gradient);
    -webkit-background-clip: text;
    background-clip: text;
    -webkit-text-fill-color: transparent;
    animation: fadeInUp 1s ease;
}

.hero-subtitle {
    font-size: 1.2rem;
    color: var(--text-gray);
    margin-bottom: 3rem;
    animation: fadeInUp 1s ease 0.2s both;
}

/* Subject Grid */
.subjects-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
    gap: 2rem;
    margin-top: 3rem;
}

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

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

.subject-card:hover::before {
    left: 100%;
}

.subject-card:hover {
    transform: translateY(-8px) scale(1.02);
    border-color: var(--secondary-blue);
    box-shadow: 0 20px 40px rgba(79, 70, 229, 0.3);
}

.subject-icon {
    width: 60px;
    height: 60px;
    margin: 0 auto 1rem;
    background: var(--accent-gradient);
    border-radius: 12px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.5rem;
}

.subject-title {
    font-size: 1.5rem;
    font-weight: bold;
    margin-bottom: 0.5rem;
    color: var(--text-light);
}

.subject-description {
    color: var(--text-muted);
    font-size: 0.9rem;
}

/* Subject Detail Page */
.subject-detail {
    display: none;
    animation: fadeIn 0.5s ease;
}

.subject-detail.active {
    display: block;
}

.back-button {
    background: var(--accent-gradient);
    color: white;
    border: none;
    padding: 0.75rem 1.5rem;
    border-radius: 8px;
    cursor: pointer;
    font-size: 1rem;
    transition: all 0.3s ease;
    margin-bottom: 2rem;
}

.back-button:hover {
    transform: translateY(-2px);
    box-shadow: 0 8px 16px rgba(79, 70, 229, 0.4);
}

.subject-header {
    text-align: center;
    margin-bottom: 3rem;
}

.subject-header h1 {
    font-size: 2.5rem;
    margin-bottom: 1rem;
    background: var(--accent-gradient);
    -webkit-background-clip: text;
    background-clip: text;
    -webkit-text-fill-color: transparent;
}

.subject-header p {
    color: var(--text-gray);
}

/* Topic Navigation */
.topic-nav {
    display: flex;
    justify-content: center;
    gap: 1rem;
    margin-bottom: 3rem;
    flex-wrap: wrap;
}

.topic-btn {
    background: var(--card-bg);
    border: 1px solid var(--border-color);
    color: var(--text-light);
    padding: 0.75rem 1.5rem;
    border-radius: 25px;
    cursor: pointer;
    transition: all 0.3s ease;
    font-size: 0.9rem;
}

.topic-btn:hover,
.topic-btn.active {
    background: var(--accent-gradient);
    transform: translateY(-2px);
    box-shadow: 0 8px 16px rgba(79, 70, 229, 0.4);
}

/* Content Area */
.content-area {
    background: var(--card-bg);
    border: 1px solid var(--border-color);
    border-radius: 16px;
    padding: 2rem;
    margin-bottom: 2rem;
    min-height: 400px;
}

.content-section {
    display: none;
}

.content-section.active {
    display: block;
    animation: slideIn 0.3s ease;
}

.content-section h3 {
    color: var(--light-blue);
    margin-bottom: 1rem;
    font-size: 1.3rem;
}

.content-section p {
    line-height: 1.6;
    margin-bottom: 1rem;
    color: var(--text-gray);
}

/* Learning Page */
.learning-page {
    display: none;
    animation: fadeIn 0.5s ease;
}

.learning-page.active {
    display: block;
}

.learning-header {
    text-align: center;
    margin-bottom: 2rem;
}

.learning-header h1 {
    font-size: 2.5rem;
    margin-bottom: 1rem;
    background: var(--accent-gradient);
    -webkit-background-clip: text;
    background-clip: text;
    -webkit-text-fill-color: transparent;
}

.learning-header p {
    color: var(--text-gray);
}

.learning-progress {
    display: flex;
    align-items: center;
    gap: 1rem;
    margin-bottom: 2rem;
    padding: 0 1rem;
}

.progress-bar {
    flex: 1;
    height: 8px;
    background: rgba(129, 140, 248, 0.2);
    border-radius: 4px;
    overflow: hidden;
}

.progress-fill {
    height: 100%;
    background: var(--accent-gradient);
    width: 0%;
    transition: width 0.3s ease;
}

.progress-text {
    font-size: 0.9rem;
    color: var(--text-gray);
    min-width: 100px;
}

.learning-content {
    background: var(--card-bg);
    border: 1px solid var(--border-color);
    border-radius: 16px;
    padding: 2rem;
    margin-bottom: 2rem;
    min-height: 500px;
}

.learning-navigation {
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 2rem;
    flex-wrap: wrap;
    padding: 1rem;
    background: var(--card-bg);
    border-radius: 12px;
    border: 1px solid var(--border-color);
}

.nav-section {
    display: flex;
    gap: 1rem;
    align-items: center;
}

.nav-btn {
    background: var(--card-bg);
    border: 1px solid var(--border-color);
    color: var(--text-light);
    padding: 0.75rem 1.5rem;
    border-radius: 8px;
    cursor: pointer;
    transition: all 0.3s ease;
    font-size: 0.9rem;
}

.nav-btn:hover:not(:disabled) {
    background: var(--accent-gradient);
    transform: translateY(-2px);
}

.nav-btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

/* Action Buttons */
.action-buttons {
    display: flex;
    gap: 1rem;
    justify-content: center;
    flex-wrap: wrap;
}

.action-btn {
    background: var(--accent-gradient);
    color: white;
    border: none;
    padding: 1rem 2rem;
    border-radius: 12px;
    cursor: pointer;
    font-size: 1rem;
    font-weight: 600;
    transition: all 0.3s ease;
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.action-btn:hover {
    transform: translateY(-3px);
    box-shadow: 0 12px 24px rgba(79, 70, 229, 0.4);
}

.action-btn:disabled {
    opacity: 0.6;
    cursor: not-allowed;
    transform: none;
}

/* Modal Styles */
.modal {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.8);
    backdrop-filter: blur(5px);
    z-index: 1000;
    animation: fadeIn 0.3s ease;
}

.modal.active {
    display: flex;
    align-items: center;
    justify-content: center;
}

.modal-content {
    background: var(--dark-bg);
    border: 1px solid var(--border-color);
    border-radius: 16px;
    padding: 2rem;
    max-width: 800px;
    max-height: 80vh;
    overflow-y: auto;
    position: relative;
    animation: scaleIn 0.3s ease;
    margin: 1rem;
}

.modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 1.5rem;
}

.modal-title {
    font-size: 1.5rem;
    background: var(--accent-gradient);
    -webkit-background-clip: text;
    background-clip: text;
    -webkit-text-fill-color: transparent;
}

.close-btn {
    background: none;
    border: none;
    color: var(--text-muted);
    font-size: 1.5rem;
    cursor: pointer;
    transition: color 0.3s ease;
}

.close-btn:hover {
    color: var(--text-light);
}

/* Quiz Styles */
.quiz-container {
    max-width: 800px;
    margin: 0 auto;
}

.quiz-header {
    text-align: center;
    margin-bottom: 2rem;
}

.quiz-progress {
    background: rgba(129, 140, 248, 0.2);
    border-radius: 10px;
    height: 8px;
    margin-bottom: 2rem;
    overflow: hidden;
}

.quiz-progress-bar {
    background: var(--accent-gradient);
    height: 100%;
    width: 0%;
    transition: width 0.3s ease;
}

.question-card {
    background: var(--card-bg);
    border: 1px solid var(--border-color);
    border-radius: 16px;
    padding: 2rem;
    margin-bottom: 2rem;
}

.question-text {
    font-size: 1.2rem;
    margin-bottom: 1.5rem;
    line-height: 1.6;
    color: var(--text-light);
}

.answer-options {
    display: grid;
    gap: 1rem;
}

.answer-option {
    background: var(--card-bg);
    border: 1px solid var(--border-color);
    border-radius: 12px;
    padding: 1rem;
    cursor: pointer;
    transition: all 0.3s ease;
    position: relative;
    color: var(--text-light);
}

.answer-option:hover {
    background: rgba(129, 140, 248, 0.2);
    border-color: var(--primary-blue);
    transform: translateX(5px);
}

.answer-option.selected {
    background: var(--accent-gradient);
    border-color: var(--secondary-blue);
}

.answer-option.correct {
    background: linear-gradient(135deg, #10B981, #059669);
    border-color: #10B981;
}

.answer-option.incorrect {
    background: linear-gradient(135deg, #EF4444, #DC2626);
    border-color: #EF4444;
}

.quiz-results {
    text-align: center;
    padding: 2rem;
}

.score-display {
    font-size: 3rem;
    font-weight: bold;
    background: var(--accent-gradient);
    -webkit-background-clip: text;
    background-clip: text;
    -webkit-text-fill-color: transparent;
    margin-bottom: 1rem;
}

.quiz-navigation {
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 2rem;
    margin-top: 2rem;
    padding: 1rem;
    background: var(--card-bg);
    border-radius: 12px;
    border: 1px solid var(--border-color);
}

/* Tools Menu */
.tools-menu {
    position: fixed;
    bottom: 2rem;
    right: 2rem;
    z-index: 100;
}

.tools-toggle {
    width: 60px;
    height: 60px;
    background: var(--accent-gradient);
    border: none;
    border-radius: 50%;
    color: white;
    cursor: pointer;
    font-size: 1.4rem;
    transition: all 0.3s ease;
    box-shadow: 0 4px 12px rgba(79, 70, 229, 0.3);
    display: flex;
    align-items: center;
    justify-content: center;
}

.tools-toggle:hover {
    transform: scale(1.1);
    box-shadow: 0 8px 20px rgba(79, 70, 229, 0.4);
}

.tools-items {
    position: absolute;
    bottom: 80px;
    right: 0;
    display: flex;
    flex-direction: column;
    gap: 1rem;
    opacity: 0;
    visibility: hidden;
    transform: translateY(20px);
    transition: all 0.3s ease;
}

.tools-items.show {
    opacity: 1;
    visibility: visible;
    transform: translateY(0);
}

.tool-btn {
    width: 50px;
    height: 50px;
    background: var(--card-bg);
    border: 1px solid var(--border-color);
    border-radius: 50%;
    color: var(--text-light);
    cursor: pointer;
    font-size: 1.2rem;
    transition: all 0.3s ease;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.2);
    display: flex;
    align-items: center;
    justify-content: center;
}

.tool-btn:hover {
    background: var(--accent-gradient);
    transform: scale(1.1);
    box-shadow: 0 8px 20px rgba(79, 70, 229, 0.4);
}

/* Footer */
.footer {
    background: var(--card-bg);
    border-top: 1px solid var(--border-color);
    padding: 2rem 0;
    margin-top: 4rem;
}

.footer-content {
    max-width: 1200px;
    margin: 0 auto;
    padding: 0 2rem;
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
    gap: 2rem;
}

.footer-section h3 {
    color: var(--light-blue);
    margin-bottom: 1rem;
    font-size: 1.2rem;
}

.footer-section ul {
    list-style: none;
}

.footer-section li {
    margin-bottom: 0.5rem;
}

.footer-section a {
    color: var(--text-muted);
    text-decoration: none;
    transition: color 0.3s ease;
}

.footer-section a:hover {
    color: var(--text-light);
}

.footer-bottom {
    border-top: 1px solid var(--border-color);
    margin-top: 2rem;
    padding-top: 1rem;
    text-align: center;
    color: var(--text-muted);
    font-size: 0.9rem;
}

.footer-bottom a {
    color: var(--text-muted);
    text-decoration: none;
    transition: color 0.3s ease;
}

.footer-bottom a:hover {
    color: var(--text-light);
}

/* Loading Animation */
.loading {
    display: inline-block;
    width: 20px;
    height: 20px;
    border: 3px solid rgba(255, 255, 255, 0.3);
    border-radius: 50%;
    border-top-color: #fff;
    animation: spin 1s ease-in-out infinite;
}

/* Learning Content Specific Styles */
.lesson-content {
    margin-bottom: 2rem;
}

.lesson-title {
    color: var(--light-blue);
    font-size: 1.5rem;
    margin-bottom: 1rem;
}

.lesson-text {
    line-height: 1.6;
    margin-bottom: 1rem;
    color: var(--text-gray);
}

.example-box {
    background: rgba(129, 140, 248, 0.1);
    border-left: 4px solid var(--primary-blue);
    padding: 1rem;
    margin: 1rem 0;
    border-radius: 4px;
}

.formula-box {
    background: rgba(124, 58, 237, 0.1);
    border: 1px solid var(--primary-purple);
    padding: 1rem;
    margin: 1rem 0;
    border-radius: 8px;
    text-align: center;
    font-family: 'Courier New', monospace;
    font-size: 1.1rem;
}

.interactive-element {
    background: var(--card-bg);
    border: 1px solid var(--border-color);
    border-radius: 8px;
    padding: 1rem;
    margin: 1rem 0;
    cursor: pointer;
    transition: all 0.3s ease;
}

.interactive-element:hover {
    transform: translateY(-2px);
    box-shadow: 0 8px 16px rgba(79, 70, 229, 0.3);
}

/* Responsive Design */
@media (max-width: 768px) {
    .nav-menu {
        display: none;
    }
    
    .hero-title {
        font-size: 2.5rem;
    }
    
    .subjects-grid {
        grid-template-columns: 1fr;
        gap: 1rem;
    }
    
    .topic-nav {
        flex-direction: column;
        align-items: center;
    }
    
    .action-buttons {
        flex-direction: column;
        align-items: center;
    }
    
    .learning-navigation {
        flex-direction: column;
        gap: 1rem;
    }
    
    .nav-section {
        justify-content: center;
    }
    
    .quiz-navigation {
        flex-direction: column;
        gap: 1rem;
    }
    
    .tools-menu {
        bottom: 1rem;
        right: 1rem;
    }
    
    .modal-content {
        margin: 0.5rem;
        max-height: 90vh;
    }
    
    .learning-progress {
        flex-direction: column;
        gap: 0.5rem;
    }
    
    .progress-text {
        text-align: center;
    }
    
    .footer-content {
        grid-template-columns: 1fr;
        text-align: center;
    }
}

/* Hidden class */
.hidden {
    display: none !important;
}

        /* AI Assistant Styles */
        .highlighted-text {
            background: linear-gradient(120deg, #fef08a 0%, #facc15 100%);
            position: relative;
            cursor: pointer;
            padding: 2px 4px;
            border-radius: 3px;
            transition: all 0.3s ease;
        }

        .highlighted-text:hover {
            background: linear-gradient(120deg, #facc15 0%, #eab308 100%);
            box-shadow: 0 2px 8px rgba(234, 179, 8, 0.3);
        }

        /* Mobile-friendly context popup styles */
        .context-popup {
            position: absolute;
            background: rgba(30, 41, 59, 0.95);
            backdrop-filter: blur(10px);
            border: 1px solid rgba(148, 163, 184, 0.3);
            border-radius: 12px;
            padding: 12px 16px;
            box-shadow: 0 10px 30px rgba(0, 0, 0, 0.3);
            z-index: 1000;
            min-width: 200px;
            max-width: 300px;
            display: none;
            animation: popupFadeIn 0.3s ease-out;
        }

        /* Mobile optimizations */
        @media (max-width: 768px) {
            .context-popup {
                min-width: 250px;
                max-width: calc(100vw - 40px);
                padding: 16px 20px;
                font-size: 16px; /* Prevent zoom on iOS */
            }
            
            .context-popup-button {
                padding: 12px 20px;
                font-size: 16px; /* Prevent zoom on iOS */
                min-height: 44px; /* Apple's recommended touch target */
            }
            
            .context-popup-text {
                font-size: 15px;
                margin-bottom: 12px;
            }
        }

        @keyframes popupFadeIn {
            from {
                opacity: 0;
                transform: translateY(-10px) scale(0.95);
            }
            to {
                opacity: 1;
                transform: translateY(0) scale(1);
            }
        }

        .context-popup::before {
            content: '';
            position: absolute;
            top: -8px;
            left: 20px;
            width: 0;
            height: 0;
            border-left: 8px solid transparent;
            border-right: 8px solid transparent;
            border-bottom: 8px solid rgba(30, 41, 59, 0.95);
        }

        .context-popup-text {
            color: #e2e8f0;
            font-size: 14px;
            margin-bottom: 10px;
            line-height: 1.4;
        }

        .context-popup-button {
            background: linear-gradient(135deg, #818cf8 0%, #6366f1 100%);
            color: white;
            border: none;
            padding: 8px 16px;
            border-radius: 8px;
            cursor: pointer;
            font-size: 13px;
            font-weight: 500;
            transition: all 0.3s ease;
            width: 100%;
        }

        .context-popup-button:hover {
            background: linear-gradient(135deg, #6366f1 0%, #4f46e5 100%);
            transform: translateY(-1px);
            box-shadow: 0 4px 12px rgba(99, 102, 241, 0.4);
        }

        /* AI Chat Modal */
        .ai-chat-modal {
            position: fixed;
            top: 0;
            left: 0;
            right: 0;
            bottom: 0;
            background: rgba(0, 0, 0, 0.7);
            backdrop-filter: blur(5px);
            display: none;
            z-index: 2000;
            animation: modalFadeIn 0.3s ease-out;
        }

        .ai-chat-container {
            position: absolute;
            top: 50%;
            left: 50%;
            transform: translate(-50%, -50%);
            width: 90%;
            max-width: 800px;
            height: 80vh;
            background: linear-gradient(135deg, #1e293b 0%, #334155 100%);
            border-radius: 20px;
            border: 1px solid rgba(148, 163, 184, 0.3);
            box-shadow: 0 25px 50px rgba(0, 0, 0, 0.5);
            display: flex;
            flex-direction: column;
            overflow: hidden;
        }

        .ai-chat-header {
            background: linear-gradient(135deg, #6366f1 0%, #8b5cf6 100%);
            color: white;
            padding: 20px;
            display: flex;
            justify-content: space-between;
            align-items: center;
            border-bottom: 1px solid rgba(148, 163, 184, 0.3);
        }

        .ai-chat-title {
            font-size: 18px;
            font-weight: 600;
            margin: 0;
            display: flex;
            align-items: center;
            gap: 10px;
        }

        .ai-chat-close {
            background: rgba(255, 255, 255, 0.2);
            border: none;
            color: white;
            width: 32px;
            height: 32px;
            border-radius: 50%;
            cursor: pointer;
            font-size: 18px;
            display: flex;
            align-items: center;
            justify-content: center;
            transition: all 0.3s ease;
        }

        .ai-chat-close:hover {
            background: rgba(255, 255, 255, 0.3);
            transform: scale(1.1);
        }

        .ai-chat-messages {
            flex: 1;
            padding: 20px;
            overflow-y: auto;
            background: rgba(15, 23, 42, 0.3);
        }

        .ai-message {
            margin-bottom: 16px;
            animation: messageSlideIn 0.4s ease-out;
        }

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

        .ai-message.user {
            text-align: right;
        }

        .ai-message.assistant {
            text-align: left;
        }

        .ai-message-bubble {
            display: inline-block;
            padding: 12px 16px;
            border-radius: 18px;
            max-width: 70%;
            word-wrap: break-word;
            line-height: 1.5;
        }

        .ai-message.user .ai-message-bubble {
            background: linear-gradient(135deg, #6366f1 0%, #8b5cf6 100%);
            color: white;
        }

        .ai-message.assistant .ai-message-bubble {
            background: rgba(241, 245, 249, 0.95);
            color: #334155;
            border: 1px solid rgba(148, 163, 184, 0.3);
        }

        /* Formatting styles for AI responses */
        .ai-message-bubble p {
            margin: 0 0 8px 0;
            line-height: 1.5;
        }

        .ai-message-bubble p:last-child {
            margin-bottom: 0;
        }

        .ai-message-bubble ul, .ai-message-bubble ol {
            margin: 8px 0;
            padding-left: 20px;
        }

        .ai-message-bubble li {
            margin: 4px 0;
            line-height: 1.4;
        }

        .ai-message-bubble strong {
            font-weight: 600;
            color: #1e293b;
        }

        .ai-message-bubble em {
            font-style: italic;
            color: #475569;
        }

        .ai-message-bubble code {
            background: rgba(99, 102, 241, 0.1) !important;
            color: #6366f1 !important;
            padding: 2px 6px !important;
            border-radius: 4px !important;
            font-family: 'Courier New', monospace !important;
            font-size: 13px !important;
        }

        .ai-chat-input-container {
            padding: 20px;
            background: rgba(30, 41, 59, 0.8);
            border-top: 1px solid rgba(148, 163, 184, 0.3);
        }

        .ai-chat-input-form {
            display: flex;
            gap: 12px;
            align-items: flex-end;
        }

        .ai-chat-input {
            flex: 1;
            padding: 12px 16px;
            border: 2px solid rgba(148, 163, 184, 0.3);
            border-radius: 12px;
            background: rgba(241, 245, 249, 0.95);
            color: #334155;
            font-size: 14px;
            resize: none;
            min-height: 44px;
            max-height: 120px;
            transition: all 0.3s ease;
        }

        .ai-chat-input:focus {
            outline: none;
            border-color: #6366f1;
            box-shadow: 0 0 0 3px rgba(99, 102, 241, 0.1);
        }

        .ai-chat-send {
            background: linear-gradient(135deg, #6366f1 0%, #8b5cf6 100%);
            color: white;
            border: none;
            padding: 12px 20px;
            border-radius: 12px;
            cursor: pointer;
            font-weight: 500;
            transition: all 0.3s ease;
            display: flex;
            align-items: center;
            gap: 8px;
        }

        .ai-chat-send:hover:not(:disabled) {
            background: linear-gradient(135deg, #4f46e5 0%, #7c3aed 100%);
            transform: translateY(-1px);
            box-shadow: 0 4px 12px rgba(99, 102, 241, 0.4);
        }

        .ai-chat-send:disabled {
            opacity: 0.6;
            cursor: not-allowed;
        }

        .ai-loading {
            display: flex;
            align-items: center;
            gap: 8px;
            color: #64748b;
            font-style: italic;
            padding: 8px 0;
        }

        .ai-loading-dots {
            display: flex;
            gap: 4px;
        }

        .ai-loading-dot {
            width: 6px;
            height: 6px;
            border-radius: 50%;
            background: #6366f1;
            animation: loadingDots 1.4s infinite ease-in-out;
        }

        .ai-loading-dot:nth-child(1) { animation-delay: -0.32s; }
        .ai-loading-dot:nth-child(2) { animation-delay: -0.16s; }

        @keyframes loadingDots {
            0%, 80%, 100% {
                transform: scale(0.8);
                opacity: 0.5;
            }
            40% {
                transform: scale(1);
                opacity: 1;
            }
        }

        .ai-welcome-message {
            text-align: center;
            color: #64748b;
            padding: 40px 20px;
            font-style: italic;
        }

        .ai-welcome-title {
            font-size: 20px;
            font-weight: 600;
            color: #6366f1;
            margin-bottom: 8px;
        }

        /* Responsive Design */
        @media (max-width: 768px) {
            .ai-chat-container {
                width: 95%;
                height: 90vh;
            }
            
            .context-popup {
                max-width: 250px;
            }
        }