:root {
    --primary-blue: #2196F3;
    --success-green: #4CAF50;
    --warning-amber: #FFC107;
    --error-red: #F44336;
    --secondary-purple: #9C27B0;
    --background: #f5f5f5;
    --surface: #ffffff;
    --on-surface: #212121;
    --on-surface-variant: #757575;
    --border: #e0e0e0;
    --shadow: rgba(0, 0, 0, 0.1);
    --shadow-elevated: rgba(0, 0, 0, 0.15);
}

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

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, Cantarell, sans-serif;
    background-color: var(--background);
    color: var(--on-surface);
    line-height: 1.6;
    padding-bottom: 80px;
}

/* Header */
.app-header {
    background: var(--surface);
    padding: 1rem;
    box-shadow: 0 2px 8px var(--shadow);
    position: sticky;
    top: 0;
    z-index: 100;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.app-header h1 {
    font-size: 1.25rem;
    font-weight: 600;
    color: var(--primary-blue);
}

.add-snippet-btn {
    background: var(--primary-blue);
    color: white;
    border: none;
    padding: 0.5rem 1rem;
    border-radius: 8px;
    font-size: 0.875rem;
    font-weight: 500;
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 0.5rem;
    transition: all 0.2s ease;
}

.add-snippet-btn:hover {
    background: #1976D2;
    transform: translateY(-1px);
}

/* Main Content */
.main-content {
    padding: 1rem;
    max-width: 1200px;
    margin: 0 auto;
}

.content-section {
    display: none;
}

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

/* Search Container */
.search-container {
    margin-bottom: 1.5rem;
}

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

.search-box i {
    position: absolute;
    left: 1rem;
    top: 50%;
    transform: translateY(-50%);
    color: var(--on-surface-variant);
}

.search-box input {
    width: 100%;
    padding: 0.75rem 1rem 0.75rem 2.5rem;
    border: 1px solid var(--border);
    border-radius: 12px;
    font-size: 1rem;
    background: var(--surface);
    transition: all 0.2s ease;
}

.search-box input:focus {
    outline: none;
    border-color: var(--primary-blue);
    box-shadow: 0 0 0 3px rgba(33, 150, 243, 0.1);
}

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

.tag-filter {
    background: var(--surface);
    border: 1px solid var(--border);
    padding: 0.375rem 0.75rem;
    border-radius: 20px;
    font-size: 0.875rem;
    cursor: pointer;
    transition: all 0.2s ease;
}

.tag-filter:hover {
    border-color: var(--primary-blue);
}

.tag-filter.active {
    background: var(--primary-blue);
    color: white;
    border-color: var(--primary-blue);
}

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

.snippet-card {
    background: var(--surface);
    border-radius: 12px;
    padding: 1rem;
    box-shadow: 0 2px 8px var(--shadow);
    transition: all 0.2s ease;
    cursor: pointer;
    position: relative;
}

.snippet-card:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 16px var(--shadow-elevated);
}

.snippet-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    margin-bottom: 0.75rem;
}

.snippet-title {
    font-weight: 600;
    font-size: 1rem;
    color: var(--on-surface);
    margin-bottom: 0.25rem;
}

.snippet-language {
    background: var(--primary-blue);
    color: white;
    padding: 0.25rem 0.5rem;
    border-radius: 6px;
    font-size: 0.75rem;
    font-weight: 500;
}

.snippet-description {
    color: var(--on-surface-variant);
    font-size: 0.875rem;
    margin-bottom: 0.75rem;
    line-height: 1.4;
}

.snippet-code-preview {
    background: #f8f9fa;
    border-radius: 6px;
    padding: 0.75rem;
    font-family: 'Courier New', monospace;
    font-size: 0.75rem;
    color: #333;
    overflow: hidden;
    max-height: 100px;
    position: relative;
}

