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

body {
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    background: #f5f5f5;
    background-image: 
        radial-gradient(circle at 1px 1px, rgba(255,255,255,0.8) 1px, transparent 0);
    background-size: 20px 20px;
    color: #333;
    line-height: 1.6;
    padding-bottom: 80px;
}

.app-header {
    background: linear-gradient(135deg, #2196F3, #4CAF50);
    color: white;
    padding: 1rem;
    position: sticky;
    top: 0;
    z-index: 100;
    box-shadow: 0 2px 10px rgba(0,0,0,0.1);
}

.app-header h1 {
    font-size: 1.5rem;
    margin-bottom: 0.5rem;
    text-align: center;
}

.user-progress {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    font-size: 0.9rem;
}

.progress-bar {
    flex: 1;
    height: 6px;
    background: rgba(255,255,255,0.3);
    border-radius: 3px;
    overflow: hidden;
}

.progress-fill {
    height: 100%;
    background: #FFC107;
    width: 0%;
    transition: width 0.3s ease;
    border-radius: 3px;
}

.app-main {
    max-width: 1200px;
    margin: 0 auto;
    padding: 1rem;
}

.content-section {
    display: none;
    animation: fadeIn 0.3s ease;
}

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

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

/* Search and Filters */
.search-container {
    background: white;
    padding: 1.5rem;
    border-radius: 12px;
    box-shadow: 0 4px 15px rgba(0,0,0,0.1);
    margin-bottom: 2rem;
}

.search-box {
    position: relative;
    margin-bottom: 1rem;
}

.search-box i {
    position: absolute;
    left: 12px;
    top: 50%;
    transform: translateY(-50%);
    color: #666;
}

.search-box input {
    width: 100%;
    padding: 12px 12px 12px 40px;
    border: 2px solid #e0e0e0;
    border-radius: 8px;
    font-size: 1rem;
    transition: border-color 0.3s ease;
}

.search-box input:focus {
    outline: none;
    border-color: #2196F3;
}

.filter-buttons {
    display: flex;
    gap: 0.5rem;
    flex-wrap: wrap;
}

.filter-btn {
    padding: 8px 16px;
    border: 2px solid #e0e0e0;
    background: white;
    border-radius: 20px;
    cursor: pointer;
    transition: all 0.3s ease;
    font-size: 0.9rem;
}

.filter-btn:hover {
    border-color: #2196F3;
    color: #2196F3;
}

.filter-btn.active {
    background: #2196F3;
    color: white;
    border-color: #2196F3;
}

/* Snippets Grid */
.snippets-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
    gap: 1.5rem;
    margin-bottom: 2rem;
}

.snippet-card {
    background: white;
    border-radius: 12px;
    overflow: hidden;
    box-shadow: 0 4px 15px rgba(0,0,0,0.1);
    transition: transform 0.3s ease, box-shadow 0.3s ease;
    cursor: pointer;
}

.snippet-card:hover {
    transform: translateY(-5px);
    box-shadow: 0 8px 25px rgba(0,0,0,0.15);
}

