/* Reset and Base Styles */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    background: linear-gradient(135deg, #f5f5f5 0%, #e8e8e8 100%);
    background-image: 
        radial-gradient(circle at 20px 50px, #ffffff 2px, transparent 2px),
        radial-gradient(circle at 40px 80px, #ffffff 1px, transparent 1px),
        linear-gradient(0deg, transparent 24%, rgba(255,255,255,.05) 25%, rgba(255,255,255,.05) 26%, transparent 27%, transparent 74%, rgba(255,255,255,.05) 75%, rgba(255,255,255,.05) 76%, transparent 77%);
    background-size: 60px 60px, 40px 40px, 50px 50px;
    color: #333;
    line-height: 1.6;
    min-height: 100vh;
    padding-bottom: 80px;
}

/* Color Palette Variables */
:root {
    --primary-blue: #2196F3;
    --success-green: #4CAF50;
    --warning-yellow: #FFC107;
    --danger-red: #F44336;
    --accent-purple: #9C27B0;
    --paper-white: #fefefe;
    --text-dark: #333;
    --text-light: #666;
    --shadow-light: rgba(0,0,0,0.1);
    --shadow-medium: rgba(0,0,0,0.15);
}

/* Header */
.app-header {
    background: linear-gradient(135deg, var(--primary-blue), var(--accent-purple));
    color: white;
    padding: 20px 0;
    box-shadow: 0 2px 10px var(--shadow-medium);
    position: sticky;
    top: 0;
    z-index: 100;
}

.header-content {
    max-width: 1200px;
    margin: 0 auto;
    padding: 0 20px;
    text-align: center;
}

.header-content h1 {
    font-size: 1.8rem;
    margin-bottom: 5px;
    font-weight: 700;
}

.header-content p {
    font-size: 0.9rem;
    opacity: 0.9;
}

/* Main Content */
.app-main {
    max-width: 1200px;
    margin: 0 auto;
    padding: 20px;
}

/* Sections */
.section {
    display: none;
    animation: fadeIn 0.3s ease-in;
}

.section.active {
    display: block;
}

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

/* Welcome Card */
.welcome-card {
    background: var(--paper-white);
    border-radius: 15px;
    padding: 30px;
    box-shadow: 0 4px 20px var(--shadow-light);
    text-align: center;
    margin-bottom: 20px;
    border: 1px solid rgba(255,255,255,0.8);
}

.welcome-card h2 {
    color: var(--primary-blue);
    margin-bottom: 10px;
    font-size: 1.5rem;
}

.welcome-card p {
    color: var(--text-light);
    margin-bottom: 20px;
}

/* Stats Grid */
.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
    gap: 20px;
    margin-top: 20px;
}

.stat-card {
    background: linear-gradient(135deg, var(--success-green), #66BB6A);
    color: white;
    padding: 20px;
    border-radius: 12px;
    text-align: center;
    box-shadow: 0 3px 15px rgba(76, 175, 80, 0.3);
}

.stat-card i {
    font-size: 2rem;
    margin-bottom: 10px;
    display: block;
}

.stat-number {
    display: block;
    font-size: 1.8rem;
    font-weight: bold;
    margin-bottom: 5px;
}

.stat-label {
    font-size: 0.8rem;
    opacity: 0.9;
}

/* Experiments Grid */
.experiments-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
    gap: 20px;
    margin-top: 20px;
}

.experiment-card {
    background: var(--paper-white);
    border-radius: 12px;
    padding: 20px;
    box-shadow: 0 4px 15px var(--shadow-light);
    cursor: pointer;
    transition: all 0.3s ease;
    border: 1px solid rgba(255,255,255,0.8);
}

.experiment-card:hover {
    transform: translateY(-5px);
    box-shadow: 0 8px 25px var(--shadow-medium);
}

.experiment-card h3 {
    color: var(--primary-blue);
    margin-bottom: 10px;
    font-size: 1.2rem;
}

.experiment-card p {
    color: var(--text-light);
    margin-bottom: 15px;
    font-size: 0.9rem;
}

.experiment-meta {
    display: flex;
    justify-content: space-between;
    align-items: center;
    font-size: 0.8rem;
    color: var(--text-light);
}

.difficulty {
    padding: 4px 8px;
    border-radius: 20px;
    color: white;
    font-size: 0.7rem;
}

.difficulty.easy { background: var(--success-green); }
.difficulty.medium { background: var(--warning-yellow); color: #333; }
.difficulty.hard { background: var(--danger-red); }

/* Modal */
.modal {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0,0,0,0.8);
    z-index: 1000;
    overflow-y: auto;
}

.modal.active {
    display: flex;
    align-items: flex-start;
    justify-content: center;
    padding: 20px;
}

.modal-content {
    background: var(--paper-white);
    border-radius: 15px;
    width: 100%;
    max-width: 800px;
    max-height: 90vh;
    overflow-y: auto;
    box-shadow: 0 10px 40px rgba(0,0,0,0.3);
    margin-top: 20px;
}

.modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 20px;
    border-bottom: 1px solid #eee;
    background: linear-gradient(135deg, var(--primary-blue), var(--accent-purple));
    color: white;
    border-radius: 15px 15px 0 0;
}