.snippet-code-preview::after {
    content: '';
    position: absolute;
    bottom: 0;
    left: 0;
    right: 0;
    height: 20px;
    background: linear-gradient(transparent, #f8f9fa);
}

.snippet-tags {
    display: flex;
    flex-wrap: wrap;
    gap: 0.375rem;
    margin-top: 0.75rem;
}

.snippet-tag {
    background: var(--background);
    color: var(--on-surface-variant);
    padding: 0.25rem 0.5rem;
    border-radius: 12px;
    font-size: 0.75rem;
}

.snippet-actions {
    position: absolute;
    top: 1rem;
    right: 1rem;
    display: flex;
    gap: 0.25rem;
    opacity: 0;
    transition: opacity 0.2s ease;
}

.snippet-card:hover .snippet-actions {
    opacity: 1;
}

.action-btn {
    background: rgba(255, 255, 255, 0.9);
    border: none;
    width: 32px;
    height: 32px;
    border-radius: 50%;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s ease;
    font-size: 0.875rem;
}

.action-btn:hover {
    background: white;
    transform: scale(1.1);
}

.favorite-btn.active {
    color: var(--warning-amber);
}

/* Empty State */
.empty-state {
    text-align: center;
    padding: 3rem 1rem;
    color: var(--on-surface-variant);
    grid-column: 1 / -1;
}

.empty-state i {
    font-size: 3rem;
    margin-bottom: 1rem;
    opacity: 0.5;
}

.empty-state h3 {
    margin-bottom: 0.5rem;
    font-weight: 500;
}

/* Editor Section */
.editor-container {
    max-width: 800px;
    margin: 0 auto;
}

.snippet-form {
    background: var(--surface);
    padding: 1.5rem;
    border-radius: 12px;
    box-shadow: 0 2px 8px var(--shadow);
    margin-bottom: 1rem;
}

.form-group {
    margin-bottom: 1rem;
}

.form-row {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 1rem;
}

.form-group label {
    display: block;
    margin-bottom: 0.5rem;
    font-weight: 500;
    color: var(--on-surface);
}

.form-group input,
.form-group select,
.form-group textarea {
    width: 100%;
    padding: 0.75rem;
    border: 1px solid var(--border);
    border-radius: 8px;
    font-size: 1rem;
    font-family: inherit;
    transition: all 0.2s ease;
}

.form-group textarea {
    resize: vertical;
    font-family: 'Courier New', monospace;
}

.form-group input:focus,
.form-group select:focus,
.form-group textarea:focus {
    outline: none;
    border-color: var(--primary-blue);
    box-shadow: 0 0 0 3px rgba(33, 150, 243, 0.1);
}

.form-actions {
    display: flex;
    gap: 0.75rem;
    justify-content: flex-end;
    margin-top: 1.5rem;
}

/* Buttons */
.btn-primary,
.btn-secondary,
.btn-success,
.btn-warning,
.btn-danger {
    padding: 0.75rem 1.5rem;
    border: none;
    border-radius: 8px;
    font-size: 0.875rem;
    font-weight: 500;
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 0.5rem;
    transition: all 0.2s ease;
    text-decoration: none;
}

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

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

.btn-secondary {
    background: var(--on-surface-variant);
    color: white;
}

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

.btn-success {
    background: var(--success-green);
    color: white;
}

.btn-success:hover {
    background: #388E3C;
}

.btn-warning {
    background: var(--warning-amber);
    color: var(--on-surface);
}

.btn-warning:hover {
    background: #F57F17;
}

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

.btn-danger:hover {
    background: #D32F2F;
}

/* Preview and Execution */
.preview-container,
.execution-container {
    background: var(--surface);
    padding: 1.5rem;
    border-radius: 12px;
    box-shadow: 0 2px 8px var(--shadow);
    margin-bottom: 1rem;
}

.preview-container h3,
.execution-container h3 {
    margin-bottom: 1rem;
    color: var(--on-surface);
}

.code-preview {
    background: #f8f9fa;
    border-radius: 8px;
    padding: 1rem;
    font-family: 'Courier New', monospace;
    font-size: 0.875rem;
    overflow-x: auto;
    white-space: pre-wrap;
}

.execution-output {
    background: #1e1e1e;
    color: #d4d4d4;
    border-radius: 8px;
    padding: 1rem;
    font-family: 'Courier New', monospace;
    font-size: 0.875rem;
    min-height: 100px;
    overflow-x: auto;
    white-space: pre-wrap;
}

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

.modal-content {
    background: var(--surface);
    border-radius: 12px;
    max-width: 600px;
    width: 100%;
    max-height: 90vh;
    overflow-y: auto;
    box-shadow: 0 8px 32px var(--shadow-elevated);
}

.modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 1.5rem;
    border-bottom: 1px solid var(--border);
}

.modal-header h3 {
    margin: 0;
    color: var(--on-surface);
}

.modal-close {
    background: none;
    border: none;
    font-size: 1.25rem;
    cursor: pointer;
    color: var(--on-surface-variant);
    width: 32px;
    height: 32px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s ease;
}

