/* ============================================================
   AI之家 - 主样式表 (优化版)
   从 index.html 内联样式提取，合并 style.css
   ============================================================ */

/* --- Reset & Base --- */
* { margin: 0; padding: 0; box-sizing: border-box; }

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', sans-serif;
    line-height: 1.6;
    color: #1f2937;
    background: linear-gradient(135deg, #f8fafc 0%, #f1f5f9 100%);
    min-height: 100vh;
}

/* --- Header Banner --- */
.header-banner {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    padding: 16px 0;
    box-shadow: 0 4px 20px rgba(0,0,0,0.1);
    position: relative;
    overflow: hidden;
}

.header-banner::before {
    content: '';
    position: absolute;
    inset: 0;
    background: url('data:image/svg+xml,<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 100 100"><defs><pattern id="grain" width="100" height="100" patternUnits="userSpaceOnUse"><circle cx="25" cy="25" r="1" fill="rgba(255,255,255,0.1)"/><circle cx="75" cy="75" r="1" fill="rgba(255,255,255,0.1)"/></pattern></defs><rect width="100" height="100" fill="url(%23grain)"/></svg>');
    opacity: 0.3;
}

.header-content {
    max-width: 1400px;
    margin: 0 auto;
    display: flex;
    align-items: center;
    position: relative;
    z-index: 1;
    padding: 0 20px;
    gap: 30px;
}

.header-content::after {
    content: '';
    flex-shrink: 0;
    width: 200px;
}

/* Logo */
.logo {
    flex-shrink: 0;
    display: flex;
    align-items: center;
    text-decoration: none;
    transition: transform 0.3s ease;
}

.logo:hover { transform: translateY(-2px); }

.logo-icon {
    width: 50px;
    height: 50px;
    background: white;
    border-radius: 16px;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 8px 25px rgba(0,0,0,0.15);
    transition: all 0.3s ease;
}

.logo:hover .logo-icon {
    box-shadow: 0 12px 35px rgba(0,0,0,0.2);
    transform: scale(1.05);
}

.logo-text { margin-left: 16px; text-align: left; }

.logo h1 {
    font-size: 32px;
    font-weight: 700;
    color: white;
    margin: 0;
    line-height: 1.2;
    text-shadow: 0 2px 4px rgba(0,0,0,0.1);
}

.logo p {
    font-size: 15px;
    color: rgba(255,255,255,0.9);
    margin: 0;
    font-weight: 400;
}

/* Header Search */
.header-search {
    flex: 1;
    max-width: 600px;
    margin: 0 auto;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 8px;
}

.header-search .search-engines {
    display: flex;
    justify-content: center;
    gap: 0;
    flex-wrap: wrap;
    background: transparent;
    padding: 0;
    border-radius: 0;
    backdrop-filter: none;
    border: none;
    box-shadow: none;
    margin-bottom: 8px;
}

.header-search .search-engine {
    color: rgba(255,255,255,0.8);
    text-decoration: none;
    font-size: 14px;
    font-weight: 400;
    padding: 8px 16px;
    border-radius: 0;
    transition: all 0.3s ease;
    background: transparent;
    border: none;
    backdrop-filter: none;
    position: relative;
    border-bottom: 2px solid transparent;
}

.header-search .search-engine::before { display: none; }

.header-search .search-engine:hover {
    color: white;
    background: transparent;
    transform: none;
    box-shadow: none;
    border-bottom-color: rgba(255,255,255,0.5);
}

.header-search .search-engine.active {
    color: white !important;
    font-weight: 500 !important;
    border-bottom-color: white !important;
}

.header-search .search-box {
    position: relative;
    width: 100%;
    max-width: 600px;
}

.header-search .search-input {
    width: 100%;
    padding: 14px 50px 14px 20px;
    border: 1px solid rgba(255,255,255,0.3);
    border-radius: 28px;
    font-size: 16px;
    outline: none;
    transition: all 0.3s ease;
    background: white;
    color: #333;
    box-shadow: 0 2px 8px rgba(0,0,0,0.1);
}

