/**
 * 华医通荟 - 全站手机端响应式补丁
 * 只改样式，不改业务逻辑
 * 断点：768px（手机）、900px（平板/小屏笔记本）
 *
 * 覆盖范围：
 *  - 全站容器/网格布局 → 单列
 *  - 导航栏汉堡菜单展开抽屉
 *  - 登录/注册页 → 取消左右分栏
 *  - 个人中心 → hero-card/points-card 竖排
 *  - 商城 → product-grid 单列
 *  - 打卡页 → 平台选卡 3列→2列→1列
 *  - 健康观察 → hero/steps/features 竖排
 *  - 弹窗 → 宽度修正
 *  - 表格 → 横向滚动容器包裹
 *  - 按钮/输入框 → 自适应宽度
 *  - 图片 → max-width:100%
 */

/* ==========================================
   全局基础：防止横向溢出
   ========================================== */
html, body {
    overflow-x: hidden;
    width: 100%;
}

img {
    max-width: 100%;
    height: auto;
}

/* ==========================================
   平板断点 ≤ 900px
   ========================================== */
@media (max-width: 900px) {
    /* 导航间距缩小 */
    .nav,
    #ycq-nav {
        padding: 0 20px !important;
    }

    /* 导航链接字号缩小 */
    .nav-links a,
    #ycq-nav .nav-links a {
        font-size: 13px;
    }

    /* 导航链接间距缩小 */
    .nav-links,
    #ycq-nav .nav-links {
        gap: 14px;
    }
}

/* ==========================================
   手机断点 ≤ 768px
   ========================================== */
