/**
 * 客户前台移动端适配（Bootstrap 5.1.3 断点对齐）
 * xs: <576px  sm: <768px  md: <992px
 */

.type-icon {
    width: 96px;
    height: 96px;
}

/* ---------- 全局 ---------- */
@media (max-width: 767.98px) {
    body {
        padding-bottom: env(safe-area-inset-bottom, 0);
    }

    .container.py-5,
    main .py-5 {
        padding-top: 1.5rem !important;
        padding-bottom: 1.5rem !important;
    }

    h1, .h1 {
        font-size: 1.5rem;
    }

    h2, .h2 {
        font-size: 1.25rem;
    }

    .form-control,
    .form-select {
        font-size: 16px;
        min-height: 44px;
    }

    .btn {
        min-height: 44px;
    }

    .modal-dialog {
        margin: 0.5rem;
    }

    .modal-fullscreen-sm-down {
        max-width: 100%;
    }
}

/* ---------- 导航栏 ---------- */
@media (max-width: 767.98px) {
    .navbar {
        height: auto !important;
        min-height: 50px;
        padding-top: 0.25rem !important;
        padding-bottom: 0.25rem !important;
    }

    .navbar-brand {
        font-size: 1.1rem;
        padding: 0.2rem 0 !important;
    }

    .navbar-toggler {
        padding: 0.35rem 0.55rem !important;
        min-width: 44px;
        min-height: 44px;
    }

    .nav-link {
        padding: 0.5rem 0.75rem !important;
        font-size: 0.9rem;
    }

    #cart-count {
        font-size: 0.65rem !important;
        padding: 0.15rem 0.35rem !important;
    }

    .navbar-lang-switcher {
        width: 100%;
        margin: 0.5rem 0 0 0;
    }

    .lang-bar {
        justify-content: center;
        width: 100%;
    }

    .lang-item {
        padding: 10px 16px !important;
        font-size: 13px !important;
        min-height: 44px;
        display: inline-flex;
        align-items: center;
    }
}

@media (max-width: 991.98px) {
    .navbar-collapse {
        background-color: #212529;
        padding: 10px;
        border-radius: 0 0 8px 8px;
        box-shadow: 0 4px 10px rgba(0, 0, 0, 0.3);
    }
}

/* ---------- 浮动按钮 FAB ---------- */
@media (max-width: 767.98px) {
    #contact-float {
        bottom: calc(20px + env(safe-area-inset-bottom, 0));
        right: 20px;
        left: auto;
    }

    #contact-float > div {
        border-radius: 50%;
        width: 56px;
        height: 56px;
        padding: 0;
        display: flex;
        align-items: center;
        justify-content: center;
    }

    #contact-float i {
        margin-right: 0 !important;
        font-size: 1.8rem;
        color: white !important;
    }

    #contact-float span {
        display: none !important;
    }

    #cart-float-mobile {
        bottom: calc(90px + env(safe-area-inset-bottom, 0)) !important;
    }

    #contact-float-mobile {
        bottom: calc(20px + env(safe-area-inset-bottom, 0)) !important;
    }
}

/* ---------- 首页 ---------- */
@media (max-width: 767.98px) {
    .hero-section {
        padding-top: 70px !important;
        padding-bottom: 1.5rem !important;
    }

    .hero-section h1,
    .hero-section .display-3 {
        font-size: 1.5rem !important;
        margin-bottom: 0.8rem !important;
    }

    .hero-section h2,
    .hero-section .lead {
        font-size: 0.9rem !important;
        margin-bottom: 1rem !important;
    }

    .types-selection-section {
        padding: 1rem 0 !important;
    }

    .type-card {
        padding: 15px !important;
        margin-bottom: 1rem !important;
    }

    .type-icon {
        width: 88px !important;
        height: 88px !important;
        margin-bottom: 0.8rem !important;
        font-size: 2rem !important;
    }

    .type-icon i {
        font-size: 2rem !important;
    }

    .type-card h3 {
        font-size: 1.1rem !important;
        margin-bottom: 8px !important;
    }

    .type-card p {
        font-size: 0.85rem !important;
        min-height: auto !important;
        margin-bottom: 0.8rem !important;
    }

    .type-card .btn {
        font-size: 0.85rem !important;
        padding: 0.4rem 1rem !important;
    }

    .platform-features-section {
        padding: 1.5rem 0 !important;
    }

    .feature-card {
        padding: 1rem !important;
        margin-bottom: 0.75rem !important;
    }

    .feature-card h5 {
        font-size: 0.9rem !important;
    }

    .feature-card p {
        font-size: 0.75rem !important;
    }
}

/* ---------- 分类主题页 ---------- */
.theme-page .hero-section {
    min-height: auto;
}

