/**
 * 响应式 - 通用响应式 + 超级管理后台移动端
 */

/* ========== 通用响应式 ========== */
@media (max-width: 768px) {
    .login-box {
        padding: var(--space-8) var(--space-6);
    }
    .login-options {
        grid-template-columns: 1fr;
    }
    /* Modal bottom-sheet 移动端适配 */
    .modal-overlay {
        padding: 0;
        align-items: flex-end;
    }
    .modal-dialog {
        padding: 20px 16px max(24px, env(safe-area-inset-bottom, 0px));
        max-width: 100%;
        width: 100%;
        border-radius: 16px 16px 0 0;
        animation: modalSlideUp 0.3s cubic-bezier(0.22, 1, 0.36, 1);
    }
    @keyframes modalSlideUp {
        from { transform: translateY(100%); opacity: 0; }
        to { transform: translateY(0); opacity: 1; }
    }
    .modal-actions {
        flex-direction: column-reverse;
        gap: 10px;
    }
    .modal-actions .btn-primary,
    .modal-actions .btn-secondary {
        width: 100%;
        min-height: 48px;
        text-align: center;
    }
    .btn-primary,
    .btn-secondary {
        min-height: 44px; /* 保证触控目标 ≥ 44px */
    }
    /* 全局触控热区 */
    a, button, .btn-icon, .filter-tab, .tag, .pagination button {
        min-height: 44px;
    }
    /* 历史表格移动端优化 */
    .history-table {
        min-width: 0 !important;
    }
    .history-table thead {
        display: none;
    }
    .history-table tbody tr {
        display: block;
        margin-bottom: 10px;
        border-radius: var(--radius-md);
    }
    .history-table tbody tr td {
        display: flex;
        justify-content: space-between;
        padding: 6px 0;
        border-bottom: 1px solid rgba(255,255,255,0.04);
        font-size: 13px;
    }
    .history-table tbody tr td::before {
        content: attr(data-label);
        font-weight: 600;
        color: var(--text-muted);
        flex-shrink: 0;
    }
    /* 安全区 */
    body {
        overscroll-behavior-y: contain;
    }
}

/* =================================================================
   超级管理后台 — 移动端独立优化（≤768px / ≤480px / 横屏短屏）
   仅 SuperPage（.super-layout 子树）受影响，PC 端零回归
   作用：将桌面端表格/搜索/筛选/分页/表单/弹窗适配为移动端布局
   ================================================================= */
