/**
 * 手机 / 平板 — 独立设计，不遵循 PC 版
 * 底部 Dock 导航 + 紧凑型 UI
 */

/* ============================================
   手机（< 640px）— 紧凑布局 + 底部 Dock
   ============================================ */

/* 顶部栏：极简 */
.topbar {
    height: 44px;
}
.topbar-inner {
    padding: 0 8px;
}

.topbar-menu-btn {
    display: none !important;
}

.topbar-drawer {
    display: none !important;
}

.topbar-nav {
    display: none;
}

.topbar-logo {
    margin-right: 0;
}
.topbar-logo span {
    display: none;
}
.topbar-logo svg {
    width: 20px;
    height: 20px;
}

.topbar-settings {
    width: 36px;
    height: 36px;
}
.topbar-settings svg {
    width: 18px;
    height: 18px;
}

/* 子导航：横向滚动，紧凑 */
.subnav {
    top: 44px;
}
.subnav-inner {
    padding: 0 8px;
    height: 40px;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: none;
}
.subnav-inner::-webkit-scrollbar { display: none; }
.subnav-link {
    flex-shrink: 0;
    padding: 6px 12px;
    font-size: 13px;
    min-height: 32px;
}
/* 第三排子菜单移动端 */
.subnav-row3-inner {
    height: 36px;
}
.subnav-row3-links .subnav-link {
    font-size: 12px;
    padding: 4px 10px;
}

/* 主内容区 */
.main {
    padding: 12px 10px 72px;
    max-width: 100%;
}

/* 底部 Dock: [left2] [center_btn] [right2] */
.mobile-dock {
    display: grid;
    grid-template-columns: 1fr auto 1fr;
    align-items: center;
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    height: 56px;
    background: var(--color-glass);
    backdrop-filter: saturate(180%) blur(20px);
    -webkit-backdrop-filter: saturate(180%) blur(20px);
    border-top: 0.5px solid var(--color-glass-border);
    z-index: 1000;
    padding: 0 6px env(safe-area-inset-bottom, 0) 6px;
}

.dock-left, .dock-right {
    display: flex;
    align-items: center;
    gap: 0;
}
.dock-left { justify-content: flex-end; }
.dock-right { justify-content: flex-start; }

.dock-item {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    min-width: 0;
    width: 60px;
    padding: 4px 2px;
    color: var(--color-text-secondary);
    text-decoration: none;
    font-size: 10px;
    transition: color 0.15s;
    -webkit-tap-highlight-color: transparent;
}
.dock-item.active {
    color: var(--color-accent);
}
.dock-item svg {
    width: 22px;
    height: 22px;
    margin-bottom: 2px;
}
.dock-item span {
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    max-width: 100%;
}

/* Center drawer button */
.dock-center-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 44px;
    height: 44px;
    border-radius: 50%;
    border: none;
    background: var(--color-accent);
    color: var(--color-bg);
    cursor: pointer;
    margin: 0 10px;
    box-shadow: var(--shadow-hover);
    transition: transform 0.15s ease;
    -webkit-tap-highlight-color: transparent;
}
.dock-center-btn:active {
    transform: scale(0.92);
}
.dock-center-btn svg {
    width: 22px;
    height: 22px;
}

/* 超小屏：隐藏文字 */
@media (max-width: 360px) {
    .dock-item span { display: none; }
    .dock-item svg { margin-bottom: 0; }
    .dock-item { width: 48px; }
}

/* 页面底部：手机隐藏 */
.page-footer {
    display: none;
}

/* 紧凑卡片 */
.card {
    border-radius: 8px;
    margin-bottom: 10px;
}
.card-header {
    padding: 10px 12px;
}
.card-body {
    padding: 10px 12px;
}
.card-title {
    font-size: 14px;
}

/* 紧凑按钮 */
.btn {
    min-height: 36px;
    padding: 8px 14px;
    font-size: 13px;
}
.btn-sm, .btn-small {
    min-height: 32px;
    padding: 6px 10px;
    font-size: 12px;
}