@media (max-width: 767.98px) {
    .theme-page .hero-section {
        padding-top: 70px !important;
        padding-bottom: 1.5rem !important;
    }

    .theme-page .hero-section h1 {
        font-size: 1.6rem !important;
        line-height: 1.3 !important;
        margin-bottom: 0.8rem !important;
    }

    .theme-page .hero-section h2,
    .theme-page .hero-section .lead {
        font-size: 0.95rem !important;
        line-height: 1.4 !important;
        margin-bottom: 1rem !important;
    }

    .theme-page .hero-section .btn {
        font-size: 0.9rem !important;
        padding: 0.5rem 1.2rem !important;
        margin-bottom: 0.5rem !important;
    }

    .theme-page .hero-section .d-flex.gap-3 {
        flex-wrap: wrap !important;
        gap: 0.5rem !important;
        justify-content: center !important;
    }

    .theme-page .hero-section .col-lg-6 {
        text-align: center !important;
        margin-bottom: 1rem !important;
    }

    .theme-page .hero-section img {
        max-height: 220px !important;
    }

    .theme-page .category-card {
        margin-bottom: 1rem !important;
    }

    .theme-page .category-image div {
        height: 120px !important;
    }

    .theme-page .features-section .feature-card {
        padding: 1rem !important;
        margin-bottom: 1rem !important;
    }

    .theme-page .features-section h5 {
        font-size: 0.9rem !important;
    }

    .theme-page .features-section p {
        font-size: 0.75rem !important;
    }

    .products-section-header {
        flex-direction: column;
        align-items: stretch !important;
        text-align: center;
    }

    .product-sort-toolbar {
        justify-content: center;
        flex-wrap: wrap;
        width: 100%;
    }

    .product-sort-select {
        width: 100%;
        max-width: 280px;
    }

    .theme-page .products-section,
    .theme-page #products {
        padding-bottom: calc(120px + env(safe-area-inset-bottom, 0));
    }

    .theme-page .product-card .d-grid .btn {
        position: relative;
        z-index: 1;
    }

    /* FAB 容器不挡下方按钮；仅图标本身可点 */
    #cart-float-mobile,
    #contact-float-mobile {
        pointer-events: none;
    }

    #cart-float-mobile > a,
    #contact-float-mobile > div {
        pointer-events: auto;
    }
}

@media (hover: hover) {
    .hero-cta-btn:hover {
        transform: scale(1.05) translateY(-2px);
    }
}

@media (hover: none) {
    .hero-cta-btn {
        transform: none !important;
    }
}

/* ---------- 商品卡片列表 ---------- */
@media (max-width: 767.98px) {
    .product-card {
        margin-bottom: 0.75rem !important;
    }

    .product-card .card-title {
        font-size: 0.85rem !important;
        line-height: 1.3;
    }

    .product-card .card-text {
        font-size: 0.75rem !important;
    }

    .product-card .price-section h4 {
        font-size: 1rem !important;
    }

    .product-card .btn {
        font-size: 0.8rem !important;
        padding: 0.35rem 0.5rem !important;
    }

    .card-img-top {
        max-height: 180px;
        aspect-ratio: 1 / 1;
        height: auto;
        object-fit: cover;
    }
}

/* ---------- 商品详情 ---------- */
@media (max-width: 767.98px) {
    .product-showcase-box {
        min-height: auto !important;
        max-width: 100%;
    }

    .product-image-container {
        height: auto;
        max-height: 360px;
        min-height: 240px;
    }

    .product-image-section {
        width: 100% !important;
        max-width: 100% !important;
    }

    .size-picker-grid {
        grid-template-columns: repeat(3, 1fr) !important;
    }

    .product-detail-actions .btn {
        width: 100%;
    }

    .product-detail-qty .input-group {
        max-width: 100%;
    }

    .product-detail-qty .btn {
        min-width: 44px;
        min-height: 44px;
    }
}

/* ---------- 购物车 ---------- */
@media (max-width: 767.98px) {
    .cart-page .cart-item .row {
        row-gap: 0.75rem;
    }

    .cart-page .cart-item-img {
        max-height: 72px;
        object-fit: cover;
    }

    .cart-page .cart-item-actions {
        display: flex;
        flex-wrap: wrap;
        align-items: center;
        gap: 0.5rem;
        justify-content: space-between;
    }

    .cart-page .cart-summary-card {
        position: sticky;
        bottom: calc(8px + env(safe-area-inset-bottom, 0));
        z-index: 10;
    }

    .cart-page .cart-batch-actions .btn-group {
        display: grid;
        grid-template-columns: 1fr 1fr;
        gap: 0.5rem;
        width: 100%;
    }

    .cart-page .cart-batch-actions .btn-group .btn {
        border-radius: 0.375rem !important;
    }
}

