/* ============================================================
   JSON Formatter - Main Stylesheet
   ============================================================ */

/* Base */
:root {
    --tool-bg: #f8f9fa;
    --panel-border: #dee2e6;
    --tree-indent: 20px;
    --diff-added-bg: #d4edda;
    --diff-added-border: #c3e6cb;
    --diff-removed-bg: #f8d7da;
    --diff-removed-border: #f5c6cb;
    --diff-modified-bg: #fff3cd;
    --diff-modified-border: #ffeeba;
}

body {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    background-color: #f5f6f8;
    color: #212529;
    min-height: 100vh;
    display: flex;
    flex-direction: column;
}

main {
    flex: 1 0 auto;
}

/* Navbar */
.navbar {
    box-shadow: 0 2px 8px rgba(0,0,0,0.15);
}

.navbar-brand {
    font-size: 1.25rem;
    letter-spacing: -0.3px;
}

.navbar-dark .navbar-nav .nav-link {
    color: rgba(255,255,255,0.85);
    font-weight: 500;
    font-size: 0.9rem;
    transition: color 0.15s ease;
}

.navbar-dark .navbar-nav .nav-link:hover {
    color: #fff;
}

.dropdown-menu {
    border: none;
    box-shadow: 0 4px 16px rgba(0,0,0,0.12);
    border-radius: 0.5rem;
    font-size: 0.875rem;
}

.dropdown-item {
    padding: 0.5rem 1.25rem;
    transition: background-color 0.15s ease;
}

.dropdown-item i {
    width: 16px;
    text-align: center;
}

.dropdown-item.active,
.dropdown-item:active {
    background-color: #0d6efd;
}

/* CodeMirror Container */
.CodeMirror {
    border: 2px solid var(--panel-border);
    border-radius: 0.5rem;
    font-family: 'Consolas', 'Monaco', 'Courier New', monospace;
    font-size: 0.85rem;
    line-height: 1.6;
    height: auto;
    min-height: 400px;
    transition: border-color 0.2s ease, box-shadow 0.2s ease;
}

.CodeMirror-focused {
    border-color: #86b7fe;
    box-shadow: 0 0 0 0.2rem rgba(13, 110, 253, 0.15);
}

.CodeMirror-gutters {
    border-right: 1px solid #ddd;
    background-color: #f7f7f7;
    border-radius: 0.5rem 0 0 0.5rem;
}

.CodeMirror-linenumber {
    color: #999;
    padding: 0 6px 0 4px;
    font-size: 0.75rem;
}

.editor-cm .CodeMirror {
    min-height: 500px;
}

.diff-cm .CodeMirror {
    min-height: 350px;
}

/* CodeMirror lint markers */
.CodeMirror-lint-mark-error {
    background-image: url('data:image/svg+xml;utf8,<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 16 16"><circle cx="8" cy="8" r="6" fill="%23dc3545" opacity="0.7"/></svg>');
}

.CodeMirror-lint-mark-warning {
    background-image: url('data:image/svg+xml;utf8,<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 16 16"><polygon points="8,1 15,14 1,14" fill="%23ffc107" opacity="0.7"/></svg>');
}

/* Legacy Textarea Fallback */
.json-textarea {
    font-family: 'Consolas', 'Monaco', 'Courier New', monospace;
    font-size: 0.85rem;
    line-height: 1.6;
    min-height: 400px;
    resize: vertical;
    border: 2px solid var(--panel-border);
    border-radius: 0.5rem;
    transition: border-color 0.2s ease, box-shadow 0.2s ease;
    background-color: #fff;
}

.json-textarea:focus {
    border-color: #86b7fe;
    box-shadow: 0 0 0 0.2rem rgba(13, 110, 253, 0.15);
    outline: none;
}

.editor-textarea {
    min-height: 500px;
}

/* Tool Controls Bar */
.tool-controls-bar {
    border: 2px solid var(--panel-border);
    border-radius: 0.75rem;
    background: #fff;
}

.tool-controls-bar .btn {
    font-size: 0.85rem;
    font-weight: 500;
    padding: 0.45rem 0.9rem;
    border-radius: 0.4rem;
    transition: all 0.15s ease;
}