/* 紧凑表单 */
.form-input {
    padding: 8px 12px;
    font-size: 16px;
    min-height: 36px;
}
.form-label {
    font-size: 13px;
    margin-bottom: 4px;
}

/* 紧凑空状态 */
.empty-state,
.loading-state {
    padding: 32px 16px;
}
.empty-state svg {
    width: 36px;
    height: 36px;
}

.empty-state h3 {
    font-size: 15px;
}
.empty-state p {
    font-size: 13px;
}

/* 共享组件紧凑 */
.tabs {
    overflow-x: auto;
    scrollbar-width: none;
    -webkit-overflow-scrolling: touch;
}
.tabs::-webkit-scrollbar { display: none; }
.tab-btn {
    padding: 8px 12px;
    font-size: 13px;
    flex-shrink: 0;
}

.stats-grid {
    grid-template-columns: repeat(2, 1fr);
    gap: 8px;
    margin-bottom: 16px;
}
.stat-card {
    padding: 10px 12px;
    border-radius: 8px;
}
.stat-card-value {
    font-size: 20px;
}

.filter-bar {
    flex-direction: column;
    align-items: stretch;
    gap: 6px;
    padding: 10px 12px;
    border-radius: 8px;
    margin-bottom: 12px;
}
.filter-bar input[type="text"] {
    width: 100%;
}
.filter-bar .filter-sep {
    display: none;
}

.results-table th,
.results-table td {
    padding: 8px 10px;
    font-size: 12px;
}

.pagination {
    flex-direction: column;
    align-items: center;
    gap: 8px;
    padding: 8px 0;
}
.pagination-btns button {
    min-width: 32px;
    height: 32px;
    font-size: 12px;
}

.config-panel {
    padding: 12px;
    border-radius: 8px;
}
.config-grid {
    grid-template-columns: 1fr;
    gap: 10px;
}

.stock-toolbar {
    flex-direction: column;
    align-items: stretch;
    gap: 6px;
}
.stock-toolbar .btn {
    justify-content: center;
}

.page-title {
    font-size: 17px;
    margin-bottom: 12px;
}

/* 模态框 — 移动端不遮挡、可滚动、安全区 */
.modal-overlay {
    align-items: flex-end;
    padding: 0;
    padding-bottom: env(safe-area-inset-bottom, 0);
}
.modal-content {
    width: 100%;
    max-width: 100%;
    margin: 0;
    padding: 16px;
    padding-bottom: calc(16px + env(safe-area-inset-bottom, 0));
    max-height: 85vh;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
    border-radius: var(--radius) var(--radius) 0 0;
}
.modal-footer {
    margin-top: 16px;
    padding-top: 16px;
    border-top: 0.5px solid var(--color-border);
}
/* 输入框防 iOS 缩放与光标异常 */
input.form-input,
textarea.form-input,
input[type="text"],
input[type="password"],
textarea {
    font-size: 16px !important;
    -webkit-user-select: text;
    user-select: text;
    -webkit-tap-highlight-color: transparent;
}

/* Toast */
.toast-container {
    left: 12px;
    right: 12px;
    bottom: 72px;
    top: auto;
}
.toast {
    padding: 10px 14px;
    font-size: 13px;
}

/* info-row */
.info-row {
    flex-direction: column;
    gap: 2px;
    padding: 8px 0;
}
.info-label {
    font-size: 12px;
    min-width: 0;
}
.info-value {
    font-size: 13px;
    text-align: left;
    justify-content: flex-start;
}
.action-row {
    flex-direction: column;
    align-items: stretch;
    gap: 8px;
}

/* ============================================
   平板 (640px - 1024px)
   ============================================ */