@media (max-width: 768px) {

    /* ------ 通用容器 ------ */
    .container {
        padding: 0 16px;
    }

    /* ------ 导航栏：汉堡菜单模式 ------ */
    .nav,
    #ycq-nav {
        padding: 0 16px !important;
        height: 56px;
    }

    /* 导航 Logo 字号 */
    .nav-logo,
    #ycq-nav .nav-logo {
        font-size: 17px;
    }

    /* PC 导航链接隐藏 */
    .nav-links,
    #ycq-nav .nav-links {
        display: none !important;
    }

    /* 汉堡菜单按钮（由 nav.html 注入） */
    #ycq-hamburger {
        display: flex;
        flex-direction: column;
        justify-content: space-around;
        width: 32px;
        height: 32px;
        cursor: pointer;
        padding: 4px;
        border: none;
        background: none;
        margin-right: 8px;
        order: -1;         /* 放到 nav-right 最左侧 */
        flex-shrink: 0;
    }

    #ycq-hamburger span {
        display: block;
        width: 22px;
        height: 2px;
        background: rgba(255, 255, 255, 0.85);
        border-radius: 2px;
        transition: all 0.25s;
    }

    /* 汉堡菜单展开时变 X */
    #ycq-hamburger.open span:nth-child(1) {
        transform: translateY(7px) rotate(45deg);
    }

    #ycq-hamburger.open span:nth-child(2) {
        opacity: 0;
    }

    #ycq-hamburger.open span:nth-child(3) {
        transform: translateY(-7px) rotate(-45deg);
    }

    /* 移动端抽屉导航 */
    #ycq-mobile-drawer {
        display: none;
        position: fixed;
        top: 56px;
        left: 0;
        right: 0;
        background: rgba(10, 22, 40, 0.97);
        border-bottom: 1px solid rgba(255, 255, 255, 0.1);
        backdrop-filter: blur(16px);
        -webkit-backdrop-filter: blur(16px);
        z-index: 99;
        padding: 8px 0 16px;
        max-height: calc(100vh - 56px);
        overflow-y: auto;
    }

    #ycq-mobile-drawer.open {
        display: block;
    }

    #ycq-mobile-drawer a {
        display: block;
        padding: 14px 24px;
        color: rgba(255, 255, 255, 0.75);
        font-size: 15px;
        text-decoration: none;
        border-bottom: 1px solid rgba(255, 255, 255, 0.05);
        transition: background 0.15s, color 0.15s;
    }

    #ycq-mobile-drawer a:last-child {
        border-bottom: none;
    }

    #ycq-mobile-drawer a:active,
    #ycq-mobile-drawer a:hover {
        background: rgba(212, 168, 83, 0.1);
        color: #D4A853;
    }

    #ycq-mobile-drawer a.active,
    #ycq-mobile-drawer a.nav-active {
        color: #D4A853;
        font-weight: 600;
    }

    /* nav-right：登录按钮/头像区域缩紧 */
    .nav-right,
    #ycq-nav .nav-right {
        gap: 8px;
    }

    .user-name-mini,
    #ycq-nav .user-name-mini {
        display: none; /* 手机上隐藏名字，节省空间 */
    }

    .btn-uc,
    #ycq-nav .btn-uc {
        padding: 4px 8px;
        font-size: 11px;
    }

    .btn-logout-mini,
    #ycq-nav .btn-logout-mini {
        padding: 4px 8px;
        font-size: 11px;
    }

    /* 页面顶部留出缩小后的导航高度 */
    .page-container {
        padding-top: 64px;
    }

    .main-content {
        min-height: calc(100vh - 56px);
        padding-top: 56px;
    }

    /* ------ 通用主内容区 ------ */
    .main {
        padding: 72px 16px 40px !important;
    }

    .page {
        padding: 68px 16px 48px !important;
    }

    /* ------ 页面标题 ------ */
    .page-title {
        font-size: 22px !important;
    }

    .page-subtitle {
        font-size: 13px !important;
    }

    /* ------ 通用网格：多列 → 单列 ------ */
    [class*="grid"] {
        grid-template-columns: 1fr !important;
    }

    /* 保留 auto-fit，但保证最小宽度用完整行 */
    .product-grid,
    .services,
    .features-grid,
    .quick-actions,
    .stats-row {
        grid-template-columns: 1fr !important;
        gap: 16px !important;
    }

    /* ------ 首页 Hero ------ */
    .hero {
        padding: 100px 16px 60px !important;
        min-height: auto;
    }

    .hero h1 {
        font-size: 32px !important;
        line-height: 1.3;
    }

    .hero-sub {
        font-size: 14px !important;
    }

    .hero-btns {
        flex-direction: column;
        gap: 12px;
        align-items: center;
    }

    .hero-btns .btn-primary,
    .hero-btns .btn-secondary {
        width: 100%;
        max-width: 300px;
    }

    .stats {
        gap: 20px !important;
        margin-top: 36px !important;
    }

    .stat-num {
        font-size: 28px !important;
    }

    /* ------ 服务卡片 ------ */
    .services {
        grid-template-columns: 1fr !important;
    }

    .service-card {
        padding: 24px !important;
    }

    /* ------ 登录/注册页 ------ */
    .login-wrapper {
        flex-direction: column !important;
        gap: 24px !important;
        padding: 0 16px;
        width: 100% !important;
        max-width: 100% !important;
    }

    .login-left {
        text-align: center;
    }

    .login-left h1 {
        font-size: 28px !important;
    }

    .login-box {
        width: 100% !important;
        padding: 28px 20px !important;
    }

    /* 注册页多步骤 */
    .register-box {
        width: 100% !important;
        padding: 28px 20px !important;
    }

    /* ------ 个人中心 hero-card ------ */
    .hero-card {
        flex-direction: column !important;
        align-items: flex-start !important;
        padding: 20px !important;
        gap: 16px !important;
    }

    .hero-stats {
        gap: 16px !important;
    }

    .hero-stat-num {
        font-size: 22px !important;
    }

    .hero-edit {
        margin-left: 0 !important;
    }

    /* ------ 积分卡 ------ */
    .points-card {
        flex-direction: column !important;
        gap: 16px !important;
        padding: 20px !important;
    }

    .points-num {
        font-size: 36px !important;
    }

    /* ------ 快捷操作 ------ */
    .quick-actions {
        grid-template-columns: 1fr 1fr !important;
    }

    /* ------ 商城页 ------ */
    .card-img-area {
        height: 160px !important;
    }

    .product-name {
        font-size: 16px !important;
    }

    .product-price {
        font-size: 24px !important;
    }

    .section-title {
        font-size: 18px !important;
    }

    /* ------ 打卡页 platform 卡片网格 ------ */
    .row-big {
        grid-template-columns: repeat(2, 1fr) !important;
        gap: 12px !important;
    }

    .row-small {
        grid-template-columns: repeat(2, 1fr) !important;
        gap: 10px !important;
    }

    .card-big {
        padding: 20px 14px !important;
    }

    .card-big .platform-icon {
        font-size: 32px !important;
        margin-bottom: 8px !important;
    }

    .card-big .platform-name {
        font-size: 14px !important;
    }

    .card-small {
        padding: 14px 8px !important;
    }

    .card-small .platform-icon {
        font-size: 24px !important;
    }

    .card-small .platform-name {
        font-size: 12px !important;
    }

    /* ------ 打卡记录 ------ */
    .record-item {
        flex-direction: column !important;
        align-items: flex-start !important;
        gap: 10px !important;
        padding: 14px 16px !important;
    }

    .record-left {
        width: 100%;
    }

    .record-status,
    .record-reward {
        align-self: flex-end;
    }

    /* ------ 健康观察员页 ------ */
    .hero-banner {
        padding: 28px 20px !important;
    }

    .hero-title {
        font-size: 22px !important;
    }

    .hero-desc {
        font-size: 13px !important;
    }

    .steps {
        flex-direction: column !important;
        align-items: flex-start !important;
        gap: 8px !important;
        padding: 0 16px;
    }

    .step-arrow {
        transform: rotate(90deg);
    }

    .cta-section {
        padding: 24px 16px !important;
    }

    /* ------ 区域服务页 ------ */
    .stats-row {
        grid-template-columns: repeat(3, 1fr) !important;
        gap: 10px !important;
    }

    .stat-box .num {
        font-size: 22px !important;
    }

    .region-selector {
        flex-direction: column !important;
        padding: 16px !important;
        gap: 10px !important;
    }

    .region-selector select {
        width: 100% !important;
        min-width: auto !important;
    }

    /* ------ 体验金账户页 ------ */
    .account-card {
        padding: 24px 20px !important;
    }

    .account-balance {
        font-size: 36px !important;
    }

    .account-stats {
        gap: 16px !important;
    }

    .action-btns {
        flex-direction: column !important;
        gap: 12px !important;
    }

    .action-btns button,
    .action-btns a {
        width: 100% !important;
        text-align: center;
    }

    /* ------ 通用数据表格：横向滚动 ------ */
    .data-table {
        display: block;
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
        white-space: nowrap;
    }

    /* ------ 通用卡片 ------ */
    .card {
        padding: 16px !important;
    }

    /* ------ 弹窗/模态框 ------ */
    .modal-box {
        width: calc(100vw - 32px) !important;
        max-width: calc(100vw - 32px) !important;
        padding: 24px 16px !important;
        max-height: 85vh;
        overflow-y: auto;
    }

    .form-modal,
    .form-overlay .form-modal {
        width: calc(100vw - 24px) !important;
        max-width: calc(100vw - 24px) !important;
        padding: 24px 16px !important;
        max-height: 88vh;
        overflow-y: auto;
    }

    /* ------ 上传区域 ------ */
    .upload-area {
        padding: 24px !important;
    }

    /* ------ 通用按钮全宽 ------ */
    .btn-submit {
        width: 100% !important;
        padding: 13px !important;
    }

    /* 验证码行不强制全宽 */
    .code-group {
        display: flex;
        gap: 8px;
    }

    .code-group input {
        flex: 1;
        min-width: 0;
    }

    .btn-code {
        min-width: 90px !important;
        padding: 12px 10px !important;
        font-size: 12px !important;
    }

    /* ------ 悬浮 AI 按钮 ------ */
    .float-ai-btn,
    .ycq-kefu-float-btn {
        right: 16px !important;
        bottom: 20px !important;
        width: 50px !important;
        height: 50px !important;
    }

    .float-ai-btn {
        font-size: 24px !important;
    }

    /* ------ 区域搜索结果表 ------ */
    .agent-table-wrap {
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
    }

    /* ------ uc_index 状态横幅 ------ */
    .status-banner {
        flex-wrap: wrap !important;
        gap: 10px !important;
        padding: 12px 16px !important;
    }

    .banner-btn {
        width: 100%;
        text-align: center;
    }

    /* ------ 知识库/素材库 内容列表 ------ */
    .content-grid,
    .media-grid {
        grid-template-columns: 1fr !important;
    }

    /* ------ 底部版权 ------ */
    .footer {
        padding: 16px;
        font-size: 11px !important;
        line-height: 2 !important;
    }

    /* ------ 注册页 ------ */
    .register-container {
        padding: 72px 16px 40px !important;
    }

    /* ------ ai-chat 页面 ------ */
    .chat-container {
        padding: 64px 0 0 !important;
    }

    /* ------ local_panel / pay-test ------ */
    .panel-grid,
    .pay-grid {
        grid-template-columns: 1fr !important;
    }

    /* ------ 二维码支付区域 ------ */
    #qrcode-wrap,
    #qr-container {
        width: 100% !important;
        max-width: 280px;
        margin: 0 auto;
    }

    /* ------ Tag 标签自动换行 ------ */
    .tag-row {
        flex-wrap: wrap;
    }

    /* ------ 通用 flex 行在小屏堆叠 ------ */
    .info-row,
    .price-row {
        flex-wrap: wrap;
    }
}

/* ==========================================
   超小屏 ≤ 390px（iPhone SE / 老机型）
   ========================================== */
@media (max-width: 390px) {
    .hero h1 {
        font-size: 26px !important;
    }

    .row-big {
        grid-template-columns: 1fr !important;
    }

    .row-small {
        grid-template-columns: repeat(2, 1fr) !important;
    }

    .quick-actions {
        grid-template-columns: 1fr !important;
    }

    .stats-row {
        grid-template-columns: 1fr !important;
    }

    .account-stats {
        flex-direction: column !important;
        gap: 10px !important;
    }

    .login-box {
        padding: 20px 14px !important;
    }
}
