/* ===== Tool Page Styles ===== */

/* Breadcrumb */
.breadcrumb {
    padding: 16px 0;
    background: var(--bg-secondary);
    border-bottom: 1px solid var(--border);
    font-size: 0.9rem;
    color: var(--text-secondary);
}

.breadcrumb a {
    color: var(--text-secondary);
}

.breadcrumb a:hover {
    color: var(--primary);
}

.breadcrumb span {
    margin: 0 8px;
}

/* Tool Section */
.tool-section {
    padding: 40px 0 80px;
    min-height: calc(100vh - 200px);
}

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

.tool-title {
    font-size: 2rem;
    font-weight: 700;
    margin-bottom: 12px;
}

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

/* Tool Container */
.tool-container {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    overflow: hidden;
}

/* Toolbar */
.toolbar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-wrap: wrap;
    gap: 12px;
    padding: 16px;
    background: var(--bg-secondary);
    border-bottom: 1px solid var(--border);
}

.toolbar-group {
    display: flex;
    align-items: center;
    gap: 8px;
    flex-wrap: wrap;
}

.btn-sm {
    padding: 8px 16px;
    font-size: 0.875rem;
}

.select {
    padding: 8px 12px;
    background: var(--bg-tertiary);
    color: var(--text-primary);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    font-size: 0.875rem;
    cursor: pointer;
}

/* Editor Container */
.editor-container {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 0;
    min-height: 400px;
}

.editor-panel {
    display: flex;
    flex-direction: column;
    border-right: 1px solid var(--border);
}

.editor-panel:last-child {
    border-right: none;
}

.editor-label {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 12px 16px;
    background: var(--bg-tertiary);
    font-size: 0.875rem;
    font-weight: 500;
    color: var(--text-secondary);
}

.char-count {
    font-size: 0.8rem;
    color: var(--text-muted);
}

.editor {
    flex: 1;
    padding: 16px;
    background: var(--bg-primary);
    color: var(--text-primary);
    font-family: 'Monaco', 'Menlo', 'Consolas', monospace;
    font-size: 14px;
    line-height: 1.6;
    border: none;
    resize: none;
    outline: none;
    overflow: auto;
    white-space: pre-wrap;
    word-wrap: break-word;
}

.editor.output {
    margin: 0;
}

.editor.success {
    color: var(--success);
}

.editor.error {
    color: var(--danger);
}

.editor.warning {
    color: #f59e0b;
    font-style: italic;
}

/* JSON Syntax Highlighting */
.json-key {
    color: #818cf8;
}

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

.json-number {
    color: #fbbf24;
}

.json-boolean {
    color: #f472b6;
}

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

/* JSON Collapse/Expand */
.json-block {
    position: relative;
}

