/* CSV格式化工具样式 */

/* ========== 主题变量 ========== */
:root {
    /* 亮色主题 */
    --bg-primary: #ffffff;
    --bg-secondary: #f8f9fa;
    --bg-tertiary: #e9ecef;
    --text-primary: #333333;
    --text-secondary: #666666;
    --text-tertiary: #999999;
    --border-color: #dddddd;
    --border-hover: #cccccc;
    --accent-primary: #007bff;
    --accent-hover: #0056b3;
    --accent-secondary: #6c757d;
    --accent-success: #28a745;
    --accent-warning: #ffc107;
    --accent-danger: #dc3545;
    --shadow-sm: 0 1px 3px rgba(0, 0, 0, 0.1);
    --shadow-md: 0 4px 6px rgba(0, 0, 0, 0.1);
    --shadow-lg: 0 10px 15px rgba(0, 0, 0, 0.1);
    --header-bg: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    --header-text: #ffffff;
    --button-primary: #007bff;
    --button-primary-hover: #0056b3;
    --button-secondary: #6c757d;
    --button-secondary-hover: #545b62;
    --tab-bg: #f8f9fa;
    --tab-active-bg: #ffffff;
    --tab-active-border: #007bff;
    --editor-bg: #ffffff;
    --editor-text: #333333;
    --editor-border: #dddddd;
    --editor-focus: #007bff;
    --output-bg: #f8f9fa;
    --output-border: #e9ecef;
    --settings-bg: #ffffff;
    --settings-border: #e9ecef;
    --help-bg: #ffffff;
    --help-border: #e9ecef;
    --footer-bg: #f8f9fa;
    --footer-text: #6c757d;
    --notification-success: #28a745;
    --notification-warning: #ffc107;
    --notification-error: #dc3545;
    --notification-info: #007bff;
    --modal-bg: #ffffff;
    --modal-backdrop: rgba(0, 0, 0, 0.5);
}

