/* ===== 手机端统一适配 ===== */

/* ===== 侧边栏 ===== */
@media (max-width: 768px) {
    .sidebar-wrapper {
        transform: translateX(-100%);
        width: 280px !important;
        z-index: 200;
        box-shadow: none;
        transition: transform 0.25s cubic-bezier(0.4, 0, 0.2, 1);
    }

    .sidebar-wrapper[data-state="expanded"] {
        transform: translateX(0);
        box-shadow: 8px 0 32px rgba(0,0,0,0.3);
    }

    .sidebar-main {
        margin-left: 0 !important;
    }

    .sidebar-trigger {
        opacity: 1 !important;
        pointer-events: auto !important;
        top: 12px;
        left: 8px !important;
        width: 36px;
        height: 36px;
        background: var(--u-card, #fff);
        border: 1px solid var(--u-border, #e8e8e8);
        box-shadow: 0 2px 8px rgba(0,0,0,0.08);
        border-radius: 8px;
        z-index: 210;
    }

    .sidebar-trigger svg {
        width: 18px;
        height: 18px;
    }

    .sidebar-overlay {
        display: none;
        position: fixed;
        inset: 0;
        background: rgba(0,0,0,0.45);
        z-index: 190;
        -webkit-tap-highlight-color: transparent;
    }

    .sidebar-wrapper[data-state="expanded"] ~ .sidebar-overlay {
        display: block;
    }

    .sidebar-wrapper .sidebar-label,
    .sidebar-wrapper .sidebar-group-label,
    .sidebar-wrapper .sidebar-user-info,
    .sidebar-wrapper .sidebar-header-text,
    .sidebar-wrapper .sidebar-menu-text {
        opacity: 1 !important;
        width: auto !important;
        overflow: visible !important;
    }

    .sidebar-wrapper .sidebar-menu-btn {
        justify-content: flex-start !important;
        padding: 8px 10px !important;
    }

    .sidebar-wrapper .sidebar-tooltip {
        display: none !important;
    }

    .sidebar-collapse-btn {
        display: none !important;
    }
}

/* ===== 全局基础 ===== */
@media (max-width: 768px) {
    html {
        overflow-x: hidden;
    }

    body {
        overflow-x: hidden;
        -webkit-text-size-adjust: 100%;
    }

    .app-layout {
        min-height: 100vh;
        min-height: 100dvh;
    }

    /* 主内容区 - 强制覆盖内联样式 */
    .main-content,
    .user-theme .main-content,
    .admin-theme .main-content {
        padding: 14px !important;
        margin-left: 0 !important;
        width: 100% !important;
        max-width: 100vw;
        overflow-x: hidden;
    }

    /* 顶部栏 */
    .top-bar {
        flex-direction: column !important;
        align-items: flex-start !important;
        gap: 8px !important;
        margin-bottom: 14px !important;
        padding-top: 42px !important;
    }

    .top-bar h1 {
        font-size: 17px !important;
    }

    .top-bar-right {
        width: 100% !important;
    }
}

/* ===== 统计卡片 ===== */
@media (max-width: 768px) {
    .stats-grid,
    .admin-stats,
    .stats-grid[style*="grid-template-columns"],
    .admin-stats[style*="grid-template-columns"] {
        display: grid !important;
        grid-template-columns: repeat(2, 1fr) !important;
        gap: 8px !important;
    }

    .stat-card,
    .admin-stat-card {
        padding: 12px !important;
        display: flex !important;
        flex-direction: column !important;
    }

    .stat-card .stat-icon,
    .admin-stat-card .stat-icon {
        width: 30px !important;
        height: 30px !important;
        font-size: 13px !important;
        margin-bottom: 8px !important;
        border-radius: 6px !important;
    }

    .stat-card .stat-label,
    .admin-stat-card .stat-info h4 {
        font-size: 10px !important;
        margin-bottom: 2px !important;
    }

    .stat-card .stat-value,
    .admin-stat-card .stat-info .value {
        font-size: 17px !important;
        font-weight: 800 !important;
    }

    /* 后台统计卡特殊布局 */
    .admin-stat-card {
        flex-direction: row !important;
        align-items: center !important;
        gap: 10px !important;
    }

    .admin-stat-card .stat-icon {
        margin-bottom: 0 !important;
        flex-shrink: 0 !important;
    }

    .admin-stat-card .stat-info {
        min-width: 0 !important;
    }
}

@media (max-width: 480px) {
    .stats-grid,
    .admin-stats,
    .stats-grid[style*="grid-template-columns"],
    .admin-stats[style*="grid-template-columns"] {
        grid-template-columns: 1fr 1fr !important;
        gap: 6px !important;
    }

    .stat-card .stat-value,
    .admin-stat-card .stat-info .value {
        font-size: 15px !important;
    }

    /* 用户端统计卡 - 3个时改为横向滚动 */
    .user-theme .stats-grid[style*="repeat(3"] {
        display: flex !important;
        overflow-x: auto !important;
        -webkit-overflow-scrolling: touch;
        gap: 8px !important;
        scroll-snap-type: x mandatory;
    }

    .user-theme .stats-grid[style*="repeat(3"] > .stat-card {
        flex: 0 0 45% !important;
        scroll-snap-align: start;
    }
}

/* ===== 卡片 ===== */
@media (max-width: 768px) {
    .card {
        margin-bottom: 10px !important;
    }

    .card-header {
        padding: 12px 14px !important;
    }

    .card-header h3 {
        font-size: 13px !important;
    }

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

/* ===== 表格 ===== */
@media (max-width: 768px) {
    .table-container {
        overflow-x: auto !important;
        -webkit-overflow-scrolling: touch;
        margin: 0 -14px;
        padding: 0 14px;
    }

    table {
        min-width: 550px !important;
    }

    table th, table td {
        padding: 8px 10px !important;
        font-size: 11px !important;
        white-space: nowrap !important;
    }
}

/* ===== 按钮 ===== */
@media (max-width: 768px) {
    .btn {
        padding: 8px 14px !important;
        font-size: 12px !important;
    }

    .btn-sm {
        padding: 5px 10px !important;
        font-size: 11px !important;
    }

    .btn-lg {
        padding: 11px 18px !important;
        font-size: 13px !important;
    }

    .btn-block {
        width: 100% !important;
    }

    .form-actions {
        flex-direction: column !important;
        gap: 8px !important;
    }

    .form-actions .btn,
    .form-actions .btn-lg {
        width: 100% !important;
    }
}

/* ===== 表单 ===== */
@media (max-width: 768px) {
    .form-row {
        grid-template-columns: 1fr !important;
        gap: 10px !important;
    }

    .form-input,
    .form-group select,
    .form-group textarea {
        font-size: 14px !important;
        padding: 10px 12px !important;
    }

    .form-group {
        margin-bottom: 12px !important;
    }

    .form-group label {
        font-size: 11px !important;
        margin-bottom: 4px !important;
    }

    .form-hint {
        font-size: 10px !important;
    }

    .search-bar {
        flex-direction: column !important;
        gap: 8px !important;
    }

    .search-bar .form-input,
    .search-bar select,
    .search-bar .btn {
        width: 100% !important;
    }
}

/* ===== 标签页 ===== */
@media (max-width: 768px) {
    .tab-nav {
        overflow-x: auto !important;
        -webkit-overflow-scrolling: touch;
        gap: 0 !important;
        margin-bottom: 14px !important;
    }

    .tab-nav a, .tab-nav button {
        padding: 9px 12px !important;
        font-size: 12px !important;
        white-space: nowrap !important;
    }
}

/* ===== 两栏布局 ===== */
@media (max-width: 768px) {
    .two-col {
        grid-template-columns: 1fr !important;
        gap: 12px !important;
    }

    /* 首页顶部网格 */
    .dashboard-top-grid {
        grid-template-columns: 1fr !important;
        gap: 10px !important;
    }
}

/* ===== 用户信息卡 ===== */
@media (max-width: 768px) {
    .user-profile-card {
        margin-bottom: 10px !important;
    }

    .user-profile-header {
        padding: 16px !important;
    }

    .user-avatar {
        width: 48px !important;
        height: 48px !important;
        font-size: 20px !important;
    }

    .user-profile-body {
        padding: 14px !important;
    }

    .user-info-row {
        padding: 8px 0 !important;
        font-size: 12px !important;
    }

    .dashboard-user-card {
        padding: 14px !important;
    }

    .dashboard-user-card .avatar {
        width: 40px !important;
        height: 40px !important;
    }
}

/* ===== 快捷操作 ===== */
@media (max-width: 768px) {
    .quick-actions {
        grid-template-columns: 1fr 1fr !important;
        gap: 6px !important;
    }

    .quick-action-btn {
        padding: 10px !important;
        font-size: 11px !important;
        gap: 4px !important;
    }

    .quick-action-btn svg {
        width: 14px !important;
        height: 14px !important;
    }
}

@media (max-width: 480px) {
    .quick-actions {
        grid-template-columns: 1fr !important;
    }
}

/* ===== 教程卡片 ===== */
@media (max-width: 768px) {
    .guide-grid {
        grid-template-columns: 1fr !important;
        gap: 10px !important;
    }

    .guide-card-icon {
        height: 80px !important;
    }

    .guide-card-icon svg {
        width: 28px !important;
        height: 28px !important;
    }

    .guide-card-body {
        padding: 12px !important;
    }

    .guide-card-body h3 {
        font-size: 13px !important;
    }

    .guide-card-body p {
        font-size: 12px !important;
    }

    /* 购买页顶部教程 - 横滑 */
    .guide-top-cards {
        display: flex !important;
        overflow-x: auto !important;
        -webkit-overflow-scrolling: touch;
        scroll-snap-type: x mandatory;
        gap: 8px !important;
        padding-bottom: 4px;
        grid-template-columns: none !important;
    }

    .guide-top-cards > a {
        flex: 0 0 82% !important;
        scroll-snap-align: center;
    }
}

/* ===== 充值信息 ===== */
@media (max-width: 768px) {
    .recharge-info {
        grid-template-columns: 1fr !important;
        gap: 8px !important;
    }

    .recharge-info-item {
        padding: 12px !important;
    }

    .recharge-info-item .icon svg {
        width: 20px !important;
        height: 20px !important;
    }

    .recharge-info-item h4 {
        font-size: 12px !important;
    }

    .recharge-info-item p {
        font-size: 11px !important;
    }
}

/* ===== 提现余额卡 ===== */
@media (max-width: 768px) {
    .withdraw-balance-card {
        padding: 20px 14px !important;
        margin-bottom: 14px !important;
    }

    .withdraw-balance-card .balance-label {
        font-size: 11px !important;
    }

    .withdraw-balance-card .balance-value {
        font-size: 28px !important;
    }

    .withdraw-balance-card .balance-sub {
        font-size: 11px !important;
    }
}

/* ===== 截图 ===== */
@media (max-width: 768px) {
    .screenshot-grid,
    .order-screenshots {
        grid-template-columns: 1fr !important;
        gap: 8px !important;
    }

    .order-detail-grid {
        grid-template-columns: 1fr !important;
        gap: 12px !important;
    }

    .order-info-item {
        font-size: 12px !important;
        padding: 8px 0 !important;
    }
}

/* ===== 分页 ===== */
@media (max-width: 768px) {
    .pagination {
        gap: 4px !important;
        margin-top: 14px !important;
    }

    .pagination a, .pagination span {
        min-width: 28px !important;
        height: 28px !important;
        font-size: 11px !important;
        padding: 0 6px !important;
    }
}

/* ===== 公告 ===== */
@media (max-width: 768px) {
    .announcement-item {
        padding: 10px 12px !important;
        margin-bottom: 6px !important;
    }

    .announcement-item .ann-title {
        font-size: 12px !important;
    }

    .announcement-item .ann-content {
        font-size: 11px !important;
    }
}

/* ===== 弹窗 ===== */
@media (max-width: 768px) {
    #detailModal,
    #rejectModal,
    #adjustModal,
    #editModal {
        padding: 0 !important;
    }

    #detailModal > div,
    #rejectModal > div,
    #adjustModal > div,
    #editModal > div {
        width: 100% !important;
        max-width: 100% !important;
        max-height: 90vh !important;
        max-height: 90dvh !important;
        border-radius: 12px 12px 0 0 !important;
        padding: 16px !important;
        margin-top: auto !important;
    }

    #detailModal h3,
    #rejectModal h3,
    #adjustModal h3,
    #editModal h3 {
        font-size: 14px !important;
    }
}

