/* Global Styles - Unified Theme */
:root {
    --primary: #6366f1;
    --primary-dark: #4f46e5;
    --primary-light: #818cf8;
    --bg: #f5f7fa;
    --card-bg: #ffffff;
    --text: #333333;
    --text-muted: #888888;
    --border: #e5e5e5;
    --shadow: 0 2px 8px rgba(0,0,0,0.08);
    --shadow-hover: 0 8px 25px rgba(99, 102, 241, 0.15);
    --radius: 12px;
    --radius-sm: 8px;
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', 'PingFang SC', 'Microsoft YaHei', sans-serif;
    background: var(--bg);
    color: var(--text);
    line-height: 1.6;
}

/* Navbar */
.navbar {
    background: white;
    box-shadow: var(--shadow);
    padding: 15px 0;
}

.navbar-brand {
    font-size: 1.5rem;
    font-weight: 700;
    color: var(--primary) !important;
}

.nav-link {
    color: var(--text);
    font-weight: 500;
    padding: 8px 16px !important;
    border-radius: var(--radius-sm);
    transition: all 0.3s;
    margin: 0 2px;
}

.nav-link:hover, .nav-link.active {
    color: var(--primary);
    background: rgba(99, 102, 241, 0.1);
}

/* Hero Section */
.hero {
    background: linear-gradient(135deg, #6366f1 0%, #4f46e5 50%, #818cf8 100%);
    padding: 50px 0 60px;
    color: white;
    text-align: center;
    margin-bottom: 30px;
}

.hero h1 {
    font-size: 2.5rem;
    font-weight: 700;
    margin-bottom: 12px;
}

.hero p {
    font-size: 1.1rem;
    opacity: 0.95;
    margin-bottom: 25px;
}

/* Search Box */
.search-box {
    background: white;
    border-radius: var(--radius);
    padding: 6px;
    max-width: 550px;
    margin: 0 auto 25px;
    box-shadow: var(--shadow);
    display: flex;
    gap: 8px;
}

.search-input {
    flex: 1;
    border: none;
    padding: 12px 18px;
    font-size: 1rem;
    border-radius: var(--radius-sm);
}

.search-input:focus {
    outline: none;
    box-shadow: none;
}

.search-btn {
    background: linear-gradient(135deg, var(--primary) 0%, var(--primary-dark) 100%);
    color: white;
    border: none;
    padding: 12px 25px;
    border-radius: var(--radius-sm);
    font-weight: 600;
    transition: all 0.3s;
    white-space: nowrap;
}

.search-btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(99, 102, 241, 0.3);
    color: white;
}

/* Hot Tags */
.hot-tag {
    display: inline-block;
    background: rgba(255,255,255,0.2);
    padding: 6px 15px;
    border-radius: 20px;
    margin: 4px;
    color: white;
    font-size: 0.9rem;
    text-decoration: none;
    transition: all 0.3s;
}

.hot-tag:hover {
    background: rgba(255,255,255,0.3);
    color: white;
    text-decoration: none;
}

/* Card Styles */
.tool-card, .news-card {
    background: var(--card-bg);
    border-radius: var(--radius);
    padding: 18px;
    margin-bottom: 12px;
    box-shadow: var(--shadow);
    transition: all 0.3s;
    text-decoration: none;
    color: inherit;
    display: block;
}

.tool-card:hover, .news-card:hover {
    transform: translateY(-3px);
    box-shadow: var(--shadow-hover);
}

/* Tool Logo */
.tool-logo {
    width: 48px;
    height: 48px;
    background: linear-gradient(135deg, var(--primary), var(--primary-light));
    border-radius: var(--radius-sm);
    display: flex;
    align-items: center;
    justify-content: center;
    color: white;
    font-size: 1.2rem;
    font-weight: 700;
    flex-shrink: 0;
    overflow: hidden;
}

.tool-logo img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

/* Tool Name */
.tool-name {
    font-size: 1rem;
    font-weight: 600;
    color: var(--text);
    margin-bottom: 4px;
}

