/* 全局样式 */
:root {
    --primary-color: #007bff;
    --secondary-color: #6c757d;
    --success-color: #28a745;
    --warning-color: #ffc107;
    --danger-color: #dc3545;
    --info-color: #17a2b8;
    --light-color: #f8f9fa;
    --dark-color: #343a40;
    --border-radius: 12px;
    --box-shadow: 0 4px 6px rgba(0, 0, 0, 0.1);
    --transition: all 0.3s ease;
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    line-height: 1.6;
    color: #333;
    background-color: #f8f9fa;
}

/* 导航栏样式 */
.navbar {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%) !important;
    box-shadow: var(--box-shadow);
    backdrop-filter: blur(10px);
}

.navbar-brand {
    font-size: 1.5rem;
    font-weight: 700;
}

.navbar-nav .nav-link {
    font-weight: 500;
    margin: 0 0.5rem;
    border-radius: 8px;
    transition: var(--transition);
}

.navbar-nav .nav-link:hover {
    background-color: rgba(255, 255, 255, 0.1);
    transform: translateY(-2px);
}

/* 首页导航栏特殊样式 */
.navbar .input-group {
    min-width: 300px;
}

.navbar .input-group .form-control {
    background: rgba(255, 255, 255, 0.95);
    border: none;
}

.navbar .input-group .form-control:focus {
    background: white;
    box-shadow: 0 0 0 0.2rem rgba(255, 255, 255, 0.25);
}

.navbar .btn-group .btn-outline-light {
    border-color: rgba(255, 255, 255, 0.5);
    color: rgba(255, 255, 255, 0.8);
}

.navbar .btn-group .btn-outline-light:hover {
    background-color: rgba(255, 255, 255, 0.1);
    border-color: rgba(255, 255, 255, 0.8);
    color: white;
}

.navbar .btn-group .btn-outline-light.active {
    background-color: rgba(255, 255, 255, 0.2);
    border-color: white;
    color: white;
}

/* 搜索英雄区域 */
.search-hero {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    position: relative;
    overflow: hidden;
}

.search-hero::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 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="50" cy="50" r="1" fill="white" opacity="0.1"/></pattern></defs><rect width="100" height="100" fill="url(%23grain)"/></svg>');
    pointer-events: none;
}

.search-hero .input-group-text {
    background: white;
    border: none;
    padding: 1rem;
}

.search-hero .form-control {
    border: none;
    padding: 1rem 1.5rem;
    font-size: 1.1rem;
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.1);
}

.search-hero .form-control:focus {
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.15);
}

.search-hero .btn-outline-light {
    border: 2px solid rgba(255, 255, 255, 0.3);
    color: white;
    background: rgba(255, 255, 255, 0.1);
    backdrop-filter: blur(10px);
    transition: var(--transition);
}

.search-hero .btn-outline-light:hover,
.search-hero .btn-outline-light.active {
    background: rgba(255, 255, 255, 0.2);
    border-color: rgba(255, 255, 255, 0.5);
    color: white;
    transform: translateY(-2px);
}

/* 简化的工具卡片 */
.tools-section .card {
    transition: var(--transition);
    border: none;
    border-radius: 12px;
    overflow: hidden;
}

.tools-section .card:hover {
    transform: translateY(-3px);
    box-shadow: 0 8px 25px rgba(0, 0, 0, 0.12);
}

.tools-section .card-body {
    padding: 1.5rem;
}

.tools-section .card-title {
    font-size: 1.1rem;
    font-weight: 600;
    color: #2c3e50;
}

.tools-section .card-text {
    font-size: 0.9rem;
    line-height: 1.5;
}

.tools-section .btn-primary {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    border: none;
    font-size: 0.85rem;
    padding: 0.5rem 1rem;
    border-radius: 8px;
}

.tools-section .btn-primary:hover {
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(102, 126, 234, 0.4);
}

/* 瀑布流网格优化 */
.masonry-grid {
    column-count: 1;
    column-gap: 1.25rem;
    column-fill: balance;
}

@media (min-width: 576px) {
    .masonry-grid { 
        column-count: 2; 
        column-gap: 1.25rem;
    }
}

@media (min-width: 992px) {
    .masonry-grid { 
        column-count: 3; 
        column-gap: 1.5rem;
    }
}