.modal-header h3 {
    margin: 0;
    font-size: 1.3rem;
}

.close-btn {
    background: none;
    border: none;
    color: white;
    font-size: 1.5rem;
    cursor: pointer;
    padding: 5px;
    border-radius: 50%;
    width: 35px;
    height: 35px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.close-btn:hover {
    background: rgba(255,255,255,0.2);
}

.modal-body {
    padding: 20px;
}

.safety-section,
.results-section,
.applications-section {
    margin-bottom: 20px;
    padding: 15px;
    border-radius: 8px;
    background: #f8f9fa;
}

.safety-section {
    border-left: 4px solid var(--warning-yellow);
}

.results-section {
    border-left: 4px solid var(--success-green);
}

.applications-section {
    border-left: 4px solid var(--primary-blue);
}

.safety-section h4,
.results-section h4,
.applications-section h4 {
    margin-bottom: 10px;
    color: var(--text-dark);
}

/* Canvas Container */
.experiment-canvas-container {
    background: #fff;
    border-radius: 8px;
    padding: 20px;
    margin: 20px 0;
    box-shadow: inset 0 2px 5px var(--shadow-light);
    text-align: center;
}

#experiment-canvas {
    border: 2px solid #ddd;
    border-radius: 8px;
    max-width: 100%;
    height: auto;
}

/* Controls */
.controls-section {
    margin: 20px 0;
}

#experiment-controls {
    margin-bottom: 15px;
}

.control-group {
    margin-bottom: 15px;
}

.control-group label {
    display: block;
    margin-bottom: 5px;
    font-weight: 600;
    color: var(--text-dark);
}

.control-group input,
.control-group select {
    width: 100%;
    padding: 8px 12px;
    border: 2px solid #ddd;
    border-radius: 6px;
    font-size: 0.9rem;
}

.control-group input:focus,
.control-group select:focus {
    outline: none;
    border-color: var(--primary-blue);
}

/* Buttons */
.btn {
    padding: 12px 24px;
    border: none;
    border-radius: 8px;
    cursor: pointer;
    font-size: 0.9rem;
    font-weight: 600;
    transition: all 0.3s ease;
    margin: 5px;
    text-decoration: none;
    display: inline-block;
    text-align: center;
}

.btn-primary {
    background: var(--primary-blue);
    color: white;
}

.btn-primary:hover {
    background: #1976D2;
    transform: translateY(-2px);
}

.btn-secondary {
    background: var(--text-light);
    color: white;
}

.btn-secondary:hover {
    background: #555;
    transform: translateY(-2px);
}

.btn-danger {
    background: var(--danger-red);
    color: white;
}

.btn-danger:hover {
    background: #D32F2F;
    transform: translateY(-2px);
}

/* Results Section */
.results-filters {
    display: flex;
    gap: 10px;
    margin-bottom: 20px;
    flex-wrap: wrap;
}

.results-filters select {
    padding: 8px 12px;
    border: 2px solid #ddd;
    border-radius: 6px;
    font-size: 0.9rem;
    flex: 1;
    min-width: 200px;
}

.results-container {
    display: grid;
    grid-template-columns: 1fr;
    gap: 20px;
}

#results-chart-container {
    background: var(--paper-white);
    padding: 20px;
    border-radius: 12px;
    box-shadow: 0 4px 15px var(--shadow-light);
}

.results-list {
    background: var(--paper-white);
    border-radius: 12px;
    box-shadow: 0 4px 15px var(--shadow-light);
    overflow: hidden;
}

.result-item {
    padding: 15px 20px;
    border-bottom: 1px solid #eee;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.result-item:last-child {
    border-bottom: none;
}

.result-info h4 {
    margin: 0 0 5px 0;
    color: var(--primary-blue);
    font-size: 1rem;
}

.result-info p {
    margin: 0;
    color: var(--text-light);
    font-size: 0.8rem;
}

.result-score {
    font-weight: bold;
    font-size: 1.1rem;
}

.result-score.success { color: var(--success-green); }
.result-score.partial { color: var(--warning-yellow); }
.result-score.failed { color: var(--danger-red); }

/* FAQ Section */
.faq-container {
    background: var(--paper-white);
    border-radius: 12px;
    box-shadow: 0 4px 15px var(--shadow-light);
    overflow: hidden;
}

.faq-item {
    border-bottom: 1px solid #eee;
}