.modal-close:hover {
    background: var(--background);
}

.modal-body {
    padding: 1.5rem;
}

.modal-actions {
    display: flex;
    gap: 0.75rem;
    justify-content: flex-end;
    padding: 1.5rem;
    border-top: 1px solid var(--border);
}

/* FAQ Section */
.faq-container {
    max-width: 800px;
    margin: 0 auto;
}

.faq-item {
    background: var(--surface);
    border-radius: 12px;
    margin-bottom: 1rem;
    box-shadow: 0 2px 8px var(--shadow);
    overflow: hidden;
}

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

.faq-question:hover {
    background: var(--background);
}

.faq-icon {
    font-size: 1.25rem;
    transition: transform 0.2s ease;
}

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

.faq-answer {
    padding: 0 1.5rem 1.5rem;
    color: var(--on-surface-variant);
    line-height: 1.6;
    animation: slideDown 0.3s ease;
}

.faq-answer[hidden] {
    display: none;
}

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

/* Bottom Navigation */
.bottom-nav {
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    background: var(--surface);
    border-top: 1px solid var(--border);
    display: flex;
    justify-content: space-around;
    padding: 0.5rem 0;
    z-index: 100;
}

.nav-item {
    display: flex;
    flex-direction: column;
    align-items: center;
    text-decoration: none;
    color: var(--on-surface-variant);
    font-size: 0.75rem;
    padding: 0.5rem;
    border-radius: 8px;
    transition: all 0.2s ease;
    min-width: 60px;
}

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

.nav-item.active {
    color: var(--primary-blue);
}

.nav-item:hover {
    background: var(--background);
}

/* Footer */
footer {
    text-align: center;
    padding: 2rem 1rem;
    color: var(--on-surface-variant);
    font-size: 0.875rem;
    background: var(--surface);
    margin-top: 2rem;
    border-top: 1px solid var(--border);
}

/* Syntax Highlighting */
.code-highlight {
    background: #f8f9fa;
    border-radius: 8px;
    padding: 1rem;
    font-family: 'Courier New', monospace;
    font-size: 0.875rem;
    overflow-x: auto;
    white-space: pre-wrap;
}

.keyword { color: #d73a49; font-weight: bold; }
.string { color: #032f62; }
.comment { color: #6a737d; font-style: italic; }
.number { color: #005cc5; }
.function { color: #6f42c1; }
.variable { color: #e36209; }
.operator { color: #d73a49; }
.tag { color: #22863a; }
.attribute { color: #6f42c1; }
.value { color: #032f62; }

/* Responsive Design */
@media (max-width: 768px) {
    .app-header {
        padding: 0.75rem 1rem;
    }
    
    .app-header h1 {
        font-size: 1.125rem;
    }
    
    .add-snippet-btn {
        padding: 0.5rem 0.75rem;
        font-size: 0.8125rem;
    }
    
    .form-row {
        grid-template-columns: 1fr;
    }
    
    .form-actions {
        flex-direction: column;
    }
    
    .snippets-grid {
        grid-template-columns: 1fr;
    }
    
    .modal {
        padding: 0.5rem;
    }
    
    .modal-actions {
        flex-direction: column;
    }
}

@media (max-width: 480px) {
    .main-content {
        padding: 0.75rem;
    }
    
    .snippet-form {
        padding: 1rem;
    }
    
    .nav-item {
        font-size: 0.6875rem;
        padding: 0.375rem;
        min-width: 50px;
    }
    
    .nav-item i {
        font-size: 1.125rem;
    }
}

/* Dark mode support */
@media (prefers-color-scheme: dark) {
    :root {
        --background: #121212;
        --surface: #1e1e1e;
        --on-surface: #e0e0e0;
        --on-surface-variant: #a0a0a0;
        --border: #333333;
        --shadow: rgba(0, 0, 0, 0.3);
        --shadow-elevated: rgba(0, 0, 0, 0.5);
    }
    
    .code-preview {
        background: #2d2d2d;
        color: #e0e0e0;
    }
    
    .snippet-code-preview {
        background: #2d2d2d;
        color: #e0e0e0;
    }
    
    .snippet-code-preview::after {
        background: linear-gradient(transparent, #2d2d2d);
    }
    
    .code-highlight {
        background: #2d2d2d;
        color: #e0e0e0;
    }
}
