body {
    font-family: sans-serif;
    line-height: 1.6;
    margin: 0;
    padding: 20px;
    background-color: #f4f4f4;
    color: #333;
}

.container {
    max-width: 1200px;
    margin: auto;
    background: #fff;
    padding: 30px;
    border-radius: 8px;
    box-shadow: 0 2px 10px rgba(0,0,0,0.1);
}

h1, h2 {
    text-align: center;
    color: #333;
    margin-bottom: 20px;
}

h3 {
    color: #444;
    margin-bottom: 15px;
    font-size: 1.1em;
}

.converter-area {
    margin-bottom: 30px;
    padding-bottom: 20px;
    border-bottom: 1px solid #ccc;
}

.textarea-container {
    display: flex;
    gap: 20px;
    margin-bottom: 15px;
}

.textarea-wrapper {
    flex: 1;
    display: flex;
    flex-direction: column;
}

label {
    margin-bottom: 5px;
    font-weight: bold;
    color: #555;
}

textarea {
    width: 100%;
    height: 250px;
    padding: 10px;
    border: 1px solid #ccc;
    border-radius: 4px;
    font-family: Consolas, Monaco, 'Andale Mono', 'Ubuntu Mono', monospace;
    font-size: 14px;
    box-sizing: border-box;
    resize: vertical;
}

#output-textarea {
    background-color: #e9e9e9;
}

.controls, .rule-buttons {
    display: flex;
    gap: 10px;
    margin-top: 10px;
    justify-content: center;
}

button {
    padding: 10px 15px;
    background-color: #007bff;
    color: white;
    border: none;
    border-radius: 4px;
    cursor: pointer;
    font-size: 14px;
    transition: background-color 0.3s ease;
}

button:hover {
    background-color: #0056b3;
}

button:active {
    background-color: #004085;
}

/* Customization Section */
.customization {
    margin-top: 30px;
}

.customization-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 20px;
}

.customization-header h2 {
    margin: 0;
    text-align: left;
}

/* View Toggle (VS Code style) */
.view-toggle {
    display: flex;
    background-color: #e9e9e9;
    border-radius: 4px;
    padding: 2px;
}

.view-button {
    padding: 8px 16px;
    background-color: transparent;
    color: #555;
    border: none;
    border-radius: 3px;
    font-size: 13px;
    cursor: pointer;
    transition: all 0.2s ease;
}

.view-button:hover {
    background-color: #ddd;
    color: #333;
}

.view-button.active {
    background-color: #fff;
    color: #007bff;
    box-shadow: 0 1px 3px rgba(0,0,0,0.1);
}

/* Rule Views */
.rule-view {
    animation: fadeIn 0.2s ease;
}

.rule-view.hidden {
    display: none;
}

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

.view-description {
    margin-bottom: 20px;
    font-size: 0.9em;
    color: #555;
    line-height: 1.5;
    padding: 10px 15px;
    background-color: #f8f9fa;
    border-radius: 4px;
    border-left: 3px solid #007bff;
}

/* Add Rule Section */
.add-rule-section {
    background-color: #f8f9fa;
    padding: 20px;
    border-radius: 8px;
    margin-bottom: 20px;
    border: 1px solid #e9e9e9;
}

.add-rule-form .form-row {
    display: flex;
    gap: 15px;
    align-items: flex-end;
    flex-wrap: wrap;
}

.form-group {
    display: flex;
    flex-direction: column;
    flex: 1;
    min-width: 150px;
}

.form-group label {
    font-size: 0.85em;
    margin-bottom: 5px;
    color: #555;
}

.form-group input,
.form-group select {
    padding: 10px;
    border: 1px solid #ccc;
    border-radius: 4px;
    font-size: 14px;
    font-family: Consolas, Monaco, 'Andale Mono', 'Ubuntu Mono', monospace;
}

.form-group input:focus,
.form-group select:focus {
    outline: none;
    border-color: #007bff;
    box-shadow: 0 0 0 2px rgba(0,123,255,0.1);
}

.add-button {
    background-color: #28a745;
    min-width: 100px;
    height: 42px;
}

.add-button:hover {
    background-color: #218838;
}

/* Search and Filter */
.search-filter-section {
    display: flex;
    gap: 15px;
    margin-bottom: 15px;
    align-items: center;
    flex-wrap: wrap;
}

.search-box {
    flex: 1;
    min-width: 200px;
}

.search-box input {
    width: 100%;
    padding: 10px 15px;
    border: 1px solid #ccc;
    border-radius: 4px;
    font-size: 14px;
    box-sizing: border-box;
}

.search-box input:focus {
    outline: none;
    border-color: #007bff;
    box-shadow: 0 0 0 2px rgba(0,123,255,0.1);
}

.filter-buttons {
    display: flex;
    gap: 5px;
    flex-wrap: wrap;
}

