/* ============================================
   基础样式
   ============================================ */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

:root {
    --bg-primary: #0f172a;
    --bg-secondary: #1e293b;
    --bg-tertiary: #334155;
    --text-primary: #f1f5f9;
    --text-secondary: #cbd5e1;
    --text-muted: #94a3b8;
    --accent-blue: #3b82f6;
    --accent-green: #10b981;
    --accent-red: #ef4444;
    --accent-yellow: #f59e0b;
    --accent-purple: #8b5cf6;
    --accent-orange: #f97316;
    --border-color: #475569;
    --success-bg: rgba(16, 185, 129, 0.1);
    --warning-bg: rgba(245, 158, 11, 0.1);
    --error-bg: rgba(239, 68, 68, 0.1);
    --hover-bg: rgba(59, 130, 246, 0.1);
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', 'Roboto', 'Oxygen', 'Ubuntu', 'Cantarell', sans-serif;
    background: var(--bg-primary);
    color: var(--text-primary);
    line-height: 1.6;
    min-height: 100vh;
}

/* ============================================
   容器和布局
   ============================================ */
.container {
    max-width: 1600px;
    margin: 0 auto;
    padding: 20px;
}

header {
    text-align: center;
    padding: 30px 20px;
    margin-bottom: 30px;
}

h1 {
    font-size: 2.5rem;
    background: linear-gradient(135deg, var(--accent-blue), var(--accent-purple));
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    margin-bottom: 10px;
}

.subtitle {
    color: var(--text-secondary);
    font-size: 1.1rem;
}

main {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 20px;
    margin-bottom: 20px;
}

/* ============================================
   面板样式
   ============================================ */
.panel {
    background: var(--bg-secondary);
    border-radius: 12px;
    padding: 20px;
    border: 1px solid var(--border-color);
}

.panel-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 15px;
    flex-wrap: wrap;
    gap: 10px;
}

.panel-title {
    font-size: 1.2rem;
    font-weight: 600;
    color: var(--text-primary);
}

.toolbar {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
}

/* ============================================
   按钮样式
   ============================================ */
.btn {
    padding: 8px 16px;
    border: none;
    border-radius: 6px;
    cursor: pointer;
    font-size: 0.9rem;
    font-weight: 500;
    transition: all 0.2s;
    background: var(--bg-tertiary);
    color: var(--text-primary);
    border: 1px solid var(--border-color);
    min-height: 44px;
    min-width: 44px;
}

.btn:hover:not(:disabled) {
    background: var(--bg-tertiary);
    border-color: var(--accent-blue);
    transform: translateY(-1px);
    box-shadow: 0 4px 8px rgba(0, 0, 0, 0.2);
}

.btn:active {
    transform: translateY(0);
}

.btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
    transform: none;
}

.btn-primary {
    background: var(--accent-blue);
    border-color: var(--accent-blue);
    color: white;
}

.btn-primary:hover:not(:disabled) {
    background: #2563eb;
    border-color: #2563eb;
}

.btn-success {
    background: var(--accent-green);
    border-color: var(--accent-green);
    color: white;
}

.btn-success:hover:not(:disabled) {
    background: #059669;
    border-color: #059669;
}

.btn-danger {
    background: var(--accent-red);
    border-color: var(--accent-red);
    color: white;
}

.btn-danger:hover:not(:disabled) {
    background: #dc2626;
    border-color: #dc2626;
}

.btn-warning {
    background: var(--accent-orange);
    border-color: var(--accent-orange);
    color: white;
    animation: pulse 2s infinite;
}

.btn-warning:hover:not(:disabled) {
    background: #ea580c;
    border-color: #ea580c;
    animation: none;
}

@keyframes pulse {
    0%, 100% {
        box-shadow: 0 0 0 0 rgba(249, 115, 22, 0.7);
    }
    50% {
        box-shadow: 0 0 0 10px rgba(249, 115, 22, 0);
    }
}

.btn-download {
    background: var(--accent-purple);
    border-color: var(--accent-purple);
    color: white;
}

.btn-download:hover:not(:disabled) {
    background: #7c3aed;
    border-color: #7c3aed;
}

/* ============================================
   输入区域
   ============================================ */
.input-area {
    position: relative;
    margin-bottom: 15px;
}

textarea {
    width: 100%;
    min-height: 400px;
    padding: 15px;
    background: var(--bg-primary);
    border: 2px solid var(--border-color);
    border-radius: 8px;
    color: var(--text-primary);
    font-family: 'Consolas', 'Monaco', 'Courier New', monospace;
    font-size: 14px;
    line-height: 1.6;
    resize: vertical;
    transition: border-color 0.2s;
}

textarea:focus {
    outline: none;
    border-color: var(--accent-blue);
}

