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

:root {
    --bg-primary: #f5f5f5;
    --bg-secondary: #ffffff;
    --text-primary: #333333;
    --text-secondary: #7f8c8d;
    --border-color: #e0e0e0;
    --header-bg: #2c3e50;
    --header-text: #ffffff;
    --output-bg: #f8f8f8;
}

[data-theme="dark"] {
    --bg-primary: #1a1a1a;
    --bg-secondary: #2d2d2d;
    --text-primary: #e0e0e0;
    --text-secondary: #a0a0a0;
    --border-color: #404040;
    --header-bg: #1f1f1f;
    --header-text: #e0e0e0;
    --output-bg: #1f1f1f;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
    background-color: var(--bg-primary);
    color: var(--text-primary);
    transition: background-color 0.3s ease, color 0.3s ease;
    line-height: 1.6;
    min-height: 100vh;
    display: flex;
    flex-direction: column;
}

header {
    background-color: var(--header-bg);
    color: var(--header-text);
    padding: 1.5rem 0;
    box-shadow: 0 2px 5px rgba(0,0,0,0.1);
}

main {
    flex: 1;
    width: 100%;
}


.header-content {
    max-width: 1400px;
    margin: 0 auto;
    padding: 0 20px;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

header h1 {
    font-size: 2rem;
    margin-bottom: 0.5rem;
}

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

.header-actions {
    display: flex;
    align-items: center;
    gap: 1rem;
}

.fixit-link {
    display: inline-flex;
    flex-direction: column;
    align-items: center;
    padding: 0.4rem 1rem;
    background: rgba(255, 255, 255, 0.1);
    color: var(--header-text);
    text-decoration: none;
    border-radius: 8px;
    font-weight: 500;
    transition: all 0.3s ease;
    line-height: 1.2;
}

.fixit-link .more-tools {
    font-size: 0.7rem;
    opacity: 0.8;
    margin-bottom: 0.1rem;
    display: block;
    text-align: center;
    padding-left: 0.3rem;
}

.fixit-link .fixit-name {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.3rem;
}


.fixit-link:hover {
    background: rgba(255, 255, 255, 0.2);
    transform: translateY(-2px);
}

.theme-toggle {
    background: transparent;
    border: 2px solid var(--header-text);
    color: var(--header-text);
    width: 40px;
    height: 40px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.2rem;
    cursor: pointer;
    transition: transform 0.3s ease;
}

.theme-toggle:hover {
    transform: scale(1.1);
}

.container {
    display: flex;
    gap: 20px;
    max-width: 1400px;
    margin: 2rem auto;
    padding: 0 20px;
    min-height: 600px;
}

.input-section, .output-section {
    flex: 1;
    background: var(--bg-secondary);
    border-radius: 8px;
    box-shadow: 0 2px 10px rgba(0,0,0,0.1);
    display: flex;
    flex-direction: column;
    position: relative;
}

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

.section-header h2 {
    font-size: 1.25rem;
    color: var(--text-primary);
}

button {
    padding: 0.5rem 1rem;
    border: none;
    border-radius: 4px;
    cursor: pointer;
    font-size: 0.9rem;
    transition: background-color 0.3s ease;
}

.clear-btn {
    background-color: #e74c3c;
    color: white;
}

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

.copy-btn {
    background-color: #27ae60;
    color: white;
}

.copy-btn:hover {
    background-color: #229954;
}

#jsonInput {
    flex: 1;
    width: 100%;
    padding: 1.5rem;
    border: none;
    resize: none;
    font-family: 'Consolas', 'Monaco', 'Courier New', monospace;
    font-size: 14px;
    line-height: 1.5;
    outline: none;
    background-color: transparent;
    color: var(--text-primary);
}

#jsonOutput {
    flex: 1;
    padding: 1.5rem;
    margin: 0;
    overflow: auto;
    font-family: 'Consolas', 'Monaco', 'Courier New', monospace;
    font-size: 14px;
    line-height: 1.5;
    background-color: var(--output-bg);
    color: var(--text-primary);
}

.error {
    color: #e74c3c;
    font-weight: bold;
}

footer {
    background-color: var(--header-bg);
    color: var(--header-text);
    text-align: center;
    padding: 2rem 0;
    margin-top: auto;
}

footer p {
    margin: 0.5rem 0;
    font-size: 0.9rem;
}

footer a {
    color: var(--header-text);
    text-decoration: none;
    opacity: 0.8;
    transition: opacity 0.3s ease;
}

footer a:hover {
    opacity: 1;
    text-decoration: underline;
}

.button-group {
    display: flex;
    gap: 0.5rem;
}

.history-btn {
    background-color: #3498db;
    color: white;
}

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

.modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background-color: rgba(0, 0, 0, 0.5);
    display: none;
    align-items: center;
    justify-content: center;
    z-index: 1000;
    padding: 20px;
}

.modal-overlay.show {
    display: flex;
}

.modal-content {
    background: var(--bg-secondary);
    border-radius: 12px;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.3);
    width: 100%;
    max-width: 600px;
    max-height: 80vh;
    display: flex;
    flex-direction: column;
    animation: modalSlideIn 0.3s ease;
}

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

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

.modal-header h2 {
    color: var(--text-primary);
    font-size: 1.5rem;
    margin: 0;
}

.modal-close {
    background: none;
    border: none;
    font-size: 2rem;
    color: var(--text-secondary);
    cursor: pointer;
    width: 40px;
    height: 40px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
    transition: background-color 0.2s ease;
}

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

.modal-body {
    flex: 1;
    overflow: hidden;
    display: flex;
    flex-direction: column;
}

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

.history-info {
    color: var(--text-secondary);
    font-size: 0.9rem;
    margin: 0;
}

.clear-history-btn {
    background-color: #95a5a6;
    color: white;
    font-size: 0.8rem;
    padding: 0.4rem 0.8rem;
}

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

.history-list {
    flex: 1;
    overflow-y: auto;
    padding: 1.5rem;
}

.history-item {
    background: var(--output-bg);
    border: 1px solid var(--border-color);
    border-radius: 4px;
    padding: 0.8rem;
    margin-bottom: 0.8rem;
    cursor: pointer;
    transition: box-shadow 0.2s ease;
}

.history-item:hover {
    box-shadow: 0 2px 8px rgba(0,0,0,0.1);
}

.history-item.active {
    background: var(--header-bg);
    border-color: var(--header-bg);
}

.history-item.active .history-date,
.history-item.active .history-preview {
    color: var(--header-text);
}

.history-item-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 0.5rem;
}

.history-date {
    font-size: 0.8rem;
    color: var(--text-secondary);
}

.history-delete {
    background-color: #e74c3c;
    color: white;
    padding: 0.2rem 0.5rem;
    font-size: 0.7rem;
    border: none;
    border-radius: 3px;
    cursor: pointer;
}

.history-delete:hover {
    background-color: #c0392b;
}

.history-preview {
    font-family: 'Consolas', 'Monaco', 'Courier New', monospace;
    font-size: 0.85rem;
    color: var(--text-primary);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    max-width: 100%;
}

.empty-history {
    text-align: center;
    padding: 3rem;
    color: var(--text-secondary);
}

@media (max-width: 768px) {
    .container {
        flex-direction: column;
        min-height: auto;
    }

    .input-section, .output-section {
        min-height: 400px;
    }

    header h1 {
        font-size: 1.5rem;
    }

    header p {
        font-size: 0.9rem;
    }

    .header-content {
        flex-direction: column;
        text-align: center;
        gap: 1rem;
    }
}