/* ============================================
   AI智能公文系统 - 全平台响应式适配
   覆盖首页、用户中心、管理后台
   断点: 480 / 576 / 768 / 992 / 1024 / 1200 / 1400
   ============================================ */

/* ========== 基础触摸优化 ========== */
@media (hover: none) and (pointer: coarse) {
    * { -webkit-tap-highlight-color: transparent; }
    select, input, textarea, button, a { font-size: 16px !important; }
    .btn, button, a.nav-item { min-height: 44px; }
}

/* ========== 超小屏手机 < 480px ========== */
@media (max-width: 480px) {
    .hero-title { font-size: 1.6rem !important; }
    .hero-desc { font-size: 0.85rem !important; }
    .hero-buttons { flex-direction: column; gap: 10px; }
    .btn-hero { width: 100%; justify-content: center; }
    .hero-badge { font-size: 0.75rem; padding: 4px 12px; }
    .hero-visual { display: none !important; }
    .hero-content { max-width: 100% !important; }
    
    .section-title { font-size: 1.2rem !important; }
    .section-subtitle { font-size: 0.8rem !important; }
    .features-grid { grid-template-columns: 1fr !important; gap: 10px; }
    .scenarios-grid { grid-template-columns: 1fr !important; }
    .doctype-grid { grid-template-columns: repeat(3, 1fr) !important; gap: 8px; }
    .doctype-item { padding: 10px !important; }
    .doctype-item .doctype-icon { width: 36px; height: 36px; font-size: 16px; }
    .doctype-item .doctype-name { font-size: 0.7rem; }
    .resource-grid { grid-template-columns: 1fr !important; }
    .testimonials-grid { grid-template-columns: 1fr !important; }
    .advantage-grid { grid-template-columns: 1fr !important; }
    .footer-links { flex-direction: column; gap: 24px; }
    
    .member-header { display: none !important; }
    .mobile-top-header { display: flex !important; }
    .member-body { padding-top: 56px !important; }
}

/* ========== 小屏手机 480-576px ========== */
@media (min-width: 481px) and (max-width: 576px) {
    .hero-title { font-size: 1.8rem !important; }
    .hero-visual { display: none !important; }
    .hero-content { max-width: 100% !important; }
    .features-grid { grid-template-columns: 1fr 1fr !important; }
    .doctype-grid { grid-template-columns: repeat(4, 1fr) !important; }
    .resource-grid { grid-template-columns: 1fr !important; }
    .testimonials-grid { grid-template-columns: 1fr !important; }
    .advantage-grid { grid-template-columns: 1fr 1fr !important; }
    .scenarios-grid { grid-template-columns: 1fr 1fr !important; }
    .section-title { font-size: 1.3rem !important; }
    
    .member-header { display: none !important; }
    .mobile-top-header { display: flex !important; }
    .member-body { padding-top: 56px !important; }
}