@media (max-width: 768px) {
    /* 1) 顶部 mobile-bar 玻璃拟态强化 */
    .super-layout ~ .super-mobile-bar,
    .super-mobile-bar {
        padding: 10px 14px;
        background: linear-gradient(135deg,
            rgba(26, 26, 26, 0.92),
            rgba(19, 19, 19, 0.92));
        -webkit-backdrop-filter: blur(16px) saturate(1.4);
        backdrop-filter: blur(16px) saturate(1.4);
        box-shadow: 0 1px 0 rgba(255, 255, 255, 0.04),
                    0 4px 16px rgba(0, 0, 0, 0.4);
    }
    .super-mobile-bar .super-mobile-title {
        font-size: 15px;
        font-weight: 600;
        max-width: calc(100vw - 110px);
        white-space: nowrap;
        overflow: hidden;
        text-overflow: ellipsis;
        letter-spacing: 0.2px;
    }

    /* 2) Header 收紧 + 防挤压 */
    .super-layout .super-header {
        padding-bottom: 12px;
        margin-bottom: 14px;
        gap: 10px;
    }
    .super-layout .super-header h1 {
        font-size: 19px;
        line-height: 1.3;
    }
    .super-layout .super-header p {
        font-size: 12px;
        margin-top: 2px;
    }
    .super-layout .super-admin-badge {
        padding: 6px 12px;
        font-size: 12px;
    }

    /* 3) 搜索栏：纵向堆叠，全宽 */
    .super-layout .search-bar {
        flex-direction: column;
        gap: 8px;
        margin-bottom: 12px;
    }
    .super-layout .search-bar input,
    .super-layout .search-bar select {
        max-width: 100% !important;
        width: 100%;
        min-height: 44px;
        font-size: 16px; /* iOS 防自动缩放 */
        padding: 11px 14px;
    }
    .super-layout .search-bar > button,
    .super-layout .search-bar .btn {
        width: 100%;
        min-height: 44px;
        padding: 11px 14px;
        font-size: 14px;
    }

    /* 4) 筛选 tab 横向滚动，防换行高度爆炸 */
    .super-layout .filter-tabs-row,
    .super-layout .orders-filter {
        flex-wrap: nowrap;
        overflow-x: auto;
        overflow-y: hidden;
        -webkit-overflow-scrolling: touch;
        padding-bottom: 4px;
        scroll-snap-type: x mandatory;
        scrollbar-width: none;
        margin-left: -4px;
        margin-right: -4px;
        padding-left: 4px;
        padding-right: 4px;
    }
    .super-layout .filter-tabs-row::-webkit-scrollbar,
    .super-layout .orders-filter::-webkit-scrollbar {
        display: none;
    }
    .super-layout .filter-tab,
    .super-layout .orders-filter .filter-btn {
        flex-shrink: 0;
        scroll-snap-align: start;
        min-height: 36px;
        padding: 7px 14px;
    }
    .super-layout .filter-label {
        flex-shrink: 0;
        min-width: auto;
        margin-right: 4px;
    }

    /* 5) 数据表 → 卡片列表（核心改造） */
    .super-layout .table-container {
        background: transparent;
        border: none;
        border-radius: 0;
        overflow: visible;
        padding: 0;
    }
    .super-layout .data-table {
        min-width: 0 !important;
        width: 100%;
        display: block;
        border-collapse: separate;
    }
    .super-layout .data-table thead {
        display: none;
    }
    .super-layout .data-table tbody {
        display: block;
    }
    .super-layout .data-table tbody tr {
        display: block;
        background: linear-gradient(135deg, #1e1e1e 0%, #181818 100%);
        border: 1px solid #2a2a2a;
        border-radius: 12px;
        margin-bottom: 12px;
        padding: 12px 14px;
        box-shadow: 0 2px 10px rgba(0, 0, 0, 0.3);
        transition:
            transform 0.25s cubic-bezier(0.34, 1.56, 0.64, 1),
            border-color 0.2s ease,
            box-shadow 0.2s ease;
        position: relative;
        overflow: hidden;
    }
    .super-layout .data-table tbody tr::before {
        content: "";
        position: absolute;
        top: 0;
        left: 0;
        width: 3px;
        height: 100%;
        background: linear-gradient(180deg, #03dac6, rgba(3, 218, 198, 0.3));
        opacity: 0.7;
    }
    .super-layout .data-table tbody tr:hover {
        background: rgba(3, 218, 198, 0.04);
    }
    .super-layout .data-table tbody tr:active {
        transform: scale(0.99);
        border-color: rgba(3, 218, 198, 0.4);
        box-shadow: 0 4px 16px rgba(3, 218, 198, 0.12);
    }
    .super-layout .data-table tbody td {
        display: flex;
        justify-content: space-between;
        align-items: center;
        padding: 7px 0;
        border-bottom: 1px dashed rgba(255, 255, 255, 0.05);
        font-size: 13.5px;
        gap: 12px;
        text-align: right;
        word-break: break-word;
        min-height: 32px;
    }
    .super-layout .data-table tbody td:last-child {
        border-bottom: none;
        padding-top: 10px;
        padding-bottom: 2px;
    }
    /* 通过 data-label 显示左侧字段标签 */
    .super-layout .data-table tbody td[data-label]::before {
        content: attr(data-label);
        color: #808080;
        font-size: 12px;
        font-weight: 500;
        flex-shrink: 0;
        text-align: left;
        letter-spacing: 0.3px;
    }
    /* 操作列：按钮组横向排列，自动换行 */
    .super-layout .data-table tbody td.actions-cell {
        flex-wrap: wrap;
        justify-content: flex-end;
        gap: 6px;
    }
    .super-layout .data-table tbody td.actions-cell .btn,
    .super-layout .data-table tbody td.actions-cell .btn-sm,
    .super-layout .data-table tbody td.actions-cell button {
        min-height: 36px;
        padding: 7px 12px;
        font-size: 12.5px;
        flex: 0 1 auto;
    }

    /* 6) 分页极简化 */
    .super-layout .pagination {
        gap: 4px;
        flex-wrap: wrap;
        padding: 12px 4px;
        justify-content: center;
    }
    .super-layout .pagination button {
        min-width: 40px;
        height: 40px;
        font-size: 13px;
        padding: 0 10px;
    }

    /* 7) 表单：紧凑 + 大触控 */
    .super-layout .settings-form {
        max-width: 100%;
        padding: 16px 14px;
        border-radius: 12px;
    }
    .super-layout .settings-section {
        margin-bottom: 18px;
        padding-bottom: 14px;
    }
    .super-layout .settings-section h3 {
        font-size: 15px;
        margin-bottom: 12px;
    }
    .super-layout .form-group {
        margin-bottom: 14px;
    }
    .super-layout .form-group input,
    .super-layout .form-group select,
    .super-layout .form-group textarea {
        font-size: 16px;       /* iOS 防自动缩放 */
        min-height: 44px;
        padding: 11px 14px;
    }
    .super-layout .btn-save {
        width: 100%;
        padding: 14px;
        font-size: 16px;
    }

    /* 8) Stats / Dashboard mini cards 收紧 */
    .super-layout .stat-card {
        padding: 12px 14px;
    }
    .super-layout .stat-card .value {
        font-size: 22px;
    }
    .super-layout .dashboard-mini-card {
        padding: 10px 12px;
    }
    .super-layout .dashboard-mini-card .mini-icon {
        width: 32px;
        height: 32px;
        font-size: 14px;
    }
    .super-layout .dashboard-mini-card .mini-value {
        font-size: 18px;
    }
    .super-layout .chart-card {
        padding: 14px;
    }
    .super-layout .chart-card h3 {
        font-size: 13px;
    }

    /* 9) 通用按钮组：水平自适应 */
    .super-layout .super-actions-row {
        display: flex;
        flex-wrap: wrap;
        gap: 8px;
    }
    .super-layout .super-actions-row > * {
        flex: 1 1 auto;
        min-width: 0;
    }
}

/* 超小屏 ≤480px：进一步紧凑 */
@media (max-width: 480px) {
    .super-mobile-bar .super-mobile-title {
        font-size: 14px;
        max-width: calc(100vw - 100px);
    }
    .super-layout .super-header h1 {
        font-size: 17px;
    }
    .super-layout .data-table tbody tr {
        padding: 10px 12px;
        margin-bottom: 10px;
    }
    .super-layout .data-table tbody td {
        font-size: 13px;
    }
    .super-layout .data-table tbody td[data-label]::before {
        font-size: 11.5px;
    }
    .super-layout .filter-label {
        font-size: 12px;
    }
    .super-layout .stat-card {
        padding: 10px 12px;
    }
    .super-layout .stat-card .value {
        font-size: 20px;
    }
}

/* 横屏短屏（如 iPhone 横向）：抽屉高度修正 */
@media (max-width: 900px) and (max-height: 520px) {
    .super-sidebar {
        padding: 10px 0 16px;
    }
    .super-logo {
        padding: 4px 18px 12px;
        font-size: 15px;
    }
    .menu-group-header {
        padding: 7px 14px;
    }
    .menu-group-body .super-menu-item {
        padding: 6px 14px 6px 36px;
    }
}
