* {
    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;
    --success-color: #27ae60;
    --error-color: #e74c3c;
    --warning-color: #f39c12;
}

[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 {
    max-width: 1400px;
    margin: 2rem auto;
    padding: 0 20px;
}

.mode-selector {
    display: flex;
    gap: 0.5rem;
    margin-bottom: 2rem;
    background: var(--bg-secondary);
    padding: 0.5rem;
    border-radius: 8px;
    width: fit-content;
    box-shadow: 0 2px 10px rgba(0,0,0,0.1);
}

.mode-btn {
    padding: 0.8rem 1.5rem;
    border: none;
    background: transparent;
    color: var(--text-secondary);
    border-radius: 6px;
    cursor: pointer;
    font-size: 0.95rem;
    font-weight: 500;
    transition: all 0.3s ease;
}

.mode-btn.active {
    background: var(--header-bg);
    color: var(--header-text);
}

.mode-btn:hover:not(.active) {
    background: var(--border-color);
    color: var(--text-primary);
}

.mode-content {
    display: none;
    gap: 20px;
}

.mode-content.active {
    display: flex;
}

.input-section, .output-section, .file-section, .file-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-group {
    display: flex;
    gap: 0.5rem;
    align-items: center;
}

.format-select {
    padding: 0.5rem 0.8rem;
    border: 1px solid var(--border-color);
    border-radius: 4px;
    background: var(--bg-secondary);
    color: var(--text-primary);
    font-size: 0.9rem;
    cursor: pointer;
}

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: var(--error-color);
    color: white;
}

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

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

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

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

.download-btn:hover:not(:disabled) {
    background-color: #2980b9;
}

.download-btn:disabled {
    background-color: var(--text-secondary);
    cursor: not-allowed;
    opacity: 0.6;
}

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

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

#textInput {
    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);
    min-height: 400px;
}

.output-display {
    flex: 1;
    width: 100%;
    padding: 1.5rem;
    border: none;
    font-family: 'Consolas', 'Monaco', 'Courier New', monospace;
    font-size: 14px;
    line-height: 1.5;
    background-color: var(--output-bg);
    color: var(--text-primary);
    min-height: 400px;
    overflow: auto;
    white-space: pre-wrap;
    word-wrap: break-word;
}

.output-display:empty::before {
    content: attr(data-placeholder);
    color: var(--text-secondary);
    font-style: italic;
}

/* Syntax Highlighting */
.syntax-highlighted {
    font-family: 'Consolas', 'Monaco', 'Courier New', monospace;
    line-height: 1.5;
    white-space: pre-wrap;
    overflow-wrap: break-word;
}

.json-key {
    color: #0066cc;
    font-weight: 500;
}

.json-string {
    color: #067d17;
}

.json-number {
    color: #1c00cf;
}

.json-boolean {
    color: #d73e48;
    font-weight: 500;
}

.json-null {
    color: #808080;
    font-style: italic;
}

.json-punctuation {
    color: #333333;
}

.xml-tag {
    color: #0066cc;
    font-weight: 500;
}

.xml-attribute {
    color: #d73e48;
}

.xml-value {
    color: #067d17;
}

.xml-text {
    color: #333333;
}

.xml-declaration {
    color: #808080;
    font-style: italic;
}

.yaml-key {
    color: #0066cc;
    font-weight: 500;
}

.yaml-string {
    color: #067d17;
}

.yaml-number {
    color: #1c00cf;
}

.yaml-boolean {
    color: #d73e48;
    font-weight: 500;
}

.yaml-null {
    color: #808080;
    font-style: italic;
}

.yaml-array-indicator {
    color: #333333;
    font-weight: bold;
}

.csv-header {
    color: #0066cc;
    font-weight: 600;
    background-color: rgba(0, 102, 204, 0.1);
}

.csv-value {
    color: #333333;
}

.csv-number {
    color: #1c00cf;
}

.csv-quoted {
    color: #067d17;
}

/* Dark theme adjustments */
[data-theme="dark"] .json-key,
[data-theme="dark"] .xml-tag,
[data-theme="dark"] .yaml-key {
    color: #4fc3f7;
}