/* 暗色主题 */
[data-theme="dark"] {
    --bg-primary: #121212;
    --bg-secondary: #1e1e1e;
    --bg-tertiary: #2d2d2d;
    --text-primary: #e0e0e0;
    --text-secondary: #b0b0b0;
    --text-tertiary: #808080;
    --border-color: #3d3d3d;
    --border-hover: #4d4d4d;
    --accent-primary: #5c9aff;
    --accent-hover: #4287f5;
    --accent-secondary: #9ca3af;
    --accent-success: #34d399;
    --accent-warning: #fbbf24;
    --accent-danger: #f87171;
    --shadow-sm: 0 1px 3px rgba(0, 0, 0, 0.3);
    --shadow-md: 0 4px 6px rgba(0, 0, 0, 0.3);
    --shadow-lg: 0 10px 15px rgba(0, 0, 0, 0.3);
    --header-bg: linear-gradient(135deg, #1a1a2e 0%, #16213e 100%);
    --header-text: #e0e0e0;
    --button-primary: #5c9aff;
    --button-primary-hover: #4287f5;
    --button-secondary: #6b7280;
    --button-secondary-hover: #4b5563;
    --tab-bg: #1e1e1e;
    --tab-active-bg: #2d2d2d;
    --tab-active-border: #5c9aff;
    --editor-bg: #1e1e1e;
    --editor-text: #e0e0e0;
    --editor-border: #3d3d3d;
    --editor-focus: #5c9aff;
    --output-bg: #1e1e1e;
    --output-border: #3d3d3d;
    --settings-bg: #1e1e1e;
    --settings-border: #3d3d3d;
    --help-bg: #1e1e1e;
    --help-border: #3d3d3d;
    --footer-bg: #1a1a1a;
    --footer-text: #b0b0b0;
    --notification-success: #34d399;
    --notification-warning: #fbbf24;
    --notification-error: #f87171;
    --notification-info: #5c9aff;
    --modal-bg: #1e1e1e;
    --modal-backdrop: rgba(0, 0, 0, 0.7);
}

/* Solarized主题 */
[data-theme="solarized"] {
    --bg-primary: #fdf6e3;
    --bg-secondary: #eee8d5;
    --bg-tertiary: #e0dbd3;
    --text-primary: #657b83;
    --text-secondary: #839496;
    --text-tertiary: #93a1a1;
    --border-color: #d8ccc4;
    --border-hover: #c6bdb5;
    --accent-primary: #268bd2;
    --accent-hover: #1b619c;
    --accent-secondary: #657b83;
    --accent-success: #859900;
    --accent-warning: #b58900;
    --accent-danger: #dc322f;
    --shadow-sm: 0 1px 3px rgba(101, 123, 131, 0.1);
    --shadow-md: 0 4px 6px rgba(101, 123, 131, 0.1);
    --shadow-lg: 0 10px 15px rgba(101, 123, 131, 0.1);
    --header-bg: linear-gradient(135deg, #2aa198 0%, #268bd2 100%);
    --header-text: #fdf6e3;
    --button-primary: #268bd2;
    --button-primary-hover: #1b619c;
    --button-secondary: #657b83;
    --button-secondary-hover: #4a5f69;
    --tab-bg: #eee8d5;
    --tab-active-bg: #fdf6e3;
    --tab-active-border: #268bd2;
    --editor-bg: #fdf6e3;
    --editor-text: #657b83;
    --editor-border: #d8ccc4;
    --editor-focus: #268bd2;
    --output-bg: #eee8d5;
    --output-border: #d8ccc4;
    --settings-bg: #fdf6e3;
    --settings-border: #d8ccc4;
    --help-bg: #fdf6e3;
    --help-border: #d8ccc4;
    --footer-bg: #eee8d5;
    --footer-text: #657b83;
    --notification-success: #859900;
    --notification-warning: #b58900;
    --notification-error: #dc322f;
    --notification-info: #268bd2;
    --modal-bg: #fdf6e3;
    --modal-backdrop: rgba(101, 123, 131, 0.5);
}

/* Monokai主题 */
[data-theme="monokai"] {
    --bg-primary: #272822;
    --bg-secondary: #383830;
    --bg-tertiary: #49483e;
    --text-primary: #f8f8f2;
    --text-secondary: #a59f85;
    --text-tertiary: #75715e;
    --border-color: #49483e;
    --border-hover: #59584e;
    --accent-primary: #66d9ef;
    --accent-hover: #49b8d1;
    --accent-secondary: #75715e;
    --accent-success: #a6e22e;
    --accent-warning: #f1fa8c;
    --accent-danger: #ff5555;
    --shadow-sm: 0 1px 3px rgba(0, 0, 0, 0.3);
    --shadow-md: 0 4px 6px rgba(0, 0, 0, 0.3);
    --shadow-lg: 0 10px 15px rgba(0, 0, 0, 0.3);
    --header-bg: linear-gradient(135deg, #66d9ef 0%, #ae81ff 100%);
    --header-text: #272822;
    --button-primary: #66d9ef;
    --button-primary-hover: #49b8d1;
    --button-secondary: #75715e;
    --button-secondary-hover: #59584e;
    --tab-bg: #383830;
    --tab-active-bg: #272822;
    --tab-active-border: #66d9ef;
    --editor-bg: #383830;
    --editor-text: #f8f8f2;
    --editor-border: #49483e;
    --editor-focus: #66d9ef;
    --output-bg: #383830;
    --output-border: #49483e;
    --settings-bg: #383830;
    --settings-border: #49483e;
    --help-bg: #383830;
    --help-border: #49483e;
    --footer-bg: #222222;
    --footer-text: #75715e;
    --notification-success: #a6e22e;
    --notification-warning: #f1fa8c;
    --notification-error: #ff5555;
    --notification-info: #66d9ef;
    --modal-bg: #383830;
    --modal-backdrop: rgba(0, 0, 0, 0.7);
}

/* ========== 基础样式 ========== */
body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, Cantarell, 'Open Sans', 'Helvetica Neue', sans-serif;
    background-color: var(--bg-primary);
    color: var(--text-primary);
    line-height: 1.6;
    margin: 0;
    padding: 0;
    transition: background-color 0.3s ease, color 0.3s ease;
}

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

/* ========== 页面头部 ========== */
.page-header {
    background: var(--header-bg);
    color: var(--header-text);
    padding: 30px 0;
    margin-bottom: 30px;
    box-shadow: var(--shadow-md);
}

.page-header h1 {
    margin: 0 0 10px 0;
    font-size: 2.5rem;
    font-weight: 700;
}

.page-header .subtitle {
    margin: 0 0 20px 0;
    font-size: 1.1rem;
    opacity: 0.9;
}

.tool-nav {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    align-items: center;
}

.nav-item {
    color: var(--header-text);
    text-decoration: none;
    padding: 5px 10px;
    border-radius: 4px;
    transition: background-color 0.2s ease;
}

.nav-item:hover {
    background-color: rgba(255, 255, 255, 0.1);
}

.nav-divider {
    color: var(--header-text);
    opacity: 0.6;
}

/* ========== 主内容区域 ========== */
.main-content {
    padding-bottom: 50px;
}

/* 操作按钮 */
.action-buttons {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    margin-bottom: 20px;
    padding: 20px;
    background-color: var(--bg-secondary);
    border-radius: 8px;
    box-shadow: var(--shadow-sm);
}

/* 按钮样式 */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 10px 20px;
    border: none;
    border-radius: 4px;
    font-size: 14px;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s ease;
    text-decoration: none;
    outline: none;
}

.btn:hover {
    transform: translateY(-1px);
    box-shadow: var(--shadow-md);
}

.btn:active {
    transform: translateY(0);
    box-shadow: var(--shadow-sm);
}

.btn-primary {
    background-color: var(--button-primary);
    color: white;
}

.btn-primary:hover {
    background-color: var(--button-primary-hover);
}

.btn-secondary {
    background-color: var(--button-secondary);
    color: white;
}

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

.btn-small {
    padding: 8px 16px;
    font-size: 13px;
}

/* 文件上传按钮 */
.file-upload-label {
    position: relative;
    overflow: hidden;
    cursor: pointer;
}

.file-upload-input {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    opacity: 0;
    cursor: pointer;
}

/* 工具容器 */
.tool-container {
    display: grid;
    grid-template-columns: 1fr 350px;
    gap: 30px;
    margin-bottom: 30px;
}

/* 编辑器区域 */
.editor-section {
    background-color: var(--bg-secondary);
    border-radius: 8px;
    overflow: hidden;
    box-shadow: var(--shadow-md);
}

/* 标签页 */
.tabs {
    display: flex;
    flex-wrap: wrap;
    background-color: var(--tab-bg);
    border-bottom: 1px solid var(--border-color);
}

.tab-btn {
    padding: 12px 20px;
    border: none;
    background: none;
    color: var(--text-secondary);
    cursor: pointer;
    font-size: 14px;
    font-weight: 500;
    transition: all 0.2s ease;
    border-bottom: 2px solid transparent;
}

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

.tab-btn.active {
    color: var(--tab-active-border);
    background-color: var(--tab-active-bg);
    border-bottom-color: var(--tab-active-border);
}

/* 编辑器容器 */
.editor-container {
    position: relative;
    height: 600px;
    overflow: hidden;
}

.editor-panel {
    display: none;
    height: 100%;
    overflow: hidden;
}

.editor-panel.active {
    display: block;
}

/* 输入区域 */
#source-editor {
    width: 100%;
    height: 100%;
    padding: 20px;
    border: none;
    background-color: var(--editor-bg);
    color: var(--editor-text);
    font-family: 'Consolas', 'Monaco', 'Courier New', monospace;
    font-size: 14px;
    line-height: 1.5;
    resize: none;
    outline: none;
    box-sizing: border-box;
}

