/* ============================================================
   智享生活 - 响应式多端适配重设计
   手机端 / 平板端 / 电脑端 三套布局
   ============================================================ */

/* ========== 全局: 桌面端默认 (≥1025px) ========== */
/* 桌面端隐藏手机端专属元素 */
.bottom-nav { display: none !important; }
.mobile-sidebar-overlay { display: none !important; }
.mobile-sidebar { display: none !important; }

/* 手机端顶部栏在桌面端隐藏 */
.mobile-header-actions { display: none !important; }
.mobile-back-btn { display: none !important; }

/* ============================================================
   手机端 (≤768px) - 核心设计
   ============================================================ */
@media (max-width: 768px) {

    /* ---------- 全局 container 手机端全宽覆盖 ---------- */
    .container {
        max-width: 100% !important;
        width: 100% !important;
        margin: 0 !important;
        padding: 0 !important;
        box-sizing: border-box;
    }

    body {
        overflow-x: hidden;
        width: 100%;
        margin: 0;
        padding: 0;
        background: #fff;
    }

    html {
        overflow-x: hidden;
        margin: 0;
        padding: 0;
    }

    .main-content {
        padding: 0 !important;
        margin: 0 !important;
        width: 100% !important;
    }

    .center-section {
        margin: 0 !important;
        border-radius: 0 !important;
        border-left: none !important;
        border-right: none !important;
        box-shadow: none !important;
        overflow: visible;
    }

    /* ---------- 桌面端元素隐藏 ---------- */
    .main-nav { display: none !important; }
    .header-top .header-actions { display: none !important; }
    .price-ticker { display: none !important; }
    .promo-banner { display: none !important; }
    .float-report-btn { display: none !important; }
    .footer { display: none !important; }

    /* ---------- 手机端恢复侧边栏显示 ---------- */
    .mobile-sidebar-overlay { display: block !important; }
    .mobile-sidebar { display: block !important; }

    /* ---------- 手机端顶部栏 ---------- */
    .header {
        position: sticky;
        top: 0;
        z-index: 1000;
        background: #fff;
        box-shadow: 0 1px 4px rgba(0,0,0,0.08);
        width: 100% !important;
        margin: 0 !important;
        padding: 0 !important;
        overflow: hidden;
    }
    .header-top {
        padding: 8px 12px;
        border-bottom: none;
    }
    .header-top .container {
        display: flex;
        align-items: center;
        justify-content: space-between;
        padding: 0 16px !important;
        gap: 8px;
        width: 100% !important;
        max-width: 100% !important;
        margin: 0 !important;
        box-sizing: border-box;
    }

    /* 汉堡菜单按钮 - 左上角 */
    .hamburger {
        display: flex !important;
        flex-direction: column;
        gap: 5px;
        cursor: pointer;
        width: 44px;
        height: 44px;
        align-items: center;
        justify-content: center;
        padding: 10px;
        z-index: 1001;
        background: none;
        border: none;
    }
    .hamburger span {
        width: 20px;
        height: 2px;
        background: #333;
        border-radius: 2px;
        transition: all 0.3s;
    }
    .hamburger.active span:nth-child(1) {
        transform: rotate(45deg) translate(5px, 5px);
    }
    .hamburger.active span:nth-child(2) {
        opacity: 0;
    }
    .hamburger.active span:nth-child(3) {
        transform: rotate(-45deg) translate(5px, -5px);
    }

    /* Logo */
    .logo {
        display: flex;
        align-items: center;
        gap: 6px;
        font-size: 16px;
        font-weight: 700;
        color: var(--primary-color);
        white-space: nowrap;
    }
    .logo i { font-size: 20px; }
    #regionSelector {
        font-size: 12px;
        padding: 6px 10px;
        min-height: 36px;
        display: inline-flex;
        align-items: center;
    }

    /* 手机端右侧操作区 */
    .mobile-header-actions {
        display: flex !important;
        align-items: center;
        gap: 4px;
    }
    .mobile-header-actions .mobile-action-btn {
        width: 44px;
        height: 44px;
        display: flex;
        align-items: center;
        justify-content: center;
        border-radius: 50%;
        color: #333;
        font-size: 16px;
        background: none;
        border: none;
        cursor: pointer;
        transition: background 0.2s;
    }
    .mobile-header-actions .mobile-action-btn:active {
        background: #f0f0f0;
    }
    .mobile-header-actions .mobile-action-btn .badge-dot {
        position: absolute;
        top: 6px;
        right: 6px;
        width: 8px;
        height: 8px;
        background: #e63946;
        border-radius: 50%;
        border: 2px solid #fff;
    }

    /* 手机端返回按钮 */
    .mobile-back-btn {
        display: flex;
        align-items: center;
        justify-content: center;
        width: 40px;
        height: 40px;
        font-size: 18px;
        color: #333;
        text-decoration: none;
        flex-shrink: 0;
    }
    .mobile-back-btn:hover {
        background: #f5f5f5;
        border-radius: 50%;
    }

    /* 手机端搜索栏 */
    .mobile-search {
        display: block;
        padding: 0 12px 10px;
        background: #fff;
    }
    .mobile-search .search-wrapper {
        display: flex;
        align-items: center;
        gap: 0;
        background: #f5f5f5;
        border-radius: 20px;
        padding: 0 4px;
        border: 1px solid #eee;
    }
    .mobile-search .search-wrapper i {
        color: #666;
        font-size: 14px;
        padding: 0 8px 0 12px;
    }
    .mobile-search input {
        flex: 1;
        padding: 10px 0;
        border: none;
        background: transparent;
        font-size: 14px;
        outline: none;
    }
    .mobile-search .search-btn {
        padding: 10px 18px;
        min-height: 40px;
        background: var(--primary-color);
        color: #fff;
        border: none;
        border-radius: 16px;
        font-size: 13px;
        cursor: pointer;
    }

    /* ---------- 手机端栏目切换 Tab ---------- */
    .mobile-category-tabs {
        display: flex;
        background: #fff;
        padding: 0 12px;
        gap: 0;
        border-bottom: 1px solid #f0f0f0;
        overflow-x: auto;
        scrollbar-width: none;
        -ms-overflow-style: none;
    }
    .mobile-category-tabs::-webkit-scrollbar { display: none; }
    .mobile-category-tabs .cat-tab {
        padding: 12px 16px;
        font-size: 14px;
        font-weight: 500;
        color: #666;
        border-bottom: 2px solid transparent;
        cursor: pointer;
        white-space: nowrap;
        transition: all 0.2s;
        background: none;
        border-top: none;
        border-left: none;
        border-right: none;
        text-decoration: none;
    }
    .mobile-category-tabs .cat-tab.active {
        color: var(--primary-color);
        border-bottom-color: var(--primary-color);
        font-weight: 600;
    }
    .mobile-category-tabs .cat-more-btn {
        margin-left: auto;
        padding: 12px;
        font-size: 16px;
        color: #666;
        background: none;
        border: none;
        cursor: pointer;
        position: relative;
    }

    /* ---------- 手机端更多弹出框 ---------- */
    .mobile-more-popup {
        position: fixed;
        top: 0;
        right: 0;
        width: 80vw;
        height: 100vh;
        background: #fff;
        z-index: 2001;
        transform: translateX(100%);
        transition: transform 0.3s ease;
        overflow-y: auto;
        box-shadow: -4px 0 20px rgba(0,0,0,0.15);
    }
    .mobile-more-popup.active {
        transform: translateX(0);
    }
    .mobile-more-popup .popup-header {
        display: flex;
        align-items: center;
        justify-content: space-between;
        padding: 16px;
        border-bottom: 1px solid #f0f0f0;
        position: sticky;
        top: 0;
        background: #fff;
        z-index: 1;
    }
    .mobile-more-popup .popup-header h3 {
        font-size: 16px;
        font-weight: 600;
    }
    .mobile-more-popup .popup-close {
        width: 44px;
        height: 44px;
        display: flex;
        align-items: center;
        justify-content: center;
        border-radius: 50%;
        background: #f5f5f5;
        border: none;
        font-size: 16px;
        cursor: pointer;
    }
    .mobile-more-popup .popup-grid {
        display: grid;
        grid-template-columns: repeat(3, 1fr);
        gap: 12px;
        padding: 16px;
    }
    .mobile-more-popup .popup-item {
        display: flex;
        flex-direction: column;
        align-items: center;
        gap: 8px;
        padding: 14px 8px;
        background: #f8f9fa;
        border-radius: 10px;
        text-decoration: none;
        color: #333;
        transition: all 0.2s;
    }
    .mobile-more-popup .popup-item:active {
        background: #f0f0f0;
        transform: scale(0.96);
    }
    .mobile-more-popup .popup-item i {
        font-size: 22px;
        color: var(--primary-color);
    }
    .mobile-more-popup .popup-item span {
        font-size: 12px;
        text-align: center;
    }

    /* ---------- 左侧侧边栏（滑出） ---------- */
    .mobile-sidebar-overlay {
        position: fixed;
        top: 0;
        left: 0;
        width: 100vw;
        height: 100vh;
        background: rgba(0,0,0,0.5);
        z-index: 2000;
        opacity: 0;
        visibility: hidden;
        transition: all 0.3s;
    }
    .mobile-sidebar-overlay.active {
        opacity: 1;
        visibility: visible;
    }

    .mobile-sidebar {
        position: fixed;
        top: 0;
        left: 0;
        width: 80vw;
        max-width: 320px;
        height: 100vh;
        background: #fff;
        z-index: 2001;
        transform: translateX(-100%);
        transition: transform 0.3s ease;
        overflow-y: auto;
        overflow-x: hidden;
        -webkit-overflow-scrolling: touch;
        scrollbar-width: none;
        visibility: hidden;
    }
    .mobile-sidebar::-webkit-scrollbar {
        display: none;
    }
    .mobile-sidebar.active {
        transform: translateX(0);
        visibility: visible;
    }

    /* 侧边栏顶部个人信息 */
    .sidebar-profile {
        background: linear-gradient(135deg, #e63946, #f4a261);
        padding: 24px 16px 20px;
        color: #fff;
    }
    .sidebar-profile .profile-top {
        display: flex;
        align-items: center;
        gap: 12px;
        margin-bottom: 12px;
    }
    .sidebar-profile .profile-avatar {
        width: 56px;
        height: 56px;
        border-radius: 50%;
        background: rgba(255,255,255,0.25);
        display: flex;
        align-items: center;
        justify-content: center;
        font-size: 24px;
        font-weight: 700;
        border: 2px solid rgba(255,255,255,0.5);
        flex-shrink: 0;
    }
    .sidebar-profile .profile-info h4 {
        font-size: 16px;
        font-weight: 600;
        margin-bottom: 4px;
    }
    .sidebar-profile .profile-info .profile-role {
        font-size: 12px;
        background: rgba(255,255,255,0.25);
        padding: 2px 10px;
        border-radius: 10px;
        display: inline-flex;
        align-items: center;
        gap: 4px;
    }

    /* 侧边栏快捷工具栏 */
    .sidebar-tools {
        display: grid;
        grid-template-columns: repeat(4, 1fr);
        gap: 8px;
        padding: 16px;
        border-bottom: 1px solid #f0f0f0;
    }
    .sidebar-tool-item {
        display: flex;
        flex-direction: column;
        align-items: center;
        gap: 6px;
        padding: 8px 4px;
        text-decoration: none;
        color: #333;
        border-radius: 8px;
        transition: background 0.2s;
    }
    .sidebar-tool-item:active {
        background: #f5f5f5;
    }
    .sidebar-tool-item i {
        font-size: 20px;
        color: var(--primary-color);
    }
    .sidebar-tool-item span {
        font-size: 11px;
        text-align: center;
        line-height: 1.2;
    }

    /* 侧边栏菜价表格 */
    .sidebar-price-section {
        padding: 16px;
        border-bottom: 1px solid #f0f0f0;
    }
    .sidebar-price-section h5 {
        font-size: 14px;
        font-weight: 600;
        margin-bottom: 10px;
        display: flex;
        align-items: center;
        gap: 6px;
        color: #333;
    }
    .sidebar-price-section h5 i {
        color: var(--primary-color);
    }
    .sidebar-price-table {
        width: 100%;
        border-collapse: collapse;
    }
    .sidebar-price-table th,
    .sidebar-price-table td {
        padding: 8px 6px;
        text-align: left;
        font-size: 13px;
        border-bottom: 1px solid #f5f5f5;
    }
    .sidebar-price-table th {
        color: #666;
        font-weight: 500;
        font-size: 12px;
    }
    .sidebar-price-table .price-up { color: #e63946; }
    .sidebar-price-table .price-down { color: #2a9d8f; }
    .sidebar-price-table .price-flat { color: #666; }

    /* 侧边栏天气 */
    .sidebar-weather {
        padding: 16px;
        border-bottom: 1px solid #f0f0f0;
    }
    .sidebar-weather .weather-card {
        background: linear-gradient(135deg, #74b9ff, #0984e3);
        border-radius: 12px;
        padding: 14px;
        color: #fff;
        display: flex;
        align-items: center;
        justify-content: space-between;
    }
    .sidebar-weather .weather-left {
        display: flex;
        align-items: center;
        gap: 10px;
    }
    .sidebar-weather .weather-icon {
        font-size: 36px;
    }
    .sidebar-weather .weather-temp {
        font-size: 28px;
        font-weight: 700;
    }
    .sidebar-weather .weather-desc {
        font-size: 12px;
        opacity: 0.9;
    }
    .sidebar-weather .weather-location {
        font-size: 11px;
        opacity: 0.8;
        text-align: right;
    }

    /* 侧边栏功能展示 */
    .sidebar-features {
        padding: 16px;
    }
    .sidebar-features h5 {
        font-size: 14px;
        font-weight: 600;
        margin-bottom: 10px;
        display: flex;
        align-items: center;
        gap: 6px;
        color: #333;
    }
    .sidebar-features .feature-list {
        display: flex;
        flex-direction: column;
        gap: 10px;
    }
    .sidebar-features .feature-item {
        display: flex;
        align-items: center;
        gap: 10px;
        padding: 10px;
        background: #f8f9fa;
        border-radius: 8px;
    }
    .sidebar-features .feature-item i {
        font-size: 18px;
        color: var(--primary-color);
        width: 20px;
        text-align: center;
    }
    .sidebar-features .feature-item span {
        font-size: 13px;
        color: #333;
    }

    /* 侧边栏底部安全区 */
    .sidebar-bottom-space {
        height: 24px;
    }

    /* ---------- 手机端主内容区 ---------- */
    .main-content {
        padding: 0;
    }
    .main-content .container {
        display: flex !important;
        flex-direction: column;
        gap: 0;
        padding: 0 !important;
        max-width: 100% !important;
        width: 100% !important;
        margin: 0 !important;
        box-sizing: border-box;
    }
    .sidebar-left { display: none !important; }
    .sidebar-right { display: none !important; }
    .main-center { 
        width: 100% !important;
        max-width: 100% !important;
        box-sizing: border-box;
    }

    .center-section {
        background: #fff;
        margin: 0;
        padding: 14px;
        border-radius: 0;
        border-bottom: 8px solid #f5f5f5;
    }
    .section-header {
        padding-bottom: 8px;
        margin-bottom: 10px;
    }
    .section-header h2 { font-size: 15px; }

    /* 新闻资讯标签栏手机端适配 */
    .news-feed-section .section-header {
        flex-direction: column;
        align-items: flex-start;
        gap: 10px;
    }
    .news-feed-section .tabs {
        width: 100%;
        overflow-x: auto;
        flex-wrap: nowrap;
        gap: 6px;
        padding-bottom: 4px;
        scrollbar-width: none;
        -ms-overflow-style: none;
    }
    .news-feed-section .tabs::-webkit-scrollbar { display: none; }
    .news-feed-section .tabs .tab {
        padding: 8px 14px;
        min-height: 36px;
        font-size: 13px;
        white-space: nowrap;
        flex-shrink: 0;
    }
    .news-feed-section .more-link {
        margin-left: 0;
        width: 100%;
        text-align: right;
    }

    /* 百事圈内容流在主页 */
    .news-feed { gap: 0; }
    .news-feed-item {
        padding: 14px 0;
        border-bottom: 1px solid #f5f5f5;
        border-radius: 0;
        border-left: none !important;
    }
    .news-feed-item:last-child { border-bottom: none; }
    .news-feed-item .feed-icon {
        width: 40px; height: 40px; font-size: 18px;
    }

    /* ---------- 手机端底部导航栏 ---------- */
    .bottom-nav {
        display: flex !important;
        position: fixed;
        bottom: 0;
        left: 0;
        right: 0;
        background: #fff;
        border-top: 1px solid #eee;
        z-index: 1000;
        padding: 4px 0;
        padding-bottom: env(safe-area-inset-bottom, 4px);
    }
    .bottom-nav a {
        flex: 1;
        display: flex;
        flex-direction: column;
        align-items: center;
        gap: 2px;
        padding: 10px 0 6px;
        min-height: 48px;
        text-decoration: none;
        color: #666;
        font-size: 10px;
        transition: color 0.2s;
        position: relative;
    }
    .bottom-nav a.active,
    .bottom-nav a:hover {
        color: var(--primary-color);
    }
    .bottom-nav a i {
        font-size: 20px;
    }
    .bottom-nav a span {
        line-height: 1;
        font-size: 10px;
    }
    .bottom-nav a .nav-badge {
        position: absolute;
        top: 2px;
        right: calc(50% - 18px);
        min-width: 16px;
        height: 16px;
        background: #e63946;
        color: #fff;
        font-size: 10px;
        border-radius: 8px;
        display: flex;
        align-items: center;
        justify-content: center;
        padding: 0 4px;
    }

    /* 底部导航适配 - 安全区 */
    body {
        padding-bottom: 60px;
        overflow-x: hidden;
    }

    /* ---------- 手机端广告位调整 ---------- */
    .ad-banner-top { display: none !important; }
    .ad-card { margin-bottom: 0; }

    /* ---------- 手机端页面底部留白 ---------- */
    .main-center section:last-child {
        border-bottom: none;
    }

    .search-box {
        display: none !important;
    }

    /* 今日特惠网格手机端2列覆盖 */
    .promo-grid {
        grid-template-columns: repeat(2, 1fr) !important;
        gap: 10px;
    }

    /* 便民服务网格手机端2列 */
    .service-grid {
        grid-template-columns: repeat(2, 1fr);
        gap: 12px;
    }
}

/* ============================================================
   平板端 (769px - 1024px) - 双列布局
   ============================================================ */
@media (min-width: 769px) and (max-width: 1024px) {

    /* 隐藏手机端专属 */
    .mobile-sidebar-overlay { display: none !important; }
    .mobile-sidebar { display: none !important; }
    .mobile-search { display: none !important; }
    .mobile-category-tabs { display: none !important; }
    .mobile-more-popup { display: none !important; }
    .mobile-header-actions { display: none !important; }

    /* 底部导航保留 */
    .bottom-nav {
        display: flex !important;
        position: fixed;
        bottom: 0;
        left: 0;
        right: 0;
        background: #fff;
        border-top: 1px solid #eee;
        z-index: 1000;
        padding: 4px 0;
        padding-bottom: env(safe-area-inset-bottom, 4px);
    }
    .bottom-nav a {
        flex: 1;
        display: flex;
        flex-direction: column;
        align-items: center;
        gap: 2px;
        padding: 6px 0 4px;
        text-decoration: none;
        color: #666;
        font-size: 10px;
        transition: color 0.2s;
    }
    .bottom-nav a.active,
    .bottom-nav a:hover {
        color: var(--primary-color);
    }
    .bottom-nav a i { font-size: 20px; }
    .bottom-nav a span { line-height: 1; font-size: 10px; }
    .bottom-nav a .nav-badge {
        position: absolute;
        top: 2px;
        right: calc(50% - 18px);
        min-width: 16px;
        height: 16px;
        background: #e63946;
        color: #fff;
        font-size: 10px;
        border-radius: 8px;
        display: flex;
        align-items: center;
        justify-content: center;
        padding: 0 4px;
    }

    body { padding-bottom: 60px; }

    /* 平板顶部导航 */
    .header-top .container {
        display: flex;
        flex-wrap: wrap;
    }
    .search-box {
        order: 3;
        width: 100%;
        margin-top: 8px;
    }

    /* 平板双列布局 */
    .main-content .container {
        display: grid !important;
        grid-template-columns: 1fr 280px;
        gap: 16px;
        padding: 0 16px;
    }
    .sidebar-left { display: none !important; }
    .sidebar-right { display: block !important; }

    .sidebar-section {
        padding: 14px;
    }

    /* 平板端内容调整 */
    .center-section {
        margin-bottom: 16px;
    }
    .promo-grid {
        grid-template-columns: repeat(2, 1fr);
    }

    /* 浮动按钮 */
    .float-report-btn {
        bottom: 80px;
        right: 20px;
    }
    .floating-buttons {
        bottom: 80px;
        right: 15px;
    }
    .float-btn {
        width: 50px;
        height: 50px;
    }
    .float-btn i {
        font-size: 18px;
    }
}

/* ============================================================
   小屏手机 (≤480px) 补充适配
   ============================================================ */
@media (max-width: 480px) {
    .mobile-sidebar {
        width: 85vw;
    }
    .sidebar-profile {
        padding: 20px 12px 16px;
    }
    .sidebar-profile .profile-avatar {
        width: 48px;
        height: 48px;
        font-size: 20px;
    }
    .sidebar-tools {
        grid-template-columns: repeat(4, 1fr);
        gap: 6px;
        padding: 12px;
    }
    .sidebar-tool-item i { font-size: 18px; }
    .sidebar-tool-item span { font-size: 10px; }

    .mobile-more-popup {
        width: 85vw;
    }
    .mobile-more-popup .popup-grid {
        grid-template-columns: repeat(3, 1fr);
        gap: 8px;
        padding: 12px;
    }

    .bottom-nav a i { font-size: 18px; }
    .bottom-nav a span { font-size: 9px; }

    /* 小屏浮动按钮 */
    .floating-buttons {
        bottom: 70px;
        right: 10px;
    }
    .float-btn {
        width: 46px;
        height: 46px;
    }
    .float-btn i {
        font-size: 16px;
    }
    .float-btn span {
        font-size: 10px;
    }
}

/* ============================================================
   横屏模式适配
   ============================================================ */
@media (orientation: landscape) and (max-height: 500px) {
    .mobile-sidebar {
        width: 50vw;
    }
    .sidebar-profile {
        padding: 12px;
    }
    .sidebar-profile .profile-avatar {
        width: 40px;
        height: 40px;
        font-size: 18px;
    }
}

/* ============================================================
   桌面端 (≥1025px) 完整三栏
   ============================================================ */
@media (min-width: 1025px) {
    .main-content .container {
        display: grid !important;
        grid-template-columns: minmax(260px, 280px) 1fr minmax(280px, 320px);
        gap: 20px;
        max-width: 1400px;
    }
    .sidebar-left { display: block !important; }
    .sidebar-right { display: block !important; }
    .main-nav .nav-list { display: flex !important; }
    .bottom-nav { display: none !important; }
    .mobile-search { display: none !important; }
    .mobile-category-tabs { display: none !important; }
    .mobile-header-actions { display: none !important; }
    .mobile-more-popup { display: none !important; }

    body { padding-bottom: 0; }

    .main-center {
        min-width: 0;
    }
}