/* Tool Description */
.tool-desc {
    color: var(--text-muted);
    font-size: 0.85rem;
    margin-bottom: 8px;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

/* Price Tag */
.tool-price {
    color: #f59e0b;
    font-weight: 600;
    font-size: 0.85rem;
}

/* Category Tag */
.tool-tag, .badge-category {
    background: rgba(99, 102, 241, 0.1);
    color: var(--primary);
    padding: 4px 10px;
    border-radius: 15px;
    font-size: 0.75rem;
}

/* Stats Cards */
.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
    gap: 16px;
    margin-bottom: 30px;
}

.stat-card {
    background: var(--card-bg);
    border-radius: var(--radius);
    padding: 20px;
    text-align: center;
    box-shadow: var(--shadow);
}

.stat-card-icon {
    width: 44px;
    height: 44px;
    border-radius: 10px;
    display: flex;
    align-items: center;
    justify-content: center;
    margin: 0 auto 12px;
    font-size: 1.3rem;
}

.stat-card-icon.primary {
    background: rgba(99, 102, 241, 0.1);
    color: var(--primary);
}

.stat-card-icon.success {
    background: rgba(16, 185, 129, 0.1);
    color: #10b981;
}

.stat-card-icon.warning {
    background: rgba(245, 158, 11, 0.1);
    color: #f59e0b;
}

.stat-card-icon.danger {
    background: rgba(239, 68, 68, 0.1);
    color: #ef4444;
}