.header-search .search-input::placeholder { color: #999; font-weight: 400; }

.header-search .search-input:focus {
    border-color: rgba(255,255,255,0.6);
    box-shadow: 0 4px 12px rgba(0,0,0,0.15);
}

.header-search .search-button {
    position: absolute;
    right: 6px;
    top: 50%;
    transform: translateY(-50%);
    width: 40px;
    height: 40px;
    background: #f8f9fa;
    border: 1px solid #e9ecef;
    border-radius: 50%;
    color: #666;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 16px;
    transition: all 0.3s ease;
}

.header-search .search-button:hover { background: #e9ecef; color: #333; }

/* 站内搜索提示 */
.search-hint {
    position: fixed;
    top: 20px;
    right: 20px;
    background: #667eea;
    color: white;
    padding: 12px 24px;
    border-radius: 12px;
    font-size: 14px;
    font-weight: 500;
    z-index: 9999;
    box-shadow: 0 8px 24px rgba(102,126,234,0.3);
    animation: slideIn 0.3s ease, fadeOut 0.3s ease 2.7s;
    pointer-events: none;
}

@keyframes slideIn {
    from { opacity: 0; transform: translateX(30px); }
    to { opacity: 1; transform: translateX(0); }
}

@keyframes fadeOut {
    from { opacity: 1; }
    to { opacity: 0; }
}

/* --- Main Container --- */
.main-container {
    display: flex;
    max-width: 1600px;
    margin: 0 auto;
    gap: 24px;
    padding: 32px 20px;
    min-height: calc(100vh - 400px);
}

/* --- Sidebar --- */
.sidebar {
    width: 240px;
    background: white;
    border-radius: 20px;
    padding: 24px 0;
    height: fit-content;
    position: sticky;
    top: 32px;
    box-shadow: 0 4px 20px rgba(0,0,0,0.08);
    border: 1px solid #f1f3f4;
}

.sidebar-section { margin-bottom: 32px; }
.sidebar-section:last-child { margin-bottom: 0; }

.sidebar-title {
    font-size: 12px;
    font-weight: 700;
    color: #6b7280;
    margin-bottom: 16px;
    padding: 0 24px;
    display: flex;
    align-items: center;
    gap: 10px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.sidebar-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 14px 24px;
    color: #6b7280;
    text-decoration: none;
    font-size: 15px;
    font-weight: 500;
    transition: all 0.3s ease;
    cursor: pointer;
    border-left: 3px solid transparent;
    border-radius: 12px;
}

.sidebar-item:hover {
    background: linear-gradient(90deg, #f0f4ff 0%, #e6f0ff 100%);
    color: #4c63d2;
    border-left-color: #4c63d2;
    transform: translateX(2px) translateY(-1px);
    box-shadow: 0 2px 8px rgba(76, 99, 210, 0.15);
}

.sidebar-item.active {
    background: #f5f7ff;
    color: #374151;
    border-left-color: #4c63d2;
    font-weight: 600;
    box-shadow: inset 0 0 0 1px #e6eaff;
}

.sidebar-item.active .sidebar-icon { color: #4c63d2; }
.sidebar-item:hover .sidebar-count { background: #4c63d2; color: white; }
.sidebar-item.active .sidebar-count { background: #e6eaff; color: #4c63d2; border: 1px solid #d9e0ff; }

.sidebar-icon { font-size: 18px; width: 24px; text-align: center; }

.sidebar-count {
    margin-left: auto;
    font-size: 12px;
    background: #f1f5f9;
    color: #64748b;
    padding: 2px 8px;
    border-radius: 10px;
    font-weight: 600;
}

/* --- Content Area --- */
.content-area {
    flex: 1;
    background: white;
    border-radius: 20px;
    padding: 32px;
    min-height: 600px;
    box-shadow: 0 4px 20px rgba(0,0,0,0.08);
    border: 1px solid #f1f3f4;
    overflow-y: auto;
}

.content-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 24px;
    padding-bottom: 16px;
    border-bottom: 2px solid #f1f3f4;
    position: sticky;
    top: 0;
    background: white;
    z-index: 10;
}

.content-title {
    font-size: 24px;
    font-weight: 700;
    color: #1f2937;
    display: flex;
    align-items: center;
    gap: 12px;
}

.more-link {
    color: #667eea;
    text-decoration: none;
    font-size: 14px;
    font-weight: 600;
    padding: 8px 16px;
    border-radius: 20px;
    transition: all 0.3s ease;
    border: 1px solid #e5e7eb;
}

.more-link:hover { background: #667eea; color: white; transform: translateY(-1px); }

/* --- Category Card --- */
.category-section { margin-bottom: 16px; }

.category-card {
    background: #ffffff;
    border-radius: 16px;
    box-shadow: 0 2px 10px rgba(0,0,0,0.05);
    border: 1px solid #e5e7eb;
    overflow: hidden;
    transition: box-shadow 0.2s ease, transform 0.2s ease;
    margin-bottom: 24px;
}

.category-card:hover {
    box-shadow: 0 6px 18px rgba(0,0,0,0.08);
    transform: translateY(-2px);
}

.category-header {
    background: #ffffff;
    padding: 16px 20px 12px 20px;
    position: relative;
}

.category-header.active {
    background: linear-gradient(135deg, #fee2e2 0%, #fecaca 100%);
    border-bottom-color: #f87171;
}

.category-title {
    font-size: 20px;
    font-weight: 700;
    color: #1e293b;
    margin-bottom: 4px;
    letter-spacing: -0.025em;
}

.category-count {
    font-size: 13px;
    color: #64748b;
    font-weight: 600;
    background: #f1f5f9;
    padding: 2px 8px;
    border-radius: 12px;
    display: inline-block;
}

.category-content {
    padding: 0 20px 20px 20px;
    background: #ffffff;
    display: grid;
    grid-template-columns: repeat(6, 1fr);
    gap: 12px;
}

.category-description { font-size: 14px; color: #6b7280; }

/* --- Tool Card & Grid --- */
.tools-grid {
    display: grid;
    grid-template-columns: repeat(6, 1fr);
    gap: 6px;
}

.tool-card {
    border: none;
    border-radius: 8px;
    padding: 12px;
    transition: all 0.3s ease;
    cursor: pointer;
    background: #f8f9fa;
    position: relative;
    overflow: hidden;
    display: flex;
    flex-direction: row;
    align-items: center;
    text-align: left;
    gap: 12px;
    min-height: 80px;
}

.tool-card:hover { background: #e9ecef; transform: translateY(-1px); }

.tool-card.highlight {
    border: 2px solid #667eea;
    box-shadow: 0 4px 16px rgba(102,126,234,0.25);
    transform: translateY(-2px);
}

.tool-icon {
    width: 48px;
    height: 48px;
    border-radius: 8px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 20px;
    background: white;
    flex-shrink: 0;
    box-shadow: 0 2px 8px rgba(0,0,0,0.1);
    overflow: hidden;
}

.tool-icon img {
    width: 48px;
    height: 48px;
    border-radius: 8px;
    object-fit: cover;
    transition: opacity 0.3s ease;
}

/* 懒加载占位 */
.tool-icon img[data-src] {
    opacity: 0;
}

.tool-icon img.loaded {
    opacity: 1;
}

.tool-info { flex: 1; min-width: 0; }

.tool-info h3,
.tool-title {
    font-size: 15px;
    font-weight: 600;
    color: #111827;
    margin-bottom: 4px;
    line-height: 1.3;
    letter-spacing: -0.025em;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.tool-description {
    color: #9ca3af;
    font-size: 13px;
    font-weight: 400;
    line-height: 1.4;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.tool-category { display: none; }
.tool-header { display: none; }
.tool-footer { display: none; }
.tool-rating { display: none; }
.tool-price { display: none; }

/* Featured */
.tool-card.featured {
    border-color: #a855f7;
    background: linear-gradient(135deg, #faf5ff 0%, #f3e8ff 100%);
}

.tool-card.featured .tool-info h3::before {
    content: '🔥';
    margin-right: 6px;
}

/* Price badges (hidden by default) */
.price-free {
    background: linear-gradient(135deg, #d1fae5 0%, #a7f3d0 100%);
    color: #065f46;
}

.price-paid {
    background: linear-gradient(135deg, #fecaca 0%, #fca5a5 100%);
    color: #991b1b;
}

/* --- Scrollbar --- */
.content-area::-webkit-scrollbar { width: 8px; }
.content-area::-webkit-scrollbar-track { background: #f8f9fa; border-radius: 4px; }
.content-area::-webkit-scrollbar-thumb { background: linear-gradient(135deg, #d1d5db 0%, #9ca3af 100%); border-radius: 4px; }
.content-area::-webkit-scrollbar-thumb:hover { background: linear-gradient(135deg, #9ca3af 0%, #6b7280 100%); }

/* --- Footer --- */
footer {
    background: linear-gradient(135deg, #f8f9fa 0%, #ffffff 100%);
    border-top: 1px solid #e5e7eb;
    margin-top: 0;
    padding: 48px 20px 32px;
    text-align: center;
    box-shadow: 0 -4px 20px rgba(0,0,0,0.03);
}

.footer-content { max-width: 1200px; margin: 0 auto; }

.footer-nav {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 20px;
    flex-wrap: wrap;
    margin-bottom: 24px;
}

.footer-nav-link {
    color: #667eea;
    text-decoration: none;
    font-size: 16px;
    font-weight: 600;
    transition: all 0.3s ease;
    padding: 8px 16px;
    border-radius: 20px;
}

.footer-nav-link:hover { background: #667eea; color: white; transform: translateY(-1px); }

.footer-separator { color: #d1d5db; font-weight: 300; }

.copyright { margin-bottom: 24px; }
.copyright p { color: #374151; font-size: 16px; font-weight: 500; margin: 0; letter-spacing: 0.5px; }

.beian-info {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 20px;
    flex-wrap: wrap;
    margin-bottom: 16px;
}

.beian-link {
    color: #9ca3af;
    text-decoration: none;
    font-size: 14px;
    font-weight: 500;
    transition: color 0.3s ease;
    display: flex;
    align-items: center;
    gap: 6px;
}

.beian-link:hover { color: #667eea; }
.beian-separator { color: #d1d5db; font-weight: 300; }
.police-badge { width: 16px; height: 16px; filter: drop-shadow(0 1px 2px rgba(0,0,0,0.1)); }

.footer-description { margin-top: 24px; }
.footer-description p { color: #9ca3af; font-size: 13px; margin: 0; line-height: 1.5; }

/* --- Animation --- */
.fade-in { animation: fadeIn 0.6s ease-out; }

@keyframes fadeIn {
    from { opacity: 0; transform: translateY(30px); }
    to { opacity: 1; transform: translateY(0); }
}

.loading {
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 40px;
    color: #6b7280;
}

.loading::after {
    content: '';
    width: 20px;
    height: 20px;
    border: 2px solid #e5e7eb;
    border-top: 2px solid #667eea;
    border-radius: 50%;
    animation: spin 1s linear infinite;
    margin-left: 12px;
}

@keyframes spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

/* --- Accessibility --- */
.sidebar-item:active,
.sidebar-item:focus-visible {
    background: linear-gradient(90deg, #f0f4ff 0%, #e6f0ff 100%);
    color: #4c63d2;
    border-left-color: #4c63d2;
    transform: translateX(2px) translateY(-1px);
    box-shadow: 0 2px 8px rgba(76, 99, 210, 0.15);
    outline: none;
}

.sidebar-item { -webkit-tap-highlight-color: transparent; }

/* TOP10 网格 (from style.css) */
.top10-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
    gap: 20px;
    padding-bottom: 20px;
}

.top10-card { background: #f8f9fa; border-radius: 12px; padding: 20px; border: 1px solid #e5e7eb; }
.top10-header { display: flex; align-items: center; gap: 12px; margin-bottom: 15px; }
.top10-icon { width: 40px; height: 40px; border-radius: 10px; background: white; display: flex; align-items: center; justify-content: center; font-size: 20px; }
.top10-info h3 { font-size: 16px; font-weight: bold; color: #1f2937; margin-bottom: 2px; }
.top10-count { font-size: 12px; color: #6b7280; }
.rank-list { display: flex; flex-direction: column; gap: 10px; }
.rank-item { display: flex; align-items: center; gap: 10px; padding: 8px; background: white; border-radius: 8px; }
.rank-number { width: 24px; height: 24px; border-radius: 50%; display: flex; align-items: center; justify-content: center; font-size: 12px; font-weight: bold; color: white; flex-shrink: 0; }
.rank-1 { background: #fbbf24; }
.rank-2 { background: #9ca3af; }
.rank-3 { background: #f59e0b; }
.rank-info h4 { font-size: 14px; font-weight: 600; color: #1f2937; margin-bottom: 2px; }
.rank-rating { font-size: 12px; color: #6b7280; }

/* 最后一个分类留底部空间 */
.category-section:last-child .category-card { margin-bottom: 40px; min-height: calc(100vh - 180px); }

/* ============================================================
   Responsive Design
   ============================================================ */
@media (max-width: 1500px) {
    .category-content { grid-template-columns: repeat(5, 1fr); gap: 10px; }
}

@media (max-width: 1400px) {
    .tools-grid { grid-template-columns: repeat(4, 1fr); gap: 6px; }
}

@media (max-width: 1200px) {
    .category-content { grid-template-columns: repeat(4, 1fr); gap: 8px; }
    .category-card { margin-bottom: 20px; }
    .tools-grid { grid-template-columns: repeat(3, 1fr); gap: 6px; }
    .tool-card { min-height: 70px; padding: 10px; }
    .tool-icon { width: 44px; height: 44px; font-size: 18px; }
    .tool-icon img { width: 44px; height: 44px; }
}

@media (max-width: 1024px) {
    .main-container { gap: 12px; padding: 16px 8px; }
    .sidebar { width: 180px; }
    .tools-grid { grid-template-columns: repeat(2, 1fr); gap: 4px; }
    .category-content { padding: 8px; }
    .category-header { padding: 8px 12px; }
    .tool-card { padding: 6px; gap: 6px; }
    .tool-icon { width: 28px; height: 28px; font-size: 14px; }
    .tool-icon img { width: 28px; height: 28px; }
}

@media (max-width: 992px) {
    .category-content { grid-template-columns: repeat(3, 1fr); gap: 6px; }
    .category-card { margin-bottom: 18px; }
    .tool-card { min-height: 65px; padding: 8px; }
    .tool-icon { width: 40px; height: 40px; font-size: 16px; }
    .tool-icon img { width: 40px; height: 40px; }
}

@media (max-width: 768px) {
    .header-banner { padding: 20px 0; }
    .logo h1 { font-size: 24px; }
    .logo p { font-size: 13px; }
    .main-container { flex-direction: column; padding: 20px 16px; }
    .sidebar { width: 100%; position: static; order: 2; padding: 16px 8px; }
    .sidebar-item { padding: 16px 20px; border-radius: 14px; }
    .sidebar-item:hover { transform: translateX(1px) translateY(-0.5px); box-shadow: 0 1px 6px rgba(76,99,210,0.12); }
    .content-area { order: 1; padding: 24px; }
    .tools-grid { grid-template-columns: 1fr; gap: 16px; }
    .category-content { grid-template-columns: repeat(2, 1fr); gap: 4px; }
    .tool-card { padding: 8px; min-height: 60px; }
    .tool-icon { width: 36px; height: 36px; font-size: 14px; }
    .tool-icon img { width: 36px; height: 36px; }
    .tool-info h3, .tool-title { font-size: 13px; }
    .tool-description { font-size: 11px; }
    .beian-info { flex-direction: column; gap: 12px; }
    .beian-separator { display: none; }
    .footer-nav { flex-direction: column; gap: 12px; }
    .footer-separator { display: none; }
}

@media (max-width: 480px) {
    .search-engines { gap: 12px; }
    .search-engine { font-size: 12px; padding: 6px 12px; }
    .content-title { font-size: 20px; }
    .tool-card { padding: 6px; min-height: 55px; }
    .tool-icon { width: 32px; height: 32px; font-size: 12px; }
    .tool-icon img { width: 32px; height: 32px; }
    .tool-info h3, .tool-title { font-size: 12px; }
    .tool-description { font-size: 10px; }
    .category-content { grid-template-columns: repeat(2, 1fr); gap: 4px; }
}

/* 降低动效 */
@media (prefers-reduced-motion: reduce) {
    .sidebar-item, .sidebar-item:hover, .sidebar-item:active, .sidebar-item:focus-visible,
    .category-card, .category-card:hover { transition: none; transform: none; }
}
