/* ========== tools.css ========== */
/**
 * 工具箱模块样式 - Nebula 暗色设计语言
 * 玻璃拟态 · 紫靛渐变 · 微光发光 · 高级质感
 * 变量回退值确保独立可用：--primary:#6366f1  --accent:#06b6d4
 * --bg-base:#0a0c1e  --bg-card:rgba(20,22,48,0.6)  --border:rgba(99,102,241,0.15)
 */

/* ============ 页面容器 ============ */
.toolbox-container {
    padding: 28px 32px 48px;
    max-width: 1600px;
    margin: 0 auto;
    color: var(--text-primary, #e7e9f5);
    animation: toolbox-fade-in .5s cubic-bezier(.22,1,.36,1);
}

@keyframes toolbox-fade-in {
    from { opacity: 0; transform: translateY(12px); }
    to   { opacity: 1; transform: translateY(0); }
}

/* ============ 顶部标题区 ============ */
.toolbox-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    flex-wrap: wrap;
    gap: 20px;
    margin-bottom: 32px;
    padding: 26px 30px;
    position: relative;
    overflow: hidden;
    border-radius: 20px;
    border: 1px solid var(--border, rgba(99, 102, 241, 0.15));
    background: linear-gradient(135deg,
        rgba(99, 102, 241, 0.08) 0%,
        rgba(6, 182, 212, 0.04) 100%),
        var(--bg-card, rgba(20, 22, 48, 0.6));
    backdrop-filter: blur(20px) saturate(160%);
    -webkit-backdrop-filter: blur(20px) saturate(160%);
    box-shadow: 0 12px 40px rgba(0, 0, 0, .35),
                inset 0 1px 0 rgba(255, 255, 255, .04);
}

/* 标题区右上角光晕装饰 */
.toolbox-header::before {
    content: '';
    position: absolute;
    top: -60px;
    right: -40px;
    width: 260px;
    height: 260px;
    background: radial-gradient(circle,
        rgba(99, 102, 241, .28) 0%,
        rgba(6, 182, 212, .12) 45%,
        transparent 72%);
    pointer-events: none;
    filter: blur(8px);
}

