/* 移动端优化样式 */

/* ==================== 基础移动端适配 ==================== */

/* 触摸优化 */
* {
    -webkit-tap-highlight-color: transparent;
    -webkit-touch-callout: none;
    -webkit-user-select: none;
    -moz-user-select: none;
    -ms-user-select: none;
    user-select: none;
}

/* 允许文本选择的元素 */
input, textarea, [contenteditable] {
    -webkit-user-select: text;
    -moz-user-select: text;
    -ms-user-select: text;
    user-select: text;
}

/* 移动端滚动优化 */
body {
    -webkit-overflow-scrolling: touch;
    overscroll-behavior: contain;
}

/* ==================== 头部导航移动端优化 ==================== */

@media (max-width: 768px) {
    /* 头部导航 */
    .header-nav {
        padding: 0 1rem;
        height: 56px;
        min-height: 56px;
    }

    .header-logo {
        width: 100px !important;
        flex: 0 0 100px;
    }

    .header-logo img {
        max-height: 32px;
        width: auto;
    }

    /* 搜索框移动端优化 */
    .header-search {
        margin: 0 0.75rem;
        max-width: none;
        flex: 1;
    }

    .header-search input {
        font-size: 16px; /* 防止iOS缩放 */
        padding: 8px 12px;
        border-radius: 20px;
        background: #f8f9fa;
        border: 1px solid #e9ecef;
    }

    .header-search input:focus {
        background: white;
        border-color: var(--brand-color, #1890ff);
        box-shadow: 0 0 0 2px rgba(24, 144, 255, 0.1);
    }

    /* 用户菜单移动端优化 */
    .header-user {
        width: 80px !important;
        flex: 0 0 80px;
    }

    .header-user .dropdown-toggle {
        padding: 6px 8px;
        font-size: 14px;
    }

    .header-user .user-avatar {
        width: 28px;
        height: 28px;
    }
}

/* ==================== 商品网格移动端优化 ==================== */

@media (max-width: 768px) {
    .goods-grid {
        grid-template-columns: repeat(2, 1fr);
        gap: 12px;
        padding: 0 1rem;
    }

    .goods-item {
        border-radius: 12px;
        overflow: hidden;
        background: white;
        box-shadow: 0 2px 8px rgba(0, 0, 0, 0.06);
        transition: all 0.3s ease;
    }

    .goods-item:active {
        transform: scale(0.98);
        box-shadow: 0 1px 4px rgba(0, 0, 0, 0.1);
    }

    .goods-item-image {
        height: 120px;
        width: 100%;
        object-fit: cover;
    }

    .goods-item-content {
        padding: 12px;
    }

    .goods-item-title {
        font-size: 14px;
        line-height: 1.4;
        margin-bottom: 8px;
        display: -webkit-box;
        -webkit-line-clamp: 2;
        -webkit-box-orient: vertical;
        overflow: hidden;
    }

    .goods-item-price {
        font-size: 16px;
        font-weight: 600;
        color: #ff4757;
    }
}

@media (max-width: 480px) {
    .goods-grid {
        gap: 8px;
        padding: 0 0.75rem;
    }

    .goods-item-image {
        height: 100px;
    }

    .goods-item-content {
        padding: 10px;
    }

    .goods-item-title {
        font-size: 13px;
        margin-bottom: 6px;
    }

    .goods-item-price {
        font-size: 15px;
    }
}

/* ==================== 按钮移动端优化 ==================== */

@media (max-width: 768px) {
    .btn, .default-btn-primary, .default-btn-secondary {
        min-height: 44px; /* iOS推荐的最小触摸目标 */
        padding: 12px 20px;
        font-size: 16px;
        border-radius: 8px;
        font-weight: 500;
        transition: all 0.2s ease;
    }

    .btn:active {
        transform: scale(0.98);
    }

    .btn-sm {
        min-height: 36px;
        padding: 8px 16px;
        font-size: 14px;
    }

    .btn-lg {
        min-height: 52px;
        padding: 16px 24px;
        font-size: 18px;
    }
}

/* ==================== 表单元素移动端优化 ==================== */

@media (max-width: 768px) {
    input, textarea, select {
        font-size: 16px; /* 防止iOS缩放 */
        min-height: 44px;
        padding: 12px 16px;
        border-radius: 8px;
        border: 1px solid #e1e5e9;
        background: white;
        transition: all 0.2s ease;
    }

    input:focus, textarea:focus, select:focus {
        border-color: var(--brand-color, #1890ff);
        box-shadow: 0 0 0 3px rgba(24, 144, 255, 0.1);
        outline: none;
    }

    textarea {
        min-height: 100px;
        resize: vertical;
    }

    /* 表单组 */
    .form-group {
        margin-bottom: 20px;
    }

    .form-label {
        font-size: 14px;
        font-weight: 500;
        margin-bottom: 8px;
        display: block;
        color: #374151;
    }
}

/* ==================== 卡片移动端优化 ==================== */

@media (max-width: 768px) {
    .card, .default-card, .bg-blue-50 {
        padding: 16px;
    }

    .card-header {
        padding: 16px 16px 12px;
        border-bottom: 1px solid #f1f3f4;
        margin: -16px -16px 16px;
    }

    .card-title {
        font-size: 18px;
        font-weight: 600;
        margin: 0;
    }
}

/* ==================== 模态框移动端优化 ==================== */

@media (max-width: 768px) {
    .modal-overlay {
        padding: 16px;
    }

    .modal-container, .bg-white.rounded-2xl.shadow-2xl {
        width: 100%;
        max-width: 100%;
        margin: 0;
        border-radius: 16px 16px 0 0;
        position: fixed;
        bottom: 0;
        left: 0;
        right: 0;
        transform: translateY(100%);
        transition: transform 0.3s ease;
        max-height: 90vh;
        overflow-y: auto;
    }

    .modal-overlay.show .modal-container,
    .modal-overlay.show .bg-white.rounded-2xl.shadow-2xl {
        transform: translateY(0);
    }

    .modal-header {
        padding: 20px 20px 16px;
        border-bottom: 1px solid #f1f3f4;
        position: sticky;
        top: 0;
        background: white;
        z-index: 1;
    }

    .modal-content {
        padding: 20px;
    }
}

/* ==================== 导航菜单移动端优化 ==================== */

@media (max-width: 768px) {
    .nav-menu {
        position: fixed;
        top: 56px;
        left: 0;
        right: 0;
        background: white;
        box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
        transform: translateY(-100%);
        transition: transform 0.3s ease;
        z-index: 1000;
        max-height: calc(100vh - 56px);
        overflow-y: auto;
    }

    .nav-menu.show {
        transform: translateY(0);
    }

    .nav-menu-item {
        padding: 16px 20px;
        border-bottom: 1px solid #f1f3f4;
        font-size: 16px;
        color: #374151;
        text-decoration: none;
        display: block;
        transition: background-color 0.2s ease;
    }

    .nav-menu-item:hover,
    .nav-menu-item:active {
        background-color: #f8f9fa;
        color: var(--brand-color, #1890ff);
    }

    .nav-menu-item.active {
        background-color: rgba(24, 144, 255, 0.1);
        color: var(--brand-color, #1890ff);
        font-weight: 500;
    }
}

/* ==================== 底部安全区域适配 ==================== */

@media (max-width: 768px) {
    .safe-area-bottom {
        padding-bottom: env(safe-area-inset-bottom);
    }

    .fixed-bottom {
        bottom: env(safe-area-inset-bottom);
    }
}

/* ==================== 触摸反馈优化 ==================== */

@media (max-width: 768px) {
    .touchable {
        cursor: pointer;
        transition: all 0.2s ease;
    }

    .touchable:active {
        transform: scale(0.98);
        opacity: 0.8;
    }

    /* 链接触摸优化 */
    a {
        -webkit-tap-highlight-color: rgba(24, 144, 255, 0.1);
        tap-highlight-color: rgba(24, 144, 255, 0.1);
    }
}