.tool-controls-bar .btn-primary {
    background-color: #0d6efd;
    border-color: #0d6efd;
    box-shadow: 0 2px 4px rgba(13,110,253,0.2);
}

.tool-controls-bar .btn-primary:hover {
    background-color: #0b5ed7;
    transform: translateY(-1px);
    box-shadow: 0 4px 8px rgba(13,110,253,0.25);
}

.tool-controls-bar .btn-outline-success {
    color: #198754;
    border-color: #198754;
}

.tool-controls-bar .btn-outline-success:hover {
    background-color: #198754;
    border-color: #198754;
    color: #fff;
}

.tool-controls-bar .btn-outline-info {
    color: #0dcaf0;
    border-color: #0dcaf0;
}

.tool-controls-bar .btn-outline-info:hover {
    background-color: #0dcaf0;
    border-color: #0dcaf0;
    color: #000;
}

/* Tree View */
.tree-view {
    font-family: 'Consolas', 'Monaco', 'Courier New', monospace;
    font-size: 0.85rem;
    line-height: 1.8;
}

.tree-view ul {
    list-style: none;
    padding-left: 0;
    margin: 0;
}

.tree-view ul ul {
    padding-left: var(--tree-indent);
    border-left: 1px dashed #d0d5dd;
    margin-left: 8px;
}

.tree-view li {
    position: relative;
    padding: 1px 0;
    cursor: default;
}

.tree-view li.collapsible {
    cursor: pointer;
}

.tree-view li.collapsible > ul.collapsed {
    display: none;
}

.tree-toggle {
    display: inline-block;
    width: 16px;
    cursor: pointer;
    user-select: none;
    color: #6c757d;
    font-size: 0.7rem;
    transition: transform 0.15s ease;
}

.tree-toggle:hover {
    color: #0d6efd;
}

.tree-key {
    color: #7d3c98;
    font-weight: 500;
}

.tree-bracket {
    color: #6c757d;
    margin: 0 2px;
}

.tree-count {
    color: #6c757d;
    font-size: 0.8rem;
    font-style: italic;
    margin-left: 4px;
}

/* JSON Syntax Highlighting */
.json-string {
    color: #0b8a3e;
}

.json-number {
    color: #0550ae;
}

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

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

/* Badge Sizes */
.badge-sm {
    font-size: 0.75rem;
    padding: 0.15em 0.5em;
    font-weight: 500;
}

/* Diff Styles */
.diff-list {
    font-family: 'Consolas', 'Monaco', 'Courier New', monospace;
    font-size: 0.85rem;
}

.diff-item {
    border: 1px solid transparent;
    transition: background-color 0.2s ease;
}

.diff-added {
    background-color: var(--diff-added-bg);
    border-color: var(--diff-added-border);
    color: #0f5132;
}

.diff-removed {
    background-color: var(--diff-removed-bg);
    border-color: var(--diff-removed-border);
    color: #842029;
}

.diff-modified {
    background-color: var(--diff-modified-bg);
    border-color: var(--diff-modified-border);
    color: #664d03;
}

/* Footer */
footer {
    border-top: 3px solid #0d6efd;
}

footer .text-muted {
    color: rgba(255,255,255,0.65) !important;
}

footer a.text-muted {
    color: rgba(255,255,255,0.55) !important;
}

footer a.text-muted:hover {
    color: #fff !important;
}

footer .list-unstyled li {
    margin-bottom: 0.3rem;
}

/* Cards */
.card {
    border-radius: 0.75rem;
    box-shadow: 0 1px 3px rgba(0,0,0,0.06);
    transition: box-shadow 0.2s ease, transform 0.2s ease;
}

.card:hover {
    box-shadow: 0 4px 12px rgba(0,0,0,0.1);
    transform: translateY(-2px);
}

.card-header {
    border-bottom: 1px solid var(--panel-border);
}

/* Buttons */
.btn {
    border-radius: 0.4rem;
    transition: all 0.15s ease;
}