textarea.drag-over {
    border-color: var(--accent-blue);
    background: var(--hover-bg);
}

/* ============================================
   消息提示样式
   ============================================ */

/* 成功提示 */
.success-display {
    background: var(--success-bg);
    border: 1px solid var(--accent-green);
    border-radius: 8px;
    padding: 12px;
    margin-top: 10px;
    display: none;
    align-items: center;
    gap: 8px;
    color: var(--accent-green);
    font-size: 0.9rem;
    animation: slideDown 0.3s ease-out;
}

.success-display.show {
    display: flex;
}

.success-icon::before {
    content: '✓';
    font-weight: bold;
    font-size: 1.2rem;
}

/* 警告提示 */
.warning-display {
    background: var(--warning-bg);
    border: 1px solid var(--accent-yellow);
    border-radius: 8px;
    padding: 12px;
    margin-top: 10px;
    display: none;
    color: var(--accent-yellow);
    font-size: 0.9rem;
    animation: slideDown 0.3s ease-out;
}

.warning-display.show {
    display: block;
}

/* 错误提示 */
.error-display {
    background: var(--error-bg);
    border: 1px solid var(--accent-red);
    border-radius: 8px;
    padding: 12px;
    margin-top: 10px;
    display: none;
    max-height: 400px;
    overflow-y: auto;
    animation: slideDown 0.3s ease-out;
}

.error-display.show {
    display: block;
}

/* 错误统计摘要 */
.error-summary {
    background: rgba(239, 68, 68, 0.2);
    border-radius: 6px;
    padding: 10px 12px;
    margin-bottom: 12px;
    font-weight: 600;
    color: var(--accent-red);
    font-size: 1rem;
    display: flex;
    align-items: center;
    gap: 8px;
}

.error-summary::before {
    content: '🔴';
    font-size: 1.2rem;
}