[data-theme="dark"] .json-string,
[data-theme="dark"] .xml-value,
[data-theme="dark"] .yaml-string,
[data-theme="dark"] .csv-quoted {
    color: #81c784;
}

[data-theme="dark"] .json-number,
[data-theme="dark"] .yaml-number,
[data-theme="dark"] .csv-number {
    color: #ba68c8;
}

[data-theme="dark"] .json-boolean,
[data-theme="dark"] .xml-attribute,
[data-theme="dark"] .yaml-boolean {
    color: #f06292;
}

[data-theme="dark"] .json-null,
[data-theme="dark"] .yaml-null,
[data-theme="dark"] .xml-declaration {
    color: #90a4ae;
}

[data-theme="dark"] .json-punctuation,
[data-theme="dark"] .xml-text,
[data-theme="dark"] .yaml-array-indicator,
[data-theme="dark"] .csv-value {
    color: #e0e0e0;
}

[data-theme="dark"] .csv-header {
    color: #4fc3f7;
    background-color: rgba(79, 195, 247, 0.1);
}

.validation-status {
    padding: 0.8rem 1.5rem;
    font-size: 0.9rem;
    border-top: 1px solid var(--border-color);
    min-height: 50px;
    display: flex;
    align-items: center;
}

.validation-status.valid {
    background-color: rgba(39, 174, 96, 0.1);
    color: var(--success-color);
}

.validation-status.invalid {
    background-color: rgba(231, 76, 60, 0.1);
    color: var(--error-color);
}

.validation-status.warning {
    background-color: rgba(243, 156, 18, 0.1);
    color: var(--warning-color);
}

.file-upload-area {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    min-height: 300px;
    border: 2px dashed var(--border-color);
    border-radius: 8px;
    margin: 1.5rem;
    transition: all 0.3s ease;
}

.file-upload-area.dragover {
    border-color: var(--success-color);
    background-color: rgba(39, 174, 96, 0.05);
}

.file-upload-label {
    display: flex;
    flex-direction: column;
    align-items: center;
    cursor: pointer;
    padding: 2rem;
    text-align: center;
    width: 100%;
}

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

.file-upload-label p {
    margin: 0.5rem 0;
    color: var(--text-primary);
}

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

.file-info-display {
    background: var(--output-bg);
    border-radius: 6px;
    padding: 1rem;
    margin-top: 1rem;
    width: calc(100% - 3rem);
    display: none;
}

.file-info-display.show {
    display: block;
}

.file-details {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 0.5rem;
}

.file-name {
    font-weight: 500;
    color: var(--text-primary);
}

.file-size {
    color: var(--text-secondary);
    font-size: 0.9rem;
}

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;
}

.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: 700px;
    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: 6px;
    padding: 1rem;
    margin-bottom: 1rem;
    cursor: pointer;
    transition: all 0.2s ease;
}

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

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

.conversion-info {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    font-size: 0.9rem;
    font-weight: 500;
    color: var(--text-primary);
}

.format-arrow {
    color: var(--text-secondary);
}

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

.history-delete {
    background-color: var(--error-color);
    color: white;
    padding: 0.2rem 0.5rem;
    font-size: 0.7rem;
    border: none;
    border-radius: 3px;
    cursor: pointer;
    margin-left: 0.5rem;
}

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

.history-preview {
    font-family: 'Consolas', 'Monaco', 'Courier New', monospace;
    font-size: 0.8rem;
    color: var(--text-primary);
    background: var(--bg-secondary);
    padding: 0.8rem;
    border-radius: 4px;
    border: 1px solid var(--border-color);
    white-space: pre-wrap;
    overflow: hidden;
    max-height: 100px;
    position: relative;
}

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

@media (max-width: 768px) {
    .mode-content {
        flex-direction: column;
    }

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

    header h1 {
        font-size: 1.5rem;
    }

    header p {
        font-size: 0.9rem;
    }

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

    .container {
        padding: 0 15px;
    }

    .file-upload-area {
        margin: 1rem;
        min-height: 250px;
    }

    .upload-icon {
        font-size: 2.5rem;
    }
}