#source-editor:focus {
    box-shadow: inset 0 0 0 1px var(--editor-focus);
}

/* 输出区域 */
.output {
    width: 100%;
    height: 100%;
    padding: 20px;
    margin: 0;
    background-color: var(--output-bg);
    color: var(--editor-text);
    font-family: 'Consolas', 'Monaco', 'Courier New', monospace;
    font-size: 14px;
    line-height: 1.5;
    overflow: auto;
    white-space: pre-wrap;
    word-wrap: break-word;
    box-sizing: border-box;
}

/* HTML表格输出容器 */
.output-table-container {
    width: 100%;
    height: 100%;
    padding: 20px;
    background-color: var(--output-bg);
    overflow: auto;
    box-sizing: border-box;
}

/* 表格样式 */
.csv-table {
    width: 100%;
    border-collapse: collapse;
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, Cantarell, 'Open Sans', 'Helvetica Neue', sans-serif;
    font-size: 14px;
}

.csv-table th, .csv-table td {
    padding: 10px;
    border: 1px solid var(--border-color);
    text-align: left;
}

.csv-table th {
    background-color: var(--bg-tertiary);
    font-weight: 600;
}

.csv-table tr:nth-child(even) {
    background-color: var(--bg-tertiary);
}

/* 错误输出 */
.error-output {
    color: var(--accent-danger);
}