/* 错误列表 */
.error-list {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

/* 错误项 */
.error-item {
    background: var(--bg-primary);
    border-left: 3px solid var(--accent-red);
    border-radius: 4px;
    padding: 10px 12px;
}

.error-item.error-priority-main {
    border-left-color: var(--accent-red);
    border-left-width: 4px;
}

.error-item.error-priority-secondary {
    border-left-color: var(--accent-yellow);
    opacity: 0.9;
}

/* 错误优先级标签 */
.error-priority-badge {
    display: inline-block;
    padding: 2px 8px;
    border-radius: 4px;
    font-size: 0.75rem;
    font-weight: 600;
    margin-right: 8px;
    text-transform: uppercase;
}
.error-priority-badge.main {
    background: var(--accent-red);
    color: white;
}

.error-priority-badge.secondary {
    background: var(--accent-yellow);
    color: var(--bg-primary);
}

/* 错误消息 */
.error-message {
    color: var(--accent-red);
    font-size: 0.9rem;
    margin-bottom: 6px;
    font-weight: 500;
    line-height: 1.5;
}

/* 错误位置 */
.error-position {
    color: var(--text-muted);
    font-size: 0.85rem;
    font-family: monospace;
    margin-bottom: 6px;
}

/* 错误上下文 */
.error-context {
    background: var(--bg-secondary);
    border-left: 3px solid var(--accent-red);
    padding: 8px 12px;
    margin: 8px 0;
    font-family: monospace;
    font-size: 0.85rem;
    color: var(--text-secondary);
    overflow-x: auto;
    border-radius: 4px;
}

.error-highlight {
    background: rgba(239, 68, 68, 0.4);
    border-radius: 2px;
    padding: 0 2px;
    font-weight: bold;
    color: var(--accent-red);
}

/* 修复建议 */
.error-suggestion {
    background: var(--bg-secondary);
    border-left: 3px solid var(--accent-blue);
    padding: 8px 12px;
    margin-top: 8px;
    border-radius: 4px;
}

.error-suggestion-title {
    color: var(--accent-blue);
    font-size: 0.85rem;
    font-weight: 600;
    margin-bottom: 4px;
}

.error-suggestion-title::before {
    content: '💡 ';
}

.error-suggestion-text {
    color: var(--text-secondary);
    font-size: 0.85rem;
    line-height: 1.5;
}

/* 修复步骤列表 */
.fix-steps {
    margin-top: 12px;
    padding: 10px;
    background: var(--bg-secondary);
    border-radius: 6px;
}

.fix-steps-title {
    color: var(--accent-green);
    font-size: 0.9rem;
    font-weight: 600;
    margin-bottom: 8px;
}

.fix-steps-title::before {
    content: '🔧 ';
}

.fix-steps-list {
    list-style: none;
    counter-reset: step-counter;
}

.fix-steps-list li {
    counter-increment: step-counter;
    padding-left: 30px;
    position: relative;
    margin-bottom: 6px;
    color: var(--text-secondary);
    font-size: 0.85rem;
    line-height: 1.5;
}

.fix-steps-list li::before {
    content: counter(step-counter);
    position: absolute;
    left: 0;
    top: 0;
    background: var(--accent-green);
    color: white;
    width: 20px;
    height: 20px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.75rem;
    font-weight: bold;
}

/* ============================================
   输出区域
   ============================================ */
.loading {
    display: none;
    text-align: center;
    padding: 20px;
    color: var(--accent-blue);
}

.loading.show {
    display: block;
}

.spinner {
    border: 3px solid var(--border-color);
    border-top: 3px solid var(--accent-blue);
    border-radius: 50%;
    width: 40px;
    height: 40px;
    animation: spin 1s linear infinite;
    margin: 0 auto 10px;
}

@keyframes spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

.output-area {
    min-height: 400px;
    max-height: 600px;
    overflow-y: auto;
    background: var(--bg-primary);
    border: 2px solid var(--border-color);
    border-radius: 8px;
    padding: 15px;
    font-family: 'Consolas', 'Monaco', 'Courier New', monospace;
    font-size: 14px;
    line-height: 1.6;
}

/* 滚动条样式 */
.output-area::-webkit-scrollbar,
.error-display::-webkit-scrollbar {
    width: 8px;
    height: 8px;
}

.output-area::-webkit-scrollbar-track,
.error-display::-webkit-scrollbar-track {
    background: var(--bg-secondary);
    border-radius: 4px;
}

.output-area::-webkit-scrollbar-thumb,
.error-display::-webkit-scrollbar-thumb {
    background: var(--border-color);
    border-radius: 4px;
}

.output-area::-webkit-scrollbar-thumb:hover,
.error-display::-webkit-scrollbar-thumb:hover {
    background: var(--text-muted);
}

/* ============================================
   JSON树样式
   ============================================ */
.json-tree {
    list-style: none;
    padding-left: 0;
}

.json-tree li {
    margin: 4px 0;
}

.json-key {
    color: var(--accent-blue);
    font-weight: 600;
}

.json-string {
    color: var(--accent-green);
}

.json-number {
    color: var(--accent-yellow);
}

.json-boolean {
    color: var(--accent-purple);
}

.json-null {
    color: var(--text-muted);
    font-style: italic;
}

.json-bracket {
    color: var(--text-secondary);
    font-weight: bold;
}

.json-comma {
    color: var(--text-muted);
}

.json-comment {
    color: var(--text-muted);
    font-size: 0.85em;
    font-style: italic;
}

/* 树节点折叠/展开 */
.tree-toggle {
    cursor: pointer;
    user-select: none;
    display: inline-block;
    width: 16px;
    height: 16px;
    margin-right: 4px;
    text-align: center;
    line-height: 16px;
    background: var(--bg-tertiary);
    border-radius: 3px;
    font-size: 12px;
    transition: all 0.2s;
}

.tree-toggle:hover {
    background: var(--border-color);
    transform: scale(1.1);
}

.tree-toggle.expanded::before {
    content: '−';
}

.tree-toggle.collapsed::before {
    content: '+';
}

.tree-children {
    margin-left: 20px;
    border-left: 1px dashed var(--border-color);
    padding-left: 15px;
    transition: opacity 0.2s;
}

.tree-children.collapsed {
    display: none;
}

/* ============================================
   统计信息
   ============================================ */
.stats {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
    gap: 15px;
    margin-top: 15px;
    padding-top: 15px;
    border-top: 1px solid var(--border-color);
}

.stat-item {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 12px;
    background: var(--bg-primary);
    border-radius: 8px;
    border: 1px solid var(--border-color);
    transition: all 0.2s;
    cursor: default;
    position: relative;
}

.stat-item:hover {
    border-color: var(--accent-blue);
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(59, 130, 246, 0.2);
}

.stat-icon {
    font-size: 1.5rem;
    line-height: 1;
}

.stat-content {
    display: flex;
    flex-direction: column;
    gap: 2px;
    flex: 1;
}

.stat-label {
    color: var(--text-muted);
    font-size: 0.75rem;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.stat-value {
    color: var(--accent-blue);
    font-size: 1.3rem;
    font-weight: 700;
    line-height: 1;
}

.stat-value.depth {
    color: var(--accent-purple);
}

.stat-value.types {
    color: var(--accent-green);
}

/* 类型详情弹窗 */
.stat-types-item {
    cursor: pointer;
}

.type-details {
    position: absolute;
    top: 100%;
    left: 0;
    margin-top: 8px;
    background: var(--bg-secondary);
    border: 1px solid var(--border-color);
    border-radius: 8px;
    padding: 12px;
    min-width: 200px;
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.4);
    z-index: 100;
    animation: fadeIn 0.2s ease-out;
}

.type-details-header {
    font-weight: 600;
    color: var(--text-primary);
    margin-bottom: 10px;
    padding-bottom: 8px;
    border-bottom: 1px solid var(--border-color);
    font-size: 0.9rem;
}

.type-details-content {
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.type-detail-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    font-size: 0.85rem;
    padding: 4px 0;
}

.type-detail-name {
    color: var(--text-secondary);
    font-family: monospace;
}

.type-detail-count {
    color: var(--accent-blue);
    font-weight: 600;
    font-family: monospace;
}

.type-detail-row::before {
    content: '├─';
    margin-right: 6px;
    color: var(--text-muted);
}

.type-detail-row:last-child::before {
    content: '└─';
}

/* ============================================
   空状态
   ============================================ */
.empty-state {
    text-align: center;
    padding: 60px 20px;
    color: var(--text-muted);
}

.empty-state svg {
    width: 64px;
    height: 64px;
    margin-bottom: 20px;
    opacity: 0.5;
}

/* ============================================
   Toast通知
   ============================================ */
.toast {
    position: fixed;
    top: 20px;
    right: 20px;
    background: var(--bg-secondary);
    border: 1px solid var(--border-color);
    border-radius: 8px;
    padding: 12px 20px;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.3);
    display: none;
    align-items: center;
    gap: 10px;
    z-index: 1000;
    animation: slideIn 0.3s ease-out;
    min-width: 250px;
}