/* ===== 文件上传 ===== */
@media (max-width: 768px) {
    .file-upload {
        padding: 16px !important;
    }

    .file-upload-label .upload-icon {
        font-size: 20px !important;
    }

    .file-upload-label span {
        font-size: 11px !important;
    }
}

/* ===== 徽章 ===== */
@media (max-width: 768px) {
    .badge {
        font-size: 10px !important;
        padding: 2px 6px !important;
    }
}

/* ===== 强制覆盖内联样式 ===== */
@media (max-width: 768px) {
    /* 首页顶部 */
    .dashboard-top-grid {
        display: flex !important;
        flex-direction: column !important;
    }

    /* 两栏布局 */
    .two-col {
        display: flex !important;
        flex-direction: column !important;
    }

    /* 充值页面 */
    .recharge-info {
        display: flex !important;
        flex-direction: column !important;
    }

    /* 订单详情两栏 */
    .order-detail-grid {
        display: flex !important;
        flex-direction: column !important;
    }

    /* 弹窗内的 grid */
    #detailModal [style*="grid-template-columns"] {
        display: flex !important;
        flex-direction: column !important;
        gap: 8px !important;
    }

    /* 后台统计 2列保持 */
    .admin-stats[style*="repeat(3"] {
        display: grid !important;
        grid-template-columns: repeat(2, 1fr) !important;
    }

    .admin-stats[style*="repeat(3"] > .admin-stat-card {
        flex-direction: row !important;
    }
}

/* ===== 滚动条 ===== */
* {
    scrollbar-width: thin;
    scrollbar-color: #d4d4d4 transparent;
}

*::-webkit-scrollbar {
    width: 4px;
    height: 4px;
}

*::-webkit-scrollbar-track {
    background: transparent;
}

*::-webkit-scrollbar-thumb {
    background: #d4d4d4;
    border-radius: 2px;
}

/* ===== 触摸优化 ===== */
@media (hover: none) and (pointer: coarse) {
    .btn-sm {
        min-height: 36px;
        min-width: 36px;
    }

    .sidebar-menu-btn {
        min-height: 44px;
    }

    .tab-nav a, .tab-nav button {
        min-height: 40px;
    }

    .pagination a, .pagination span {
        min-width: 32px;
        min-height: 32px;
    }
}

/* ===== 安全区域 ===== */
@supports (padding-bottom: env(safe-area-inset-bottom)) {
    .sidebar-wrapper {
        padding-bottom: env(safe-area-inset-bottom);
    }

    .main-content {
        padding-bottom: calc(14px + env(safe-area-inset-bottom)) !important;
    }
}