.json-toggle {
    display: inline-block;
    width: 16px;
    height: 16px;
    line-height: 14px;
    text-align: center;
    font-size: 12px;
    font-weight: bold;
    color: var(--text-secondary, #94a3b8);
    background: var(--bg-secondary, #1e293b);
    border: 1px solid var(--border, #334155);
    border-radius: 3px;
    cursor: pointer;
    margin-right: 4px;
    user-select: none;
    transition: all 0.15s ease;
    vertical-align: middle;
    position: relative;
    top: -1px;
}

.json-toggle:hover {
    background: var(--primary, #6366f1);
    border-color: var(--primary, #6366f1);
    color: white;
}

.json-bracket {
    color: var(--text-primary, #e2e8f0);
    font-weight: 600;
}

.json-preview {
    color: var(--text-secondary, #94a3b8);
    font-style: italic;
}

.json-content {
    display: inline;
}

.json-block.collapsed .json-content {
    display: none;
}

.json-block.collapsed .json-preview {
    display: inline;
}

/* JSON Depth Control */
.depth-control {
    display: none !important;
    align-items: center;
    gap: 6px;
    padding: 3px 10px;
    background: rgba(99, 102, 241, 0.08);
    border-radius: 8px;
    border: 1px solid rgba(99, 102, 241, 0.15);
}

.depth-control.show {
    display: flex !important;
}

.depth-btn {
    display: inline-flex !important;
    align-items: center;
    gap: 4px;
    font-weight: 500;
    transition: all 0.15s ease;
}

.depth-btn:hover {
    background: var(--primary);
    color: white;
    border-color: var(--primary);
}

.depth-btn:hover .depth-icon {
    color: white;
}

.depth-icon {
    font-size: 11px;
    color: var(--primary);
    transition: transform 0.15s ease;
}

.depth-select {
    min-width: 85px;
    padding: 5px 28px 5px 10px;
    border-radius: 6px;
    background: var(--bg-primary);
    border: 1px solid var(--border);
    color: var(--text-primary);
    font-size: 0.85rem;
    cursor: pointer;
    transition: border-color 0.15s ease;
}

.depth-select:hover,
.depth-select:focus {
    border-color: var(--primary);
    outline: none;
}

.depth-select option {
    background: var(--bg-secondary);
    color: var(--text-primary);
    padding: 6px 10px;
}

/* Status Bar */
.status-bar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 12px 16px;
    background: var(--bg-secondary);
    border-top: 1px solid var(--border);
    font-size: 0.875rem;
}

.status-text {
    color: var(--text-secondary);
}

.error-text {
    color: var(--danger);
    font-family: monospace;
    font-size: 0.8rem;
}

/* Ad Container */
.ad-container {
    margin: 40px 0;
    text-align: center;
    min-height: 100px;
}

/* Tool Features */
.tool-features {
    margin-top: 60px;
}

.tool-features h2 {
    font-size: 1.5rem;
    font-weight: 600;
    margin-bottom: 24px;
    text-align: center;
}

.features-list {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
    gap: 20px;
}

.feature-item {
    display: flex;
    gap: 16px;
    padding: 20px;
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
}

.feature-icon {
    font-size: 2rem;
    flex-shrink: 0;
}

.feature-item h3 {
    font-size: 1rem;
    font-weight: 600;
    margin-bottom: 4px;
}

.feature-item p {
    font-size: 0.9rem;
    color: var(--text-secondary);
}

/* ===== Form Components ===== */

.form-group {
    margin-bottom: 16px;
}

.form-group label {
    display: block;
    font-weight: 500;
    margin-bottom: 6px;
    color: var(--text-primary);
    font-size: 0.95rem;
}

.form-group input[type="text"],
.form-group input[type="number"],
.form-group input[type="url"],
.form-group input[type="email"],
.form-group textarea {
    width: 100%;
    padding: 10px 14px;
    background: var(--bg-primary);
    color: var(--text-primary);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm, 6px);
    font-size: 0.95rem;
    transition: border-color 0.2s;
    box-sizing: border-box;
}

.form-group input:focus,
.form-group textarea:focus {
    border-color: var(--primary);
    outline: none;
}

.form-group textarea {
    resize: vertical;
    font-family: 'Monaco', 'Menlo', 'Consolas', monospace;
}

.checkbox-label {
    display: flex;
    align-items: center;
    gap: 8px;
    cursor: pointer;
    font-size: 0.95rem;
    padding: 4px 0;
}

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

/* 2-column grid helper */
.grid-2col {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 16px;
}

/* Input + Copy button row */
.input-copy-row {
    display: flex;
    gap: 6px;
    align-items: stretch;
}
.input-copy-row input {
    flex: 1;
    min-width: 0;
}
.btn-copy {
    flex-shrink: 0;
    width: 36px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--bg-secondary, #f3f4f6);
    border: 1px solid var(--border, #e5e7eb);
    border-radius: 6px;
    cursor: pointer;
    font-size: 14px;
    transition: background .15s, border-color .15s;
}
.btn-copy:hover {
    background: var(--primary, #3b82f6);
    border-color: var(--primary, #3b82f6);
    filter: brightness(1.1);
}

/* Responsive */
@media (max-width: 768px) {
    .editor-container {
        grid-template-columns: 1fr;
        min-height: auto;
    }
    
    .editor-panel {
        border-right: none;
        border-bottom: 1px solid var(--border);
        min-height: 200px;
    }
    
    .toolbar {
        flex-direction: column;
        align-items: stretch;
    }
    
    .toolbar-group {
        justify-content: center;
    }
    
    .tool-title {
        font-size: 1.5rem;
    }

    .grid-2col {
        grid-template-columns: 1fr;
    }
}

/* Search & Replace Bar */
.search-replace-bar {
    display: none;
    background: var(--bg-tertiary);
    border-bottom: 1px solid var(--border);
    padding: 4px 16px;
    gap: 4px;
    flex-direction: column;
}
.search-replace-bar.show {
    display: flex;
}
.search-row {
    display: flex;
    align-items: center;
    gap: 6px;
}
.search-row input {
    flex: 1;
    padding: 5px 10px;
    background: var(--bg-primary);
    color: var(--text-primary);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    font-size: 13px;
    outline: none;
    font-family: inherit;
}
.search-row input:focus {
    border-color: var(--primary);
}
.search-btn {
    padding: 4px 8px;
    background: var(--bg-card);
    color: var(--text-secondary);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    cursor: pointer;
    font-size: 13px;
    line-height: 1;
    white-space: nowrap;
    transition: all 0.15s;
}
.search-btn:hover {
    background: var(--primary);
    color: #fff;
    border-color: var(--primary);
}
.search-btn.danger:hover {
    background: var(--danger);
    border-color: var(--danger);
}
.search-btn.active {
    background: var(--primary);
    color: #fff;
    border-color: var(--primary);
}
.search-count {
    font-size: 12px;
    color: var(--text-muted);
    min-width: 50px;
    text-align: center;
    white-space: nowrap;
}
.search-close {
    padding: 4px 8px;
    background: none;
    border: none;
    color: var(--text-muted);
    cursor: pointer;
    font-size: 16px;
    line-height: 1;
}
.search-close:hover {
    color: var(--danger);
}
.search-label {
    font-size: 12px;
    color: var(--text-muted);
    min-width: 32px;
    text-align: right;
}

/* Textarea highlight wrapper */
.highlight-wrapper {
    position: relative;
    flex: 1;
    overflow: hidden;
}
.highlight-backdrop {
    position: absolute;
    top: 0; left: 0; right: 0; bottom: 0;
    padding: 16px;
    font-family: 'Monaco', 'Menlo', 'Consolas', monospace;
    font-size: 14px;
    line-height: 1.6;
    white-space: pre-wrap;
    word-wrap: break-word;
    color: transparent;
    overflow: auto;
    pointer-events: none;
}
.highlight-backdrop mark {
    background: #fbbf24;
    color: transparent;
    border-radius: 2px;
    padding: 0;
}
.highlight-backdrop mark.active-match {
    background: #f97316;
}
.highlight-wrapper textarea {
    position: relative;
    z-index: 1;
    background: transparent;
    height: 100%;
    min-height: 300px;
    overflow: auto;
}
