/* 移动端增强样式 - 美化版 */

/* ========================================
   1. 底部导航栏（移动端）
   ======================================== */
.mobile-bottom-nav {
    position: fixed;
    /* 放置在公司导航条之上 */
    bottom: 4.25rem;
    left: 0;
    right: 0;
    background: rgba(255, 255, 255, 0.95);
    backdrop-filter: blur(10px);
    border-top: 1px solid #e2e8f0;
    padding: 0.5rem 0;
    padding-bottom: max(0.5rem, env(safe-area-inset-bottom));
    z-index: 9995;
    display: none;
    box-shadow: 0 -2px 10px rgba(0, 0, 0, 0.05);
}

.dark .mobile-bottom-nav {
    background: rgba(15, 23, 42, 0.95);
    border-top-color: #334155;
}

@media (max-width: 768px) {
    .mobile-bottom-nav {
        display: flex;
        justify-content: space-around;
        align-items: center;
    }
    
    /* 为底部导航栏预留空间 */
    body {
        padding-bottom: calc(8rem + env(safe-area-inset-bottom));
    }
}

.mobile-nav-item {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 0.5rem 1rem;
    color: #64748b;
    text-decoration: none;
    font-size: 0.75rem;
    font-weight: 500;
    transition: all 0.3s ease;
    position: relative;
    flex: 1;
    min-width: 0;
}

.dark .mobile-nav-item {
    color: #94a3b8;
}

.mobile-nav-item.active {
    color: #1173d4;
    transform: translateY(-2px);
}

.dark .mobile-nav-item.active {
    color: #3b82f6;
}

.mobile-nav-item svg {
    width: 1.5rem;
    height: 1.5rem;
    margin-bottom: 0.25rem;
    transition: transform 0.3s ease;
}

.mobile-nav-item.active svg {
    transform: scale(1.1);
}

.mobile-nav-item span {
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    max-width: 100%;
}

/* 导航项激活指示器 */
.mobile-nav-item::before {
    content: '';
    position: absolute;
    top: 0;
    left: 50%;
    transform: translateX(-50%) scaleX(0);
    width: 40%;
    height: 2px;
    background: #1173d4;
    border-radius: 0 0 2px 2px;
    transition: transform 0.3s ease;
}

.mobile-nav-item.active::before {
    transform: translateX(-50%) scaleX(1);
}

/* ========================================
   2. 返回顶部按钮
   ======================================== */
.back-to-top {
    position: fixed;
    bottom: calc(5.5rem + env(safe-area-inset-bottom));
    left: 1rem;
    width: 3rem;
    height: 3rem;
    background: #1173d4;
    color: white;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    opacity: 0;
    visibility: hidden;
    transition: all 0.3s ease;
    box-shadow: 0 4px 12px rgba(17, 115, 212, 0.3);
    z-index: 9996;
}

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

.back-to-top:hover {
    transform: translateY(-3px);
    box-shadow: 0 6px 16px rgba(17, 115, 212, 0.4);
}

.back-to-top:active {
    transform: translateY(-1px);
}

.dark .back-to-top {
    background: #3b82f6;
    box-shadow: 0 4px 12px rgba(59, 130, 246, 0.3);
}

@media (min-width: 769px) {
    .back-to-top {
        bottom: 2rem;
        right: 6rem;
        left: auto;
        width: 3.5rem;
        height: 3.5rem;
    }
}

/* ========================================
   3. 移动端顶部导航增强
   ======================================== */
@media (max-width: 768px) {
    /* 让顶部导航更紧凑 */
    header .container > div {
        height: 3.5rem;
    }
    
    /* Logo和公司名称优化 */
    header .logo-container {
        width: 1.75rem;
        height: 1.75rem;
    }
    
    header .company-name {
        font-size: 0.95rem;
    }
    
    /* 隐藏桌面登录按钮，改用底部导航 */
    header button[class*="sm:inline-block"] {
        display: none !important;
    }
}

/* ========================================
   4. 卡片和内容区域优化
   ======================================== */