.filter-button {
    padding: 8px 12px;
    background-color: #e9e9e9;
    color: #555;
    border: 1px solid #ddd;
    font-size: 12px;
}

.filter-button:hover {
    background-color: #ddd;
}

.filter-button.active {
    background-color: #007bff;
    color: white;
    border-color: #007bff;
}

/* Rules List */
.rules-list-container {
    border: 1px solid #ddd;
    border-radius: 8px;
    overflow: hidden;
    margin-bottom: 20px;
}

.rules-list-header {
    display: grid;
    grid-template-columns: 1fr 1.5fr 150px 100px;
    gap: 10px;
    padding: 12px 15px;
    background-color: #f1f3f4;
    font-weight: bold;
    font-size: 0.85em;
    color: #444;
    border-bottom: 1px solid #ddd;
}

.rules-list {
    max-height: 400px;
    overflow-y: auto;
}

.rule-item {
    display: grid;
    grid-template-columns: 1fr 1.5fr 150px 100px;
    gap: 10px;
    padding: 10px 15px;
    border-bottom: 1px solid #eee;
    align-items: center;
    transition: background-color 0.15s ease;
}

.rule-item:hover {
    background-color: #f8f9fa;
}

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

.rule-item .unicode-col,
.rule-item .latex-col {
    font-family: Consolas, Monaco, 'Andale Mono', 'Ubuntu Mono', monospace;
    font-size: 14px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.rule-item .type-col {
    font-size: 0.8em;
    color: #666;
}

.rule-type-badge {
    display: inline-block;
    padding: 3px 8px;
    border-radius: 12px;
    font-size: 0.75em;
    background-color: #e9e9e9;
}

.rule-type-badge.bidirectional {
    background-color: #d4edda;
    color: #155724;
}

.rule-type-badge.unicode_to_latex {
    background-color: #fff3cd;
    color: #856404;
}

.rule-type-badge.latex_to_unicode {
    background-color: #cce5ff;
    color: #004085;
}

.rule-item .actions-col {
    display: flex;
    gap: 5px;
    justify-content: flex-end;
}

.edit-button,
.delete-button {
    padding: 5px 10px;
    font-size: 12px;
    min-width: auto;
}

.edit-button {
    background-color: #6c757d;
}

.edit-button:hover {
    background-color: #5a6268;
}

.delete-button {
    background-color: #dc3545;
}

.delete-button:hover {
    background-color: #c82333;
}

/* Edit Mode */
.rule-item.editing {
    background-color: #fff3cd;
}

.rule-item.editing input {
    padding: 5px 8px;
    border: 1px solid #ccc;
    border-radius: 3px;
    font-family: Consolas, Monaco, 'Andale Mono', 'Ubuntu Mono', monospace;
    font-size: 13px;
    width: 100%;
    box-sizing: border-box;
}

.save-edit-button {
    background-color: #28a745;
}

.save-edit-button:hover {
    background-color: #218838;
}

.cancel-edit-button {
    background-color: #6c757d;
}

.cancel-edit-button:hover {
    background-color: #5a6268;
}

/* Empty State */
.rules-list-empty {
    padding: 40px 20px;
    text-align: center;
    color: #666;
    font-style: italic;
}

/* JSON View */
#rules-textarea {
    width: 100%;
    height: 400px;
    font-family: Consolas, Monaco, 'Andale Mono', 'Ubuntu Mono', monospace;
    font-size: 13px;
    box-sizing: border-box;
    margin-bottom: 10px;
}

#rule-status {
    margin-top: 10px;
    font-style: italic;
    color: green;
    min-height: 1.2em;
    text-align: center;
}

#rule-status.error {
    color: red;
}

/* Responsive */
@media (max-width: 768px) {
    .textarea-container {
        flex-direction: column;
    }
    .controls, .rule-buttons {
        flex-direction: column;
        align-items: stretch;
    }
    button {
        width: 100%;
    }
    .customization-header {
        flex-direction: column;
        gap: 15px;
    }
    .customization-header h2 {
        text-align: center;
    }
    .add-rule-form .form-row {
        flex-direction: column;
    }
    .form-group {
        width: 100%;
    }
    .add-button {
        width: 100%;
    }
    .search-filter-section {
        flex-direction: column;
    }
    .search-box {
        width: 100%;
    }
    .filter-buttons {
        width: 100%;
        justify-content: center;
    }
    .rules-list-header {
        display: none;
    }
    .rule-item {
        grid-template-columns: 1fr;
        gap: 5px;
    }
    .rule-item .unicode-col::before {
        content: "Unicode: ";
        font-weight: bold;
        font-family: sans-serif;
    }
    .rule-item .latex-col::before {
        content: "LaTeX: ";
        font-weight: bold;
        font-family: sans-serif;
    }
    .rule-item .actions-col {
        justify-content: flex-start;
        margin-top: 10px;
    }
}