.stat-num {
    font-size: 2rem;
    font-weight: 700;
    background: linear-gradient(135deg, var(--primary), var(--primary-light));
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

.stat-card-label {
    color: var(--text-muted);
    font-size: 0.85rem;
    margin-top: 4px;
}

/* Category Nav */
.category-nav {
    background: var(--card-bg);
    border-radius: var(--radius);
    padding: 18px;
    box-shadow: var(--shadow);
}

.category-nav h5 {
    color: var(--primary);
    font-weight: 700;
    font-size: 1rem;
    margin-bottom: 15px;
}

.category-item {
    display: flex;
    align-items: center;
    padding: 10px 12px;
    border-radius: var(--radius-sm);
    color: var(--text);
    text-decoration: none;
    transition: all 0.3s;
    margin-bottom: 6px;
}

.category-item:hover {
    background: rgba(99, 102, 241, 0.1);
    color: var(--primary);
}

.category-icon {
    width: 36px;
    height: 36px;
    background: linear-gradient(135deg, var(--primary), var(--primary-light));
    border-radius: var(--radius-sm);
    display: flex;
    align-items: center;
    justify-content: center;
    color: white;
    margin-right: 10px;
    font-size: 1rem;
}

/* News Card */
.news-image {
    height: 100px;
    background: linear-gradient(135deg, #f59e0b, #ec4899);
    border-radius: var(--radius-sm) var(--radius-sm) 0 0;
    display: flex;
    align-items: center;
    justify-content: center;
    color: white;
    font-size: 2rem;
}

.news-content {
    padding: 12px;
}

.news-title {
    font-size: 0.95rem;
    font-weight: 600;
    color: var(--text);
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
    margin-bottom: 8px;
}

/* Rank Badge */
.badge-rank {
    background: #f59e0b;
    color: white;
    padding: 2px 8px;
    border-radius: 8px;
    font-size: 0.75rem;
    font-weight: 600;
}

/* Section Title */
.section-title {
    font-size: 1.3rem;
    font-weight: 700;
    color: var(--text);
    margin-bottom: 20px;
    padding-bottom: 12px;
    border-bottom: 2px solid var(--primary);
    display: inline-block;
}

/* Pagination */
.page-link {
    border: none;
    padding: 8px 14px;
    border-radius: var(--radius-sm);
    color: var(--text);
    margin: 0 2px;
    transition: all 0.3s;
}

.page-link.active {
    background: linear-gradient(135deg, var(--primary), var(--primary-dark));
    color: white;
}

.page-link:hover:not(.active) {
    background: var(--bg);
}

/* Tag Badge */
.tag-badge {
    background: var(--bg);
    color: var(--text-muted);
    padding: 4px 12px;
    border-radius: 20px;
    font-size: 0.75rem;
}

/* Footer */
.footer {
    background: linear-gradient(180deg, #1e293b 0%, #0f172a 100%);
    color: #94a3b8;
    padding: 40px 0 20px;
    margin-top: 40px;
}

.footer a {
    color: #94a3b8;
    text-decoration: none;
}

.footer a:hover {
    color: white;
}

.footer h4 {
    color: white;
    font-weight: 700;
    margin-bottom: 15px;
}

.footer h6 {
    color: white;
    font-weight: 600;
    margin-bottom: 15px;
}

/* Buttons */
.btn-primary-custom {
    background: linear-gradient(135deg, var(--primary) 0%, var(--primary-dark) 100%);
    color: white;
    border: none;
    border-radius: var(--radius-sm);
    padding: 10px 20px;
    font-weight: 600;
    transition: all 0.3s;
}

.btn-primary-custom:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(99, 102, 241, 0.3);
    color: white;
}

/* Responsive */
@media (max-width: 768px) {
    .hero {
        padding: 35px 0 45px;
    }
    
    .hero h1 {
        font-size: 1.8rem;
    }
    
    .hero p {
        font-size: 0.95rem;
    }
    
    .stat-num {
        font-size: 1.6rem;
    }
    
    .section-title {
        font-size: 1.1rem;
    }
}

/* ========================================
   暗黑模式支持
   ======================================== */

[data-theme="dark"] {
    --primary: #818cf8;
    --primary-dark: #6366f1;
    --primary-light: #a5b4fc;
    --bg: #0f172a;
    --card-bg: #1e293b;
    --text: #e2e8f0;
    --text-muted: #94a3b8;
    --border: #334155;
    --shadow: 0 2px 8px rgba(0,0,0,0.3);
    --shadow-hover: 0 8px 25px rgba(129, 140, 248, 0.2);
}

[data-theme="dark"] body {
    background: var(--bg);
    color: var(--text);
}

[data-theme="dark"] .navbar {
    background: var(--card-bg);
    border-bottom: 1px solid var(--border);
}

[data-theme="dark"] .nav-link {
    color: var(--text);
}

[data-theme="dark"] .nav-link:hover,
[data-theme="dark"] .nav-link.active {
    background: rgba(129, 140, 248, 0.2);
    color: var(--primary);
}

[data-theme="dark"] .search-box {
    background: var(--card-bg);
    border: 1px solid var(--border);
}

[data-theme="dark"] .search-input {
    background: transparent;
    color: var(--text);
}

[data-theme="dark"] .search-input::placeholder {
    color: var(--text-muted);
}

[data-theme="dark"] .tool-card,
[data-theme="dark"] .news-card,
[data-theme="dark"] .category-card,
[data-theme="dark"] .feature-card {
    background: var(--card-bg);
    border: 1px solid var(--border);
}

[data-theme="dark"] .tool-name,
[data-theme="dark"] .news-title,
[data-theme="dark"] .category-name {
    color: var(--text);
}

[data-theme="dark"] .tool-desc,
[data-theme="dark"] .news-excerpt {
    color: var(--text-muted);
}

[data-theme="dark"] .section-title {
    color: var(--text);
}

[data-theme="dark"] .tag-badge {
    background: rgba(129, 140, 248, 0.2);
    color: var(--primary);
}

[data-theme="dark"] .footer {
    background: linear-gradient(135deg, #0f172a 0%, #1e293b 100%);
}

[data-theme="dark"] .dropdown-menu {
    background: var(--card-bg);
    border-color: var(--border);
}

[data-theme="dark"] .dropdown-item {
    color: var(--text);
}

[data-theme="dark"] .dropdown-item:hover {
    background: rgba(129, 140, 248, 0.2);
}

[data-theme="dark"] .form-control,
[data-theme="dark"] .form-select {
    background: var(--card-bg);
    border-color: var(--border);
    color: var(--text);
}

[data-theme="dark"] .form-control::placeholder {
    color: var(--text-muted);
}

[data-theme="dark"] .card {
    background: var(--card-bg);
    border-color: var(--border);
}

[data-theme="dark"] .modal-content {
    background: var(--card-bg);
    border-color: var(--border);
}

[data-theme="dark"] .btn-close {
    filter: invert(1);
}

[data-theme="dark"] .breadcrumb {
    background: var(--card-bg);
}

[data-theme="dark"] .breadcrumb-item a {
    color: var(--primary);
}

[data-theme="dark"] .breadcrumb-item.active {
    color: var(--text);
}

[data-theme="dark"] .alert-info {
    background: rgba(129, 140, 248, 0.2);
    border-color: var(--primary);
    color: var(--text);
}

[data-theme="dark"] .alert-warning {
    background: rgba(251, 191, 36, 0.2);
    border-color: #fbbf24;
    color: var(--text);
}

/* 暗黑模式切换按钮 */
.theme-toggle {
    background: transparent;
    border: none;
    color: var(--text);
    font-size: 1.2rem;
    padding: 8px;
    border-radius: 50%;
    cursor: pointer;
    transition: all 0.3s;
}

.theme-toggle:hover {
    background: rgba(99, 102, 241, 0.2);
    color: var(--primary);
}

/* ========================================
   返回顶部按钮
   ======================================== */

.scroll-to-top {
    position: fixed;
    bottom: 30px;
    right: 30px;
    width: 50px;
    height: 50px;
    background: linear-gradient(135deg, var(--primary) 0%, var(--primary-dark) 100%);
    color: white;
    border: none;
    border-radius: 50%;
    cursor: pointer;
    opacity: 0;
    visibility: hidden;
    transition: all 0.3s ease;
    z-index: 1000;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 4px 15px rgba(99, 102, 241, 0.4);
}

.scroll-to-top.visible {
    opacity: 1;
    visibility: visible;
}

.scroll-to-top:hover {
    transform: translateY(-5px);
    box-shadow: 0 8px 25px rgba(99, 102, 241, 0.5);
}

.scroll-to-top i {
    font-size: 1.3rem;
}

@media (max-width: 768px) {
    .scroll-to-top {
        bottom: 20px;
        right: 20px;
        width: 45px;
        height: 45px;
    }
}

/* ========================================
   加载动画
   ======================================== */

.loading-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.5);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 9999;
    opacity: 0;
    visibility: hidden;
    transition: all 0.3s;
}

.loading-overlay.active {
    opacity: 1;
    visibility: visible;
}

.loading-spinner {
    width: 50px;
    height: 50px;
    border: 4px solid rgba(255, 255, 255, 0.3);
    border-top-color: var(--primary);
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

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

/* ========================================
   图片懒加载
   ======================================== */

img.lazy {
    opacity: 0;
    transition: opacity 0.3s;
}

img.lazy.loaded {
    opacity: 1;
}

/* 图片加载失败占位 */
img.img-error {
    background: linear-gradient(135deg, var(--primary) 0%, var(--primary-light) 100%);
    display: flex;
    align-items: center;
    justify-content: center;
    color: white;
    font-weight: bold;
}

/* ========================================
   分页美化
   ======================================== */

.pagination-nav {
    margin-top: 2rem;
}

.pagination {
    justify-content: center;
    gap: 5px;
}

.pagination .page-link {
    border: none;
    border-radius: var(--radius-sm);
    padding: 10px 16px;
    color: var(--text);
    background: var(--card-bg);
    box-shadow: var(--shadow);
    transition: all 0.2s;
}

.pagination .page-link:hover {
    background: var(--primary);
    color: white;
    transform: translateY(-2px);
}

.pagination .page-item.active .page-link {
    background: var(--primary);
    color: white;
}

.pagination .page-item.disabled .page-link {
    background: var(--bg);
    color: var(--text-muted);
}

/* ========================================
   面包屑导航
   ======================================== */

.breadcrumb-container {
    padding: 15px 0;
    background: var(--bg);
}

.breadcrumb {
    background: var(--card-bg);
    padding: 12px 20px;
    border-radius: var(--radius);
    margin-bottom: 0;
    box-shadow: var(--shadow);
}

.breadcrumb-item a {
    color: var(--primary);
    text-decoration: none;
}

.breadcrumb-item a:hover {
    text-decoration: underline;
}

.breadcrumb-item.active {
    color: var(--text-muted);
}

/* ========================================
   工具提示
   ======================================== */

[data-tooltip] {
    position: relative;
}

[data-tooltip]::after {
    content: attr(data-tooltip);
    position: absolute;
    bottom: 100%;
    left: 50%;
    transform: translateX(-50%);
    padding: 6px 12px;
    background: #1e293b;
    color: white;
    font-size: 0.85rem;
    border-radius: 6px;
    white-space: nowrap;
    opacity: 0;
    visibility: hidden;
    transition: all 0.2s;
    z-index: 100;
}

[data-tooltip]:hover::after {
    opacity: 1;
    visibility: visible;
    bottom: calc(100% + 8px);
}
