/* JSON Tools Suite - Shared Styles */

/* CSS Custom Properties for Theme System */
:root {
    /* Light theme colors */
    --bg-primary: #ffffff;
    --bg-secondary: #f8fafc;
    --bg-tertiary: #f1f5f9;
    --text-primary: #1e293b;
    --text-secondary: #64748b;
    --text-muted: #94a3b8;
    --border-color: #e2e8f0;
    --border-hover: #cbd5e1;

    /* Accent colors - more subtle */
    --accent-primary: #3b82f6;
    --accent-primary-hover: #2563eb;
    --accent-secondary: #6366f1;
    --accent-secondary-hover: #4f46e5;

    /* Status colors */
    --success-color: #10b981;
    --success-hover: #059669;
    --warning-color: #f59e0b;
    --warning-hover: #d97706;
    --error-color: #ef4444;
    --error-hover: #dc2626;

    /* Navigation colors */
    --nav-bg: var(--bg-secondary);
    --nav-text: var(--text-primary);
    --nav-text-hover: var(--accent-primary);
    --nav-active-bg: var(--accent-primary);
    --nav-active-text: #ffffff;

    /* Button colors */
    --btn-primary-bg: var(--accent-primary);
    --btn-primary-text: #ffffff;
    --btn-primary-hover: var(--accent-primary-hover);
    --btn-secondary-bg: var(--bg-tertiary);
    --btn-secondary-text: var(--text-primary);
    --btn-secondary-hover: var(--border-hover);
    --btn-success-bg: var(--success-color);
    --btn-success-text: #ffffff;
    --btn-success-hover: var(--success-hover);

    /* Shadows - Removed for cleaner design */

    /* Container backgrounds */
    --bg-container-light: #fafbfc;
    --bg-input-light: #f8fafc;
    --bg-output-light: #f1f5f9;

    /* Border radius */
    --radius-sm: 6px;
    --radius-md: 8px;
    --radius-lg: 12px;
}

/* Dark theme colors - applied via body.dark-mode OR html.dark-mode-loading */
body.dark-mode,
html.dark-mode-loading {
    --bg-primary: #0f172a;
    --bg-secondary: #1e293b;
    --bg-tertiary: #334155;
    --text-primary: #f8fafc;
    --text-secondary: #cbd5e1;
    --text-muted: #64748b;
    --border-color: #334155;
    --border-hover: #475569;

    /* Accent colors remain consistent but adjust for dark theme */
    --accent-primary: #3b82f6;
    --accent-primary-hover: #60a5fa;
    --accent-secondary: #6366f1;
    --accent-secondary-hover: #818cf8;

    /* Navigation colors for dark theme */
    --nav-bg: var(--bg-secondary);
    --nav-text: var(--text-primary);
    --nav-text-hover: var(--accent-primary-hover);
    --nav-active-bg: var(--accent-primary);
    --nav-active-text: #ffffff;

    /* Button colors for dark theme */
    --btn-secondary-bg: var(--bg-tertiary);
    --btn-secondary-text: var(--text-primary);
    --btn-secondary-hover: var(--border-hover);

    /* Shadows removed for cleaner design */

    /* Container backgrounds for dark theme */
    --bg-container-light: #1a202c;
    --bg-input-light: #2d3748;
    --bg-output-light: #374151;
}

/* Apply dark mode to body when html has dark-mode-loading */
html.dark-mode-loading body {
    background: var(--bg-primary);
    color: var(--text-primary);
}

/* Navigation Styles */
.json-tools-nav {
    background: var(--nav-bg);
    position: sticky;
    top: 0;
    z-index: 1000;
    transition: background-color 0.3s ease, border-color 0.3s ease;
}

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

.nav-brand {
    display: flex;
    align-items: center;
    gap: 10px;
    font-size: 1.3rem;
    font-weight: 700;
    color: var(--nav-text);
    flex-shrink: 0;
    white-space: nowrap;
    transition: color 0.3s ease;
}

.nav-brand i {
    font-size: 1.5rem;
}

.nav-toggle {
    display: none;
    background: none;
    border: none;
    color: var(--nav-text);
    font-size: 1.5rem;
    cursor: pointer;
    flex-shrink: 0;
    transition: color 0.3s ease;
}

.nav-menu {
    display: flex;
    list-style: none;
    margin: 0;
    padding: 0;
    gap: 5px;
    flex: 1;
    justify-content: center;
    min-width: 0;
}