/* 设置区域 */
.settings-section {
    display: flex;
    flex-direction: column;
    gap: 20px;
}

.settings-group {
    background-color: var(--settings-bg);
    border-radius: 8px;
    padding: 20px;
    box-shadow: var(--shadow-md);
    border: 1px solid var(--settings-border);
}

.settings-title {
    margin: 0 0 15px 0;
    font-size: 1.2rem;
    font-weight: 600;
    color: var(--text-primary);
}

.setting-item {
    margin-bottom: 15px;
}

.setting-item:last-child {
    margin-bottom: 0;
}

.setting-label {
    display: block;
    margin-bottom: 5px;
    font-weight: 500;
    color: var(--text-primary);
}

.setting-input {
    width: 100%;
    padding: 8px 12px;
    border: 1px solid var(--border-color);
    border-radius: 4px;
    background-color: var(--bg-primary);
    color: var(--text-primary);
    font-size: 14px;
    transition: border-color 0.2s ease;
}

.setting-input:focus {
    outline: none;
    border-color: var(--editor-focus);
}

.setting-checkbox {
    display: flex;
    align-items: center;
    cursor: pointer;
    font-weight: normal;
}

.setting-checkbox input[type="checkbox"] {
    margin-right: 8px;
}

/* 工具按钮网格 */
.tool-buttons-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 10px;
}

/* 统计信息 */
.stats-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 12px;
}

.stat-item {
    display: flex;
    justify-content: space-between;
    padding: 8px 0;
    border-bottom: 1px solid var(--border-color);
}

.stat-item:last-child {
    border-bottom: none;
}

.stat-label {
    font-weight: 500;
    color: var(--text-secondary);
}

.stat-value {
    font-weight: 600;
    color: var(--text-primary);
}

/* 帮助部分 */
.help-section {
    background-color: var(--help-bg);
    border-radius: 8px;
    padding: 30px;
    box-shadow: var(--shadow-md);
    border: 1px solid var(--help-border);
}

.help-section h2 {
    margin: 0 0 20px 0;
    font-size: 1.5rem;
    font-weight: 700;
    color: var(--text-primary);
}

.help-content {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
    gap: 20px;
}

.help-item h3 {
    margin: 0 0 10px 0;
    font-size: 1.1rem;
    font-weight: 600;
    color: var(--text-primary);
}

.help-item ul {
    margin: 0;
    padding-left: 20px;
}

.help-item li {
    margin-bottom: 8px;
    color: var(--text-secondary);
}

.help-item li:last-child {
    margin-bottom: 0;
}

