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

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    background-color: #f5f5f5;
    color: #333;
    line-height: 1.6;
}

.container {
    max-width: 1200px;
    margin: 0 auto;
    padding: 20px;
}

header {
    text-align: center;
    margin-bottom: 30px;
}

header h1 {
    color: #2c3e50;
    font-size: 2.5rem;
    font-weight: 300;
}

.editor-container {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 20px;
    height: 70vh;
}

.input-section,
.output-section {
    background: white;
    border-radius: 8px;
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.1);
    padding: 20px;
    display: flex;
    flex-direction: column;
}

.input-section h2,
.output-section h2 {
    margin-bottom: 15px;
    color: #34495e;
    font-size: 1.2rem;
    font-weight: 500;
}

#markdown-input {
    flex: 1;
    border: 1px solid #ddd;
    border-radius: 4px;
    padding: 15px;
    font-family: 'Monaco', 'Menlo', 'Ubuntu Mono', monospace;
    font-size: 14px;
    resize: none;
    outline: none;
    transition: border-color 0.3s ease;
}

#markdown-input:focus {
    border-color: #3498db;
}

#markdown-output {
    flex: 1;
    overflow-y: auto;
    padding: 15px;
    border: 1px solid #eee;
    border-radius: 4px;
    background-color: #fafafa;
}

/* Markdown output styling */
#markdown-output h1,
#markdown-output h2,
#markdown-output h3,
#markdown-output h4,
#markdown-output h5,
#markdown-output h6 {
    margin-top: 20px;
    margin-bottom: 10px;
    color: #2c3e50;
}

#markdown-output h1 {
    border-bottom: 2px solid #eee;
    padding-bottom: 10px;
}

#markdown-output h2 {
    border-bottom: 1px solid #eee;
    padding-bottom: 5px;
}

#markdown-output p {
    margin-bottom: 15px;
}

#markdown-output code {
    background-color: #f1f1f1;
    padding: 2px 4px;
    border-radius: 3px;
    font-family: 'Monaco', 'Menlo', 'Ubuntu Mono', monospace;
}

#markdown-output pre {
    background-color: #f8f8f8;
    border: 1px solid #ddd;
    border-radius: 4px;
    padding: 15px;
    overflow-x: auto;
    margin-bottom: 15px;
}

#markdown-output blockquote {
    border-left: 4px solid #ddd;
    margin: 15px 0;
    padding-left: 15px;
    color: #666;
}

#markdown-output ul,
#markdown-output ol {
    margin-bottom: 15px;
    padding-left: 30px;
}

#markdown-output table {
    border-collapse: collapse;
    width: 100%;
    margin-bottom: 15px;
}

#markdown-output th,
#markdown-output td {
    border: 1px solid #ddd;
    padding: 8px;
    text-align: left;
}

#markdown-output th {
    background-color: #f2f2f2;
}

/* Controls styling */
.controls {
    background: white;
    border-radius: 8px;
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.1);
    padding: 20px;
    margin-bottom: 20px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 20px;
}

.control-group {
    display: flex;
    gap: 10px;
}

.dropdown-group {
    display: flex;
    gap: 10px;
}

.btn {
    background-color: #3498db;
    color: white;
    border: none;
    padding: 8px 16px;
    border-radius: 4px;
    cursor: pointer;
    font-size: 14px;
    transition: background-color 0.3s ease;
}

.btn:hover {
    background-color: #2980b9;
}

.btn:active {
    transform: translateY(1px);
}

.btn-secondary {
    background-color: #95a5a6;
}

.btn-secondary:hover {
    background-color: #7f8c8d;
}

.dropdown {
    padding: 8px 12px;
    border: 1px solid #ddd;
    border-radius: 4px;
    background-color: white;
    cursor: pointer;
    font-size: 14px;
    min-width: 150px;
}

.dropdown:focus {
    outline: none;
    border-color: #3498db;
}