@media (min-width: 1400px) {
    .masonry-grid { 
        column-count: 4; 
        column-gap: 1.5rem;
    }
}

/* 工具卡片的最小高度调整 */
.tool-card {
    break-inside: avoid;
    margin-bottom: 1.25rem;
    display: inline-block;
    width: 100%;
    min-height: 140px;
}

/* 防止文本溢出的工具类 */
.min-width-0 {
    min-width: 0;
    overflow: hidden;
}

/* 卡片样式优化 */
.card {
    border: none;
    border-radius: var(--border-radius);
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.08);
    transition: var(--transition);
    overflow: hidden;
    background: #fff;
    border: 1px solid rgba(0, 0, 0, 0.04);
}

.card:hover {
    transform: translateY(-3px);
    box-shadow: 0 8px 25px rgba(0, 0, 0, 0.12);
    border-color: rgba(102, 126, 234, 0.1);
}

/* 无结果状态 */
#noResults {
    animation: fadeIn 0.5s ease-in;
}

/* 移动端优化 */
@media (max-width: 768px) {
    .search-hero .display-5 {
        font-size: 2rem;
    }
    
    .search-hero .lead {
        font-size: 1rem;
    }
    
    .search-hero .btn-group {
        flex-direction: column;
        width: 100%;
    }
    
    .search-hero .btn-group .btn {
        margin-bottom: 0.5rem;
    }
    
    .masonry-grid {
        column-gap: 1rem;
    }
    
    .tools-section .card-body {
        padding: 1rem;
    }
    
    .tool-card {
        min-height: 120px;
        margin-bottom: 1rem;
    }
    
    .tool-logo,
    .tool-logo-placeholder {
        width: 40px;
        height: 40px;
        font-size: 1rem;
    }
    
    .card-title {
        font-size: 1rem;
        margin-bottom: 0.6rem;
    }
    
    .card-text {
        font-size: 0.85rem;
        -webkit-line-clamp: 2;
        line-clamp: 2;
        line-height: 1.4;
    }
    
    .tool-card-clickable:hover {
        transform: translateY(-2px);
    }
}

/* 可点击卡片样式 */
.card-link {
    text-decoration: none;
    color: inherit;
    display: block;
}

.card-link:hover {
    text-decoration: none;
    color: inherit;
}

.tool-card-clickable {
    cursor: pointer;
    transition: all 0.3s ease;
    position: relative;
    overflow: hidden;
    border-radius: var(--border-radius);
    height: 100%;
}

.tool-card-clickable::before {
    content: '';
    position: absolute;
    top: 0;
    left: -100%;
    width: 100%;
    height: 100%;
    background: linear-gradient(90deg, transparent, rgba(255, 255, 255, 0.2), transparent);
    transition: left 0.5s;
    z-index: 1;
}

.tool-card-clickable:hover::before {
    left: 100%;
}

.tool-card-clickable:hover {
    transform: translateY(-5px);
    box-shadow: 0 12px 24px rgba(0, 0, 0, 0.15);
    border: 1px solid rgba(102, 126, 234, 0.2);
}

.tool-card-clickable:active {
    transform: translateY(-2px);
    transition: transform 0.1s ease;
}

/* 搜索框焦点状态优化 */
.search-focused {
    transform: scale(1.02);
    box-shadow: 0 4px 12px rgba(102, 126, 234, 0.3);
}

/* 触摸设备的特殊样式 */
.tool-card-clickable.touched {
    transform: translateY(-4px);
    box-shadow: 0 8px 16px rgba(0, 0, 0, 0.2);
}

/* 加载动画优化 */
.tool-card {
    will-change: opacity, transform;
}

/* 键盘导航优化 */
.card-link:focus {
    outline: none;
}

.card-link:focus .tool-card-clickable {
    box-shadow: 0 0 0 3px rgba(102, 126, 234, 0.5);
    transform: translateY(-4px);
}

/* 提高移动端体验 */
@media (max-width: 768px) {
    .tool-card-clickable {
        padding: 4px;
        margin: -4px;
    }
    
    .tool-card-clickable:active {
        transform: scale(0.95);
        transition: transform 0.1s ease;
    }
    
    /* 移动端的点击反馈 */
    .tool-card-clickable:active::before {
        content: '';
        position: absolute;
        top: 0;
        left: 0;
        right: 0;
        bottom: 0;
        background: rgba(102, 126, 234, 0.1);
        border-radius: var(--border-radius);
        z-index: 1;
    }
}

