/* Reset e estilos globais */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: #333;
    min-height: 100vh;
    padding: 20px;
}

.container {
    max-width: 1400px;
    margin: 0 auto;
    background: #fff;
    border-radius: 12px;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.3);
    overflow: hidden;
}

/* Header */
header {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    padding: 30px;
    text-align: center;
}

header h1 {
    font-size: 2.5rem;
    font-weight: 700;
    margin-bottom: 10px;
}

header .subtitle {
    font-size: 1.1rem;
    opacity: 0.9;
}

/* Controles */
.controls-section {
    display: flex;
    flex-wrap: wrap;
    gap: 20px;
    padding: 20px 30px;
    background: #f8f9fa;
    border-bottom: 1px solid #e0e0e0;
    align-items: center;
}

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

.control-group label {
    font-weight: 500;
    color: #555;
}

.checkbox-group {
    margin-left: auto;
}

#indentSelect {
    padding: 8px 12px;
    border: 2px solid #ddd;
    border-radius: 6px;
    font-size: 14px;
    background: white;
    cursor: pointer;
    transition: border-color 0.3s;
}

#indentSelect:hover,
#indentSelect:focus {
    border-color: #667eea;
    outline: none;
}

input[type="checkbox"] {
    width: 18px;
    height: 18px;
    cursor: pointer;
}

/* Botões */
.btn {
    padding: 10px 24px;
    border: none;
    border-radius: 6px;
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.btn-primary {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
}

.btn-primary:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(102, 126, 234, 0.4);
}

.btn-secondary {
    background: #6c757d;
    color: white;
}

.btn-secondary:hover {
    background: #5a6268;
    transform: translateY(-2px);
}

.btn-small {
    padding: 6px 14px;
    border: none;
    border-radius: 4px;
    font-size: 12px;
    font-weight: 600;
    cursor: pointer;
    background: #667eea;
    color: white;
    transition: all 0.3s;
}

.btn-small:hover {
    background: #5568d3;
    transform: translateY(-1px);
}

.btn-small.active {
    background: #28a745;
}

/* Conteúdo principal */
.main-content {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 20px;
    padding: 30px;
    min-height: 500px;
}

.panel {
    display: flex;
    flex-direction: column;
    border: 2px solid #e0e0e0;
    border-radius: 8px;
    overflow: hidden;
    background: #fff;
}

.panel-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 15px 20px;
    background: #f8f9fa;
    border-bottom: 2px solid #e0e0e0;
}

.panel-header h2 {
    font-size: 1.3rem;
    color: #333;
    font-weight: 600;
}

.input-options,
.output-options {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
}

/* Textarea e Pre */
#inputJson {
    flex: 1;
    padding: 20px;
    border: none;
    font-family: 'Courier New', Courier, monospace;
    font-size: 14px;
    line-height: 1.6;
    resize: none;
    background: #fafafa;
}

#inputJson:focus {
    outline: none;
    background: #fff;
}

#outputJson {
    flex: 1;
    padding: 20px;
    margin: 0;
    font-family: 'Courier New', Courier, monospace;
    font-size: 14px;
    line-height: 1.6;
    background: #fafafa;
    overflow: auto;
    white-space: pre-wrap;
    word-wrap: break-word;
}

.panel-footer {
    padding: 10px 20px;
    background: #f8f9fa;
    border-top: 1px solid #e0e0e0;
    display: flex;
    justify-content: space-between;
    align-items: center;
    font-size: 12px;
}

.stats {
    color: #666;
}

.validation-status {
    font-weight: 600;
}

.validation-status.valid {
    color: #28a745;
}

.validation-status.invalid {
    color: #dc3545;
}

/* Painel de erro */
.error-panel {
    margin: 0 30px 30px;
    padding: 20px;
    background: #fff3cd;
    border: 2px solid #ffc107;
    border-radius: 8px;
    position: relative;
    animation: fadeIn 0.3s ease-out;
}

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

.error-header h3 {
    color: #856404;
    font-size: 1.2rem;
}

.close-btn {
    background: none;
    border: none;
    font-size: 28px;
    cursor: pointer;
    color: #856404;
    line-height: 1;
    padding: 0;
    width: 30px;
    height: 30px;
}

.close-btn:hover {
    color: #533f03;
}

.error-message {
    color: #856404;
    font-family: 'Courier New', Courier, monospace;
    font-size: 14px;
    white-space: pre-wrap;
    line-height: 1.6;
}

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

