/**
 * AINAV.ART 移动端优化样式
 * 确保在所有设备上的完美显示，符合谷歌移动端友好性要求
 */

/* 基础响应式设置 */
* {
    box-sizing: border-box;
}

html {
    -webkit-text-size-adjust: 100%;
    -ms-text-size-adjust: 100%;
}

body {
    margin: 0;
    padding: 0;
    min-width: 320px; /* 最小宽度支持 */
}

/* 图片响应式 */
img {
    max-width: 100%;
    height: auto;
    display: block;
}

/* 表格响应式 */
table {
    width: 100%;
    overflow-x: auto;
    display: block;
    white-space: nowrap;
}

@media screen and (max-width: 768px) {
    table {
        font-size: 14px;
    }
}

/* 移动端导航优化 */
@media screen and (max-width: 768px) {
    .navbar-nav {
        flex-direction: column;
        width: 100%;
    }
    
    .navbar-nav .nav-item {
        width: 100%;
        text-align: center;
        border-bottom: 1px solid #eee;
    }
    
    .navbar-nav .nav-link {
        padding: 15px 20px;
        font-size: 16px; /* 确保触摸友好 */
    }
}

/* 按钮和链接触摸优化 */
button, 
.btn, 
a {
    min-height: 44px; /* Apple推荐的最小触摸目标 */
    min-width: 44px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    text-decoration: none;
    border: none;
    background: transparent;
    cursor: pointer;
    transition: all 0.2s ease;
}

/* 表单元素移动端优化 */
input, 
textarea, 
select {
    width: 100%;
    padding: 12px 16px;
    font-size: 16px; /* 防止iOS缩放 */
    border: 1px solid #ddd;
    border-radius: 4px;
    background-color: #fff;
    -webkit-appearance: none;
    -moz-appearance: none;
    appearance: none;
}

input:focus, 
textarea:focus, 
select:focus {
    outline: none;
    border-color: #667eea;
    box-shadow: 0 0 0 2px rgba(102, 126, 234, 0.2);
}

/* 搜索框优化 */
.search-container {
    position: relative;
    width: 100%;
    max-width: 500px;
    margin: 0 auto;
}

@media screen and (max-width: 768px) {
    .search-container {
        margin: 10px;
        max-width: calc(100% - 20px);
    }
    
    .search-input {
        font-size: 16px;
        padding: 15px 50px 15px 20px;
        border-radius: 25px;
        border: 2px solid #e0e0e0;
        width: 100%;
    }
    
    .search-button {
        position: absolute;
        right: 5px;
        top: 50%;
        transform: translateY(-50%);
        width: 40px;
        height: 40px;
        border-radius: 50%;
        background: #667eea;
        color: white;
        border: none;
        display: flex;
        align-items: center;
        justify-content: center;
    }
}

/* 卡片布局响应式 */
.card-grid {
    display: grid;
    gap: 20px;
    padding: 20px;
}

@media screen and (min-width: 1200px) {
    .card-grid {
        grid-template-columns: repeat(4, 1fr);
    }
}

@media screen and (min-width: 768px) and (max-width: 1199px) {
    .card-grid {
        grid-template-columns: repeat(3, 1fr);
    }
}

@media screen and (min-width: 480px) and (max-width: 767px) {
    .card-grid {
        grid-template-columns: repeat(2, 1fr);
        gap: 15px;
        padding: 15px;
    }
}

@media screen and (max-width: 479px) {
    .card-grid {
        grid-template-columns: 1fr;
        gap: 10px;
        padding: 10px;
    }
}

/* AI工具卡片移动端优化 */
.tool-card {
    background: white;
    border-radius: 12px;
    padding: 20px;
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.1);
    transition: transform 0.2s ease, box-shadow 0.2s ease;
    cursor: pointer;
}

.tool-card:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.15);
}

@media screen and (max-width: 768px) {
    .tool-card {
        padding: 15px;
        border-radius: 8px;
    }
    
    .tool-card:active {
        transform: scale(0.98);
    }
}

.tool-card .tool-logo {
    width: 48px;
    height: 48px;
    border-radius: 8px;
    margin-bottom: 12px;
    object-fit: cover;
}

.tool-card .tool-name {
    font-size: 18px;
    font-weight: 600;
    color: #333;
    margin-bottom: 8px;
    line-height: 1.3;
}