@media (min-width: 640px) {
    .mobile-dock {
        display: none;
    }

    .topbar-nav {
        display: flex;
    }
    .topbar-menu-btn {
        display: none;
    }
    .topbar-logo span {
        display: inline;
    }

    .main {
        padding: 16px 16px 24px;
    }

    .page-footer {
        display: block;
    }

    .card-header,
    .card-body {
        padding: 14px 16px;
    }
    .btn {
        min-height: 40px;
    }
    .form-input {
        min-height: 40px;
    }

    /* 共享组件恢复 */
    .stats-grid {
        grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
        gap: 12px;
    }
    .stat-card {
        padding: 14px;
    }
    .stat-card-value {
        font-size: 22px;
    }
    .filter-bar {
        flex-direction: row;
        flex-wrap: wrap;
        align-items: center;
        gap: 10px;
        padding: 12px 16px;
    }
    .filter-bar input[type="text"] {
        width: 180px;
    }
    .filter-bar .filter-sep {
        display: block;
    }
    .stock-toolbar {
        flex-direction: row;
        flex-wrap: wrap;
        justify-content: flex-end;
    }
    .config-grid {
        grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    }
    .pagination {
        flex-direction: row;
        justify-content: space-between;
    }
}

/* ============================================
   桌面 (1025px+)
   ============================================ */
@media (min-width: 1025px) {
    .main {
        max-width: 1200px;
        margin: 0 auto;
        padding: var(--spacing-2xl) var(--spacing-xl) 64px;
    }
    .topbar-inner,
    .subnav-inner {
        max-width: 1800px;
        margin: 0 auto;
        padding: 0 24px;
    }
    .card-header,
    .card-body {
        padding: var(--spacing-xl);
    }
    .btn {
        min-height: 40px;
    }
    .form-input {
        min-height: 40px;
    }
}

/* ============================================
   App drawer mobile: bottom-sheet style
   ============================================ */
@media (max-width: 639px) {
    .app-drawer-overlay {
        align-items: flex-end;
        justify-content: center;
        padding: 0;
    }
    .app-drawer {
        width: 100%;
        max-width: 100%;
        max-height: 80vh;
        border-radius: 16px 16px 0 0;
        border-bottom: none;
        transform-origin: bottom center;
        animation: drawerSlideUp 0.28s cubic-bezier(0.2, 0.9, 0.3, 1);
    }
    @keyframes drawerSlideUp {
        from { opacity: 0; transform: translateY(40px); }
        to { opacity: 1; transform: translateY(0); }
    }
    .app-drawer-header {
        padding: 14px 16px 0;
    }
    .app-drawer-body {
        padding: 6px 12px 20px;
        padding-bottom: calc(20px + env(safe-area-inset-bottom, 0));
    }
    .app-drawer-card {
        padding: 10px 6px 8px;
    }
    .app-drawer-card-icon {
        width: 48px;
        height: 48px;
        border-radius: 12px;
    }
    .app-drawer-card-icon svg {
        width: 22px;
        height: 22px;
    }
}

/* ============================================
   Homepage mobile: component cards
   ============================================ */
@media (max-width: 640px) {
    .component-card,
    .component-card.size-1x1,
    .component-card.size-2x1,
    .component-card.size-1x05,
    .component-card.size-2x05 {
        grid-column: span 1 !important;
        min-height: 260px;
    }
    .card-resize-handle {
        display: none !important;
    }
    .hcfg-modal {
        position: fixed !important;
        bottom: 0 !important;
        left: 0 !important;
        right: 0 !important;
        top: auto !important;
        max-height: 85vh;
        border-radius: 16px 16px 0 0 !important;
        width: 100% !important;
        max-width: 100% !important;
        padding-bottom: env(safe-area-inset-bottom);
    }
    .hcfg-overlay {
        align-items: flex-end !important;
    }
    .hc-nlp-input-wrap {
        position: sticky;
        bottom: 0;
        background: var(--color-bg-card);
        padding: 8px;
        border-top: 1px solid var(--color-border);
    }
}