/* Math formula styling */
.MathJax {
    font-size: 1.1em !important;
}

/* Responsive design */
@media (max-width: 768px) {
    .editor-container {
        grid-template-columns: 1fr;
        height: auto;
    }
    
    .input-section,
    .output-section {
        height: 50vh;
    }
    
    header h1 {
        font-size: 2rem;
    }
    
    .controls {
        flex-direction: column;
        align-items: stretch;
        gap: 15px;
    }
    
    .control-group {
        justify-content: center;
        order: 1;
    }
    
    .search-group {
        order: 2;
        margin: 0;
        max-width: none;
    }
    
    .dropdown-group {
        justify-content: center;
        order: 3;
    }
    
    .dropdown {
        min-width: auto;
        flex: 1;
    }
}

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

.modal-content {
    background-color: white;
    margin: 2% auto;
    padding: 0;
    border-radius: 8px;
    width: 90%;
    max-width: 1000px;
    max-height: 90vh;
    overflow: hidden;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.3);
    animation: slideIn 0.3s ease;
}

.modal-header {
    background-color: #3498db;
    color: white;
    padding: 20px;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.modal-header h2 {
    margin: 0;
    font-size: 1.5rem;
}

.close {
    font-size: 28px;
    font-weight: bold;
    cursor: pointer;
    transition: color 0.3s ease;
}

.close:hover {
    color: #f1c40f;
}

.modal-body {
    padding: 20px;
    max-height: calc(90vh - 80px);
    overflow-y: auto;
}

.template-selector {
    margin-bottom: 20px;
}

.modal-dropdown {
    width: 100%;
    padding: 10px;
    border: 1px solid #ddd;
    border-radius: 4px;
    font-size: 16px;
    background-color: white;
}

.modal-preview {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 20px;
    height: 60vh;
}

.modal-input,
.modal-output {
    display: flex;
    flex-direction: column;
}

.modal-input h3,
.modal-output h3 {
    margin: 0 0 10px 0;
    color: #2c3e50;
    font-size: 1.1rem;
}

#modal-markdown-code,
#modal-math-code {
    flex: 1;
    border: 1px solid #ddd;
    border-radius: 4px;
    padding: 15px;
    font-family: 'Monaco', 'Menlo', 'Ubuntu Mono', monospace;
    font-size: 14px;
    resize: none;
    background-color: #f8f9fa;
    margin-bottom: 10px;
}

#modal-markdown-preview,
#modal-math-preview {
    flex: 1;
    border: 1px solid #eee;
    border-radius: 4px;
    padding: 15px;
    background-color: #fafafa;
    overflow-y: auto;
}

#copy-markdown-code,
#copy-math-code {
    align-self: flex-start;
    background-color: #27ae60;
}

#copy-markdown-code:hover,
#copy-math-code:hover {
    background-color: #229954;
}

/* Modal animations */
@keyframes fadeIn {
    from { opacity: 0; }
    to { opacity: 1; }
}

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

/* Modal responsive design */
@media (max-width: 768px) {
    .modal-content {
        width: 95%;
        margin: 5% auto;
    }
    
    .modal-preview {
        grid-template-columns: 1fr;
        height: auto;
    }
    
    .modal-input,
    .modal-output {
        height: 40vh;
    }
    
    .modal-header h2 {
        font-size: 1.2rem;
    }
}/* 
MathJax specific styling */
.MathJax_Display {
    margin: 1em 0 !important;
}

.MathJax {
    outline: none;
}

/* Ensure MathJax renders properly in modals */
#modal-markdown-preview .MathJax,
#modal-math-preview .MathJax {
    font-size: 1em !important;
}

#modal-markdown-preview .MathJax_Display,
#modal-math-preview .MathJax_Display {
    margin: 0.5em 0 !important;
}

/* Fix for MathJax in preview areas */
#markdown-output .MathJax_Display,
#modal-markdown-preview .MathJax_Display,
#modal-math-preview .MathJax_Display {
    text-align: center;
    margin: 1em 0;
}