.toolbox-header h2 {
    position: relative;
    z-index: 1;
    margin: 0;
    font-size: 30px;
    font-weight: 800;
    letter-spacing: -0.02em;
    background: linear-gradient(135deg,
        var(--primary, #6366f1) 0%,
        var(--accent, #06b6d4) 100%);
    -webkit-background-clip: text;
    background-clip: text;
    -webkit-text-fill-color: transparent;
    color: transparent;
}

/* ============ 搜索框 ============ */
.toolbox-search {
    position: relative;
    z-index: 1;
    flex: 1 1 320px;
    max-width: 420px;
    display: flex;
    align-items: center;
}

.toolbox-search .search-icon {
    position: absolute;
    left: 18px;
    font-size: 16px;
    line-height: 1;
    opacity: .65;
    pointer-events: none;
    transition: opacity .25s ease, transform .25s ease;
}

#toolbox-search-input {
    width: 100%;
    height: 48px;
    padding: 0 18px 0 48px;
    font-size: 14px;
    color: var(--text-primary, #e7e9f5);
    background: rgba(10, 12, 30, 0.55);
    border: 1px solid var(--border, rgba(99, 102, 241, 0.15));
    border-radius: 14px;
    outline: none;
    transition: border-color .25s ease, box-shadow .25s ease, background .25s ease;
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
}

#toolbox-search-input::placeholder {
    color: rgba(231, 233, 245, .4);
}

#toolbox-search-input:hover {
    border-color: rgba(99, 102, 241, .35);
}

#toolbox-search-input:focus {
    border-color: var(--primary, #6366f1);
    background: rgba(10, 12, 30, 0.75);
    box-shadow: 0 0 0 4px rgba(99, 102, 241, .14),
                0 0 24px rgba(99, 102, 241, .25);
}

.toolbox-search:focus-within .search-icon {
    opacity: 1;
    transform: scale(1.08);
}

/* ============ 分类容器 ============ */
.toolbox-categories {
    display: flex;
    flex-direction: column;
    gap: 40px;
}

.toolbox-category {
    animation: toolbox-fade-in .5s cubic-bezier(.22,1,.36,1) both;
}

.toolbox-category:nth-child(2) { animation-delay: .06s; }
.toolbox-category:nth-child(3) { animation-delay: .12s; }
.toolbox-category:nth-child(4) { animation-delay: .18s; }

/* ============ 分类标题（左侧渐变色条） ============ */
.toolbox-category-title {
    display: flex;
    align-items: center;
    gap: 12px;
    margin: 0 0 22px 0;
    padding: 4px 0 4px 18px;
    position: relative;
    font-size: 22px;
    font-weight: 700;
    letter-spacing: -0.01em;
    color: var(--text-primary, #e7e9f5);
}

/* 左侧渐变色条 */
.toolbox-category-title::before {
    content: '';
    position: absolute;
    left: 0;
    top: 50%;
    transform: translateY(-50%);
    width: 5px;
    height: 26px;
    border-radius: 6px;
    background: linear-gradient(180deg,
        var(--primary, #6366f1) 0%,
        var(--accent, #06b6d4) 100%);
    box-shadow: 0 0 14px rgba(99, 102, 241, .55);
}

.toolbox-category-title .cat-icon {
    font-size: 22px;
    line-height: 1;
    filter: drop-shadow(0 2px 6px rgba(99, 102, 241, .35));
}

/* ============ 工具卡片网格 ============ */
.toolbox-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
    gap: 20px;
}

/* ============ 工具卡片 ============ */
.toolbox-card {
    position: relative;
    display: flex;
    flex-direction: column;
    gap: 12px;
    padding: 24px 22px 22px;
    cursor: pointer;
    border-radius: 16px;
    background: var(--bg-card, rgba(20, 22, 48, 0.6));
    border: 1px solid var(--border, rgba(99, 102, 241, 0.15));
    backdrop-filter: blur(16px) saturate(150%);
    -webkit-backdrop-filter: blur(16px) saturate(150%);
    box-shadow: 0 8px 24px rgba(0, 0, 0, .28),
                inset 0 1px 0 rgba(255, 255, 255, .04);
    overflow: hidden;
    transition: transform .35s cubic-bezier(.22,1,.36,1),
                box-shadow .35s ease,
                border-color .35s ease;
    isolation: isolate;
}

/* 卡片顶部柔光 */
.toolbox-card::after {
    content: '';
    position: absolute;
    top: -1px;
    left: -1px;
    right: -1px;
    height: 70%;
    background: radial-gradient(ellipse at top,
        rgba(99, 102, 241, .10) 0%,
        transparent 60%);
    opacity: 0;
    transition: opacity .35s ease;
    pointer-events: none;
    z-index: -1;
}

/* hover 渐变发光边框 */
.toolbox-card::before {
    content: '';
    position: absolute;
    inset: 0;
    border-radius: 16px;
    padding: 1.5px;
    background: linear-gradient(135deg,
        var(--primary, #6366f1) 0%,
        var(--accent, #06b6d4) 100%);
    -webkit-mask: linear-gradient(#fff 0 0) content-box, linear-gradient(#fff 0 0);
    -webkit-mask-composite: xor;
            mask-composite: exclude;
    opacity: 0;
    transition: opacity .35s ease;
    pointer-events: none;
    z-index: 1;
}

.toolbox-card:hover {
    transform: translateY(-6px);
    border-color: transparent;
    box-shadow: 0 22px 48px rgba(0, 0, 0, .45),
                0 0 28px rgba(99, 102, 241, .28),
                0 0 48px rgba(6, 182, 212, .14);
}

.toolbox-card:hover::before,
.toolbox-card:hover::after {
    opacity: 1;
}

.toolbox-card:active {
    transform: translateY(-3px) scale(.99);
}

/* ============ 工具图标（48px 圆形渐变容器） ============ */
.toolbox-card-icon {
    width: 48px;
    height: 48px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 24px;
    line-height: 1;
    border-radius: 50%;
    background: linear-gradient(135deg,
        rgba(99, 102, 241, .22) 0%,
        rgba(6, 182, 212, .16) 100%);
    border: 1px solid rgba(99, 102, 241, .25);
    box-shadow: 0 6px 18px rgba(99, 102, 241, .22),
                inset 0 1px 0 rgba(255, 255, 255, .12);
    transition: transform .35s cubic-bezier(.22,1,.36,1),
                box-shadow .35s ease;
    /* 统一 emoji 大小与基线 */
    font-family: "Apple Color Emoji", "Segoe UI Emoji", "Noto Color Emoji", sans-serif;
}

.toolbox-card:hover .toolbox-card-icon {
    transform: scale(1.12) rotate(-4deg);
    box-shadow: 0 10px 26px rgba(99, 102, 241, .4),
                0 0 22px rgba(6, 182, 212, .35),
                inset 0 1px 0 rgba(255, 255, 255, .18);
}

/* ============ 卡片名称与描述 ============ */
.toolbox-card-name {
    font-size: 15px;
    font-weight: 600;
    color: var(--text-primary, #e7e9f5);
    letter-spacing: -0.005em;
    transition: color .25s ease;
}

.toolbox-card:hover .toolbox-card-name {
    background: linear-gradient(135deg,
        var(--primary, #6366f1) 0%,
        var(--accent, #06b6d4) 100%);
    -webkit-background-clip: text;
    background-clip: text;
    -webkit-text-fill-color: transparent;
    color: transparent;
}

.toolbox-card-desc {
    font-size: 12.5px;
    line-height: 1.5;
    color: var(--text-secondary, rgba(231, 233, 245, .55));
}

/* 卡片底部箭头提示 */
.toolbox-card-name::after {
    content: '→';
    margin-left: 6px;
    opacity: 0;
    transform: translateX(-6px);
    display: inline-block;
    transition: opacity .3s ease, transform .3s ease;
    -webkit-text-fill-color: var(--accent, #06b6d4);
}

.toolbox-card:hover .toolbox-card-name::after {
    opacity: .9;
    transform: translateX(0);
}

/* ============ 空状态（搜索无结果） ============ */
/* 显式空状态容器 */
.toolbox-empty {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 14px;
    padding: 64px 24px;
    text-align: center;
    border-radius: 16px;
    border: 1px dashed var(--border, rgba(99, 102, 241, 0.15));
    background: rgba(20, 22, 48, 0.35);
    color: var(--text-secondary, rgba(231, 233, 245, .55));
}

.toolbox-empty .empty-icon {
    font-size: 44px;
    line-height: 1;
    filter: drop-shadow(0 4px 14px rgba(99, 102, 241, .35));
}

.toolbox-empty .empty-title {
    font-size: 16px;
    font-weight: 600;
    color: var(--text-primary, #e7e9f5);
}

.toolbox-empty .empty-desc {
    font-size: 13px;
    opacity: .8;
}

/* 渐进增强：当所有分类被隐藏时，在分类容器末尾自动显示友好提示 */
.toolbox-categories:not(:has(.toolbox-category:not([style*="none"])))::after {
    content: '🔍 没有找到匹配的工具\A试试其他关键词吧';
    white-space: pre-wrap;
    text-align: center;
    display: block;
    padding: 56px 24px;
    font-size: 15px;
    line-height: 1.7;
    color: var(--text-secondary, rgba(231, 233, 245, .55));
    border-radius: 16px;
    border: 1px dashed var(--border, rgba(99, 102, 241, 0.15));
    background: rgba(20, 22, 48, 0.35);
}

/* ============ 工具详情弹窗 ============ */
.tool-modal {
    position: fixed;
    inset: 0;
    z-index: 1000;
    display: none;
    align-items: center;
    justify-content: center;
    padding: 24px;
}

.tool-modal-backdrop {
    position: absolute;
    inset: 0;
    background: rgba(6, 8, 22, .72);
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
    animation: toolbox-backdrop-in .25s ease;
}

@keyframes toolbox-backdrop-in {
    from { opacity: 0; }
    to   { opacity: 1; }
}

.tool-modal-content {
    position: relative;
    z-index: 1;
    width: 100%;
    max-width: 760px;
    max-height: 88vh;
    display: flex;
    flex-direction: column;
    border-radius: 20px;
    border: 1px solid var(--border, rgba(99, 102, 241, 0.15));
    background: var(--bg-card, rgba(20, 22, 48, 0.6));
    backdrop-filter: blur(28px) saturate(160%);
    -webkit-backdrop-filter: blur(28px) saturate(160%);
    box-shadow: 0 30px 80px rgba(0, 0, 0, .55),
                0 0 60px rgba(99, 102, 241, .18),
                inset 0 1px 0 rgba(255, 255, 255, .05);
    overflow: hidden;
    animation: toolbox-modal-in .35s cubic-bezier(.22,1,.36,1);
}

@keyframes toolbox-modal-in {
    from { opacity: 0; transform: translateY(24px) scale(.97); }
    to   { opacity: 1; transform: translateY(0) scale(1); }
}

.tool-modal-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
    padding: 22px 26px;
    border-bottom: 1px solid var(--border, rgba(99, 102, 241, 0.15));
    background: linear-gradient(135deg,
        rgba(99, 102, 241, .08) 0%,
        transparent 100%);
}

.tool-modal-header h3 {
    margin: 0;
    font-size: 19px;
    font-weight: 700;
    letter-spacing: -0.01em;
    color: var(--text-primary, #e7e9f5);
}

.tool-modal-header .btn-close,
.tool-modal-header button.btn-close {
    width: 40px;
    height: 40px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 0;
    font-size: 16px;
    line-height: 1;
    color: var(--text-secondary, rgba(231, 233, 245, .6));
    background: rgba(255, 255, 255, .04);
    border: 1px solid var(--border, rgba(99, 102, 241, 0.15));
    border-radius: 10px;
    cursor: pointer;
    transition: all .2s ease;
}

.tool-modal-header .btn-close:hover {
    color: #fff;
    background: rgba(239, 68, 68, .18);
    border-color: rgba(239, 68, 68, .4);
    transform: rotate(90deg);
}

.tool-modal-body {
    padding: 26px;
    overflow-y: auto;
    color: var(--text-primary, #e7e9f5);
}

.tool-modal-body::-webkit-scrollbar { width: 8px; }
.tool-modal-body::-webkit-scrollbar-track { background: transparent; }
.tool-modal-body::-webkit-scrollbar-thumb {
    background: rgba(99, 102, 241, .3);
    border-radius: 8px;
}

/* ============ 响应式 ============ */
@media (max-width: 768px) {
    .toolbox-container { padding: 20px 16px 40px; }
    .toolbox-header { padding: 20px; }
    .toolbox-header h2 { font-size: 24px; }
    .toolbox-search { flex: 1 1 100%; max-width: none; }
    .toolbox-category-title { font-size: 19px; }
    .toolbox-grid {
        grid-template-columns: repeat(auto-fill, minmax(160px, 1fr));
        gap: 14px;
    }
    .toolbox-card { padding: 18px 16px; }
    .tool-modal-content { max-height: 92vh; }
    .tool-modal-body { padding: 18px; }
}

@media (max-width: 420px) {
    .toolbox-grid { grid-template-columns: 1fr 1fr; }
}

/* 减弱动画偏好 */
@media (prefers-reduced-motion: reduce) {
    .toolbox-container,
    .toolbox-category,
    .tool-modal-content,
    .tool-modal-backdrop {
        animation: none !important;
    }
    .toolbox-card,
    .toolbox-card-icon,
    #toolbox-search-input {
        transition: none !important;
    }
}
