/* Custom Styles for JSON Formatter */
/* SEO-Optimized with fast loading and accessibility */

:root {
    --primary-color: #2563eb;
    --success-color: #16a34a;
    --error-color: #dc2626;
    --bg-code: #f8fafc;
}

/* Smooth scrolling */
html {
    scroll-behavior: smooth;
}

/* Custom scrollbar */
::-webkit-scrollbar {
    width: 8px;
    height: 8px;
}

::-webkit-scrollbar-track {
    background: #f1f1f1;
}

::-webkit-scrollbar-thumb {
    background: #c1c1c1;
    border-radius: 4px;
}

::-webkit-scrollbar-thumb:hover {
    background: #a8a8a8;
}

/* JSON Syntax Highlighting */
.json-key {
    color: #d946ef;
    font-weight: 600;
}

.json-string {
    color: #16a34a;
}

.json-number {
    color: #2563eb;
}

.json-boolean {
    color: #ea580c;
    font-weight: 600;
}

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

/* Tree View Styles */
.tree-node {
    margin-left: 20px;
    position: relative;
}

.tree-node::before {
    content: '';
    position: absolute;
    left: -12px;
    top: 0;
    bottom: 0;
    width: 1px;
    background: #e5e7eb;
}

.tree-toggle {
    cursor: pointer;
    user-select: none;
    display: inline-flex;
    align-items: center;
    color: #6b7280;
}

.tree-toggle:hover {
    color: #2563eb;
}

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

.tree-icon {
    width: 16px;
    height: 16px;
    margin-right: 4px;
    transition: transform 0.2s;
}

.tree-collapsed .tree-icon {
    transform: rotate(-90deg);
}

/* Editor focus states */
textarea:focus {
    background-color: #fafafa;
}

/* Loading animation */
.loading {
    display: inline-block;
    width: 20px;
    height: 20px;
    border: 3px solid rgba(255,255,255,.3);
    border-radius: 50%;
    border-top-color: #fff;
    animation: spin 1s ease-in-out infinite;
}

@keyframes spin {
    to { transform: rotate(360deg); }
}

/* Success/Error states */
.status-success {
    color: var(--success-color);
}

.status-error {
    color: var(--error-color);
}

/* Print styles */
@media print {
    header, footer, .no-print {
        display: none;
    }
    
    textarea {
        border: 1px solid #ccc;
    }
}

/* Mobile optimizations */
@media (max-width: 768px) {
    textarea {
        font-size: 16px; /* Prevent zoom on iOS */
    }
}

/* Accessibility */
.sr-only {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    border-width: 0;
}

/* Focus visible for keyboard navigation */
button:focus-visible,
a:focus-visible,
textarea:focus-visible {
    outline: 2px solid var(--primary-color);
    outline-offset: 2px;
}