/* 高对比度模式支持 */
@media (prefers-contrast: high) {
    .tool-card-clickable {
        border: 2px solid #000;
    }
    
    .tool-card-clickable:hover {
        border-color: #0066cc;
        background-color: #f0f8ff;
    }
}

/* Logo 样式 */
.tool-logo {
    width: 48px;
    height: 48px;
    object-fit: cover;
    border-radius: 8px;
    border: 2px solid #e9ecef;
    background-color: #fff;
    transition: var(--transition);
    flex-shrink: 0;
}

.tool-logo:hover {
    border-color: var(--primary-color);
    transform: scale(1.05);
}

.tool-logo-placeholder {
    width: 48px;
    height: 48px;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    border-radius: 8px;
    display: flex;
    align-items: center;
    justify-content: center;
    color: white;
    font-size: 1.2rem;
    flex-shrink: 0;
    transition: var(--transition);
}

.tool-logo-placeholder:hover {
    transform: scale(1.05);
}

/* 卡片内容区域优化 */
.card-body {
    padding: 1.25rem;
    position: relative;
    z-index: 2;
}

.card-body .d-flex {
    align-items: flex-start;
    gap: 1rem;
}

.card-title {
    font-size: 1.1rem;
    font-weight: 600;
    color: #2c3e50;
    margin-bottom: 0.75rem;
    line-height: 1.3;
    word-break: break-word;
    overflow-wrap: break-word;
}

.card-text {
    font-size: 0.9rem;
    line-height: 1.5;
    color: #6c757d;
    margin-bottom: 0;
    display: -webkit-box;
    -webkit-line-clamp: 3;
    -webkit-box-orient: vertical;
    line-clamp: 3;
    overflow: hidden;
    word-break: break-word;
    overflow-wrap: break-word;
}

/* 减少动画模式支持 */
@media (prefers-reduced-motion: reduce) {
    .tool-card-clickable,
    .tool-card-clickable::before,
    .tool-logo,
    .tool-logo-placeholder {
        transition: none;
    }
    
    .tool-card-clickable:hover,
    .tool-logo:hover,
    .tool-logo-placeholder:hover {
        transform: none;
    }
    
    .tool-card {
        transition: none;
    }
}

/* 搜索框样式 */
.search-box {
    position: relative;
}

.search-box .form-control {
    border-radius: 50px;
    padding: 1rem 1.5rem;
    border: 2px solid #e9ecef;
    font-size: 1.1rem;
    transition: var(--transition);
}

.search-box .form-control:focus {
    border-color: var(--primary-color);
    box-shadow: 0 0 0 0.2rem rgba(0, 123, 255, 0.25);
}

.search-box .input-group-text {
    border-radius: 50px 0 0 50px;
    border: 2px solid var(--primary-color);
    border-right: none;
}

/* 步骤指示器 */
.step-item {
    text-align: center;
    margin-bottom: 2rem;
}

.step-icon {
    width: 60px;
    height: 60px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.5rem;
    margin: 0 auto 1rem;
    position: relative;
}

.step-icon::after {
    content: '';
    position: absolute;
    top: 50%;
    left: 100%;
    width: 100px;
    height: 2px;
    background: #dee2e6;
    z-index: -1;
}

.step-item:last-child .step-icon::after {
    display: none;
}

/* 表单样式 */
.form-control {
    border-radius: 8px;
    border: 2px solid #e9ecef;
    padding: 0.75rem 1rem;
    transition: var(--transition);
}

.form-control:focus {
    border-color: var(--primary-color);
    box-shadow: 0 0 0 0.2rem rgba(0, 123, 255, 0.25);
}

.form-control-lg {
    padding: 1rem 1.25rem;
    font-size: 1.1rem;
}

/* 按钮样式 */
.btn {
    border-radius: 8px;
    font-weight: 600;
    padding: 0.75rem 1.5rem;
    transition: var(--transition);
    border: none;
    position: relative;
    overflow: hidden;
}

.btn::before {
    content: '';
    position: absolute;
    top: 0;
    left: -100%;
    width: 100%;
    height: 100%;
    background: linear-gradient(90deg, transparent, rgba(255, 255, 255, 0.2), transparent);
    transition: left 0.5s;
}