.toast.show {
    display: flex;
}

.toast-icon {
    font-size: 1.2rem;
    line-height: 1;
}

.toast.success {
    border-color: var(--accent-green);
    background: var(--success-bg);
}

.toast.success .toast-icon::before {
    content: '✓';
    color: var(--accent-green);
}

.toast.error {
    border-color: var(--accent-red);
    background: var(--error-bg);
}

.toast.error .toast-icon::before {
    content: '✗';
    color: var(--accent-red);
}

.toast.warning {
    border-color: var(--accent-yellow);
    background: var(--warning-bg);
}

.toast.warning .toast-icon::before {
    content: '⚠';
    color: var(--accent-yellow);
}

.toast.info {
    border-color: var(--accent-blue);
    background: var(--hover-bg);
}

.toast.info .toast-icon::before {
    content: 'ℹ';
    color: var(--accent-blue);
}

@keyframes slideIn {
    from {
        transform: translateX(400px);
        opacity: 0;
    }
    to {
        transform: translateX(0);
        opacity: 1;
    }
}

@keyframes slideDown {
    from {
        transform: translateY(-10px);
        opacity: 0;
    }
    to {
        transform: translateY(0);
        opacity: 1;
    }
}

@keyframes fadeIn {
    from {
        opacity: 0;
        transform: scale(0.95);
    }
    to {
        opacity: 1;
        transform: scale(1);
    }
}

/* ============================================
   页脚
   ============================================ */
footer {
    text-align: center;
    padding: 20px;
    color: var(--text-muted);
    font-size: 0.9rem;
    margin-top: 40px;
    border-top: 1px solid var(--border-color);
}

.shortcut-hint {
    font-size: 0.8rem;
    color: var(--text-muted);
    margin-top: 10px;
}

/* ============================================
   响应式设计
   ============================================ */
@media (max-width: 768px) {
    main {
        grid-template-columns: 1fr;
    }
    
    h1 {
        font-size: 1.8rem;
    }

    .container {
        padding: 10px;
    }

    .panel {
        padding: 15px;
    }

    .toolbar {
        width: 100%;
    }

    .btn {
        flex: 1;
        min-width: auto;
    }

    textarea {
        min-height: 300px;
    }

    .output-area {
        min-height: 300px;
    }

    .toast {
        left: 10px;
        right: 10px;
        min-width: auto;
    }

    .stats {
        grid-template-columns: repeat(2, 1fr);
    }

    .type-details {
        left: auto;
        right: 0;
    }
}

@media (max-width: 480px) {
    .stats {
        grid-template-columns: 1fr;
    }

    .panel-header {
        flex-direction: column;
        align-items: flex-start;
    }

    .toolbar {
        width: 100%;
        flex-direction: column;
    }

    .btn {
        width: 100%;
    }
}

/* ============================================
   辅助功能
   ============================================ */
*:focus-visible {
    outline: 2px solid var(--accent-blue);
    outline-offset: 2px;
}

/* 减少动画（尊重用户偏好） */
@media (prefers-reduced-motion: reduce) {
    *,
    *::before,
    *::after {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
    }
}