.help-item kbd {
    display: inline-block;
    padding: 2px 6px;
    margin: 0 2px;
    background-color: var(--bg-tertiary);
    border: 1px solid var(--border-color);
    border-radius: 3px;
    font-size: 12px;
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, Cantarell, 'Open Sans', 'Helvetica Neue', sans-serif;
    box-shadow: 0 1px 1px rgba(0, 0, 0, 0.1);
}

/* ========== 页脚 ========== */
.page-footer {
    background-color: var(--footer-bg);
    color: var(--footer-text);
    padding: 30px 0;
    border-top: 1px solid var(--border-color);
}

.page-footer p {
    margin: 5px 0;
    text-align: center;
}

.footer-links a {
    color: var(--footer-text);
    text-decoration: none;
    transition: color 0.2s ease;
}

.footer-links a:hover {
    color: var(--accent-primary);
}

/* ========== 通知组件 ========== */
.notification {
    position: fixed;
    top: 20px;
    right: 20px;
    padding: 15px 20px;
    background-color: var(--notification-info);
    color: white;
    border-radius: 4px;
    box-shadow: var(--shadow-lg);
    z-index: 1000;
    opacity: 0;
    transform: translateX(100%);
    transition: all 0.3s ease;
    max-width: 350px;
}

.notification.show {
    opacity: 1;
    transform: translateX(0);
}

.notification.success {
    background-color: var(--notification-success);
}

.notification.warning {
    background-color: var(--notification-warning);
    color: var(--text-primary);
}

.notification.error {
    background-color: var(--notification-error);
}

.notification.info {
    background-color: var(--notification-info);
}

/* ========== 模态框 ========== */
.modal {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: var(--modal-backdrop);
    z-index: 1000;
    overflow: auto;
}

.modal-content {
    background-color: var(--modal-bg);
    margin: 10% auto;
    padding: 0;
    border-radius: 8px;
    box-shadow: var(--shadow-lg);
    width: 90%;
    max-width: 600px;
    max-height: 80vh;
    overflow: hidden;
    display: flex;
    flex-direction: column;
    animation: modalFadeIn 0.3s ease;
}

@keyframes modalFadeIn {
    from { opacity: 0; transform: translateY(-20px); }
    to { opacity: 1; transform: translateY(0); }
}

.modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 20px;
    border-bottom: 1px solid var(--border-color);
}

.modal-header h2 {
    margin: 0;
    font-size: 1.3rem;
    font-weight: 600;
    color: var(--text-primary);
}

.close-modal,
.close-tool-modal {
    font-size: 28px;
    font-weight: bold;
    color: var(--text-tertiary);
    cursor: pointer;
    transition: color 0.2s ease;
}

.close-modal:hover,
.close-tool-modal:hover {
    color: var(--text-primary);
}

.modal-body {
    padding: 20px;
    overflow-y: auto;
    flex-grow: 1;
}

.modal-output {
    width: 100%;
    min-height: 200px;
    padding: 15px;
    margin: 0;
    background-color: var(--output-bg);
    color: var(--text-primary);
    border: 1px solid var(--border-color);
    border-radius: 4px;
    font-family: 'Consolas', 'Monaco', 'Courier New', monospace;
    font-size: 14px;
    line-height: 1.5;
    overflow: auto;
    white-space: pre-wrap;
    word-wrap: break-word;
    box-sizing: border-box;
}

.modal-footer {
    display: flex;
    justify-content: flex-end;
    gap: 10px;
    padding: 20px;
    border-top: 1px solid var(--border-color);
}

/* 工具模态框内容 */
.tool-modal-content {
    padding: 10px 0;
}

/* ========== 语法高亮样式 ========== */
/* CSV语法高亮 */
.csv-header {
    font-weight: bold;
    color: var(--accent-primary);
}

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

.csv-number {
    color: var(--accent-success);
}

.csv-string {
    color: var(--accent-warning);
}

.csv-boolean {
    color: var(--accent-danger);
}

/* JSON语法高亮 */
.json-key {
    color: var(--accent-primary);
}

.json-string {
    color: var(--accent-warning);
}

.json-number {
    color: var(--accent-success);
}

