/* ============================================================
   在线工具箱公共样式
   ============================================================ */

.tool-page {
    max-width: 900px;
    margin: 0 auto;
    padding: 20px 0 40px;
}

.tool-header {
    margin-bottom: 28px;
    padding-bottom: 20px;
    border-bottom: 1px solid var(--md-default-fg-color--lightest);
}

.tool-header h1 {
    font-size: 2rem;
    font-weight: 700;
    margin-bottom: 8px;
    display: flex;
    align-items: center;
    gap: 12px;
}

.tool-header .tool-desc {
    color: var(--md-default-fg-color--light);
    font-size: 1rem;
    margin: 0;
}

.tool-card {
    background: var(--md-default-bg-color);
    border: 1px solid var(--md-default-fg-color--lightest);
    border-radius: 16px;
    padding: 24px;
    margin-bottom: 20px;
    box-shadow: 0 2px 8px rgba(0,0,0,0.04);
}

.tool-label {
    display: block;
    font-weight: 600;
    margin-bottom: 10px;
    color: var(--md-default-fg-color);
}

.tool-textarea,
.tool-input,
.tool-select {
    width: 100%;
    padding: 12px 16px;
    border: 1px solid var(--md-default-fg-color--lightest);
    border-radius: 10px;
    background: var(--md-default-bg-color);
    color: var(--md-default-fg-color);
    font-family: var(--md-code-font-family), monospace;
    font-size: 0.95rem;
    line-height: 1.5;
    transition: border-color 0.2s ease, box-shadow 0.2s ease;
}

.tool-textarea:focus,
.tool-input:focus,
.tool-select:focus {
    outline: none;
    border-color: var(--md-primary-fg-color);
    box-shadow: 0 0 0 3px rgba(99, 102, 241, 0.12);
}

.tool-textarea {
    min-height: 160px;
    resize: vertical;
}

.tool-row {
    display: flex;
    gap: 12px;
    flex-wrap: wrap;
    align-items: center;
    margin-bottom: 16px;
}

.tool-row .tool-input,
.tool-row .tool-select {
    flex: 1;
    min-width: 160px;
    margin-bottom: 0;
}

.tool-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    padding: 10px 20px;
    border: none;
    border-radius: 10px;
    background: var(--md-primary-fg-color);
    color: var(--md-primary-bg-color);
    font-size: 0.95rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s ease;
}

.tool-btn:hover {
    opacity: 0.9;
    transform: translateY(-1px);
}

.tool-btn.secondary {
    background: var(--md-default-fg-color--lightest);
    color: var(--md-default-fg-color);
}

.tool-btn.secondary:hover {
    background: var(--md-default-fg-color--lighter);
}

.tool-btn.danger {
    background: #ef4444;
    color: #fff;
}

.tool-actions {
    display: flex;
    gap: 12px;
    flex-wrap: wrap;
    margin: 16px 0;
}

.tool-result {
    min-height: 80px;
    padding: 16px;
    border-radius: 10px;
    background: var(--md-code-bg-color);
    border: 1px solid var(--md-default-fg-color--lightest);
    font-family: var(--md-code-font-family), monospace;
    font-size: 0.9rem;
    line-height: 1.5;
    white-space: pre-wrap;
    word-break: break-all;
    overflow-x: auto;
}

.tool-result:empty::before {
    content: "处理结果将显示在这里";
    color: var(--md-default-fg-color--light);
}

.tool-result.error {
    background: #fef2f2;
    border-color: #fecaca;
    color: #991b1b;
}

.tool-result.success {
    background: #f0fdf4;
    border-color: #bbf7d0;
    color: #166534;
}

.tool-tips {
    margin-top: 20px;
    padding: 14px 18px;
    border-radius: 10px;
    background: var(--md-accent-fg-color--transparent, rgba(99,102,241,0.08));
    border-left: 4px solid var(--md-primary-fg-color);
}

.tool-tips h4 {
    margin: 0 0 8px;
    font-size: 0.95rem;
}

.tool-tips p,
.tool-tips li {
    font-size: 0.88rem;
    color: var(--md-default-fg-color--light);
}

.tool-back {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    margin-top: 24px;
    color: var(--md-primary-fg-color);
    text-decoration: none;
    font-weight: 500;
}

.tool-back:hover {
    text-decoration: underline;
}

/* 文件上传 */
.tool-file-input {
    display: block;
    width: 100%;
    padding: 12px;
    border: 2px dashed var(--md-default-fg-color--lightest);
    border-radius: 10px;
    text-align: center;
    cursor: pointer;
    transition: border-color 0.2s ease;
}

.tool-file-input:hover {
    border-color: var(--md-primary-fg-color);
}

/* 表格样式 */
.tool-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.9rem;
}

.tool-table th,
.tool-table td {
    padding: 10px 12px;
    border: 1px solid var(--md-default-fg-color--lightest);
    text-align: left;
}

.tool-table th {
    background: var(--md-default-fg-color--lightest);
    font-weight: 600;
}

/* 代码片段列表 */
.snippet-item {
    padding: 16px;
    border: 1px solid var(--md-default-fg-color--lightest);
    border-radius: 12px;
    margin-bottom: 12px;
}

.snippet-item h4 {
    margin: 0 0 8px;
    font-size: 1rem;
}

.snippet-meta {
    font-size: 0.8rem;
    color: var(--md-default-fg-color--light);
    margin-bottom: 10px;
}