.nav-menu li a {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 8px 16px;
    color: var(--nav-text);
    text-decoration: none;
    border-radius: var(--radius-sm);
    transition: all 0.3s ease;
    font-size: 0.95rem;
    white-space: nowrap;
}

.nav-menu li a:hover {
    background: var(--bg-tertiary);
    color: var(--nav-text-hover);
}

.nav-menu li a.active {
    background: var(--nav-active-bg);
    color: var(--nav-active-text);
    font-weight: 600;
}

/* Dropdown Menu Styles */
.nav-dropdown {
    position: relative;
}

.nav-dropdown-toggle {
    position: relative;
}

.nav-dropdown-toggle .fa-chevron-down {
    font-size: 0.8rem;
    margin-left: 4px;
    transition: transform 0.3s ease;
}

.nav-dropdown.active .nav-dropdown-toggle .fa-chevron-down {
    transform: rotate(180deg);
}

.nav-dropdown-menu {
    position: absolute;
    top: 100%;
    left: 0;
    background: var(--bg-secondary);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    min-width: 200px;
    opacity: 0;
    visibility: hidden;
    transform: translateY(-10px);
    transition: all 0.3s ease;
    z-index: 1000;
    list-style: none;
    margin: 0;
    padding: 8px 0;
}

.nav-dropdown.active .nav-dropdown-menu {
    opacity: 1;
    visibility: visible;
    transform: translateY(0);
}

.nav-dropdown-menu li {
    margin: 0;
}

.nav-dropdown-menu li a {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 10px 16px;
    color: var(--nav-text);
    text-decoration: none;
    font-size: 0.9rem;
    transition: all 0.3s ease;
    border-radius: 0;
}

.nav-dropdown-menu li a:hover {
    background: var(--bg-tertiary);
    color: var(--nav-text-hover);
}

.nav-dropdown-menu li a.active {
    background: var(--nav-active-bg);
    color: var(--nav-active-text);
    font-weight: 600;
}

.theme-toggle-btn {
    background: var(--bg-tertiary);
    border: 1px solid var(--border-color);
    color: var(--nav-text);
    width: 40px;
    height: 40px;
    border-radius: 50%;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.3s ease;
    flex-shrink: 0;
}

.theme-toggle-btn:hover {
    background: var(--border-hover);
    transform: rotate(15deg);
}

/* Tool Container Styles */
.tool-container {
    max-width: 1400px;
    margin: 30px auto;
    padding: 0 20px;
    /* background: var(--bg-secondary); */
}

.tool-header {
    text-align: center;
    margin-bottom: 30px;
}

.tool-header h1 {
    font-size: 2.5rem;
    color: var(--text-primary);
    margin-bottom: 10px;
}

.tool-header p {
    font-size: 1.1rem;
    color: var(--text-secondary);
}

/* Input/Output Areas */
.tool-workspace {
    border-radius: var(--radius-lg);
    padding: 30px;
    margin-bottom: 20px;
    transition: background-color 0.3s ease;
}

.input-section, .output-section {
    margin-bottom: 25px;
}

.section-label {
    display: block;
    font-weight: 600;
    color: var(--text-primary);
    margin-bottom: 10px;
    font-size: 1.1rem;
}

.json-input {
    width: 100%;
    min-height: 300px;
    padding: 15px;
    font-family: 'JetBrains Mono', 'Courier New', monospace;
    font-size: 14px;
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    resize: vertical;
    transition: border-color 0.3s ease, background-color 0.3s ease;
    background: var(--bg-input-light);
}

.json-output {
    min-height: 300px;
    padding: 15px;
    font-family: 'JetBrains Mono', 'Courier New', monospace;
    font-size: 14px;
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    resize: vertical;
    transition: border-color 0.3s ease, background-color 0.3s ease;
    background: var(--bg-output-light);
    color: var(--text-primary);
}

.json-input:focus {
    outline: none;
    border-color: var(--accent-primary);
}

.json-output {
    background-color: var(--bg-secondary);
    cursor: text;
}

/* JSON Output Viewer with Line Numbers and Collapsible Elements */
.json-output-viewer {
    min-height: 300px;
    background: var(--bg-secondary);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    overflow: auto;
    font-family: 'JetBrains Mono', 'Courier New', monospace;
    font-size: 14px;
    line-height: 1.6;
    position: relative;
}

.json-output-viewer .output-placeholder {
    padding: 60px 20px;
    text-align: center;
    color: var(--text-muted);
    font-size: 14px;
}