@media (max-width: 768px) {
    /* Hero Section 优化 */
    .hero-section,
    section[class*="hero"] {
        padding-top: 3rem;
        padding-bottom: 3rem;
    }
    
    /* 特色产品卡片网格 */
    .grid.grid-cols-1.sm\\:grid-cols-2.lg\\:grid-cols-3 {
        gap: 1rem;
    }
    
    /* 表单输入框更大更易点击 */
    input[type="text"],
    input[type="tel"],
    input[type="email"],
    input[type="password"],
    select,
    textarea {
        min-height: 3rem;
        font-size: 1rem;
    }
    
    /* 按钮更大 */
    button,
    .btn,
    a[class*="btn"] {
        min-height: 3rem;
        padding: 0.875rem 1.5rem;
        font-size: 1rem;
    }
}

/* ========================================
   5. 宣传横幅移动端优化
   ======================================== */
@media (max-width: 640px) {
    .promotional-slogan-banner {
        padding: 1rem 0;
    }
    
    .promotional-slogan-banner .slogan-segment {
        font-size: 0.875rem !important;
        line-height: 1.4;
    }
    
    .promotional-slogan-banner .text-2xl {
        font-size: 1.25rem;
    }
}

/* ========================================
   6. 产品表格移动端卡片视图
   ======================================== */
@media (max-width: 768px) {
    #productsTable {
        display: block;
        overflow: visible;
    }
    
    #productsTable thead {
        display: none;
    }
    
    #productsTable tbody {
        display: block;
    }
    
    #productsTable tbody tr {
        display: block;
        margin-bottom: 1rem;
        background: white;
        border-radius: 0.75rem;
        padding: 1rem;
        box-shadow: 0 2px 8px rgba(0, 0, 0, 0.08);
        border: 1px solid #e2e8f0;
        cursor: pointer;
        transition: all 0.3s ease;
    }
    
    .dark #productsTable tbody tr {
        background: #1e293b;
        border-color: #334155;
    }
    
    #productsTable tbody tr:hover {
        transform: translateY(-2px);
        box-shadow: 0 4px 12px rgba(0, 0, 0, 0.12);
    }
    
    #productsTable tbody td {
        display: block;
        padding: 0.75rem 0;
        border-bottom: 1px solid #f1f5f9;
        text-align: left;
        font-size: 0.9rem;
        line-height: 1.6;
    }
    
    .dark #productsTable tbody td {
        border-bottom-color: #334155;
    }
    
    #productsTable tbody td:last-child {
        border-bottom: none;
    }
    
    /* 使用data-label属性显示列名（行内显示） */
    #productsTable tbody td::before {
        content: attr(data-label) ": ";
        display: inline;
        font-weight: 600;
        color: #64748b;
        margin-right: 0.5rem;
    }
    
    .dark #productsTable tbody td::before {
        color: #94a3b8;
    }
    
    /* 数据值容器样式 */
    #productsTable tbody td {
        color: #334155;
        font-weight: 500;
        /* 限制文本长度，超出显示省略号 */
        white-space: nowrap;
        overflow: hidden;
        text-overflow: ellipsis;
        max-width: 100%;
    }
    
    .dark #productsTable tbody td {
        color: #cbd5e1;
    }
    
    /* 名称列允许换行（因为可能较长） */
    #productsTable tbody td[data-label="名称"] {
        white-space: normal;
        word-break: break-word;
    }
    
    /* 价格列特殊样式 */
    #productsTable tbody td[data-label="价格"] {
        color: #1173d4;
        font-weight: 700;
        font-size: 1rem;
    }
    
    .dark #productsTable tbody td[data-label="价格"] {
        color: #3b82f6;
    }
    
    /* 型号列特殊样式 */
    #productsTable tbody td[data-label="型号"] {
        color: #0f172a;
        font-weight: 600;
        font-size: 0.95rem;
    }
    
    .dark #productsTable tbody td[data-label="型号"] {
        color: #f1f5f9;
    }
    
    /* 移动端隐藏箭头图标，因为整个卡片都是可点击的 */
    #productsTable tbody td .arrow-icon {
        display: none;
    }
    
    /* 移动端完全隐藏备注列（第8列），因为内容太长影响显示 */
    #productsTable tbody td:nth-child(8) {
        display: none !important;
    }
    
    /* 为卡片添加触摸反馈提示 */
    #productsTable tbody tr::after {
        content: '点击查看详情 ›';
        display: block;
        text-align: center;
        padding: 0.5rem 0 0.25rem;
        margin-top: 0.5rem;
        border-top: 1px solid #e2e8f0;
        color: #64748b;
        font-size: 0.75rem;
        font-weight: 500;
    }
    
    .dark #productsTable tbody tr::after {
        border-top-color: #334155;
        color: #94a3b8;
    }
    
    /* 移动端卡片激活状态 */
    #productsTable tbody tr:active {
        transform: scale(0.98);
        box-shadow: 0 2px 4px rgba(0, 0, 0, 0.08);
    }
}

