/* ============================================================
   AI 工具中心样式（移动优先）
   供：tools.html（工具中心首页）+ tools/*.html（工具页）
   依赖：styles.css（设计变量）
   ============================================================ */

/* ---------- 工具中心首页 ---------- */

.tools-page {
    padding: 90px 0 60px;
    min-height: 100vh;
    background: linear-gradient(135deg, #f8fafc 0%, #eef2f7 100%);
}

.tools-hero {
    text-align: center;
    padding: 24px 0 32px;
}

.tools-hero h1 {
    font-size: 2rem;
    font-weight: 800;
    background: var(--gradient-primary, linear-gradient(135deg, #165DFF, #722ED1));
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    margin-bottom: 8px;
}

.tools-hero p {
    color: var(--text-gray, #666);
    font-size: 0.95rem;
    margin-bottom: 20px;
}

/* 额度状态条 */
.tools-quota-bar {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    background: #fff;
    border: 1px solid var(--border-light, #e5e5e5);
    border-radius: 999px;
    padding: 6px 16px;
    font-size: 0.85rem;
    color: var(--text-dark, #333);
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.06);
}

.tools-quota-bar .quota-num {
    font-weight: 700;
    color: var(--primary-blue, #165DFF);
}

.tools-quota-bar .btn-recharge-mini {
    margin-left: 4px;
    padding: 3px 12px;
    font-size: 0.8rem;
    border-radius: 999px;
}

.tools-quota-bar .btn-login-mini {
    margin-left: 4px;
    padding: 3px 12px;
    font-size: 0.8rem;
    border-radius: 999px;
    background: var(--bg-light, #f5f7fa);
    color: var(--text-dark, #333);
}

/* 分类导航（吸顶） */
.tools-cats {
    position: sticky;
    top: 64px;
    z-index: 50;
    background: rgba(255, 255, 255, 0.92);
    backdrop-filter: blur(8px);
    border-bottom: 1px solid var(--border-light, #e5e5e5);
    margin-bottom: 24px;
}

.tools-cats-inner {
    display: flex;
    gap: 8px;
    overflow-x: auto;
    padding: 10px 0;
    scrollbar-width: none;
    -webkit-overflow-scrolling: touch;
}

.tools-cats-inner::-webkit-scrollbar {
    display: none;
}

.cat-btn {
    flex-shrink: 0;
    padding: 7px 16px;
    border-radius: 999px;
    border: 1px solid var(--border-light, #e5e5e5);
    background: #fff;
    color: var(--text-gray, #666);
    font-size: 0.88rem;
    cursor: pointer;
    transition: all 0.2s;
    white-space: nowrap;
}

.cat-btn:hover {
    border-color: var(--primary-blue, #165DFF);
    color: var(--primary-blue, #165DFF);
}

.cat-btn.active {
    background: var(--gradient-primary, linear-gradient(135deg, #165DFF, #722ED1));
    color: #fff;
    border-color: transparent;
}

/* 搜索框 */
.tools-search-bar {
    max-width: 480px;
    margin: 0 auto 24px;
    position: relative;
}

.tools-search-bar input {
    width: 100%;
    padding: 10px 44px 10px 16px;
    border-radius: 12px;
    border: 1px solid var(--border-light, #e5e5e5);
    background: #fff;
    font-size: 0.95rem;
    outline: none;
    transition: border-color 0.2s, box-shadow 0.2s;
}

.tools-search-bar input:focus {
    border-color: var(--primary-blue, #165DFF);
    box-shadow: 0 0 0 3px rgba(22, 93, 255, 0.12);
}

.tools-search-bar .search-icon {
    position: absolute;
    right: 14px;
    top: 50%;
    transform: translateY(-50%);
    color: var(--text-gray, #666);
}

/* 工具卡片网格 */
.tools-grid {
    display: grid;
    grid-template-columns: 1fr;
    gap: 14px;
}

.tool-card {
    background: #fff;
    border: 1px solid var(--border-light, #e5e5e5);
    border-radius: 14px;
    padding: 16px;
    display: flex;
    flex-direction: column;
    gap: 8px;
    transition: transform 0.2s, box-shadow 0.2s;
    cursor: pointer;
    position: relative;
}

.tool-card:hover {
    transform: translateY(-2px);
    box-shadow: var(--shadow-light, 0 8px 30px rgba(0, 0, 0, 0.08));
}

.tool-card-header {
    display: flex;
    align-items: center;
    gap: 10px;
}

.tool-card-icon {
    width: 40px;
    height: 40px;
    border-radius: 10px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.1rem;
    color: #fff;
    flex-shrink: 0;
}

.tool-card-icon.ic-blue { background: linear-gradient(135deg, #165DFF, #4d8dff); }
.tool-card-icon.ic-purple { background: linear-gradient(135deg, #722ED1, #a06bff); }
.tool-card-icon.ic-orange { background: linear-gradient(135deg, #FF7D00, #ffab5e); }
.tool-card-icon.ic-green { background: linear-gradient(135deg, #00b578, #52c41a); }
.tool-card-icon.ic-red { background: linear-gradient(135deg, #f53f3f, #ff7d7d); }
.tool-card-icon.ic-cyan { background: linear-gradient(135deg, #14c9c9, #6fdcdc); }

.tool-card-title {
    font-size: 1rem;
    font-weight: 700;
    color: var(--text-dark, #333);
}

.tool-card-desc {
    font-size: 0.85rem;
    color: var(--text-gray, #666);
    line-height: 1.5;
    flex: 1;
}

.tool-card-footer {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-top: 4px;
}

.tool-card-cost {
    font-size: 0.78rem;
    color: var(--accent-orange, #FF7D00);
    background: rgba(255, 125, 0, 0.1);
    padding: 2px 10px;
    border-radius: 999px;
}

.tool-card-free {
    color: var(--success-green, #52C41A);
    background: rgba(82, 196, 26, 0.1);
}

.tool-card-btn {
    font-size: 0.82rem;
    padding: 5px 14px;
    border-radius: 8px;
    background: var(--gradient-primary, linear-gradient(135deg, #165DFF, #722ED1));
    color: #fff;
    border: none;
    cursor: pointer;
}

/* 空状态 */
.tools-empty {
    text-align: center;
    padding: 60px 20px;
    color: var(--text-gray, #666);
}

.tools-empty i {
    font-size: 2.5rem;
    color: var(--border-light, #e5e5e5);
    margin-bottom: 12px;
    display: block;
}

/* ---------- 工具页（tools/*.html） ---------- */

.tool-page {
    padding: 90px 0 40px;
    min-height: 100vh;
    background: var(--bg-light, #f5f7fa);
}

.tool-page-main {
    max-width: 860px;
    margin: 0 auto;
    padding: 0 16px;
}

.tool-breadcrumb {
    font-size: 0.85rem;
    color: var(--text-gray, #666);
    margin-bottom: 12px;
}

.tool-breadcrumb a {
    color: var(--primary-blue, #165DFF);
    text-decoration: none;
}

.tool-header {
    background: #fff;
    border-radius: 14px;
    padding: 20px;
    margin-bottom: 16px;
    border: 1px solid var(--border-light, #e5e5e5);
    display: flex;
    align-items: center;
    gap: 14px;
}

.tool-header-icon {
    width: 52px;
    height: 52px;
    border-radius: 12px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.4rem;
    color: #fff;
    flex-shrink: 0;
}

.tool-header h1 {
    font-size: 1.25rem;
    font-weight: 700;
    margin-bottom: 4px;
}

.tool-header .tool-header-desc {
    font-size: 0.88rem;
    color: var(--text-gray, #666);
}

.tool-header .tool-cost-badge {
    margin-left: auto;
    font-size: 0.8rem;
    color: var(--accent-orange, #FF7D00);
    background: rgba(255, 125, 0, 0.1);
    padding: 4px 12px;
    border-radius: 999px;
    white-space: nowrap;
}

.tool-cost-badge.free {
    color: var(--success-green, #52C41A);
    background: rgba(82, 196, 26, 0.1);
}

/* 输入区 */
.tool-panel {
    background: #fff;
    border: 1px solid var(--border-light, #e5e5e5);
    border-radius: 14px;
    padding: 20px;
    margin-bottom: 16px;
}

.tool-panel-title {
    font-size: 1rem;
    font-weight: 700;
    margin-bottom: 14px;
    display: flex;
    align-items: center;
    gap: 8px;
}

.tool-panel-title i {
    color: var(--primary-blue, #165DFF);
}

.tool-form-group {
    margin-bottom: 14px;
}

.tool-form-group label {
    display: block;
    font-size: 0.88rem;
    font-weight: 600;
    margin-bottom: 6px;
    color: var(--text-dark, #333);
}

.tool-form-group label .required {
    color: #f53f3f;
}

.tool-input {
    width: 100%;
    padding: 10px 14px;
    border: 1px solid var(--border-light, #e5e5e5);
    border-radius: 10px;
    font-size: 0.95rem;
    outline: none;
    transition: border-color 0.2s, box-shadow 0.2s;
    background: #fff;
}

.tool-input:focus {
    border-color: var(--primary-blue, #165DFF);
    box-shadow: 0 0 0 3px rgba(22, 93, 255, 0.12);
}

textarea.tool-input {
    min-height: 90px;
    resize: vertical;
    line-height: 1.6;
}

select.tool-input {
    appearance: none;
    background: #fff;
    cursor: pointer;
}

.tool-hint {
    font-size: 0.8rem;
    color: var(--text-gray, #666);
    margin-top: 4px;
}

/* 调用按钮（移动端底部固定） */
.tool-actions {
    display: flex;
    gap: 10px;
    flex-wrap: wrap;
    margin-top: 4px;
}

.tool-btn {
    flex: 1;
    min-width: 120px;
    padding: 11px 20px;
    border: none;
    border-radius: 10px;
    font-size: 0.95rem;
    font-weight: 600;
    cursor: pointer;
    transition: opacity 0.2s, transform 0.1s;
}

.tool-btn:active {
    transform: scale(0.98);
}

.tool-btn:disabled {
    opacity: 0.6;
    cursor: not-allowed;
}

.tool-btn-primary {
    background: var(--gradient-primary, linear-gradient(135deg, #165DFF, #722ED1));
    color: #fff;
}

.tool-btn-secondary {
    background: var(--bg-light, #f5f7fa);
    color: var(--text-dark, #333);
    border: 1px solid var(--border-light, #e5e5e5);
}

.tool-btn-outline {
    background: #fff;
    color: var(--primary-blue, #165DFF);
    border: 1px solid var(--primary-blue, #165DFF);
}

/* 结果区 */
.tool-result-panel {
    background: #fff;
    border: 1px solid var(--border-light, #e5e5e5);
    border-radius: 14px;
    padding: 20px;
    margin-bottom: 16px;
    display: none;
}

.tool-result-panel.visible {
    display: block;
}

.tool-result-toolbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 12px;
    flex-wrap: wrap;
    gap: 8px;
}

.tool-result-toolbar .title {
    font-weight: 700;
    font-size: 0.95rem;
}

.tool-result-toolbar .actions {
    display: flex;
    gap: 8px;
}

.tool-result-toolbar .mini-btn {
    padding: 5px 12px;
    font-size: 0.8rem;
    border-radius: 8px;
    border: 1px solid var(--border-light, #e5e5e5);
    background: #fff;
    cursor: pointer;
    color: var(--text-gray, #666);
    transition: all 0.2s;
}

.tool-result-toolbar .mini-btn:hover {
    border-color: var(--primary-blue, #165DFF);
    color: var(--primary-blue, #165DFF);
}

.tool-result-content {
    max-height: 480px;
    overflow: auto;
    border: 1px solid var(--border-light, #e5e5e5);
    border-radius: 10px;
    padding: 14px;
    background: #fcfcfd;
    font-size: 0.9rem;
    word-break: break-all;
}

.tool-result-text {
    white-space: pre-wrap;
    line-height: 1.7;
}

.tool-result-object .tool-result-row {
    display: flex;
    gap: 8px;
    padding: 5px 0;
    border-bottom: 1px dashed var(--border-light, #e5e5e5);
}

.tool-result-object .tool-result-row:last-child {
    border-bottom: none;
}

.tool-result-key {
    font-weight: 600;
    color: var(--primary-blue, #165DFF);
    min-width: 100px;
    flex-shrink: 0;
}

.tool-result-list .tool-result-list-item {
    display: flex;
    gap: 8px;
    padding: 6px 0;
    border-bottom: 1px dashed var(--border-light, #e5e5e5);
    align-items: flex-start;
}

.tool-result-index {
    background: var(--primary-blue, #165DFF);
    color: #fff;
    border-radius: 6px;
    font-size: 0.75rem;
    padding: 1px 7px;
    flex-shrink: 0;
    margin-top: 3px;
}

.tool-result-table-wrap {
    overflow-x: auto;
}

.tool-result-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.85rem;
}

.tool-result-table th {
    background: var(--bg-light, #f5f7fa);
    padding: 8px 10px;
    text-align: left;
    font-weight: 600;
    border-bottom: 2px solid var(--border-light, #e5e5e5);
    white-space: nowrap;
}

.tool-result-table td {
    padding: 7px 10px;
    border-bottom: 1px solid var(--border-light, #e5e5e5);
    max-width: 320px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.tool-result-table tr:hover td {
    background: #f9fafb;
}

.tool-result-more {
    font-size: 0.82rem;
    color: var(--text-gray, #666);
    padding: 8px 0;
}

.tool-result-error {
    background: #fff2f0;
    color: #cf1322;
    border: 1px solid #ffccc7;
    border-radius: 8px;
    padding: 12px 14px;
    font-size: 0.9rem;
}

.tool-result-empty {
    color: var(--text-gray, #666);
    text-align: center;
    padding: 24px 0;
}

/* 加载状态 */
.tool-loading {
    display: none;
    text-align: center;
    padding: 30px 0;
    color: var(--text-gray, #666);
}

.tool-loading .spinner {
    width: 28px;
    height: 28px;
    border: 3px solid var(--border-light, #e5e5e5);
    border-top-color: var(--primary-blue, #165DFF);
    border-radius: 50%;
    animation: tool-spin 0.8s linear infinite;
    margin: 0 auto 10px;
}

@keyframes tool-spin {
    to { transform: rotate(360deg); }
}

/* 额度提示条（工具页内） */
.tool-quota-tip {
    display: flex;
    align-items: center;
    gap: 8px;
    background: #eef5ff;
    border: 1px solid #cfe0ff;
    color: #165DFF;
    border-radius: 10px;
    padding: 10px 14px;
    font-size: 0.85rem;
    margin-bottom: 16px;
}

.tool-quota-tip a {
    color: #165DFF;
    font-weight: 600;
    margin-left: auto;
    white-space: nowrap;
}

.tool-quota-tip .quota-remain {
    font-weight: 700;
}

/* 移动端：底部固定调用按钮 */
.tool-mobile-bar {
    display: none;
}

/* ==================== 响应式 ==================== */

/* ≥640px：平板/桌面 */
@media (min-width: 640px) {
    .tools-grid {
        grid-template-columns: repeat(2, 1fr);
        gap: 16px;
    }

    .tools-hero h1 {
        font-size: 2.4rem;
    }
}

/* ≥1024px：桌面 */
@media (min-width: 1024px) {
    .tools-grid {
        grid-template-columns: repeat(3, 1fr);
        gap: 20px;
    }

    .tool-page-main {
        padding: 0 24px;
    }
}

/* ≥1280px：大屏 */
@media (min-width: 1280px) {
    .tools-grid {
        grid-template-columns: repeat(4, 1fr);
    }
}

/* <640px：移动端增强 */
@media (max-width: 639px) {
    .tool-page {
        padding: 80px 0 90px; /* 底部留出固定按钮空间 */
    }

    .tool-header {
        padding: 16px;
    }

    .tool-header-icon {
        width: 44px;
        height: 44px;
        font-size: 1.1rem;
    }

    .tool-header .tool-cost-badge {
        display: none; /* 费用移到调用确认弹窗里 */
    }

    .tool-panel {
        padding: 16px;
    }

    /* 移动端底部固定操作栏 */
    .tool-mobile-bar {
        display: block;
        position: fixed;
        bottom: 0;
        left: 0;
        right: 0;
        background: #fff;
        border-top: 1px solid var(--border-light, #e5e5e5);
        padding: 10px 16px calc(10px + env(safe-area-inset-bottom));
        z-index: 60;
        box-shadow: 0 -4px 16px rgba(0, 0, 0, 0.06);
    }

    .tool-mobile-bar .tool-btn {
        width: 100%;
    }
}
