/* 全局样式 */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    min-height: 100vh;
    color: #333;
}

.container {
    max-width: 1200px;
    margin: 0 auto;
    padding: 20px;
}

/* 头部样式 */
header {
    margin-bottom: 30px;
    color: white;
}

.header-content {
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-wrap: wrap;
    gap: 20px;
}

.header-text {
    text-align: center;
    flex: 1;
}

.header-text h1 {
    font-size: 2.5rem;
    margin-bottom: 10px;
    text-shadow: 2px 2px 4px rgba(0,0,0,0.3);
}

.header-text p {
    font-size: 1.1rem;
    opacity: 0.9;
}

.header-controls {
    display: flex;
    gap: 10px;
}

/* 语言切换按钮 */
.btn-language {
    background: rgba(255, 255, 255, 0.1);
    color: white;
    border: 2px solid rgba(255, 255, 255, 0.3);
    padding: 8px 16px;
    border-radius: 20px;
    font-size: 14px;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.3s ease;
    backdrop-filter: blur(10px);
}

.btn-language:hover {
    background: rgba(255, 255, 255, 0.2);
    border-color: rgba(255, 255, 255, 0.5);
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(255, 255, 255, 0.2);
}

/* 主要内容区域 */
.main-content {
    background: white;
    border-radius: 15px;
    padding: 30px;
    box-shadow: 0 10px 30px rgba(0,0,0,0.2);
    margin-bottom: 20px;
}

/* 顶部控制按钮 */
.controls-top {
    text-align: center;
    margin-bottom: 25px;
    padding-bottom: 20px;
    border-bottom: 2px solid #f0f0f0;
}

/* 编辑器容器 - 左右分栏 */
.editor-container {
    display: flex;
    gap: 20px;
    min-height: 500px;
}

/* 输入和输出区域 */
.input-section, .output-section {
    flex: 1;
    display: flex;
    flex-direction: column;
    min-width: 0; /* 允许flex项目缩小 */
}

/* 分隔线 */
.divider {
    width: 2px;
    background: linear-gradient(to bottom, #e0e0e0, #667eea, #e0e0e0);
    border-radius: 1px;
    flex-shrink: 0;
    position: relative;
    opacity: 0.6;
    transition: opacity 0.3s ease;
}

.divider:hover {
    opacity: 1;
}

.divider::before {
    content: '';
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: 8px;
    height: 8px;
    background: #667eea;
    border-radius: 50%;
    box-shadow: 0 2px 4px rgba(102, 126, 234, 0.3);
}

.section-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 15px;
    padding-bottom: 10px;
    border-bottom: 2px solid #f0f0f0;
}

.section-header h2 {
    color: #333;
    font-size: 1.3rem;
}

/* 文本区域容器 */
.textarea-container {
    position: relative;
    border-radius: 8px;
    overflow: hidden;
    border: 2px solid #e0e0e0;
    transition: border-color 0.3s ease;
    flex: 1;
    display: flex;
    flex-direction: column;
}

.textarea-container:focus-within {
    border-color: #667eea;
}

#jsonInput {
    width: 100%;
    height: 100%;
    min-height: 400px;
    padding: 15px;
    border: none;
    outline: none;
    font-family: 'Consolas', 'Monaco', 'Courier New', monospace;
    font-size: 14px;
    line-height: 1.5;
    resize: none;
    background: #fafafa;
    flex: 1;
}

/* 拖拽区域 */
.drop-zone {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(102, 126, 234, 0.1);
    border: 2px dashed #667eea;
    display: none;
    align-items: center;
    justify-content: center;
    backdrop-filter: blur(2px);
}

.drop-zone.active {
    display: flex;
}

.drop-content {
    text-align: center;
    color: #667eea;
}

.drop-content span {
    font-size: 3rem;
    display: block;
    margin-bottom: 10px;
}

/* 输出区域 */
.output-container {
    border: 2px solid #e0e0e0;
    border-radius: 8px;
    background: #1e1e1e;
    min-height: 400px;
    overflow: auto;
    flex: 1;
    display: flex;
    flex-direction: column;
}

#jsonOutput {
    margin: 0;
    padding: 15px;
    background: transparent;
    color: #d4d4d4;
    font-family: 'Consolas', 'Monaco', 'Courier New', monospace;
    font-size: 14px;
    line-height: 1.5;
    white-space: pre-wrap;
    word-wrap: break-word;
    flex: 1;
    height: 100%;
    overflow: auto;
}

