/* ========== 公共布局样式 ========== */
* { margin: 0; padding: 0; box-sizing: border-box; }

:root {
    --font-body: -apple-system, BlinkMacSystemFont, 'Segoe UI', 'PingFang SC', 'Microsoft YaHei', sans-serif;
    --font-code: 'Consolas', 'Monaco', 'Menlo', 'Courier New', monospace;
}

body {
    font-family: var(--font-body);
    background: #f0f2f5;
    height: 100vh;
    overflow: hidden;
}

.app-container { display: flex; height: 100vh; }

/* ========== 左侧导航 ========== */
.sidebar {
    width: 260px;
    background: linear-gradient(180deg, #1a1a2e 0%, #16213e 100%);
    color: #fff;
    display: flex;
    flex-direction: column;
    box-shadow: 2px 0 10px rgba(0,0,0,0.1);
    flex-shrink: 0;
}

.sidebar-header {
    padding: 25px 20px;
    border-bottom: 1px solid rgba(255,255,255,0.1);
}

.sidebar-header h1 {
    font-size: 1.4rem;
    font-weight: 600;
    display: flex;
    align-items: center;
    gap: 10px;
}

.sidebar-header h1 a {
    color: #fff;
    text-decoration: none;
    display: flex;
    align-items: center;
    gap: 10px;
    transition: opacity 0.2s ease;
}

.sidebar-header h1 a:hover { opacity: 0.8; }

.sidebar-header h1 .logo-icon {
    width: 36px;
    height: 36px;
    background: linear-gradient(135deg, #667eea, #764ba2);
    border-radius: 10px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 18px;
}

.sidebar-header p {
    font-size: 0.8rem;
    color: rgba(255,255,255,0.5);
    margin-top: 8px;
    padding-left: 46px;
}

.nav-list { flex: 1; overflow-y: auto; padding: 15px 0; }
.nav-list::-webkit-scrollbar { width: 4px; }
.nav-list::-webkit-scrollbar-thumb { background: rgba(255,255,255,0.2); border-radius: 2px; }

.nav-category {
    padding: 8px 20px;
    font-size: 0.7rem;
    text-transform: uppercase;
    color: rgba(255,255,255,0.4);
    letter-spacing: 1px;
    margin-top: 10px;
}

.nav-item {
    display: flex;
    align-items: center;
    padding: 12px 20px;
    cursor: pointer;
    transition: all 0.2s ease;
    border-left: 3px solid transparent;
    gap: 12px;
    text-decoration: none;
    color: inherit;
}

.nav-item:hover { background: rgba(255,255,255,0.08); }
.nav-item.active { background: rgba(102, 126, 234, 0.2); border-left-color: #667eea; }

.nav-item .icon {
    width: 32px;
    height: 32px;
    border-radius: 8px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 16px;
    flex-shrink: 0;
}

.nav-item .info { flex: 1; min-width: 0; }
.nav-item .info .name { font-size: 0.9rem; font-weight: 500; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.nav-item .info .desc { font-size: 0.7rem; color: rgba(255,255,255,0.4); margin-top: 2px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

.icon-code { background: linear-gradient(135deg, #667eea, #764ba2); }
.icon-text { background: linear-gradient(135deg, #f093fb, #f5576c); }
.icon-util { background: linear-gradient(135deg, #4facfe, #00f2fe); }
.icon-convert { background: linear-gradient(135deg, #43e97b, #38f9d7); }
.icon-compare { background: linear-gradient(135deg, #fa709a, #fee140); }
.icon-pass { background: linear-gradient(135deg, #a18cd1, #fbc2eb); }

/* ========== 右侧内容区 ========== */
.main-content { flex: 1; display: flex; flex-direction: column; min-width: 0; overflow-y: auto; }

.top-bar {
    height: 56px;
    background: #fff;
    border-bottom: 1px solid #e8e8e8;
    display: flex;
    align-items: center;
    padding: 0 24px;
    box-shadow: 0 1px 4px rgba(0,0,0,0.05);
    flex-shrink: 0;
}

.top-bar .current-tool {
    font-size: 1rem;
    font-weight: 500;
    color: #333;
    display: flex;
    align-items: center;
    gap: 8px;
}

.top-bar .current-tool .badge {
    font-size: 0.7rem;
    padding: 2px 8px;
    background: #f0f4ff;
    color: #667eea;
    border-radius: 10px;
}

.tool-container { flex: 1; padding: 30px; overflow-y: auto; }
.tool-wrapper {margin: 0 auto; }

/* ========== 工具头部 ========== */
.tool-header { text-align: center; margin-bottom: 30px; }
.tool-header h1 { font-size: 2rem; margin-bottom: 8px; display: flex; align-items: center; justify-content: center; gap: 12px; }
.tool-header .icon { width: 50px; height: 50px; background: rgba(102, 126, 234, 0.1); border-radius: 12px; display: flex; align-items: center; justify-content: center; font-size: 24px; }
.tool-header p { opacity: 0.7; font-size: 0.95rem; }

/* ========== 卡片 ========== */
.tool-card { background: #fff; border-radius: 20px; box-shadow: 0 10px 40px rgba(0,0,0,0.08); padding: 20px;margin-bottom:20px; }

/* ========== 表单元素 ========== */
.tool-card textarea {
    width: 100%;
    border: 2px solid #e2e8f0;
    border-radius: 12px;
    padding: 12px;
    font-size: 14px;
    line-height: 1.6;
    resize: vertical;
    transition: border-color 0.2s;
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', 'PingFang SC', sans-serif;
}
.tool-card textarea:focus { outline: none; border-color: #667eea; }
.tool-card label {font-size: 0.9rem; font-weight: 600; color: #4a5568; margin-bottom: 10px; }

.tool-card .btn-group { display: flex; gap: 12px; justify-content: center; flex-wrap: wrap; margin-top: 20px; }
.tool-card .btn { padding: 12px 28px; border: none; border-radius: 10px; font-size: 0.95rem; font-weight: 500; cursor: pointer; transition: all 0.2s; }
.tool-card .btn-primary { background: linear-gradient(135deg, #667eea, #764ba2); color: #fff; }
.tool-card .btn-primary:hover { transform: translateY(-2px); box-shadow: 0 4px 15px rgba(102, 126, 234, 0.4); }
.tool-card .btn-secondary { background: #e2e8f0; color: #4a5568; }
.tool-card .btn-secondary:hover { background: #cbd5e0; }
.tool-card .btn-success { background: linear-gradient(135deg, #11998e, #38ef7d); color: #fff; }
.tool-card .btn-success:hover { transform: translateY(-2px); box-shadow: 0 4px 15px rgba(17, 153, 142, 0.4); }

/* ========== 提示框 ========== */
.warning-box { background: #fff3cd; border: 1px solid #ffc107; border-radius: 8px; padding: 12px 16px; margin-bottom: 20px; font-size: 0.85rem; color: #856404; }

/* ========== 表单控件 ========== */
.form-input { width: 100%; padding: 12px; border: 2px solid #e2e8f0; border-radius: 10px; font-size: 14px; transition: border-color 0.2s; }
.form-input:focus { outline: none; border-color: #667eea; }
.form-select { padding: 8px 12px; border: 2px solid #e2e8f0; border-radius: 8px; font-size: 14px; background: #fff; }
.check-label { display: flex; align-items: center; gap: 8px; font-weight: normal; cursor: pointer; }

/* ========== 布局辅助 ========== */
.flex-wrap { display: flex; flex-wrap: wrap; gap: 20px; }
.flex-wrap.align-center { align-items: center; }
.flex-wrap.gap-15 { gap: 15px; }
.grid-2 { display: grid; grid-template-columns: repeat(2, 1fr); gap: 15px; }
.grid-3 { display: grid; grid-template-columns: repeat(3, 1fr); gap: 15px; }
.grid-4 { display: grid; grid-template-columns: repeat(4, 1fr); gap: 15px; }
.grid-5 { display: grid; grid-template-columns: repeat(5, 1fr); gap: 15px; }
.mt-12 { margin-top: 12px; }
.mt-20 { margin-top: 20px; }
.mt-25 { margin-top: 25px; }
.mb-20 { margin-bottom: 20px; }

/* ========== 设置面板 ========== */
.settings-panel { background: #f7fafc; border-radius: 12px; padding: 20px; margin-bottom: 20px; display: flex; align-items: center; }
.settings-row { display: flex; flex-wrap: nowrap; gap: 15px; width: 100%; }
.settings-row.mb-15 { margin-bottom: 15px; }
.settings-row .check-label, .settings-row .form-select, .settings-row .hint-text { display: flex; align-items: center; height: 36px; }
.settings-row .check-label input { margin: 0; }
.hint-text { font-size: 0.85rem; color: #4a5568; }

/* ========== 统计卡片 ========== */
.stats-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(140px, 1fr)); gap: 15px; margin-top: 20px; }
.stat-card { background: #f7fafc; border-radius: 12px; padding: 20px; text-align: center; border-left: 4px solid #667eea; }
.stat-card .stat-icon { font-size: 24px; margin-bottom: 8px; }
.stat-card .stat-value { font-size: 1.8rem; font-weight: 700; }
.stat-card .stat-label { font-size: 0.8rem; color: #718096; margin-top: 4px; }
.stat-card.border-red { border-left-color: #f56565; }
.stat-card.border-purple { border-left-color: #9f7aea; }
.stat-card.border-green { border-left-color: #48bb78; }
.stat-card.border-orange { border-left-color: #ed8936; }
.stat-card.border-teal { border-left-color: #38b2ac; }

/* ========== 对比/结果 ========== */
.diff-result { background: #f7fafc; border-radius: 12px; padding: 20px; min-height: 150px; display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: 15px; }
.result-output { background: #f7fafc; border-radius: 12px; padding: 16px; min-height: 80px; font-size: 16px; line-height: 1.8; }
.btn-small { padding: 8px 20px; font-size: 0.85rem; }
.btn-full { width: 100%; padding: 16px; font-size: 1.1rem; }
.text-right { text-align: right; }

/* ========== 文本对比 ========== */
.text-input-group { margin-bottom: 15px; }
.text-input-header { display: flex; justify-content: space-between; align-items: center; margin-bottom: 12px; }
.text-input-header label { margin-bottom: 0; font-size: 1rem; font-weight: 600; }
.text-count-badge { font-size: 0.8rem; padding: 4px 10px; background: #e2e8f0; color: #4a5568; border-radius: 12px; }
.text-inputs-grid { display: grid; gap: 15px; }
.text-input-item { position: relative; }
.text-input-item textarea { width: 100%; border: 2px solid #e2e8f0; border-radius: 12px; padding: 12px; font-size: 14px; line-height: 1.6; resize: vertical; transition: border-color 0.2s; }
.text-input-item textarea:focus { outline: none; border-color: #667eea; }
.text-input-item .remove-text-btn { position: absolute; top: 8px; right: 8px; width: 24px; height: 24px; background: #f56565; color: #fff; border: none; border-radius: 50%; cursor: pointer; font-size: 14px; line-height: 1; display: flex; align-items: center; justify-content: center; opacity: 0.7; transition: opacity 0.2s; }
.text-input-item .remove-text-btn:hover { opacity: 1; }

.diff-group { margin-bottom: 0; padding: 15px; background: #f7fafc; border-radius: 12px; border-left: 4px solid #667eea; }
.diff-group-title { font-size: 0.85rem; font-weight: 600; color: #2d3748; margin-bottom: 10px; display: flex; align-items: center; gap: 8px; }
.diff-group-title .badge { font-size: 0.75rem; padding: 2px 8px; background: #667eea; color: #fff; border-radius: 10px; }
.diff-group-content { font-family: monospace; font-size: 12px; line-height: 1.8; }
.diff-group-content .diff-line { padding: 3px 8px; background: #fff; border-radius: 4px; margin-bottom: 4px; }
.diff-group-empty { color: #a0aec0; font-style: italic; font-size: 0.85rem; }
.diff-group.color-1 { border-left-color: #667eea; }
.diff-group.color-2 { border-left-color: #f56565; }
.diff-group.color-3 { border-left-color: #48bb78; }
.diff-group.color-4 { border-left-color: #ed8936; }
.diff-group.color-5 { border-left-color: #9f7aea; }
.diff-group.color-1 .diff-group-title .badge { background: #667eea; }
.diff-group.color-2 .diff-group-title .badge { background: #f56565; }
.diff-group.color-3 .diff-group-title .badge { background: #48bb78; }
.diff-group.color-4 .diff-group-title .badge { background: #ed8936; }
.diff-group.color-5 .diff-group-title .badge { background: #9f7aea; }

/* ========== 底部版权 ========== */
.main-footer { padding: 16px 24px; text-align: center; background: #fff; border-top: 1px solid #e8e8e8; flex-shrink: 0; }
.main-footer p { font-size: 0.85rem; color: #666; margin: 0; }
.main-footer a { color: #667eea; text-decoration: none; font-weight: 500; }
.main-footer a:hover { text-decoration: underline; }

/* ========== 移动端 ========== */
.mobile-toggle {
    display: none;
    position: fixed;
    bottom: 60px;
    right: 20px;
    width: 50px;
    height: 50px;
    background: linear-gradient(135deg, #667eea, #764ba2);
    border-radius: 50%;
    align-items: center;
    justify-content: center;
    color: #fff;
    font-size: 20px;
    box-shadow: 0 4px 15px rgba(102, 126, 234, 0.4);
    cursor: pointer;
    z-index: 1000;
}

.overlay { display: none; position: fixed; inset: 0; background: rgba(0,0,0,0.5); z-index: 998; }
.overlay.show { display: block; }

@media (max-width: 768px) {
    .sidebar { position: fixed; left: -260px; top: 0; bottom: 0; z-index: 999; transition: left 0.3s ease; }
    .sidebar.open { left: 0; }
    .mobile-toggle { display: flex; }
    .tool-container { padding: 15px; }
    .grid-2, .grid-3, .grid-4, .grid-5 { grid-template-columns: 1fr; }
    .stats-grid { grid-template-columns: repeat(2, 1fr); }
    .text-inputs-grid { grid-template-columns: 1fr !important; }
    .settings-row { flex-wrap: wrap; }
    .diff-result { grid-template-columns: 1fr; }
    .tool-header h1 { font-size: 1.5rem; }
}

@media (min-width: 769px) and (max-width: 1200px) {
    .grid-4, .grid-5 { grid-template-columns: repeat(2, 1fr); }
}