.json-boolean {
    color: var(--accent-danger);
}

.json-null {
    color: var(--text-tertiary);
}

/* XML语法高亮 */
.xml-tag {
    color: var(--accent-primary);
}

.xml-attribute {
    color: var(--accent-warning);
}

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

.xml-comment {
    color: var(--text-tertiary);
    font-style: italic;
}

/* ========== 响应式设计 ========== */
@media (max-width: 1200px) {
    .tool-container {
        grid-template-columns: 1fr;
    }
    
    .settings-section {
        grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
    }
}

@media (max-width: 768px) {
    .container {
        padding: 0 15px;
    }
    
    .page-header {
        padding: 20px 0;
    }
    
    .page-header h1 {
        font-size: 2rem;
    }
    
    .nav-item,
    .nav-divider {
        font-size: 14px;
    }
    
    .action-buttons {
        padding: 15px;
    }
    
    .btn {
        padding: 8px 16px;
        font-size: 13px;
    }
    
    .editor-container {
        height: 400px;
    }
    
    #source-editor,
    .output {
        padding: 15px;
        font-size: 13px;
    }
    
    .settings-group {
        padding: 15px;
    }
    
    .tabs {
        flex-wrap: nowrap;
        overflow-x: auto;
    }
    
    .tab-btn {
        padding: 10px 15px;
        font-size: 13px;
        flex-shrink: 0;
    }
    
    .help-section {
        padding: 20px;
    }
    
    .help-content {
        grid-template-columns: 1fr;
    }
    
    .modal-content {
        width: 95%;
        margin: 15% auto;
    }
}

@media (max-width: 480px) {
    .tool-buttons-grid {
        grid-template-columns: 1fr;
    }
    
    .stats-grid {
        grid-template-columns: 1fr;
    }
}

/* ========== 打印样式 ========== */
@media print {
    body {
        background-color: white;
        color: black;
    }
    
    .page-header,
    .action-buttons,
    .settings-section,
    .help-section,
    .page-footer,
    .notification,
    .modal {
        display: none !important;
    }
    
    .container {
        max-width: 100%;
        padding: 0;
    }
    
    .tool-container {
        grid-template-columns: 1fr;
        gap: 0;
    }
    
    .editor-section {
        box-shadow: none;
        border-radius: 0;
    }
    
    .tabs {
        display: none;
    }
    
    .editor-container {
        height: auto;
    }
    
    .editor-panel {
        display: block !important;
        height: auto;
    }
    
    #source-editor {
        display: none;
    }
    
    .output {
        background-color: white;
        color: black;
        padding: 0;
        font-size: 12px;
    }
    
    /* 打印时只显示格式化结果 */
    #formatted-panel {
        display: block !important;
    }
    
    #compressed-panel,
    #json-panel,
    #xml-panel,
    #html-panel,
    #error-panel {
        display: none !important;
    }
}

/* ========== 动画效果 ========== */
/* 平滑滚动 */
html {
    scroll-behavior: smooth;
}

/* 加载动画 */
@keyframes spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

/* 表格行悬停效果 */
.csv-table tr:hover {
    background-color: var(--bg-tertiary) !important;
    transition: background-color 0.2s ease;
}

/* 行号显示 */
.editor-container.line-numbers .output,
.editor-container.line-numbers #source-editor {
    padding-left: 50px;
    position: relative;
}

.editor-container.line-numbers::before {
    content: "";
    position: absolute;
    left: 0;
    top: 0;
    bottom: 0;
    width: 40px;
    background-color: var(--bg-tertiary);
    border-right: 1px solid var(--border-color);
}

/* 焦点样式 */
button:focus,
input:focus,
select:focus,
textarea:focus {
    outline: 2px solid var(--editor-focus);
    outline-offset: 2px;
}

/* 禁用状态 */
button:disabled,
input:disabled,
select:disabled {
    opacity: 0.6;
    cursor: not-allowed;
}

/* 工具提示 */
[title] {
    cursor: help;
}