.faq-item:last-child {
    border-bottom: none;
}

.faq-question {
    width: 100%;
    padding: 20px;
    background: none;
    border: none;
    text-align: left;
    cursor: pointer;
    font-size: 1rem;
    font-weight: 600;
    color: var(--text-dark);
    display: flex;
    justify-content: space-between;
    align-items: center;
    transition: background-color 0.3s ease;
}

.faq-question:hover {
    background: #f8f9fa;
}

.faq-question[aria-expanded="true"] {
    background: var(--primary-blue);
    color: white;
}

.faq-question[aria-expanded="true"] .faq-icon {
    transform: rotate(45deg);
}

.faq-icon {
    font-size: 1.2rem;
    transition: transform 0.3s ease;
}

.faq-answer {
    padding: 0 20px;
    max-height: 0;
    overflow: hidden;
    transition: all 0.3s ease;
}

.faq-answer.show {
    padding: 20px;
    max-height: 200px;
}

.faq-answer p {
    margin: 0;
    color: var(--text-light);
    line-height: 1.6;
}

/* Bottom Navigation */
.bottom-nav {
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    background: var(--paper-white);
    display: flex;
    justify-content: space-around;
    padding: 10px 0 5px;
    box-shadow: 0 -2px 10px var(--shadow-light);
    border-top: 1px solid #eee;
    z-index: 999;
}

.nav-item {
    display: flex;
    flex-direction: column;
    align-items: center;
    text-decoration: none;
    color: var(--text-light);
    transition: all 0.3s ease;
    padding: 5px;
    border-radius: 8px;
    min-width: 60px;
}

.nav-item:hover,
.nav-item.active {
    color: var(--primary-blue);
    background: rgba(33, 150, 243, 0.1);
}

.nav-item i {
    font-size: 1.2rem;
    margin-bottom: 2px;
}

.nav-item span {
    font-size: 0.7rem;
    font-weight: 500;
}

/* Footer */
footer {
    text-align: center;
    padding: 20px;
    color: var(--text-light);
    font-size: 0.8rem;
    background: var(--paper-white);
    margin-top: 40px;
    box-shadow: 0 -2px 10px var(--shadow-light);
}

/* Responsive Design */
@media (max-width: 768px) {
    .app-main {
        padding: 15px;
    }
    
    .welcome-card {
        padding: 20px;
    }
    
    .stats-grid {
        grid-template-columns: 1fr;
    }
    
    .experiments-grid {
        grid-template-columns: 1fr;
    }
    
    .modal-content {
        margin: 10px;
        max-height: 95vh;
    }
    
    .modal-body {
        padding: 15px;
    }
    
    .results-filters {
        flex-direction: column;
    }
    
    .results-filters select {
        min-width: auto;
    }
    
    .result-item {
        flex-direction: column;
        align-items: flex-start;
        gap: 10px;
    }
    
    .header-content h1 {
        font-size: 1.5rem;
    }
    
    .nav-item span {
        font-size: 0.6rem;
    }
}

@media (max-width: 480px) {
    .app-main {
        padding: 10px;
    }
    
    .welcome-card {
        padding: 15px;
    }
    
    .experiment-card {
        padding: 15px;
    }
    
    .modal {
        padding: 10px;
    }
    
    .btn {
        padding: 10px 20px;
        font-size: 0.8rem;
    }
    
    .faq-question {
        padding: 15px;
        font-size: 0.9rem;
    }
    
    .faq-answer.show {
        padding: 15px;
    }
}

/* Canvas responsiveness */
@media (max-width: 600px) {
    #experiment-canvas {
        width: 100%;
        max-width: 350px;
    }
    
    #results-chart {
        width: 100%;
        max-width: 350px;
    }
}

/* Loading Animation */
.loading {
    display: inline-block;
    width: 20px;
    height: 20px;
    border: 3px solid #f3f3f3;
    border-top: 3px solid var(--primary-blue);
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

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

/* Success/Error Messages */
.message {
    padding: 10px 15px;
    border-radius: 6px;
    margin: 10px 0;
    font-size: 0.9rem;
}

.message.success {
    background: rgba(76, 175, 80, 0.1);
    color: var(--success-green);
    border: 1px solid rgba(76, 175, 80, 0.3);
}

.message.error {
    background: rgba(244, 67, 54, 0.1);
    color: var(--danger-red);
    border: 1px solid rgba(244, 67, 54, 0.3);
}

/* Accessibility improvements */
@media (prefers-reduced-motion: reduce) {
    * {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
    }
}

/* High contrast mode support */
@media (prefers-contrast: high) {
    .experiment-card,
    .welcome-card,
    .modal-content,
    .faq-container,
    .results-list {
        border: 2px solid var(--text-dark);
    }
    
    .btn {
        border: 2px solid currentColor;
    }
}