/* ---------- 订单列表 ---------- */
@media (max-width: 767.98px) {
    .orders-page .order-card-header .row {
        row-gap: 0.75rem;
    }

    .orders-page .order-card-header .order-actions {
        display: flex;
        flex-wrap: wrap;
        gap: 0.5rem;
    }

    .orders-page .order-card-header .order-actions .btn {
        flex: 1 1 auto;
        min-width: calc(50% - 0.25rem);
    }

    .orders-page .copy-order-id-btn {
        min-width: 44px;
        min-height: 44px;
    }

    .orders-page .order-items-preview {
        display: flex;
        flex-wrap: wrap;
        gap: 0.5rem;
    }

    .orders-page .order-items-preview img {
        width: 56px;
        height: 56px;
        object-fit: cover;
        border-radius: 6px;
    }
}

/* ---------- 聊天页 ---------- */
@media (max-width: 767.98px) {
    .chat-page .chat-input-bar {
        padding-bottom: calc(0.75rem + env(safe-area-inset-bottom, 0));
    }
}

.products-section-header {
    max-width: 100%;
}

.product-sort-toolbar {
    display: flex;
    align-items: center;
    flex-shrink: 0;
    flex-wrap: wrap;
    gap: 0.5rem;
}

.product-sort-label {
    color: #8B4513;
    font-weight: 500;
    white-space: nowrap;
    margin-bottom: 0;
}

.product-sort-select {
    width: auto;
    min-width: 150px;
    border-color: #8B4513;
    color: #8B4513;
}

.product-sort-select:focus {
    border-color: #8B4513;
    box-shadow: 0 0 0 0.2rem rgba(139, 69, 19, 0.25);
}

.theme-hat .navbar {
    background: #1a1a1a !important;
}

.theme-hat .navbar-brand,
.theme-hat .navbar-brand i {
    color: #FFD700 !important;
}

.theme-clothes .product-sort-label {
    color: #d63031;
}

.theme-clothes .product-sort-select {
    border-color: #d63031;
    color: #d63031;
}

.theme-clothes .product-sort-select:focus {
    border-color: #d63031;
    box-shadow: 0 0 0 0.2rem rgba(214, 48, 49, 0.25);
}

.theme-electronics .product-sort-label {
    color: #2c3e50;
}

.theme-electronics .product-sort-select {
    border-color: #2c3e50;
    color: #2c3e50;
}

.theme-electronics .product-sort-select:focus {
    border-color: #2c3e50;
    box-shadow: 0 0 0 0.2rem rgba(44, 62, 80, 0.25);
}

@media (min-width: 768px) {
    .cart-page .cart-item-actions {
        display: flex;
        align-items: center;
        justify-content: space-between;
        gap: 0.75rem;
        flex-wrap: wrap;
    }

    .cart-page .cart-item-actions .input-group {
        flex: 0 0 140px;
    }
}

@media (max-width: 767.98px) {
    .static-info-page img {
        max-width: 100%;
        height: auto;
    }

    .chat-page .form-control {
        font-size: 16px;
    }

    .chat-page #file-preview #preview-content img,
    .chat-page #file-preview #preview-content video {
        max-width: 100%;
        max-height: 180px;
        object-fit: contain;
    }

    .theme-page .product-sort-toolbar {
        flex-direction: column;
        align-items: stretch;
        width: 100%;
    }

    .theme-page .product-sort-select {
        width: 100%;
        min-width: 0;
    }

    .profile-page .btn-group-vertical .btn {
        width: 100%;
    }
}

/* ---------- Toast / 浮动提示（前台统一） ---------- */
.toast-mobile-safe {
    position: fixed;
    top: 80px;
    right: 20px;
    z-index: 9999;
    min-width: 280px;
    max-width: 500px;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
}

.toast-container-fixed {
    position: fixed;
    top: 20px;
    right: 20px;
    z-index: 9999;
    min-width: 280px;
    max-width: 500px;
}

@media (max-width: 767.98px) {
    .toast-mobile-safe,
    .toast-container-fixed {
        left: 1rem !important;
        right: 1rem !important;
        min-width: 0 !important;
        max-width: calc(100vw - 2rem) !important;
        width: auto;
    }

    #toast-container .alert {
        max-width: 100%;
    }
}

/* ---------- 聊天页（独立 layout） ---------- */
.chat-page {
    height: 100vh;
    height: 100dvh;
}

.chat-page .chat-container {
    height: 100vh;
    height: 100dvh;
}

@media (max-width: 767.98px) {
    .chat-page .chat-header {
        padding: 12px 16px;
    }

    .chat-page .messages-container {
        padding: 12px;
    }

    .chat-page .input-area {
        padding: 12px;
    }

    .chat-page .message-bubble {
        max-width: 85%;
    }

    .chat-page .whatsapp-display {
        font-size: 0.75rem;
        padding: 4px 8px;
    }
}