/* 控制按钮区域（已移动到顶部） */

.input-controls, .output-controls {
    display: flex;
    gap: 10px;
}

/* 按钮样式 */
.btn {
    padding: 10px 20px;
    border: none;
    border-radius: 6px;
    cursor: pointer;
    font-size: 14px;
    font-weight: 500;
    transition: all 0.3s ease;
    text-decoration: none;
    display: inline-block;
}

.btn-primary {
    background: linear-gradient(135deg, #667eea, #764ba2);
    color: white;
    margin: 0 5px;
}

.btn-primary:hover {
    transform: translateY(-2px);
    box-shadow: 0 5px 15px rgba(102, 126, 234, 0.4);
}

.btn-secondary {
    background: #f8f9fa;
    color: #333;
    border: 1px solid #dee2e6;
}

.btn-secondary:hover {
    background: #e9ecef;
    transform: translateY(-1px);
}

/* 状态栏 */
.status-bar {
    background: white;
    border-radius: 10px;
    padding: 15px 20px;
    margin-bottom: 20px;
    box-shadow: 0 5px 15px rgba(0,0,0,0.1);
    display: flex;
    justify-content: space-between;
    align-items: center;
}

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

.status-message.success {
    color: #28a745;
}

.status-message.error {
    color: #dc3545;
}

.status-message.info {
    color: #17a2b8;
}

.json-info {
    font-size: 0.9rem;
    color: #666;
}

/* 页脚 */
footer {
    text-align: center;
    color: white;
    margin-top: 30px;
}

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

.feature {
    background: rgba(255,255,255,0.1);
    padding: 15px;
    border-radius: 10px;
    backdrop-filter: blur(10px);
}

.feature .icon {
    font-size: 1.5rem;
    margin-right: 10px;
}

/* 响应式设计 */
@media (max-width: 768px) {
    .container {
        padding: 10px;
    }

    .header-content {
        flex-direction: column;
        text-align: center;
        gap: 15px;
    }

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

    .main-content {
        padding: 20px;
    }

    /* 移动端改为上下布局 */
    .editor-container {
        flex-direction: column;
        gap: 20px;
    }

    .divider {
        width: 100%;
        height: 2px;
        background: linear-gradient(to right, #e0e0e0, #f0f0f0, #e0e0e0);
    }

    .section-header {
        flex-direction: column;
        align-items: flex-start;
        gap: 10px;
    }

    .input-controls, .output-controls {
        flex-wrap: wrap;
    }

    #jsonInput {
        min-height: 250px;
    }

    .output-container {
        min-height: 250px;
    }

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

    .status-bar {
        flex-direction: column;
        gap: 10px;
        text-align: center;
    }
}

/* 平板设备优化 */
@media (max-width: 1024px) and (min-width: 769px) {
    .editor-container {
        gap: 15px;
    }

    .main-content {
        padding: 25px;
    }

    #jsonInput {
        min-height: 350px;
    }

    .output-container {
        min-height: 350px;
    }
}

/* 滚动条样式 */
::-webkit-scrollbar {
    width: 8px;
}

::-webkit-scrollbar-track {
    background: #f1f1f1;
    border-radius: 4px;
}

::-webkit-scrollbar-thumb {
    background: #888;
    border-radius: 4px;
}

::-webkit-scrollbar-thumb:hover {
    background: #555;
}

/* 动画效果 */
@keyframes fadeIn {
    from { opacity: 0; transform: translateY(20px); }
    to { opacity: 1; transform: translateY(0); }
}

.main-content {
    animation: fadeIn 0.6s ease-out;
}

/* 代码高亮自定义样式 */
.token.string {
    color: #98c379 !important;
}

.token.number {
    color: #d19a66 !important;
}

.token.boolean {
    color: #56b6c2 !important;
}

.token.null {
    color: #c678dd !important;
}

.token.property {
    color: #e06c75 !important;
}

/* 验证错误样式 */
.validation-error {
    color: #d4d4d4;
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    line-height: 1.5;
    text-align: left;
}

.validation-error .error-header {
    margin-bottom: 15px;
}

.validation-error .error-header h3 {
    color: #ff6b6b;
    margin: 0 0 15px 0;
    font-size: 1.2rem;
}

.validation-error .error-details h4 {
    color: #ffd93d;
    margin: 20px 0 8px 0;
    font-size: 1rem;
}

