/* ============================================================
   移动端全局适配样式 — 彩票平台
   覆盖所有模板页面（admin/shop/register）
   ============================================================ */

/* ========== 基础重置 ========== */
html {
    -webkit-text-size-adjust: 100%;
    -webkit-tap-highlight-color: transparent;
    touch-action: manipulation;
}

/* 移动端全局防溢出 */
@media (max-width: 767.98px) {
    html, body {
        overflow-x: hidden;
        width: 100%;
        max-width: 100vw;
    }

    /* 所有 d-flex 容器允许换行 */
    .d-flex {
        flex-wrap: wrap;
    }

    /* 但导航栏内部保持不换行 */
    .navbar .d-flex,
    nav .d-flex {
        flex-wrap: nowrap;
    }
}

/* ========== 安全区适配 (iPhone X+ 刘海屏) ========== */
body {
    padding-bottom: env(safe-area-inset-bottom, 0px);
    padding-left: env(safe-area-inset-left, 0px);
    padding-right: env(safe-area-inset-right, 0px);
}

/* ========== 触摸友好 — 最小 44px 触摸目标 ========== */
@media (max-width: 767.98px) {
    .btn,
    .btn-sm,
    .nav-link,
    .pagination .page-link,
    .dropdown-item,
    .form-check-label {
        min-height: 44px;
        display: inline-flex;
        align-items: center;
    }

    .btn-sm {
        min-height: 36px;
        padding: 6px 14px;
        font-size: 0.85rem;
    }

    /* 表单元素放大 */
    .form-control,
    .form-select {
        min-height: 44px;
        font-size: 16px !important;  /* 防止 iOS 缩放 */
    }

    .form-control-sm,
    .form-select-sm {
        min-height: 38px;
        font-size: 14px !important;
    }

    .form-label {
        font-size: 0.9rem;
    }
}

/* ========== 模态框全屏化 ========== */
@media (max-width: 575.98px) {
    .modal-dialog {
        margin: 0;
        max-width: 100%;
        height: 100%;
    }

    .modal-content {
        border-radius: 0;
        min-height: 100vh;
    }

    .modal-header {
        border-radius: 0;
        padding: 14px 16px;
        position: sticky;
        top: 0;
        background: #fff;
        z-index: 10;
    }

    .modal-body {
        padding: 16px;
        overflow-y: auto;
    }

    .modal-footer {
        padding: 12px 16px;
        position: sticky;
        bottom: 0;
        background: #fff;
        z-index: 10;
        border-top: 1px solid #e2e8f0;
    }

    .modal-footer .btn {
        flex: 1;
        min-height: 48px;
        font-size: 1rem;
    }
}

/* ========== 表格移动端优化 ========== */
@media (max-width: 767.98px) {
    .table-responsive {
        -webkit-overflow-scrolling: touch;
    }

    .table-responsive::-webkit-scrollbar {
        height: 4px;
    }

    .table-responsive::-webkit-scrollbar-thumb {
        background: #cbd5e1;
        border-radius: 2px;
    }

    .table th,
    .table td {
        padding: 10px 12px;
        font-size: 0.82rem;
        white-space: nowrap;
    }

    .table .btn-sm {
        padding: 5px 10px;
        font-size: 0.78rem;
    }

    /* 操作列按钮垂直排列 */
    .action-btn-group {
        flex-direction: column;
    }

    .action-btn-group .btn {
        width: 100%;
    }
}

/* ========== 卡片间距优化 ========== */
@media (max-width: 767.98px) {
    .card {
        border-radius: 10px;
    }

    .card-header {
        padding: 12px 16px;
    }

    .card-body {
        padding: 14px;
    }

    .row.g-3 {
        --bs-gutter-x: 0.5rem;
        --bs-gutter-y: 0.5rem;
    }
}

/* ========== 统计卡片移动端 ========== */
@media (max-width: 575.98px) {
    .stat-card {
        padding: 12px 14px !important;
    }

    .stat-card .stat-value {
        font-size: 1.3rem;
    }

    .stat-card .stat-label {
        font-size: 0.72rem;
    }

    .stat-card .stat-icon {
        font-size: 1.8rem;
        right: 8px;
        opacity: 0.08;
    }
}

/* ========== 分页移动端适配 ========== */
@media (max-width: 575.98px) {
    .pagination {
        flex-wrap: wrap;
        justify-content: center;
        gap: 4px;
    }

    .pagination .page-link {
        padding: 6px 10px;
        font-size: 0.8rem;
        border-radius: 6px;
        min-width: 36px;
        text-align: center;
    }

    /* 隐藏省略号两端的页码 */
    .pagination .page-item:nth-child(1),
    .pagination .page-item:nth-last-child(1) {
        /* 保留首尾 */;
    }
}

/* ========== Toast 提示移动端 ========== */
@media (max-width: 575.98px) {
    .toast-msg {
        left: 10px;
        right: 10px;
        transform: none;
        border-radius: 10px;
        font-size: 0.85rem;
        padding: 12px 16px;
        text-align: center;
        justify-content: center;
    }

    .toast-msg.show {
        transform: translateY(0);
    }
}

/* ========== 页面标题 ========== */
@media (max-width: 575.98px) {
    .page-title {
        font-size: 1.1rem;
    }
}

/* ========== 筛选栏移动端 ========== */
@media (max-width: 575.98px) {
    .filter-bar {
        flex-direction: column;
    }

    .filter-bar .form-select,
    .filter-bar .form-control {
        flex: 1 1 100%;
        min-height: 42px;
    }
}

/* ========== 标题区域移动端 ========== */
@media (max-width: 575.98px) {
    h5, .h5 { font-size: 1.1rem; }
    h6, .h6 { font-size: 1rem; }

    .d-flex.justify-content-between.align-items-center.mb-4 {
        flex-direction: column;
        align-items: flex-start !important;
        gap: 6px;
    }
}

/* ========== 导航栏移动端 ========== */
@media (max-width: 767.98px) {
    .navbar {
        padding-left: 12px;
        padding-right: 12px;
    }

    .navbar-brand {
        font-size: 0.9rem;
    }

    .navbar .btn-sm {
        padding: 5px 10px;
        font-size: 0.78rem;
    }
}

/* ========== 内容区内边距 ========== */
@media (max-width: 767.98px) {
    main,
    .container-fluid {
        padding: 12px !important;
    }
}

/* ========== 金刚区/快捷入口移动端 ========== */
@media (max-width: 575.98px) {
    .quick-entry-item {
        padding: 12px 4px;
        border-radius: 10px;
    }

    .quick-entry-item .quick-icon {
        width: 40px;
        height: 40px;
        border-radius: 12px;
        font-size: 1rem;
    }

    .quick-entry-item .quick-text {
        font-size: 0.7rem;
    }
}

/* ========== 大屏设备容器宽度限制 ========== */
@media (min-width: 1400px) {
    .container-fluid {
        max-width: 1320px;
        margin: 0 auto;
    }
}

/* ========== 打印优化 ========== */
@media print {
    .sidebar,
    .navbar,
    .sidebar-overlay,
    .toast-msg,
    .btn,
    #pagination {
        display: none !important;
    }

    main {
        margin: 0 !important;
        padding: 0 !important;
    }
}