/* Accordion */
.accordion-button:not(.collapsed) {
    background-color: rgba(13, 110, 253, 0.05);
    color: #0d6efd;
}

.accordion-button:focus {
    box-shadow: none;
    border-color: #86b7fe;
}

/* Toast Notification */
.toast-notification {
    position: fixed;
    bottom: 24px;
    right: 24px;
    padding: 0.75rem 1.25rem;
    border-radius: 0.5rem;
    font-size: 0.875rem;
    font-weight: 500;
    color: #fff;
    opacity: 0;
    transform: translateY(20px);
    transition: all 0.3s ease;
    z-index: 9999;
    box-shadow: 0 4px 16px rgba(0,0,0,0.2);
}

.toast-notification.show {
    opacity: 1;
    transform: translateY(0);
}

.toast-success {
    background-color: #198754;
}

.toast-error {
    background-color: #dc3545;
}

.toast-info {
    background-color: #0dcaf0;
    color: #000;
}

/* Loading Spinner */
.spinner-overlay {
    position: absolute;
    inset: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    background: rgba(255,255,255,0.7);
    z-index: 10;
    border-radius: 0.5rem;
}

/* Responsive */
@media (max-width: 767.98px) {
    .json-textarea {
        min-height: 250px;
    }

    .editor-textarea {
        min-height: 300px;
    }

    .tool-controls-bar {
        gap: 0.35rem !important;
    }

    .tool-controls-bar .btn {
        font-size: 0.8rem;
        padding: 0.35rem 0.7rem;
    }

    .tree-view {
        font-size: 0.78rem;
    }
}

@media (max-width: 575.98px) {
    h1.h3 {
        font-size: 1.25rem;
    }

    .card-body {
        padding: 1rem;
    }

    footer {
        text-align: center;
    }
}

/* Scrollbar Styling */
.json-textarea::-webkit-scrollbar,
.tree-view::-webkit-scrollbar {
    width: 8px;
    height: 8px;
}

.json-textarea::-webkit-scrollbar-track,
.tree-view::-webkit-scrollbar-track {
    background: #f1f1f1;
    border-radius: 4px;
}

.json-textarea::-webkit-scrollbar-thumb,
.tree-view::-webkit-scrollbar-thumb {
    background: #c1c1c1;
    border-radius: 4px;
}

.json-textarea::-webkit-scrollbar-thumb:hover,
.tree-view::-webkit-scrollbar-thumb:hover {
    background: #a8a8a8;
}

/* Smooth transitions */
a, button, .card, .json-textarea, .dropdown-item {
    transition: all 0.15s ease;
}

/* Focus visible for accessibility */
:focus-visible {
    outline: 2px solid #0d6efd;
    outline-offset: 2px;
}

/* Select styling */
.form-select-sm {
    border-radius: 0.4rem;
    font-size: 0.85rem;
}

/* Text muted link hover */
.text-decoration-none:hover {
    text-decoration: underline !important;
}

/* Flag icon in language dropdown */
.flag-icon {
    flex-shrink: 0;
}

.language-dropdown .dropdown-item {
    padding: 0.5rem 1rem;
    font-size: 0.875rem;
}

.language-dropdown .dropdown-item.active {
    background-color: rgba(13, 110, 253, 0.1);
    color: #0d6efd;
    font-weight: 600;
}

/* Tree view enhancements */
.tree-root {
    padding-left: 0 !important;
}

.tree-toggle-empty {
    display: inline-block;
    width: 16px;
    flex-shrink: 0;
}

/* TOS / Privacy content styling */
.tos-content h5,
.privacy-content h5 {
    color: #212529;
}

.tos-content p,
.privacy-content p {
    line-height: 1.8;
}

/* Breadcrumb */
.breadcrumb {
    font-size: 0.875rem;
}

/* SEO content section */
.seo-content-section {
    background: linear-gradient(135deg, #f8f9fa 0%, #e9ecef 100%);
}

.seo-content-section h2 {
    font-size: 1.5rem;
}

.seo-content-section h3 {
    font-size: 1.2rem;
}

.seo-content-section p,
.seo-content-section li {
    line-height: 1.8;
    color: #495057;
}