.snippet-header {
    padding: 1rem;
    background: linear-gradient(135deg, #f8f9fa, #e9ecef);
    border-bottom: 1px solid #e0e0e0;
}

.snippet-title {
    font-size: 1.1rem;
    font-weight: 600;
    margin-bottom: 0.5rem;
    color: #333;
}

.snippet-meta {
    display: flex;
    justify-content: space-between;
    align-items: center;
    font-size: 0.85rem;
    color: #666;
}

.language-tag {
    padding: 4px 8px;
    border-radius: 12px;
    font-size: 0.75rem;
    font-weight: 500;
}

.language-tag.javascript { background: #f7df1e; color: #000; }
.language-tag.html { background: #e34f26; color: white; }
.language-tag.css { background: #1572b6; color: white; }
.language-tag.python { background: #3776ab; color: white; }

.difficulty-tag {
    padding: 4px 8px;
    border-radius: 12px;
    font-size: 0.75rem;
    font-weight: 500;
}

.difficulty-tag.beginner { background: #4CAF50; color: white; }
.difficulty-tag.intermediate { background: #FFC107; color: #000; }
.difficulty-tag.advanced { background: #F44336; color: white; }

.snippet-description {
    padding: 1rem;
    color: #666;
    font-size: 0.9rem;
    line-height: 1.5;
}

.snippet-actions {
    padding: 1rem;
    display: flex;
    gap: 0.5rem;
    border-top: 1px solid #e0e0e0;
}

.btn-primary, .btn-secondary {
    padding: 8px 16px;
    border: none;
    border-radius: 6px;
    cursor: pointer;
    font-size: 0.9rem;
    transition: all 0.3s ease;
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.btn-primary {
    background: #2196F3;
    color: white;
}

.btn-primary:hover {
    background: #1976D2;
}

.btn-secondary {
    background: #e0e0e0;
    color: #666;
}

.btn-secondary:hover {
    background: #d0d0d0;
}

.btn-favorite {
    background: none;
    border: none;
    font-size: 1.2rem;
    cursor: pointer;
    color: #ccc;
    transition: color 0.3s ease;
}

.btn-favorite.favorited {
    color: #F44336;
}

/* Playground */
.playground-container {
    background: white;
    border-radius: 12px;
    overflow: hidden;
    box-shadow: 0 4px 15px rgba(0,0,0,0.1);
}

.playground-header {
    padding: 1.5rem;
    background: linear-gradient(135deg, #9C27B0, #673AB7);
    color: white;
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-wrap: wrap;
    gap: 1rem;
}

.playground-header h2 {
    margin: 0;
}

.playground-controls {
    display: flex;
    gap: 0.5rem;
    align-items: center;
    flex-wrap: wrap;
}

.playground-controls select {
    padding: 8px 12px;
    border: none;
    border-radius: 6px;
    background: white;
    color: #333;
}

.playground-editor {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 1px;
    background: #e0e0e0;
}

.editor-section, .output-section {
    background: white;
    padding: 1rem;
}

.editor-section h3, .output-section h3 {
    margin-bottom: 1rem;
    color: #333;
    font-size: 1rem;
}

#code-editor {
    width: 100%;
    height: 300px;
    border: 1px solid #e0e0e0;
    border-radius: 6px;
    padding: 12px;
    font-family: 'Monaco', 'Menlo', 'Ubuntu Mono', monospace;
    font-size: 14px;
    resize: vertical;
    background: #f8f9fa;
}

#code-output {
    min-height: 300px;
    border: 1px solid #e0e0e0;
    border-radius: 6px;
    padding: 12px;
    background: #f8f9fa;
    font-family: 'Monaco', 'Menlo', 'Ubuntu Mono', monospace;
    font-size: 14px;
    white-space: pre-wrap;
    overflow-y: auto;
}

#html-preview {
    width: 100%;
    height: 300px;
    border: 1px solid #e0e0e0;
    border-radius: 6px;
    background: white;
}

/* Modal */
.modal {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0,0,0,0.5);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1000;
    padding: 1rem;
}

.modal-content {
    background: white;
    border-radius: 12px;
    width: 100%;
    max-width: 600px;
    max-height: 90vh;
    overflow-y: auto;
    box-shadow: 0 10px 30px rgba(0,0,0,0.3);
}

.modal-header {
    padding: 1.5rem;
    background: linear-gradient(135deg, #2196F3, #4CAF50);
    color: white;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.modal-header h3 {
    margin: 0;
}

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

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

.form-group {
    padding: 1rem 1.5rem;
}

.form-group label {
    display: block;
    margin-bottom: 0.5rem;
    font-weight: 500;
    color: #333;
}

.form-group input, .form-group select, .form-group textarea {
    width: 100%;
    padding: 12px;
    border: 2px solid #e0e0e0;
    border-radius: 6px;
    font-size: 1rem;
    transition: border-color 0.3s ease;
}

.form-group textarea {
    resize: vertical;
    min-height: 100px;
    font-family: 'Monaco', 'Menlo', 'Ubuntu Mono', monospace;
}

.form-group input:focus, .form-group select:focus, .form-group textarea:focus {
    outline: none;
    border-color: #2196F3;
}

.form-actions {
    padding: 1.5rem;
    display: flex;
    gap: 1rem;
    justify-content: flex-end;
    border-top: 1px solid #e0e0e0;
}

/* Stats Cards */
.community-stats, .profile-stats {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(120px, 1fr));
    gap: 1rem;
    margin-bottom: 2rem;
}

.stat-card, .profile-stat {
    background: white;
    padding: 1.5rem;
    border-radius: 12px;
    text-align: center;
    box-shadow: 0 4px 15px rgba(0,0,0,0.1);
}

.stat-card i {
    font-size: 2rem;
    margin-bottom: 0.5rem;
    color: #2196F3;
}

.stat-number, .stat-value {
    display: block;
    font-size: 2rem;
    font-weight: bold;
    color: #333;
    margin-bottom: 0.25rem;
}

.stat-label {
    color: #666;
    font-size: 0.9rem;
}

/* Achievements */
.achievements-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
    gap: 1rem;
    margin-bottom: 2rem;
}

.achievement-card {
    background: white;
    padding: 1.5rem;
    border-radius: 12px;
    text-align: center;
    box-shadow: 0 4px 15px rgba(0,0,0,0.1);
    transition: transform 0.3s ease;
}

.achievement-card.unlocked {
    background: linear-gradient(135deg, #FFC107, #FF9800);
    color: white;
    transform: scale(1.05);
}

.achievement-icon {
    font-size: 3rem;
    margin-bottom: 1rem;
}

.achievement-title {
    font-weight: bold;
    margin-bottom: 0.5rem;
}

.achievement-description {
    font-size: 0.9rem;
    opacity: 0.8;
}

/* Progress by Language */
.progress-by-language {
    background: white;
    padding: 1.5rem;
    border-radius: 12px;
    box-shadow: 0 4px 15px rgba(0,0,0,0.1);
}

.language-progress {
    margin-bottom: 1rem;
}

.language-progress:last-child {
    margin-bottom: 0;
}

.language-progress-header {
    display: flex;
    justify-content: space-between;
    margin-bottom: 0.5rem;
}

.language-progress-bar {
    height: 8px;
    background: #e0e0e0;
    border-radius: 4px;
    overflow: hidden;
}

.language-progress-fill {
    height: 100%;
    border-radius: 4px;
    transition: width 0.3s ease;
}

/* FAQ */
.faq-section {
    background: white;
    margin: 2rem 0;
    padding: 2rem;
    border-radius: 12px;
    box-shadow: 0 4px 15px rgba(0,0,0,0.1);
}

.faq-section h2 {
    margin-bottom: 2rem;
    text-align: center;
    color: #333;
}

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

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

.faq-question {
    width: 100%;
    padding: 1.5rem 0;
    background: none;
    border: none;
    text-align: left;
    font-size: 1.1rem;
    font-weight: 500;
    color: #333;
    cursor: pointer;
    display: flex;
    justify-content: space-between;
    align-items: center;
    transition: color 0.3s ease;
}

.faq-question:hover {
    color: #2196F3;
}

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

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

.faq-answer {
    padding-bottom: 1.5rem;
    color: #666;
    line-height: 1.6;
    animation: slideDown 0.3s ease;
}

@keyframes slideDown {
    from {
        opacity: 0;
        max-height: 0;
    }
    to {
        opacity: 1;
        max-height: 200px;
    }
}

/* Empty States */
.empty-state, .empty-favorites {
    text-align: center;
    padding: 3rem 1rem;
    color: #666;
}

.empty-state i, .empty-favorites i {
    color: #ccc;
    margin-bottom: 1rem;
}

.empty-state h3, .empty-favorites h3 {
    margin-bottom: 0.5rem;
    color: #333;
}

/* Bottom Navigation */
.bottom-nav {
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    background: white;
    border-top: 1px solid #e0e0e0;
    display: flex;
    box-shadow: 0 -2px 10px rgba(0,0,0,0.1);
    z-index: 100;
}

.nav-item {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    padding: 0.75rem 0.5rem;
    text-decoration: none;
    color: #666;
    transition: all 0.3s ease;
    font-size: 0.75rem;
}

.nav-item:hover {
    color: #2196F3;
    background: rgba(33, 150, 243, 0.1);
}

.nav-item.active {
    color: #2196F3;
    background: rgba(33, 150, 243, 0.1);
}

.nav-item i {
    font-size: 1.5rem;
    margin-bottom: 0.25rem;
}

/* Footer */
footer {
    background: #333;
    color: white;
    text-align: center;
    padding: 1rem;
    margin-top: 2rem;
    font-size: 0.9rem;
}

/* Responsive Design */
@media (max-width: 768px) {
    .playground-editor {
        grid-template-columns: 1fr;
    }
    
    .playground-header {
        flex-direction: column;
        align-items: flex-start;
    }
    
    .playground-controls {
        width: 100%;
        justify-content: flex-end;
    }
    
    .snippets-grid {
        grid-template-columns: 1fr;
    }
    
    .community-stats, .profile-stats {
        grid-template-columns: repeat(3, 1fr);
    }
    
    .achievements-grid {
        grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
    }
    
    .form-actions {
        flex-direction: column;
    }
    
    .search-box input {
        font-size: 16px; /* Prevent zoom on iOS */
    }
}

@media (max-width: 480px) {
    .app-main {
        padding: 0.5rem;
    }
    
    .search-container {
        padding: 1rem;
    }
    
    .community-stats, .profile-stats {
        grid-template-columns: 1fr;
    }
    
    .filter-buttons {
        justify-content: center;
    }
    
    .snippet-actions {
        flex-direction: column;
    }
    
    .modal {
        padding: 0.5rem;
    }
    
    .nav-item {
        font-size: 0.7rem;
    }
    
    .nav-item i {
        font-size: 1.3rem;
    }
}

/* Code Syntax Highlighting */
.code-highlight {
    background: #f8f9fa;
    border: 1px solid #e9ecef;
    border-radius: 6px;
    padding: 1rem;
    font-family: 'Monaco', 'Menlo', 'Ubuntu Mono', monospace;
    font-size: 14px;
    overflow-x: auto;
    margin: 1rem 0;
}

.code-highlight .keyword { color: #d73a49; font-weight: bold; }
.code-highlight .string { color: #032f62; }
.code-highlight .comment { color: #6a737d; font-style: italic; }
.code-highlight .number { color: #005cc5; }
.code-highlight .function { color: #6f42c1; }

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

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

/* Notification Toast */
.toast {
    position: fixed;
    bottom: 100px;
    left: 50%;
    transform: translateX(-50%);
    background: #333;
    color: white;
    padding: 1rem 1.5rem;
    border-radius: 6px;
    box-shadow: 0 4px 15px rgba(0,0,0,0.3);
    z-index: 1001;
    animation: toastSlideUp 0.3s ease;
}

.toast.success {
    background: #4CAF50;
}

.toast.error {
    background: #F44336;
}

@keyframes toastSlideUp {
    from {
        opacity: 0;
        transform: translate(-50%, 20px);
    }
    to {
        opacity: 1;
        transform: translate(-50%, 0);
    }
}
