/* =====================================================
   移动端 APP 风格全局样式 - mobile.css
   适用于所有操作页面，在手机端提供类似原生APP的体验
   ===================================================== */

/* 仅在移动设备（宽度 ≤ 768px）下生效 */
@media (max-width: 768px) {
    /* ========== 全局重置 & 基础 ========== */
    * {
        -webkit-tap-highlight-color: transparent;
        -webkit-touch-callout: none;
    }

    body {
        padding: 0 !important;
        background: #f5f7fa !important;
        font-size: 16px;
        line-height: 1.5;
        overflow-x: hidden;
        padding-bottom: 80px !important; /* 为底部导航留空间 */
    }

    /* 隐藏桌面端装饰元素 */
    body::before {
        display: none !important;
    }

    /* ========== 顶部导航栏 ========== */
    .app-header {
        position: fixed;
        top: 0;
        left: 0;
        right: 0;
        z-index: 999;
        background: linear-gradient(135deg, #0066cc, #0099ff) !important;
        padding: 12px 16px !important;
        padding-top: calc(12px + env(safe-area-inset-top, 0px)) !important;
        display: flex;
        align-items: center;
        justify-content: space-between;
        box-shadow: 0 2px 12px rgba(0, 102, 204, 0.3);
        min-height: 56px;
        border-radius: 0 !important;
        border: none !important;
        backdrop-filter: none !important;
    }

    .app-header h1,
    .app-header .title-section h1 {
        font-size: 1.1rem !important;
        color: #fff !important;
        background: none !important;
        -webkit-background-clip: unset !important;
        background-clip: unset !important;
        margin: 0;
        display: flex;
        align-items: center;
        gap: 8px;
    }

    .app-header h1 i,
    .app-header .title-section h1 i {
        color: #fff !important;
    }

    .app-header .title-section p {
        display: none;
    }

    .app-header .user-info,
    .app-header > div:last-child {
        display: flex;
        align-items: center;
        gap: 8px;
    }

    .app-header .user-info span,
    .app-header > div:last-child > span {
        color: rgba(255,255,255,0.9) !important;
        font-size: 0.85rem;
    }

    .app-header a,
    .app-header .btn-outline {
        color: #fff !important;
        background: rgba(255,255,255,0.2) !important;
        border: 1px solid rgba(255,255,255,0.3) !important;
        padding: 6px 14px !important;
        font-size: 0.8rem !important;
        border-radius: 20px !important;
        text-decoration: none !important;
        white-space: nowrap;
    }

    .app-header a:hover,
    .app-header .btn-outline:hover {
        background: rgba(255,255,255,0.3) !important;
    }

    /* 返回按钮 */
    .back-link {
        color: #fff !important;
        background: rgba(255,255,255,0.2) !important;
        border: 1px solid rgba(255,255,255,0.3) !important;
        padding: 6px 14px !important;
        font-size: 0.8rem !important;
        border-radius: 20px !important;
        text-decoration: none !important;
        display: inline-flex !important;
        align-items: center;
        gap: 4px;
        margin: 0 !important;
    }

    /* ========== 内容区域 ========== */
    .container,
    .dashboard-container {
        max-width: 100% !important;
        padding: 0 !important;
        margin: 0 !important;
        background: transparent !important;
        box-shadow: none !important;
        border-radius: 0 !important;
    }

    /* 给所有页面内容加顶部内边距避开 fixed header */
    .container,
    .dashboard-container {
        padding-top: 70px !important;
    }

    /* ========== 大按钮样式（APP风格） ========== */
    .btn,
    button,
    input[type="submit"],
    .page-btn,
    .reset-filter-btn {
        min-height: 48px !important;
        padding: 12px 24px !important;
        font-size: 1rem !important;
        border-radius: 12px !important;
        border: none !important;
        display: inline-flex !important;
        align-items: center;
        justify-content: center;
        gap: 8px;
        font-weight: 600;
        cursor: pointer;
        transition: all 0.2s;
        width: auto;
        line-height: 1.2;
        touch-action: manipulation;
    }

    .btn:active,
    button:active {
        transform: scale(0.97);
        opacity: 0.9;
    }

    .btn-primary,
    .btn {
        background: linear-gradient(135deg, #0066cc, #0099ff) !important;
        color: #fff !important;
        box-shadow: 0 4px 12px rgba(0, 102, 204, 0.3);
    }

    .btn-outline {
        background: transparent !important;
        border: 2px solid #0066cc !important;
        color: #0066cc !important;
        box-shadow: none !important;
    }

    .btn-danger {
        background: linear-gradient(135deg, #dc2626, #ef4444) !important;
        color: #fff !important;
        box-shadow: 0 4px 12px rgba(220, 38, 38, 0.3) !important;
    }

    .btn-small,
    .btn-sm {
        min-height: 40px !important;
        padding: 8px 16px !important;
        font-size: 0.9rem !important;
    }

    /* ========== 输入框 ========== */
    input[type="text"],
    input[type="password"],
    input[type="number"],
    input[type="email"],
    input[type="url"],
    input[type="date"],
    input[type="time"],
    select,
    textarea {
        width: 100% !important;
        min-height: 48px !important;
        padding: 12px 16px !important;
        font-size: 1rem !important;
        border: 2px solid #e2e8f0 !important;
        border-radius: 12px !important;
        background: #fff !important;
        color: #1e293b !important;
        outline: none !important;
        transition: border-color 0.2s;
        -webkit-appearance: none;
        appearance: none;
    }

    input:focus,
    select:focus,
    textarea:focus {
        border-color: #0066cc !important;
        box-shadow: 0 0 0 3px rgba(0, 102, 204, 0.15) !important;
    }

    label {
        font-size: 0.9rem;
        font-weight: 600;
        color: #334155;
        margin-bottom: 6px;
        display: block;
    }

    /* ========== 卡片 ========== */
    .device-card,
    .specimen-card,
    .stat-card,
    .bind-card,
    .card {
        border-radius: 16px !important;
        background: #fff !important;
        box-shadow: 0 2px 12px rgba(0, 0, 0, 0.08) !important;
        border: none !important;
        margin-bottom: 12px;
        overflow: hidden;
    }

    .device-card:hover,
    .specimen-card:hover {
        transform: none !important;
    }

    /* ========== 网格布局调整 ========== */
    .device-grid,
    .specimens-grid {
        display: flex !important;
        flex-direction: column !important;
        gap: 12px !important;
        padding: 16px !important;
    }

    .grid-2cols {
        grid-template-columns: 1fr !important;
    }

    /* ========== 底部导航栏（通用） ========== */
    .app-bottom-nav {
        position: fixed;
        bottom: 0;
        left: 0;
        right: 0;
        z-index: 999;
        background: #fff;
        display: flex;
        align-items: center;
        justify-content: space-around;
        padding: 8px 0;
        padding-bottom: calc(8px + env(safe-area-inset-bottom, 0px));
        box-shadow: 0 -2px 12px rgba(0, 0, 0, 0.08);
        border-top: 1px solid #e2e8f0;
    }

    .app-bottom-nav a,
    .app-bottom-nav button {
        display: flex;
        flex-direction: column;
        align-items: center;
        gap: 2px;
        text-decoration: none;
        color: #94a3b8;
        font-size: 0.7rem;
        background: none !important;
        border: none !important;
        padding: 4px 12px !important;
        min-height: auto !important;
        border-radius: 0 !important;
        box-shadow: none !important;
    }

    .app-bottom-nav a i,
    .app-bottom-nav button i {
        font-size: 1.4rem;
        color: #94a3b8;
    }

    .app-bottom-nav a.active,
    .app-bottom-nav a.active i {
        color: #0066cc !important;
    }

    .app-bottom-nav a:active,
    .app-bottom-nav button:active {
        transform: none;
    }

    /* ========== 模态框 ========== */
    .modal {
        align-items: flex-end !important;
    }

    .modal-content {
        width: 100% !important;
        max-width: 100% !important;
        border-radius: 20px 20px 0 0 !important;
        padding: 24px !important;
        margin: 0 !important;
        animation: slideUp 0.3s ease;
        max-height: 85vh !important;
        overflow-y: auto;
    }

    @keyframes slideUp {
        from { transform: translateY(100%); }
        to { transform: translateY(0); }
    }

    /* ========== 状态标签 ========== */
    .status-badge {
        padding: 6px 14px !important;
        font-size: 0.8rem !important;
        border-radius: 20px !important;
    }

    /* ========== 医院管理/用户管理表格 ========== */
    table {
        width: 100% !important;
    }

    table thead {
        display: none !important;
    }

    table tr {
        display: block !important;
        margin-bottom: 12px !important;
        padding: 16px !important;
        background: #fff !important;
        border-radius: 12px !important;
        box-shadow: 0 2px 8px rgba(0, 0, 0, 0.06) !important;
        border: none !important;
    }

    table td {
        display: flex !important;
        justify-content: space-between !important;
        align-items: center !important;
        padding: 8px 0 !important;
        border: none !important;
        border-bottom: 1px solid #f1f5f9 !important;
        font-size: 0.9rem;
    }

    table td:last-child {
        border-bottom: none !important;
    }

    table td:before {
        content: attr(data-label) !important;
        font-weight: 600 !important;
        color: #64748b !important;
        font-size: 0.85rem;
    }

    /* ========== 分页 ========== */
    .pagination-container {
        padding: 16px !important;
        gap: 8px !important;
    }

    .page-number {
        min-width: 40px !important;
        height: 40px !important;
        display: inline-flex !important;
        align-items: center;
        justify-content: center;
        padding: 0 !important;
    }

    /* ========== Tabs ========== */
    .tabs {
        overflow-x: auto !important;
        flex-wrap: nowrap !important;
        -webkit-overflow-scrolling: touch;
        scrollbar-width: none;
        padding: 0 16px !important;
        gap: 4px !important;
        background: #fff;
        border-bottom: 1px solid #e2e8f0;
        margin: 0 !important;
    }

    .tabs::-webkit-scrollbar {
        display: none;
    }

    .tab-btn {
        min-height: 44px !important;
        padding: 10px 16px !important;
        font-size: 0.85rem !important;
        white-space: nowrap;
        border-radius: 0 !important;
        background: transparent !important;
        color: #64748b !important;
        border-bottom: 2px solid transparent !important;
        margin-bottom: 0 !important;
    }

    .tab-btn.active {
        color: #0066cc !important;
        border-bottom-color: #0066cc !important;
        background: transparent !important;
    }

    .tab-content {
        padding: 16px !important;
    }

    /* ========== Switch 开关 ========== */
    .switch-group {
        flex-direction: column !important;
        gap: 12px !important;
    }

    .switch-label {
        width: 100% !important;
        justify-content: space-between !important;
        padding: 14px 18px !important;
        border-radius: 12px !important;
        background: #f8fafc !important;
    }

    /* ========== 状态卡片 ========== */
    .stats-row {
        padding: 12px 16px !important;
        gap: 8px !important;
    }

    .stat-card {
        padding: 12px 8px !important;
        min-width: calc(25% - 8px) !important;
        flex: 1 !important;
    }

    .stat-number {
        font-size: 1.6rem !important;
    }

    /* ========== 筛选栏 ========== */
    .filter-bar {
        margin: 0 16px 12px !important;
        padding: 12px 16px !important;
        border-radius: 12px !important;
        background: #fff !important;
        box-shadow: 0 2px 8px rgba(0, 0, 0, 0.06) !important;
    }

    /* ========== 表单组 ========== */
    .form-group {
        margin-bottom: 16px !important;
    }

    /* ========== 设备头部 ========== */
    .device-header {
        padding: 16px !important;
        gap: 12px !important;
        border-radius: 0 !important;
    }

    .device-header h2 {
        font-size: 1.3rem !important;
    }

    .device-img {
        width: 80px !important;
        height: 80px !important;
    }

    .status-panel {
        margin: 0 16px 12px !important;
        padding: 12px !important;
        border-radius: 12px !important;
    }

    /* ========== 安全配置 ========== */
    .config-section {
        padding: 16px !important;
        border-radius: 12px !important;
        margin-bottom: 12px !important;
    }

    /* ========== 报警页面 ========== */
    .warning-msg {
        margin: 0 16px 12px !important;
        border-radius: 12px !important;
        padding: 12px 16px !important;
    }

    /* ========== 404页面 ========== */
    .error-page {
        padding: 40px 20px !important;
    }

    .error-page h1 {
        font-size: 4rem !important;
    }

    /* ========== footer 隐藏 ========== */
    footer {
        display: none !important;
    }

    /* ========== 特殊：登录页面 ========== */
    .login-card {
        max-width: 100% !important;
        border-radius: 0 !important;
        min-height: 100vh;
        flex-direction: column !important;
        box-shadow: none !important;
    }

    .login-left {
        padding: 24px 20px !important;
        border-radius: 0 !important;
        min-height: 200px;
    }

    .login-left h2 {
        font-size: 1.5rem !important;
    }

    .login-left img {
        max-width: 50% !important;
    }

    .login-left p {
        font-size: 0.85rem !important;
        margin: 4px 0 !important;
    }

    .login-right {
        padding: 24px 20px !important;
    }

    .login-right h1 {
        font-size: 1.4rem !important;
    }

    /* 登录页按钮 */
    .login-right button[type="submit"] {
        min-height: 52px !important;
        font-size: 1.1rem !important;
        border-radius: 12px !important;
        width: 100% !important;
    }

    /* ========== 用户面板特殊 ========== */
    .hospital-badge {
        background: rgba(255,255,255,0.2) !important;
        color: #fff !important;
        font-size: 0.75rem !important;
        padding: 4px 12px !important;
        border-radius: 20px !important;
    }

    /* ========== 标本卡片步骤 ========== */
    .steps-grid {
        flex-wrap: wrap !important;
    }

    .step-item {
        min-width: calc(33.33% - 8px) !important;
        padding: 10px 8px !important;
    }

    /* ========== 报警记录 ========== */
    #alarmList table tr {
        display: block !important;
        margin-bottom: 8px !important;
        padding: 12px !important;
    }

    #alarmList table td {
        display: flex !important;
        justify-content: space-between !important;
        padding: 6px 0 !important;
    }

    /* ========== 安全配置 iframe ========== */
    iframe {
        min-height: 400px !important;
    }

    /* ========== Toast 提示 ========== */
    #dynamicToast {
        bottom: 80px !important;
        width: 90% !important;
        max-width: 400px !important;
        padding: 14px 20px !important;
        font-size: 0.9rem !important;
    }
}

/* ========== 平板适配 (768px - 1024px) ========== */
@media (min-width: 769px) and (max-width: 1024px) {
    body {
        padding: 1.5rem !important;
    }

    .device-grid {
        grid-template-columns: repeat(2, 1fr) !important;
    }

    .specimens-grid {
        grid-template-columns: repeat(2, 1fr) !important;
    }
}