/* Ensure proper spacing for inline math */
#markdown-output .MathJax,
#modal-markdown-preview .MathJax,
#modal-math-preview .MathJax {
    display: inline-block;
    vertical-align: middle;
}

/* Search functionality styles */
.search-group {
    flex: 1;
    max-width: 600px;
    margin: 0 10px;
}

.search-container {
    display: flex;
    gap: 10px;
    align-items: center;
    width: 100%;
}

.search-input {
    flex: 1;
    padding: 12px 16px;
    border: 2px solid #e1e5e9;
    border-radius: 8px;
    font-size: 16px;
    transition: border-color 0.3s ease;
    background: white;
}

.search-input:focus {
    outline: none;
    border-color: #3498db;
    box-shadow: 0 0 0 3px rgba(52, 152, 219, 0.1);
}

.search-btn {
    background: #3498db;
    color: white;
    border: none;
    padding: 12px 20px;
    border-radius: 8px;
    cursor: pointer;
    font-weight: 500;
    transition: background-color 0.3s ease;
}

.search-btn:hover {
    background: #2980b9;
}

.clear-search-btn {
    background: #e74c3c;
    color: white;
    border: none;
    padding: 12px 16px;
    border-radius: 8px;
    cursor: pointer;
    font-weight: 500;
    transition: background-color 0.3s ease;
}

.clear-search-btn:hover {
    background: #c0392b;
}

/* Search modal styles */
.search-modal-content {
    max-width: 900px;
    width: 95%;
    max-height: 80vh;
    overflow-y: auto;
}

.search-stats {
    padding: 10px 0;
    border-bottom: 1px solid #e1e5e9;
    margin-bottom: 15px;
    font-size: 14px;
    color: #666;
}

.search-results {
    display: flex;
    flex-direction: column;
    gap: 15px;
}

.search-result-item {
    background: #f8f9fa;
    border: 1px solid #e1e5e9;
    border-radius: 8px;
    padding: 15px;
    cursor: pointer;
    transition: all 0.3s ease;
}

.search-result-item:hover {
    background: #e3f2fd;
    border-color: #3498db;
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(52, 152, 219, 0.15);
}

.search-result-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 8px;
}

.search-result-title {
    font-weight: 600;
    color: #2c3e50;
    font-size: 16px;
}

.search-result-category {
    background: #3498db;
    color: white;
    padding: 4px 8px;
    border-radius: 4px;
    font-size: 12px;
    font-weight: 500;
}

.search-result-preview {
    color: #666;
    font-size: 14px;
    line-height: 1.4;
    max-height: 60px;
    overflow: hidden;
    text-overflow: ellipsis;
}

.search-highlight {
    background: #fff3cd;
    padding: 2px 4px;
    border-radius: 3px;
    font-weight: 600;
}

.search-no-results {
    text-align: center;
    padding: 40px 20px;
    color: #666;
}

.search-no-results h3 {
    margin-bottom: 10px;
    color: #999;
}

.search-no-results p {
    font-size: 14px;
}

/* Responsive search styles */
@media (max-width: 768px) {
    .search-container {
        flex-direction: column;
        gap: 8px;
    }
    
    .search-input {
        width: 100%;
    }
    
    .search-btn,
    .clear-search-btn {
        width: 100%;
    }
    
    .search-modal-content {
        width: 98%;
        margin: 1% auto;
    }
    
    .search-result-item {
        padding: 12px;
    }
    
    .search-result-header {
        flex-direction: column;
        align-items: flex-start;
        gap: 8px;
    }
}

/* Medium screens - keep search in middle but stack buttons */
@media (max-width: 1024px) and (min-width: 769px) {
    .search-container {
        flex-direction: column;
        gap: 8px;
    }
    
    .search-btn,
    .clear-search-btn {
        width: 100%;
    }
}