.json-line {
    display: flex;
    align-items: flex-start;
    position: relative;
    padding: 0;
    user-select: text;
}

.json-line:hover {
    background: var(--bg-tertiary);
}

.line-number {
    min-width: 50px;
    padding: 2px 12px 2px 8px;
    text-align: right;
    color: var(--text-muted);
    user-select: none;
    font-size: 13px;
    flex-shrink: 0;
}

.line-content {
    padding: 2px 12px;
    flex: 1;
    white-space: pre;
    color: var(--text-primary);
    word-wrap: break-word;
    overflow-wrap: break-word;
}

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

.json-string {
    color: #34d399;
}

.json-number {
    color: #60a5fa;
}

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

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

/* Collapsible Elements */
.json-collapsible {
    cursor: pointer;
    user-select: none;
    display: inline-flex;
    align-items: center;
    gap: 4px;
}

.json-collapsible:hover {
    opacity: 0.8;
}

.collapse-icon {
    display: inline-block;
    width: 14px;
    height: 14px;
    line-height: 14px;
    text-align: center;
    font-size: 10px;
    color: var(--text-muted);
    transition: transform 0.2s;
}

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

.json-collapsed {
    color: var(--text-muted);
    font-style: italic;
    margin-left: 4px;
}

.json-children {
    display: block;
}

.json-children.hidden {
    display: none;
}

/* Bracket and brace styling */
.json-bracket,
.json-brace,
.json-comma,
.json-colon {
    color: var(--text-secondary);
}

/* Copy button for formatted output */
.json-output-viewer .copy-output-btn {
    position: absolute;
    top: 8px;
    right: 8px;
    padding: 6px 12px;
    background: var(--btn-secondary-bg);
    color: var(--btn-secondary-text);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-sm);
    cursor: pointer;
    font-size: 12px;
    opacity: 0;
    transition: opacity 0.2s, background 0.2s;
    z-index: 10;
}

.json-output-viewer:hover .copy-output-btn {
    opacity: 1;
}

.copy-output-btn:hover {
    background: var(--btn-secondary-hover);
}

.copy-output-btn i {
    margin-right: 4px;
}

/* Two Column Layout */
.two-column {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 20px;
}

/* Action Buttons */
.action-buttons {
    display: flex;
    gap: 15px;
    justify-content: center;
    flex-wrap: wrap;
    margin: 20px 0;
}

.btn {
    padding: 12px 30px;
    font-size: 1rem;
    font-weight: 600;
    border: none;
    border-radius: 8px;
    cursor: pointer;
    transition: all 0.3s ease;
    display: inline-flex;
    align-items: center;
    gap: 8px;
}

.btn-primary {
    background: var(--btn-primary-bg);
    color: var(--btn-primary-text);
}

.btn-primary:hover {
    background: var(--btn-primary-hover);
    transform: translateY(-1px);
}

.btn-secondary {
    background: var(--btn-secondary-bg);
    color: var(--btn-secondary-text);
}

.btn-secondary:hover {
    background: var(--btn-secondary-hover);
}

.btn-success {
    background: var(--btn-success-bg);
    color: var(--btn-success-text);
}

.btn-success:hover {
    background: var(--btn-success-hover);
}

/* Error/Success Messages */
.message {
    padding: 15px 20px;
    border-radius: var(--radius-md);
    margin: 15px 0;
    display: none;
}

.message.show {
    display: block;
}

.message-error {
    background: var(--bg-secondary);
    border: 1px solid var(--error-color);
    color: var(--error-color);
}

.message-success {
    background: var(--bg-secondary);
    border: 1px solid var(--success-color);
    color: var(--success-color);
}

.message-info {
    background: var(--bg-secondary);
    border: 1px solid var(--accent-primary);
    color: var(--accent-primary);
}

/* Options Panel */
.options-panel {
    background: var(--bg-secondary);
    border-radius: var(--radius-md);
    padding: 20px;
    margin-bottom: 20px;
    transition: background-color 0.3s ease;
    display: flex;
    align-items: center;
    gap: 30px;
    flex-wrap: wrap;
}

.option-group {
    display: flex;
    align-items: center;
    gap: 12px;
    margin-bottom: 0;
}

.option-group label {
    font-weight: 600;
    color: var(--text-primary);
    margin-bottom: 0;
    white-space: nowrap;
    display: flex;
    align-items: center;
    gap: 8px;
}