.tool-card .tool-description {
    font-size: 14px;
    color: #666;
    line-height: 1.5;
    margin-bottom: 12px;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

.tool-card .tool-tags {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
}

.tool-card .tool-tag {
    background: #f0f0f0;
    color: #666;
    padding: 4px 8px;
    border-radius: 12px;
    font-size: 12px;
    white-space: nowrap;
}

/* 分类导航移动端优化 */
.category-nav {
    display: flex;
    overflow-x: auto;
    padding: 10px 0;
    gap: 10px;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: none;
    -ms-overflow-style: none;
}

.category-nav::-webkit-scrollbar {
    display: none;
}

.category-nav .category-item {
    flex-shrink: 0;
    padding: 10px 20px;
    background: #f8f9fa;
    border-radius: 20px;
    color: #666;
    text-decoration: none;
    font-size: 14px;
    font-weight: 500;
    transition: all 0.2s ease;
    white-space: nowrap;
}

.category-nav .category-item.active,
.category-nav .category-item:hover {
    background: #667eea;
    color: white;
}

@media screen and (max-width: 768px) {
    .category-nav {
        padding: 10px 15px;
    }
    
    .category-nav .category-item {
        padding: 12px 18px;
        font-size: 15px;
    }
}

/* 页脚移动端优化 */
.footer {
    background: #2c3e50;
    color: white;
    padding: 40px 20px 20px;
}

.footer-content {
    max-width: 1200px;
    margin: 0 auto;
    display: grid;
    gap: 30px;
}

@media screen and (min-width: 768px) {
    .footer-content {
        grid-template-columns: repeat(3, 1fr);
    }
}

@media screen and (max-width: 767px) {
    .footer-content {
        grid-template-columns: 1fr;
        text-align: center;
    }
    
    .footer {
        padding: 30px 15px 15px;
    }
}

.footer-section h4 {
    color: #ecf0f1;
    margin-bottom: 15px;
    font-size: 16px;
}

.footer-section ul {
    list-style: none;
    padding: 0;
    margin: 0;
}

.footer-section ul li {
    margin-bottom: 8px;
}

.footer-section ul li a {
    color: #bdc3c7;
    text-decoration: none;
    font-size: 14px;
    transition: color 0.2s ease;
}

.footer-section ul li a:hover {
    color: #ecf0f1;
}

/* Cookie同意横幅移动端优化 */
@media screen and (max-width: 768px) {
    .cookie-consent-banner {
        bottom: 0;
        left: 0;
        right: 0;
        border-radius: 0;
    }
    
    .cookie-consent-content {
        flex-direction: column;
        padding: 20px 15px;
        gap: 20px;
    }
    
    .cookie-types {
        grid-template-columns: 1fr;
        gap: 8px;
    }
    
    .cookie-consent-actions {
        min-width: auto;
    }
    
    .cookie-consent-actions .btn {
        padding: 12px 20px;
        font-size: 15px;
    }
}

/* 加载动画移动端优化 */
.loading-spinner {
    display: inline-block;
    width: 40px;
    height: 40px;
    border: 3px solid #f3f3f3;
    border-top: 3px solid #667eea;
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

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

/* 滚动条优化 */
::-webkit-scrollbar {
    width: 8px;
    height: 8px;
}

::-webkit-scrollbar-track {
    background: #f1f1f1;
    border-radius: 4px;
}

::-webkit-scrollbar-thumb {
    background: #c1c1c1;
    border-radius: 4px;
}

::-webkit-scrollbar-thumb:hover {
    background: #a8a8a8;
}

@media screen and (max-width: 768px) {
    ::-webkit-scrollbar {
        width: 4px;
        height: 4px;
    }
}

/* 文本选择优化 */
::selection {
    background: rgba(102, 126, 234, 0.2);
    color: #333;
}

::-moz-selection {
    background: rgba(102, 126, 234, 0.2);
    color: #333;
}

/* 焦点可见性优化 */
*:focus {
    outline: 2px solid #667eea;
    outline-offset: 2px;
}

button:focus,
.btn:focus {
    outline: 2px solid #667eea;
    outline-offset: 2px;
}

/* 打印样式 */
@media print {
    .cookie-consent-banner,
    .floating-buttons,
    .advertisement {
        display: none !important;
    }
    
    body {
        font-size: 12pt;
        line-height: 1.5;
    }
    
    .tool-card {
        break-inside: avoid;
        margin-bottom: 20pt;
    }
}

/* 高对比度模式支持 */
@media (prefers-contrast: high) {
    .tool-card {
        border: 2px solid #333;
    }
    
    .btn {
        border: 2px solid currentColor;
    }
}

/* 减少动画偏好 */
@media (prefers-reduced-motion: reduce) {
    *,
    *::before,
    *::after {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
        scroll-behavior: auto !important;
    }
}

/* 暗色模式支持 */
@media (prefers-color-scheme: dark) {
    body {
        background-color: #1a1a1a;
        color: #e0e0e0;
    }
    
    .tool-card {
        background: #2d2d2d;
        color: #e0e0e0;
        border: 1px solid #404040;
    }
    
    .tool-card .tool-name {
        color: #ffffff;
    }
    
    .tool-card .tool-description {
        color: #b0b0b0;
    }
    
    .category-nav .category-item {
        background: #3d3d3d;
        color: #e0e0e0;
    }
    
    input, textarea, select {
        background-color: #2d2d2d;
        color: #e0e0e0;
        border-color: #404040;
    }
}

/* 横屏模式优化 */
@media screen and (max-height: 500px) and (orientation: landscape) {
    .cookie-consent-banner {
        position: fixed;
        top: 0;
        bottom: auto;
        max-height: 80vh;
        overflow-y: auto;
    }
    
    .header {
        padding: 10px 0;
    }
    
    .main-content {
        padding-top: 60px;
    }
}