/* Diff 高亮 */
.diff-line {
    padding: 2px 8px;
    font-family: monospace;
    white-space: pre-wrap;
}
.diff-added { background: #dcfce7; color: #166534; }
.diff-removed { background: #fee2e2; color: #991b1b; }
.diff-unchanged { color: var(--md-default-fg-color--light); }

/* 颜色选择器 */
.color-preview {
    width: 60px;
    height: 60px;
    border-radius: 10px;
    border: 1px solid var(--md-default-fg-color--lightest);
    margin-bottom: 12px;
}

/* 工具箱首页网格 */
.tools-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
    gap: 16px;
    margin-top: 16px;
}

/* 工具箱首页布局 */
.tools-index-layout {
    display: flex;
    justify-content: center;
    gap: 24px;
    padding: 20px 0 40px;
}

.tools-index-sidebar {
    position: sticky;
    top: 100px;
    width: 170px;
    height: fit-content;
    background: var(--md-default-bg-color);
    border: 1px solid var(--md-default-fg-color--lightest);
    border-radius: 16px;
    padding: 18px 14px;
    box-shadow: 0 2px 8px rgba(0,0,0,0.04);
    flex-shrink: 0;
    align-self: flex-start;
}

.tools-index-sidebar-title {
    font-size: 0.95rem;
    font-weight: 700;
    color: var(--md-default-fg-color);
    margin-bottom: 12px;
    padding: 0 10px 10px;
    border-bottom: 1px solid var(--md-default-fg-color--lightest);
}

.tools-index-sidebar a {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 10px 12px;
    border-radius: 10px;
    font-size: 0.88rem;
    color: var(--md-default-fg-color--light);
    text-decoration: none;
    transition: all 0.2s;
    margin-bottom: 2px;
}

.tools-index-sidebar a:hover {
    background: var(--md-accent-fg-color--transparent, rgba(99,102,241,0.08));
    color: var(--md-primary-fg-color);
}

.tools-index-content {
    max-width: 800px;
    width: 100%;
}

html {
    scroll-behavior: smooth;
}

/* 隐藏工具箱首页默认左侧导航 */
body:has(.tools-index-layout) .md-sidebar--primary,
body:has(.tools-index-layout) .md-sidebar--secondary {
    display: none !important;
}

body:has(.tools-index-layout) .md-content {
    margin-left: auto !important;
    margin-right: auto !important;
    max-width: 61rem !important;
}

.tools-category {
    margin-bottom: 40px;
}

.tools-category h2 {
    font-size: 1.3rem;
    font-weight: 700;
    margin-bottom: 16px;
    padding-bottom: 10px;
    border-bottom: 2px solid var(--md-primary-fg-color);
    display: flex;
    align-items: center;
    gap: 10px;
}

.tool-link-card {
    display: flex;
    align-items: flex-start;
    gap: 14px;
    padding: 18px;
    border: 1px solid var(--md-default-fg-color--lightest);
    border-radius: 14px;
    text-decoration: none;
    color: inherit;
    transition: all 0.2s ease;
    background: var(--md-default-bg-color);
}

.tool-link-card:hover {
    border-color: var(--md-primary-fg-color);
    box-shadow: 0 4px 16px rgba(0,0,0,0.08);
    transform: translateY(-2px);
}

.tool-link-icon {
    font-size: 1.8rem;
    flex-shrink: 0;
}

.tool-link-info h3 {
    margin: 0 0 6px;
    font-size: 1rem;
    font-weight: 600;
}

.tool-link-info p {
    margin: 0;
    font-size: 0.85rem;
    color: var(--md-default-fg-color--light);
    line-height: 1.4;
}

/* 首页工具快捷入口 */
.home-tools-section {
    margin: 40px 0;
}

.home-tools-title {
    font-size: 1.15rem;
    font-weight: 600;
    color: var(--md-default-fg-color);
    display: flex;
    align-items: center;
    gap: 10px;
    margin-bottom: 20px;
}

.home-tools-footer {
    display: flex;
    justify-content: flex-end;
    margin-top: 16px;
}

.home-tools-more {
    font-size: 0.75rem;
    color: var(--md-primary-fg-color);
    text-decoration: none;
    font-weight: 500;
}

.home-tools-more:hover {
    text-decoration: underline;
}

.home-tools-grid {
    display: grid;
    grid-template-columns: repeat(5, 1fr);
    gap: 12px;
}

.home-tool-card {
    display: flex;
    flex-direction: column;
    align-items: center;
    text-align: center;
    padding: 16px 10px;
    border: 1px solid var(--md-default-fg-color--lightest);
    border-radius: 14px;
    text-decoration: none;
    color: inherit;
    background: var(--md-default-bg-color);
    transition: all 0.2s ease;
}

.home-tool-card:hover {
    border-color: var(--md-primary-fg-color);
    box-shadow: 0 4px 16px rgba(0,0,0,0.08);
    transform: translateY(-3px);
}

.home-tool-icon {
    font-size: 1.8rem;
    margin-bottom: 8px;
}

.home-tool-name {
    font-size: 0.85rem;
    font-weight: 600;
    margin-bottom: 4px;
}

.home-tool-desc {
    font-size: 0.72rem;
    color: var(--md-default-fg-color--light);
    line-height: 1.3;
}

/* 响应式 */
@media (max-width: 768px) {
    .home-tools-grid {
        grid-template-columns: repeat(2, 1fr);
    }
    .tools-grid {
        grid-template-columns: 1fr;
    }
    .tools-index-layout {
        flex-direction: column;
        align-items: center;
    }
    .tools-index-sidebar {
        position: static;
        width: 100%;
        max-width: 800px;
        display: flex;
        flex-wrap: wrap;
        gap: 8px;
        padding: 14px;
    }
    .tools-index-sidebar a {
        flex: 1;
        min-width: 120px;
        justify-content: center;
        margin-bottom: 0;
    }
}
