/**
 * JSON Formatter Tool Styles
 * Extends main.css with tool-specific styling
 */

.json-formatter-container {
    display: flex;
    flex-direction: column;
    gap: 1.5rem;
}

/* Input Section */
.input-section {
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
}

.input-label {
    font-size: 1rem;
    font-weight: 600;
    color: var(--text-color);
}

.textarea-wrapper {
    position: relative;
}

.json-textarea {
    width: 100%;
    padding: 1rem;
    font-family: 'Monaco', 'Menlo', 'Ubuntu Mono', 'Consolas', 'source-code-pro', monospace;
    font-size: 0.9rem;
    line-height: 1.6;
    border: 2px solid var(--border-color);
    border-radius: 8px;
    background: var(--bg-color);
    color: var(--text-color);
    resize: vertical;
    transition: border-color 0.2s ease, box-shadow 0.2s ease;
}

.json-textarea:focus {
    outline: none;
    border-color: var(--primary-color);
    box-shadow: 0 0 0 3px var(--primary-color-alpha);
}

.json-textarea::placeholder {
    color: var(--text-muted);
    opacity: 0.6;
}

/* Options Container */
.options-container {
    padding: 1.25rem;
    background: var(--card-bg, #f8f9fa);
    border: 1px solid var(--border-color, #e5e7eb);
    border-radius: 8px;
}

.options-title {
    margin: 0 0 1rem 0;
    font-size: 1rem;
    font-weight: 600;
    color: var(--text-color, #1f2937);
}

.options-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 1rem;
    align-items: center;
}

.option-group {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.option-label {
    font-size: 0.9rem;
    font-weight: 500;
    color: var(--text-color, #1f2937);
}

.indent-select {
    padding: 0.5rem 0.75rem;
    font-size: 0.95rem;
    border: 2px solid var(--border-color, #e5e7eb);
    border-radius: 6px;
    background: var(--bg-color, #ffffff);
    color: var(--text-color, #1f2937);
    cursor: pointer;
    transition: border-color 0.2s ease;
}

.indent-select:focus {
    outline: none;
    border-color: var(--primary-color, #3b82f6);
}

.option-checkbox {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    cursor: pointer;
    user-select: none;
}

.option-checkbox input[type="checkbox"] {
    width: 18px;
    height: 18px;
    cursor: pointer;
    accent-color: var(--primary-color, #3b82f6);
}

.checkbox-label {
    font-size: 0.95rem;
    color: var(--text-color, #1f2937);
}

/* Action Buttons */
.action-buttons {
    display: flex;
    gap: 0.75rem;
    flex-wrap: wrap;
}

.format-btn,
.minify-btn,
.validate-btn,
.btn-copy,
.btn-clear {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    padding: 0.875rem 1.25rem;
    font-size: 0.95rem;
    font-weight: 600;
    border: none;
    border-radius: 8px;
    cursor: pointer;
    transition: all 0.2s ease;
}

.format-btn {
    background: var(--primary-color);
    color: white;
    flex: 1;
}

.format-btn:hover {
    background: var(--primary-dark);
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(59, 130, 246, 0.3);
}

.minify-btn {
    background: var(--secondary-color, #6366f1);
    color: white;
    flex: 1;
}

.minify-btn:hover {
    background: var(--secondary-dark, #4f46e5);
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(99, 102, 241, 0.3);
}

.validate-btn {
    background: var(--info-color, #14b8a6);
    color: white;
    flex: 1;
}

.validate-btn:hover {
    background: var(--info-dark, #0f766e);
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(20, 184, 166, 0.3);
}

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

.btn-copy:hover {
    background: var(--success-dark);
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(46, 213, 115, 0.3);
}

.btn-clear {
    background: var(--bg-secondary);
    color: var(--text-color);
    border: 2px solid var(--border-color);
}

.btn-clear:hover {
    background: var(--bg-tertiary);
    border-color: var(--text-muted);
}

/* Validation Status */
.validation-status {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 1rem;
    border-radius: 8px;
    font-size: 0.95rem;
}

.status-icon {
    flex-shrink: 0;
    display: flex;
    align-items: center;
    justify-content: center;
}

.status-valid {
    color: var(--success-color);
}

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

.status-message {
    font-weight: 500;
}

.status-message.status-valid {
    color: var(--success-color);
}

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

/* Statistics Container */
.stats-container {
    padding: 1.25rem;
    background: var(--card-bg);
    border: 1px solid var(--border-color);
    border-radius: 8px;
}

.stats-title {
    margin: 0 0 1rem 0;
    font-size: 1rem;
    font-weight: 600;
    color: var(--text-color);
}

.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(120px, 1fr));
    gap: 1.5rem;
}

.stat-item {
    text-align: center;
}

.stat-label {
    font-size: 0.85rem;
    color: var(--text-muted);
    margin-bottom: 0.5rem;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

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

/* Output Container */
.output-container {
    margin-top: 1rem;
}

.output-title {
    margin: 0 0 1rem 0;
    font-size: 1.1rem;
    font-weight: 600;
    color: var(--text-color);
}

.json-output {
    width: 100%;
    padding: 1rem;
    font-family: 'Monaco', 'Menlo', 'Ubuntu Mono', 'Consolas', 'source-code-pro', monospace;
    font-size: 0.9rem;
    line-height: 1.6;
    border: 2px solid var(--border-color);
    border-radius: 8px;
    background: var(--bg-color);
    color: var(--text-color);
    overflow-x: auto;
    white-space: pre;
    max-height: 500px;
    overflow-y: auto;
}

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

.json-string {
    color: #22863a;
}

.json-number {
    color: #005cc5;
}

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

.json-null {
    color: #6f42c1;
    font-weight: 600;
}

/* Dark theme syntax highlighting */
[data-theme="dark"] .json-key {
    color: #79b8ff;
}

[data-theme="dark"] .json-string {
    color: #85e89d;
}

[data-theme="dark"] .json-number {
    color: #79b8ff;
}

[data-theme="dark"] .json-boolean {
    color: #f97583;
}

[data-theme="dark"] .json-null {
    color: #b392f0;
}

/* System dark mode preference */
@media (prefers-color-scheme: dark) {
    .json-key {
        color: #79b8ff;
    }

    .json-string {
        color: #85e89d;
    }

    .json-number {
        color: #79b8ff;
    }

    .json-boolean {
        color: #f97583;
    }

    .json-null {
        color: #b392f0;
    }
}

/* Light theme explicit override */
[data-theme="light"] .json-key {
    color: #0066cc;
}

[data-theme="light"] .json-string {
    color: #22863a;
}

[data-theme="light"] .json-number {
    color: #005cc5;
}

[data-theme="light"] .json-boolean {
    color: #d73a49;
}

[data-theme="light"] .json-null {
    color: #6f42c1;
}

/* Copy Notification */
.copy-notification {
    position: fixed;
    bottom: 2rem;
    right: 2rem;
    padding: 1rem 1.5rem;
    background: var(--success-color);
    color: white;
    border-radius: 8px;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
    font-weight: 600;
    z-index: 1000;
    animation: slideIn 0.3s ease;
}

@keyframes slideIn {
    from {
        transform: translateY(100%);
        opacity: 0;
    }
    to {
        transform: translateY(0);
        opacity: 1;
    }
}

/* Responsive Design */
@media (max-width: 768px) {
    .options-grid {
        grid-template-columns: 1fr;
    }

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

    .action-buttons {
        flex-direction: column;
    }

    .format-btn,
    .minify-btn,
    .validate-btn,
    .btn-copy,
    .btn-clear {
        width: 100%;
    }

    .copy-notification {
        bottom: 1rem;
        right: 1rem;
        left: 1rem;
    }
}

/* Dark Theme Support - System Preference */
@media (prefers-color-scheme: dark) {
    .json-textarea,
    .json-output {
        background: #1e293b;
        border-color: #334155;
        color: #e2e8f0;
    }

    .options-container,
    .stats-container {
        background: #1e293b;
        border-color: #334155;
    }

    .options-title,
    .stats-title,
    .output-title,
    .input-label {
        color: #e2e8f0;
    }

    .indent-select {
        background: #1e293b;
        border-color: #334155;
        color: #e2e8f0;
    }

    .option-label,
    .checkbox-label {
        color: #e2e8f0;
    }

    .btn-clear {
        background: #1e293b;
        border-color: #334155;
        color: #e2e8f0;
    }

    .btn-clear:hover {
        background: #334155;
        border-color: #475569;
    }

    .stat-label {
        color: #94a3b8;
    }
}

/* Light Theme Specific (when explicitly set) */
[data-theme="light"] .json-textarea,
[data-theme="light"] .json-output {
    background: #ffffff;
    border-color: #e5e7eb;
    color: #1f2937;
}

[data-theme="light"] .options-container,
[data-theme="light"] .stats-container {
    background: #f8f9fa;
    border-color: #e5e7eb;
}

[data-theme="light"] .options-title,
[data-theme="light"] .stats-title,
[data-theme="light"] .output-title,
[data-theme="light"] .input-label {
    color: #1f2937;
}

[data-theme="light"] .indent-select {
    background: #ffffff;
    border-color: #e5e7eb;
    color: #1f2937;
}

[data-theme="light"] .option-label,
[data-theme="light"] .checkbox-label {
    color: #1f2937;
}

[data-theme="light"] .btn-clear {
    background: #f3f4f6;
    border-color: #e5e7eb;
    color: #1f2937;
}

[data-theme="light"] .btn-clear:hover {
    background: #e5e7eb;
    border-color: #6b7280;
}

[data-theme="light"] .stat-label {
    color: #6b7280;
}

/* Dark Theme Specific (when explicitly set) */
[data-theme="dark"] .json-textarea,
[data-theme="dark"] .json-output {
    background: #1e293b;
    border-color: #334155;
    color: #e2e8f0;
}

[data-theme="dark"] .options-container,
[data-theme="dark"] .stats-container {
    background: #1e293b;
    border-color: #334155;
}

[data-theme="dark"] .options-title,
[data-theme="dark"] .stats-title,
[data-theme="dark"] .output-title,
[data-theme="dark"] .input-label {
    color: #e2e8f0;
}

[data-theme="dark"] .indent-select {
    background: #1e293b;
    border-color: #334155;
    color: #e2e8f0;
}

[data-theme="dark"] .option-label,
[data-theme="dark"] .checkbox-label {
    color: #e2e8f0;
}

[data-theme="dark"] .btn-clear {
    background: #1e293b;
    border-color: #334155;
    color: #e2e8f0;
}

[data-theme="dark"] .btn-clear:hover {
    background: #334155;
    border-color: #475569;
}

[data-theme="dark"] .stat-label {
    color: #94a3b8;
}