.validation-error .error-details h4:first-child {
    margin-top: 0;
}

.validation-error .error-message {
    background: rgba(255, 107, 107, 0.1);
    border-left: 4px solid #ff6b6b;
    padding: 10px 15px;
    margin: 10px 0;
    border-radius: 4px;
    font-family: 'Consolas', 'Monaco', 'Courier New', monospace;
}

.validation-error .error-position {
    color: #74c0fc;
    font-weight: bold;
    margin: 5px 0;
}

.validation-error .error-code {
    background: #2d2d2d;
    border: 1px solid #444;
    border-radius: 6px;
    margin: 15px 0;
    overflow-x: auto;
    max-height: 300px;
    overflow-y: auto;
}

.validation-error .error-code pre {
    margin: 0;
    padding: 15px;
    font-family: 'Consolas', 'Monaco', 'Courier New', monospace;
    font-size: 13px;
    line-height: 1.8;
    white-space: pre-wrap;
    word-wrap: break-word;
    overflow-wrap: break-word;
}

.validation-error .error-code code {
    background: transparent;
    color: #d4d4d4;
    white-space: pre-wrap;
    word-wrap: break-word;
    display: block;
    font-family: inherit;
}

/* 行号样式 */
.line-number {
    color: #666;
    margin-right: 15px;
    user-select: none;
    display: inline-block;
    width: 40px;
    text-align: right;
    font-size: 12px;
    vertical-align: top;
    flex-shrink: 0;
}

.error-line-number {
    color: #ff6b6b;
    background: rgba(255, 107, 107, 0.15);
    margin-right: 15px;
    user-select: none;
    display: inline-block;
    width: 40px;
    text-align: right;
    font-weight: bold;
    font-size: 12px;
    padding: 2px 4px;
    border-radius: 3px;
    vertical-align: top;
    flex-shrink: 0;
}

/* 错误行高亮 */
.error-line {
    background: rgba(255, 107, 107, 0.1);
    display: inline;
    padding: 2px 4px;
    border-radius: 3px;
    margin: 0 -2px;
}

/* 代码行容器 */
.validation-error .error-code pre {
    counter-reset: line-number;
}

.validation-error .error-code .code-line {
    display: flex;
    align-items: flex-start;
    margin: 0;
    padding: 2px 0;
    min-height: 1.8em;
    line-height: 1.8;
}

.validation-error .error-code .code-line .line-number,
.validation-error .error-code .code-line .error-line-number {
    flex-shrink: 0;
    margin-right: 15px;
}

.validation-error .error-code .code-line .error-line {
    flex: 1;
    word-break: break-all;
    overflow-wrap: break-word;
    white-space: pre-wrap;
}

/* 确保普通文本也能正确换行 */
.validation-error .error-code .code-line {
    word-break: break-all;
    overflow-wrap: break-word;
    white-space: pre-wrap;
}

/* 错误字符高亮 */
.error-highlight {
    background: #ff6b6b;
    color: white;
    padding: 2px 4px;
    border-radius: 3px;
    font-weight: bold;
    animation: errorPulse 1.5s infinite;
}

@keyframes errorPulse {
    0%, 100% {
        background: #ff6b6b;
        box-shadow: 0 0 5px rgba(255, 107, 107, 0.5);
    }
    50% {
        background: #ff5252;
        box-shadow: 0 0 15px rgba(255, 107, 107, 0.8);
    }
}

.validation-error .file-info,
.validation-error .suggestions {
    margin: 10px 0;
    padding-left: 20px;
}

.validation-error .file-info li,
.validation-error .suggestions li {
    margin: 5px 0;
    color: #b8b8b8;
    line-height: 1.4;
}

.validation-error .suggestions li {
    color: #a8e6cf;
}

.validation-error .fix-note {
    margin-top: 20px;
    padding: 10px;
    background: rgba(255, 193, 7, 0.1);
    border-left: 4px solid #ffc107;
    border-radius: 4px;
    color: #ffc107;
    font-weight: 500;
}

/* 确保验证错误容器的基本样式 */
.validation-error * {
    box-sizing: border-box;
}

.validation-error p {
    margin: 8px 0;
    line-height: 1.5;
}

.validation-error ul {
    margin: 8px 0;
    list-style-type: disc;
}

.validation-error li {
    margin: 4px 0;
}