.modal-content {
    background: white;
    border-radius: 8px;
    width: 90%;
    max-width: 500px;
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.3);
}

.modal-header {
    padding: 20px;
    border-bottom: 1px solid #e0e0e0;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.modal-header h3 {
    font-size: 1.4rem;
    color: #333;
}

.modal-body {
    padding: 20px;
}

#urlInput {
    width: 100%;
    padding: 12px;
    border: 2px solid #ddd;
    border-radius: 6px;
    font-size: 14px;
    font-family: 'Courier New', Courier, monospace;
}

#urlInput:focus {
    outline: none;
    border-color: #667eea;
}

.modal-note {
    margin-top: 10px;
    font-size: 12px;
    color: #666;
    font-style: italic;
}

.modal-footer {
    padding: 20px;
    border-top: 1px solid #e0e0e0;
    display: flex;
    justify-content: flex-end;
    gap: 10px;
}

/* Footer */
footer {
    padding: 20px;
    text-align: center;
    background: #f8f9fa;
    color: #666;
    font-size: 14px;
    border-top: 1px solid #e0e0e0;
}

/* ========== TREEVIEW STYLES ========== */
.treeview-container {
    flex: 1;
    padding: 15px;
    background: #fafafa;
    overflow: auto;
    font-family: 'Courier New', Courier, monospace;
    font-size: 14px;
    line-height: 1.5;
}

.tree-node {
    margin-left: 0;
}

.tree-node .tree-node {
    margin-left: 20px;
}

.tree-item {
    display: flex;
    align-items: flex-start;
    padding: 3px 0;
    cursor: default;
}

.tree-toggle {
    width: 18px;
    height: 18px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    color: #667eea;
    font-weight: bold;
    font-size: 12px;
    margin-right: 4px;
    border-radius: 3px;
    transition: background 0.2s;
    flex-shrink: 0;
}

.tree-toggle:hover {
    background: #e3e8ff;
}

.tree-toggle.empty {
    visibility: hidden;
}

.tree-key {
    color: #881391;
    font-weight: 600;
}

.tree-colon {
    color: #333;
    margin: 0 4px;
}

.tree-value {
    color: #1A1AA6;
}

.tree-value.string {
    color: #1A1AA6;
}

.tree-value.number {
    color: #1C00CF;
}

.tree-value.boolean {
    color: #0000FF;
    font-weight: 600;
}

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

.tree-bracket {
    color: #333;
    font-weight: 600;
}

.tree-type-badge {
    font-size: 10px;
    padding: 1px 5px;
    border-radius: 3px;
    margin-left: 6px;
    font-weight: 500;
}

.tree-type-badge.object {
    background: #e3e8ff;
    color: #667eea;
}

.tree-type-badge.array {
    background: #d4edda;
    color: #28a745;
}

.tree-children {
    display: block;
}

.tree-children.collapsed {
    display: none;
}

.tree-item:hover {
    background: #f0f4ff;
    border-radius: 4px;
}

.view-toggle-group {
    display: flex;
    gap: 4px;
    margin-right: 10px;
}

.view-toggle-group .btn-small {
    background: #e0e0e0;
    color: #555;
}

.view-toggle-group .btn-small.active {
    background: #667eea;
    color: white;
}

/* Responsivo */
@media (max-width: 968px) {
    .main-content {
        grid-template-columns: 1fr;
    }

    header h1 {
        font-size: 2rem;
    }

    .controls-section {
        flex-direction: column;
        align-items: stretch;
    }

    .checkbox-group {
        margin-left: 0;
    }

    .control-group {
        justify-content: space-between;
    }
}

@media (max-width: 600px) {
    body {
        padding: 10px;
    }

    header {
        padding: 20px;
    }

    header h1 {
        font-size: 1.5rem;
    }

    header .subtitle {
        font-size: 0.9rem;
    }

    .controls-section {
        padding: 15px;
    }

    .main-content {
        padding: 15px;
    }

    .panel-header {
        flex-direction: column;
        align-items: flex-start;
        gap: 10px;
    }

    .input-options,
    .output-options {
        width: 100%;
        justify-content: flex-start;
    }
}

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

/* Syntax highlighting para JSON */
.json-key {
    color: #881391;
}

.json-string {
    color: #1A1AA6;
}

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

.json-boolean {
    color: #0000FF;
}

.json-null {
    color: #808080;
}