/* ========================================
   6.1 质保结果页面表格优化
   ======================================== */
@media (max-width: 768px) {
    /* 质保结果页面的客户信息表格 */
    .warranty-result-table table {
        display: block;
    }
    
    .warranty-result-table thead {
        display: none;
    }
    
    .warranty-result-table tbody,
    .warranty-result-table tr {
        display: block;
    }
    
    .warranty-result-table td {
        display: flex !important;
        justify-content: space-between;
        align-items: center;
        padding: 0.75rem !important;
        border-bottom: 1px solid #f1f5f9;
        text-align: left !important;
    }
    
    .dark .warranty-result-table td {
        border-bottom-color: #334155;
    }
    
    .warranty-result-table td:last-child {
        border-bottom: none;
    }
    
    .warranty-result-table td::before {
        content: attr(data-label);
        font-weight: 600;
        color: #64748b;
        margin-right: 1rem;
        flex-shrink: 0;
    }
    
    .dark .warranty-result-table td::before {
        color: #94a3b8;
    }
    
    /* 移动端卡片样式优化 */
    .warranty-result-table {
        border-radius: 0.75rem;
        overflow: hidden;
    }
}

/* ========================================
   7. 图片懒加载占位符
   ======================================== */
img[loading="lazy"] {
    background: linear-gradient(90deg, #f1f5f9 25%, #f8fafc 50%, #f1f5f9 75%);
    background-size: 200% 100%;
    animation: shimmer 1.5s infinite;
}

@keyframes shimmer {
    0% {
        background-position: 200% 0;
    }
    100% {
        background-position: -200% 0;
    }
}

img[loading="lazy"].loaded {
    animation: none;
    background: transparent;
}

/* ========================================
   8. 搜索和筛选优化
   ======================================== */
@media (max-width: 768px) {
    /* 搜索筛选区域堆叠布局 */
    .grid.grid-cols-1.md\\:grid-cols-2.lg\\:grid-cols-4 {
        grid-template-columns: 1fr;
        gap: 0.75rem;
    }
    
    /* 筛选按钮全宽 */
    .grid.grid-cols-1.md\\:grid-cols-2.lg\\:grid-cols-4 button {
        width: 100%;
        margin-top: 0.5rem;
    }
}

/* ========================================
   9. Footer 移动端优化
   ======================================== */
@media (max-width: 768px) {
    footer {
        padding-bottom: calc(1rem + 4rem + env(safe-area-inset-bottom));
    }
    
    footer .grid {
        gap: 2rem;
        text-align: center;
    }
    
    footer .flex.items-start {
        justify-content: center;
        text-align: center;
    }
    
    footer .flex.space-x-4 {
        justify-content: center;
    }
}

/* ========================================
   10. 手势交互提示
   ======================================== */
.swipe-hint {
    position: fixed;
    bottom: calc(5rem + env(safe-area-inset-bottom));
    left: 50%;
    transform: translateX(-50%);
    background: rgba(0, 0, 0, 0.7);
    color: white;
    padding: 0.5rem 1rem;
    border-radius: 1rem;
    font-size: 0.875rem;
    opacity: 0;
    visibility: hidden;
    transition: all 0.3s ease;
    pointer-events: none;
    z-index: 50;
}

.swipe-hint.show {
    opacity: 1;
    visibility: visible;
}

/* ========================================
   11. 加载状态优化
   ======================================== */
.skeleton {
    background: linear-gradient(90deg, #f1f5f9 25%, #e2e8f0 50%, #f1f5f9 75%);
    background-size: 200% 100%;
    animation: skeleton-loading 1.5s infinite;
    border-radius: 0.5rem;
}

@keyframes skeleton-loading {
    0% {
        background-position: 200% 0;
    }
    100% {
        background-position: -200% 0;
    }
}

.dark .skeleton {
    background: linear-gradient(90deg, #1e293b 25%, #334155 50%, #1e293b 75%);
    background-size: 200% 100%;
}

/* ========================================
   12. 触摸反馈增强
   ======================================== */
@media (hover: none) and (pointer: coarse) {
    /* 触摸设备上的按钮反馈 */
    button:not(:disabled):active,
    a[role="button"]:active,
    .btn:active {
        transform: scale(0.97);
        opacity: 0.9;
    }
    
    /* 卡片点击反馈 */
    .card:active,
    .product-card:active,
    .feature-card:active {
        transform: scale(0.98);
    }
    
    /* 链接点击反馈 */
    a:active {
        opacity: 0.7;
    }
}

/* ========================================
   13. 优化文字可读性
   ======================================== */
@media (max-width: 768px) {
    /* 确保文字大小至少16px，避免iOS自动缩放 */
    body {
        font-size: 16px;
        line-height: 1.6;
    }
    
    /* 标题层级优化 */
    h1 {
        font-size: 1.875rem;
        line-height: 1.2;
        margin-bottom: 1rem;
    }
    
    h2 {
        font-size: 1.5rem;
        line-height: 1.3;
        margin-bottom: 0.875rem;
    }
    
    h3 {
        font-size: 1.25rem;
        line-height: 1.4;
        margin-bottom: 0.75rem;
    }
    
    /* 段落间距 */
    p {
        margin-bottom: 1rem;
    }
}

/* ========================================
   14. 横屏模式特殊优化
   ======================================== */
@media (max-width: 768px) and (orientation: landscape) {
    /* 减少垂直间距 */
    section {
        padding-top: 2rem !important;
        padding-bottom: 2rem !important;
    }
    
    /* Hero区域高度调整 */
    .hero-section,
    section[class*="hero"] {
        min-height: auto;
        padding-top: 2rem !important;
        padding-bottom: 2rem !important;
    }
    
    /* 减小标题大小 */
    h1 {
        font-size: 1.5rem;
    }
    
    h2 {
        font-size: 1.25rem;
    }
}

/* ========================================
   15. 性能优化
   ======================================== */
/* 减少动画以提升性能 */
@media (prefers-reduced-motion: reduce) {
    *,
    *::before,
    *::after {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
    }
}

/* 简化移动端动画 */
@media (max-width: 768px) {
    * {
        animation-duration: 0.2s !important;
        transition-duration: 0.2s !important;
    }
}

/* ========================================
   16. 暗色模式优化
   ======================================== */
@media (prefers-color-scheme: dark) {
    /* 自动适配系统暗色模式 */
    :root:not(.light) {
        color-scheme: dark;
    }
}

/* ========================================
   17. 可访问性增强
   ======================================== */
/* 焦点可见性 */
*:focus-visible {
    outline: 2px solid #1173d4;
    outline-offset: 2px;
    border-radius: 0.25rem;
}

/* 跳过导航链接 */
.skip-to-content {
    position: absolute;
    top: -100%;
    left: 0;
    background: #1173d4;
    color: white;
    padding: 0.5rem 1rem;
    text-decoration: none;
    z-index: 100;
    transition: top 0.3s ease;
}

.skip-to-content:focus {
    top: 0;
}

/* ========================================
   18. 加载中状态
   ======================================== */
.loading-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(255, 255, 255, 0.9);
    backdrop-filter: blur(5px);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 9999;
    opacity: 0;
    visibility: hidden;
    transition: all 0.3s ease;
}

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

.dark .loading-overlay {
    background: rgba(15, 23, 42, 0.9);
}

.loading-spinner {
    width: 3rem;
    height: 3rem;
    border: 3px solid #e2e8f0;
    border-top-color: #1173d4;
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
}

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