.btn:hover::before {
    left: 100%;
}

.btn-lg {
    padding: 1rem 2rem;
    font-size: 1.1rem;
}

/* 登录页面 */
.login-section {
    min-height: 100vh;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    display: flex;
    align-items: center;
}

.min-vh-75 {
    min-height: 75vh;
}

.login-icon {
    animation: pulse 2s infinite;
}

@keyframes pulse {
    0% { transform: scale(1); }
    50% { transform: scale(1.05); }
    100% { transform: scale(1); }
}

/* 管理后台 */
.admin-section {
    min-height: 100vh;
    background-color: #f8f9fa;
}

.table {
    background: white;
    border-radius: var(--border-radius);
    overflow: hidden;
    box-shadow: var(--box-shadow);
}

.table thead th {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    border: none;
    font-weight: 600;
    padding: 1rem;
}

.table tbody tr {
    transition: var(--transition);
}

.table tbody tr:hover {
    background-color: rgba(0, 123, 255, 0.05);
}

/* 空状态 */
.empty-state {
    padding: 4rem 2rem;
    text-align: center;
}

.empty-state i {
    opacity: 0.5;
    margin-bottom: 2rem;
}

/* 响应式设计 */
@media (max-width: 768px) {
    .hero-section {
        min-height: 50vh;
        text-align: center;
    }
    
    .display-4 {
        font-size: 2.5rem;
    }
    
    .masonry-grid {
        column-count: 1;
    }
    
    .step-icon::after {
        display: none;
    }
    
    .navbar-nav {
        margin-top: 1rem;
    }
    
    .navbar-nav .nav-link {
        margin: 0.25rem 0;
    }
}

@media (max-width: 576px) {
    .container {
        padding: 0 1rem;
    }
    
    .hero-section {
        padding: 2rem 0;
    }
    
    .hero-section h1 {
        font-size: 2rem;
    }
    
    .card-body {
        padding: 1.5rem;
    }
    
    .btn-lg {
        padding: 0.75rem 1.5rem;
        font-size: 1rem;
    }
}

/* 动画效果 */
.fade-in {
    animation: fadeIn 0.6s ease-in;
}

@keyframes fadeIn {
    from { opacity: 0; }
    to { opacity: 1; }
}

.slide-in-left {
    animation: slideInLeft 0.6s ease-out;
}

@keyframes slideInLeft {
    from {
        opacity: 0;
        transform: translateX(-30px);
    }
    to {
        opacity: 1;
        transform: translateX(0);
    }
}

.slide-in-right {
    animation: slideInRight 0.6s ease-out;
}

@keyframes slideInRight {
    from {
        opacity: 0;
        transform: translateX(30px);
    }
    to {
        opacity: 1;
        transform: translateX(0);
    }
}

/* 加载动画 */
.loading-spinner {
    display: inline-block;
    width: 20px;
    height: 20px;
    border: 3px solid rgba(255, 255, 255, 0.3);
    border-radius: 50%;
    border-top-color: #fff;
    animation: spin 1s ease-in-out infinite;
}

@keyframes spin {
    to { transform: rotate(360deg); }
}

/* 自定义滚动条 */
::-webkit-scrollbar {
    width: 8px;
}

::-webkit-scrollbar-track {
    background: #f1f1f1;
    border-radius: 4px;
}

::-webkit-scrollbar-thumb {
    background: #c1c1c1;
    border-radius: 4px;
}

::-webkit-scrollbar-thumb:hover {
    background: #a8a8a8;
}

/* 工具提示 */
.tooltip {
    font-size: 0.875rem;
}

/* 徽章样式 */
.badge {
    font-weight: 600;
    padding: 0.5em 0.75em;
}

/* 警告框样式 */
.alert {
    border: none;
    border-radius: var(--border-radius);
    padding: 1rem 1.5rem;
}

.alert-dismissible .btn-close {
    padding: 1rem 1.5rem;
}

/* 页脚样式 */
footer {
    margin-top: auto;
}

footer a:hover {
    color: #fff !important;
}

/* 打印样式 */
@media print {
    .navbar,
    .btn,
    footer {
        display: none !important;
    }
    
    .card {
        box-shadow: none !important;
        border: 1px solid #ddd !important;
    }
}