/* ========== 大屏手机/小平板 577-767px ========== */
@media (max-width: 767px) {
    .hero-container > div { flex-direction: column !important; }
    .hero-visual { margin-top: 20px; }
    .hero-float-card { transform: none !important; }
    .hero-content { max-width: 100% !important; }
    .features-grid { grid-template-columns: repeat(2, 1fr); gap: 12px; }
    .doctype-grid { grid-template-columns: repeat(4, 1fr); gap: 8px; }
    .resource-grid { grid-template-columns: 1fr; }
    .testimonials-grid { grid-template-columns: 1fr; }
    .advantage-grid { grid-template-columns: repeat(2, 1fr); }
    .scenarios-grid { grid-template-columns: repeat(2, 1fr); }
    .section-title { font-size: 1.4rem; }
    .section-container { padding: 40px 16px !important; }
    
    .member-header { display: none !important; }
    .mobile-top-header { display: flex !important; }
    .member-body { padding-top: 56px !important; }
    
    .member-body .admin-content { padding: 12px; }
    .member-body .card { margin-bottom: 12px; }
    .member-body .card-header { padding: 12px 14px; flex-direction: column; gap: 8px; }
    .member-body .card-body { padding: 12px 14px; }
    
    .member-body table { font-size: 0.8rem; }
    .member-body th, .member-body td { padding: 8px 6px !important; }
    
    .member-body .form-group { margin-bottom: 12px; }
    .member-body input.form-control, .member-body select.form-control, .member-body textarea.form-control { font-size: 0.85rem; }
    
    .publish-grid { grid-template-columns: 1fr !important; }
    .platform-card { border-right: none !important; border-bottom: 1px solid #e5e7eb; }
    .modal-dialog { margin: 8px; max-width: calc(100% - 16px) !important; }
    .modal-content { border-radius: 12px; }
    .data-table-wrapper { overflow-x: auto; -webkit-overflow-scrolling: touch; }
    .data-table-wrapper table { min-width: 600px; }
    
    .header-nav { overflow-x: auto; -webkit-overflow-scrolling: touch; gap: 4px !important; }
    .header-nav .nav-item { white-space: nowrap; padding: 6px 10px !important; font-size: 0.8rem !important; }
    
    .member-body .header-actions { gap: 6px; }
    .member-body .btn { padding: 6px 12px; font-size: 0.8rem; }
    .member-body .header-inner { padding: 8px 16px !important; }
}

/* ========== iPad竖屏 768-991px ========== */
@media (min-width: 768px) and (max-width: 991px) {
    .hero-visual { display: none !important; }
    .hero-content { max-width: 100% !important; }
    .features-grid { grid-template-columns: repeat(3, 1fr); }
    .doctype-grid { grid-template-columns: repeat(5, 1fr); }
    .section-container { padding: 50px 24px !important; }
    
    .member-header .header-inner { padding: 10px 20px !important; }
    .member-body .header-nav { gap: 4px; }
    .member-body .nav-item { padding: 6px 10px !important; font-size: 0.85rem !important; }
    .member-body .admin-content { padding: 16px; }
    .member-body .card-header { padding: 14px 16px; }
    .member-body .card-body { padding: 14px 16px; }
    .member-body .stats-grid { grid-template-columns: repeat(2, 1fr); }
    .data-table-wrapper { overflow-x: auto; }
    
    .publish-grid { grid-template-columns: repeat(2, 1fr) !important; }
    .modal-dialog { max-width: 90% !important; }
}

/* ========== iPad横屏/小笔记本 992-1199px ========== */
@media (min-width: 992px) and (max-width: 1199px) {
    .features-grid { grid-template-columns: repeat(4, 1fr); }
    .section-container { padding: 60px 32px !important; }
    .member-body .admin-content { padding: 20px; }
    .publish-grid { grid-template-columns: repeat(2, 1fr) !important; }
}

/* ========== 首页Hero区域响应式修正 ========== */
.hero-container { max-width: 1200px; margin: 0 auto; padding: 0 20px; }
.hero-section { overflow: hidden; }
@media (max-width: 767px) {
    .hero-section { padding: 40px 0 !important; min-height: auto !important; }
}

/* ========== 侧边栏移动端切换 ========== */
.mobile-sidebar-toggle {
    display: none;
    position: fixed;
    top: 10px;
    left: 10px;
    z-index: 101;
    width: 40px;
    height: 40px;
    border: none;
    background: var(--primary, #2563eb);
    color: #fff;
    border-radius: 10px;
    cursor: pointer;
    align-items: center;
    justify-content: center;
    font-size: 18px;
    box-shadow: 0 4px 12px rgba(37,99,235,0.3);
    transition: all 0.3s;
}
.mobile-sidebar-toggle:hover { transform: scale(1.05); }
.mobile-sidebar-toggle:active { transform: scale(0.95); }

@media (max-width: 767px) {
    .mobile-sidebar-toggle { display: flex !important; }
}

/* 侧边栏展开状态 */
.sidebar-open .admin-sidebar {
    transform: translateX(0) !important;
}
.sidebar-overlay {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,0.5);
    z-index: 99;
}
.sidebar-open .sidebar-overlay {
    display: block;
}

/* ========== 用户中心移动端抽屉菜单 ========== */
.mobile-drawer {
    position: fixed;
    top: 0;
    right: -280px;
    width: 280px;
    height: 100vh;
    background: #fff;
    z-index: 1000;
    transition: right 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    box-shadow: -4px 0 20px rgba(0,0,0,0.1);
    overflow-y: auto;
}
.mobile-drawer.open { right: 0; }
.mobile-drawer-header {
    padding: 20px 16px;
    background: linear-gradient(135deg, var(--primary, #2563eb), var(--primary-dark, #1d4ed8));
    color: #fff;
}
.mobile-drawer-user { font-weight: 600; font-size: 1rem; }
.mobile-drawer-email { font-size: 0.8rem; opacity: 0.8; margin-top: 4px; }
.mobile-drawer-close {
    position: absolute;
    top: 16px;
    right: 16px;
    width: 32px;
    height: 32px;
    border: none;
    background: rgba(255,255,255,0.2);
    color: #fff;
    border-radius: 50%;
    cursor: pointer;
    font-size: 16px;
    display: flex;
    align-items: center;
    justify-content: center;
}
.mobile-drawer-nav { padding: 8px 0; }
.mobile-drawer-nav a {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 14px 20px;
    color: #374151;
    text-decoration: none;
    font-size: 0.9rem;
    transition: background 0.2s;
    border-left: 3px solid transparent;
}
.mobile-drawer-nav a:active { background: #f3f4f6; }
.mobile-drawer-nav a i { width: 20px; text-align: center; color: #9ca3af; font-size: 1rem; }

/* ========== 表格水平滚动 ========== */
@media (max-width: 991px) {
    .table-responsive-custom {
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
        margin: 0 -4px;
    }
    .table-responsive-custom table { min-width: 700px; }
}

/* ========== 管理后台统计卡片适配 ========== */
@media (max-width: 575px) {
    .stats-card { padding: 14px; }
    .stats-card .stats-number { font-size: 1.4rem; }
    .stats-card .stats-label { font-size: 0.75rem; }
}

/* ========== 管理后台表格适配 ========== */
@media (max-width: 767px) {
    .data-table thead { display: none; }
    .data-table tbody tr {
        display: block;
        padding: 12px;
        margin-bottom: 10px;
        background: #fff;
        border-radius: 10px;
        box-shadow: 0 1px 3px rgba(0,0,0,0.08);
    }
    .data-table tbody tr + tr { border-top: none; }
    .data-table tbody td {
        display: flex;
        justify-content: space-between;
        align-items: center;
        padding: 6px 0 !important;
        border: none;
        font-size: 0.8rem;
    }
    .data-table tbody td::before {
        content: attr(data-label);
        font-weight: 600;
        color: #6b7280;
        font-size: 0.75rem;
        min-width: 80px;
    }
}

/* ========== 管理后台表单卡片适配 ========== */
@media (max-width: 575px) {
    .card { border-radius: 10px; }
}

/* ========== 移动端Toast提示 ========== */
@media (max-width: 767px) {
    .toast-container { top: 12px; right: 12px; left: 12px; }
    .toast { width: 100%; max-width: 100%; }
}

/* ========== 移动端分页 ========== */
@media (max-width: 575px) {
    .pagination { flex-wrap: wrap; gap: 4px; }
    .pagination .page-item .page-link { padding: 6px 10px; font-size: 0.8rem; }
}

/* ========== 移动端Tab切换 ========== */
@media (max-width: 767px) {
    .nav-tabs { overflow-x: auto; flex-wrap: nowrap; -webkit-overflow-scrolling: touch; }
    .nav-tabs .nav-item { white-space: nowrap; }
    .nav-tabs .nav-link { padding: 8px 12px; font-size: 0.85rem; }
}

/* ========== 移动端富文本编辑器 ========== */
@media (max-width: 767px) {
    .tox-tinymce { min-height: 300px !important; }
    .tox-editor-container { overflow-x: auto; }
}

/* ========== 移动端文件上传区域 ========== */
@media (max-width: 767px) {
    .upload-area { padding: 20px 16px; }
    .upload-area .upload-icon { font-size: 2rem; }
}

/* ========== iPad Pro 12.9竖屏优化 ========== */
@media (width: 1024px) and (height: 1366px),
       (width: 1366px) and (height: 1024px) {
    .hero-content { max-width: 100% !important; }
    .hero-visual { transform: scale(0.85); }
    .admin-sidebar { width: 220px; }
    .admin-main { margin-left: 220px; }
}

/* ========== iPad Mini竖屏优化 ========== */
@media (width: 768px) and (height: 1024px),
       (width: 1024px) and (height: 768px) {
    .hero-content { max-width: 100% !important; }
    .hero-visual { transform: scale(0.75); }
    .admin-sidebar { width: 190px; }
    .admin-main { margin-left: 190px; }
}

/* ========== 横竖屏切换适配 ========== */
@media (orientation: landscape) and (max-height: 500px) {
    .hero-section { min-height: auto !important; padding: 20px 0 !important; }
    .hero-title { font-size: 1.4rem !important; }
    .hero-visual { display: none !important; }
    .member-header .header-inner { padding: 6px 16px !important; }
    .admin-topbar { height: 48px !important; }
}

/* ========== 大屏桌面端 1400px+ ========== */
@media (min-width: 1400px) {
    .hero-container { max-width: 1320px; }
    .section-container { max-width: 1320px; margin: 0 auto; }
    .features-grid { grid-template-columns: repeat(2, 1fr); }
    .doctype-grid { grid-template-columns: repeat(7, 1fr); }
}

/* ========== 禁用用户缩放（iPad Safari）========== */
input, textarea, select { font-size: 16px; }
@media screen and (-webkit-min-device-pixel-ratio: 2) {
    input, textarea, select { font-size: 16px !important; }
}