.option-group select,
.option-group input[type="number"] {
    padding: 8px 12px;
    border: 1px solid var(--border-color);
    border-radius: var(--radius-sm);
    font-size: 0.95rem;
    background: var(--bg-primary);
    color: var(--text-primary);
    transition: border-color 0.3s ease, background-color 0.3s ease;
    min-width: 120px;
}

.option-group input[type="checkbox"] {
    margin: 0;
    transform: scale(1.1);
}

/* Stats Display */
.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 20px;
    margin-top: 20px;
}

.stat-card {
    background: var(--bg-primary);
    padding: 20px;
    border-radius: var(--radius-md);
    border-left: 4px solid var(--accent-primary);
    transition: background-color 0.3s ease;
}

.stat-label {
    font-size: 0.9rem;
    color: var(--text-secondary);
    margin-bottom: 5px;
}

.stat-value {
    font-size: 2rem;
    font-weight: 700;
    color: var(--text-primary);
}

/* Tree Viewer Styles */
.json-tree {
    font-family: 'JetBrains Mono', monospace;
    font-size: 14px;
    line-height: 1.6;
}

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

.tree-key {
    color: var(--accent-secondary);
    font-weight: 600;
    cursor: pointer;
}

.tree-value {
    color: var(--text-primary);
}

.tree-string {
    color: var(--success-color);
}

.tree-number {
    color: var(--warning-color);
}

.tree-boolean {
    color: var(--accent-primary);
}

.tree-null {
    color: var(--text-muted);
}

.tree-toggle {
    cursor: pointer;
    user-select: none;
    color: var(--text-secondary);
    margin-right: 5px;
}

.tree-collapsed {
    display: none;
}

/* Dark Mode - Enhanced with CSS Custom Properties */
body.dark-mode {
    background: var(--bg-primary);
    color: var(--text-primary);
}

/* All dark mode styles are now handled by CSS custom properties above */
/* The dark mode class automatically applies the dark theme variables */

/* Tablet Responsive */
@media (max-width: 1024px) {
    .nav-menu {
        gap: 3px;
    }

    .nav-menu li a {
        padding: 8px 12px;
        font-size: 0.85rem;
    }

    .nav-brand {
        font-size: 1.1rem;
    }
}

/* Medium screen adjustments - prevent early hiding */
@media (max-width: 900px) {
    .nav-container {
        gap: 15px;
    }

    .nav-menu {
        gap: 2px;
    }

    .nav-menu li a {
        padding: 8px 10px;
        font-size: 0.8rem;
    }

    .nav-brand span {
        font-size: 0.9rem;
    }
}

/* Mobile Responsive */
@media (max-width: 768px) {
    .nav-container {
        gap: 10px;
        flex-wrap: nowrap;
        position: relative;
    }

    .nav-brand {
        font-size: 1.1rem;
    }

    .nav-brand span {
        display: none;
    }

    .nav-brand i {
        font-size: 1.3rem;
    }

    .nav-toggle {
        display: block;
        order: 2;
        margin-left: auto;
        margin-right: 10px;
    }

    .nav-menu {
        position: absolute;
        top: 60px;
        left: 0;
        right: 0;
        background: var(--nav-bg);
        border-bottom: 1px solid var(--border-color);
        flex-direction: column;
        padding: 20px;
        gap: 10px;
        display: none;
        order: 4;
    }

    .nav-menu.active {
        display: flex;
    }

    .nav-menu li a {
        padding: 12px 16px;
    }

    /* Mobile dropdown styles */
    .nav-dropdown-menu {
        position: static;
        opacity: 1;
        visibility: visible;
        transform: none;
        border: none;
        background: var(--bg-tertiary);
        border-radius: var(--radius-sm);
        margin: 8px 0;
        max-height: 0;
        overflow: hidden;
        transition: max-height 0.3s ease, padding 0.3s ease;
        padding: 0;
    }

    .nav-dropdown.active .nav-dropdown-menu {
        max-height: 300px;
        padding: 8px 0;
    }

    .nav-dropdown-menu li a {
        padding: 8px 24px;
        font-size: 0.85rem;
    }

    .theme-toggle-btn {
        order: 3;
        flex-shrink: 0;
    }

    .two-column {
        grid-template-columns: 1fr;
    }

    .tool-header h1 {
        font-size: 2rem;
    }

    .stats-grid {
        grid-template-columns: 1fr;
    }
}

