/* mobile.css - 移动端响应式适配
 * 在 768px 以下屏幕自动启用
 * 三栏布局改为单栏 + 底部标签栏切换
 */

/* ============ 底部标签栏（仅手机端显示） ============ */
.mobile-tab-bar {
    display: none;
}

/* ============ 移动端适配（768px 以下） ============ */
@media screen and (max-width: 768px) {
    /* ---------- 基础布局 ---------- */
    html, body {
        font-size: 14px;
        -webkit-text-size-adjust: 100%;
        text-size-adjust: 100%;
    }

    /* ---------- 顶部菜单栏：隐藏桌面菜单 ---------- */
    .top-bar {
        height: 48px;
        padding: 0 12px;
        position: fixed;
        top: 0;
        left: 0;
        right: 0;
        z-index: 100;
        display: flex;
        align-items: center;
        justify-content: space-between;
    }

    .top-bar-left {
        gap: 8px;
        flex: 1;
        min-width: 0;
    }

    .top-bar-left .app-logo {
        font-size: 20px;
    }

    .top-bar-left .app-title {
        font-size: 14px;
        font-weight: 600;
        white-space: nowrap;
        overflow: hidden;
        text-overflow: ellipsis;
    }

    /* 隐藏桌面菜单（文件/编辑/视图/窗口/帮助） */
    .top-bar-center {
        display: none !important;
    }

    /* 右侧按钮只保留智能参考库，简化 */
    .top-bar-right {
        gap: 6px;
        flex-shrink: 0;
    }

    .top-bar-right .action-btn {
        padding: 6px 10px;
        font-size: 12px;
        border-radius: 16px;
        min-height: 32px;
    }

    .top-bar-right .action-btn:not(:first-child) {
        display: none;
    }

    /* ---------- 主内容区域 ---------- */
    .main-content {
        position: fixed;
        top: 48px;
        left: 0;
        right: 0;
        bottom: calc(56px + env(safe-area-inset-bottom, 0px));
        height: auto;
        display: flex;
        flex-direction: column;
        padding-bottom: 0;
        overflow: hidden;
    }

    /* 三栏改为绝对定位全屏，默认隐藏 */
    .left-panel,
    .center-panel,
    .right-panel {
        position: absolute;
        top: 0;
        left: 0;
        right: 0;
        bottom: 0;
        width: 100%;
        flex: none;
        display: none;
        z-index: 10;
        overflow: hidden;
    }

    /* 当前激活的面板显示 */
    .left-panel.mobile-active,
    .center-panel.mobile-active,
    .right-panel.mobile-active {
        display: flex;
        flex-direction: column;
    }

    /* 默认显示中间面板 */
    .center-panel {
        display: flex;
        flex-direction: column;
    }

    .left-panel,
    .right-panel {
        display: none;
    }

    /* ---------- 底部标签栏 ---------- */
    .mobile-tab-bar {
        display: flex;
        position: fixed;
        bottom: 0;
        left: 0;
        right: 0;
        height: calc(56px + env(safe-area-inset-bottom, 0px));
        padding-bottom: env(safe-area-inset-bottom, 0px);
        background: var(--bg-card, #1e1e2e);
        border-top: 1px solid var(--border, #333);
        z-index: 1000;
        justify-content: space-around;
        align-items: center;
        box-shadow: 0 -2px 8px rgba(0,0,0,0.2);
    }

    .mobile-tab {
        appearance: none;
        border: none;
        background: transparent;
        display: flex;
        flex-direction: column;
        align-items: center;
        justify-content: center;
        flex: 1;
        height: 56px;
        cursor: pointer;
        color: var(--text-secondary, #888);
        font-size: 11px;
        gap: 2px;
        transition: color 0.2s, transform 0.2s, background-color 0.2s;
        -webkit-tap-highlight-color: transparent;
    }

    .mobile-tab:active {
        transform: scale(0.98);
    }

    .mobile-tab.active {
        color: var(--accent, #1565C0);
        background: rgba(21, 101, 192, 0.08);
    }

    .mobile-tab:focus-visible {
        outline: 2px solid #1565C0;
        outline-offset: 2px;
        border-radius: 12px;
    }

    .mobile-tab-icon {
        font-size: 20px;
    }

    /* ---------- 左侧客户列表面板 ---------- */
    .left-panel {
        border-right: none;
        background: var(--bg-main, #f5f5f5);
    }

    .left-panel .panel-header {
        padding: 10px 12px;
        background: white;
        border-bottom: 1px solid var(--border, #e0e0e0);
        flex-shrink: 0;
    }

    .left-panel .search-box {
        margin-bottom: 10px;
    }

    .left-panel .search-input {
        width: 100%;
        height: 42px;
        padding: 0 14px;
        font-size: 15px;
        border-radius: 21px;
        border: 1px solid var(--border, #ddd);
        background: var(--bg-light, #f8f9fa);
    }

    .left-panel .filter-tabs {
        display: flex;
        align-items: center;
        gap: 8px;
        flex-wrap: nowrap;
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
        scrollbar-width: none;
    }

    .left-panel .filter-tabs::-webkit-scrollbar {
        display: none;
    }

    .left-panel .add-btn {
        flex-shrink: 0;
        height: 34px;
        padding: 0 14px;
        font-size: 13px;
        border-radius: 17px;
        background: linear-gradient(135deg, #1565C0 0%, #0D47A1 100%);
        color: white;
        border: none;
        box-shadow: 0 2px 6px rgba(21, 101, 192, 0.25);
        min-width: 64px;
        display: flex;
        align-items: center;
        justify-content: center;
        -webkit-tap-highlight-color: transparent;
    }

    .left-panel .filter-tab {
        flex-shrink: 0;
        height: 32px;
        padding: 0 12px;
        font-size: 12px;
        border-radius: 16px;
        display: flex;
        align-items: center;
        white-space: nowrap;
        background: white;
        border: 1px solid var(--border, #ddd);
        color: var(--text-secondary, #666);
    }

    .left-panel .filter-tab.active {
        background: #1565C0;
        color: white;
        border-color: #1565C0;
    }

    .left-panel .filter-tab .count {
        font-size: 11px;
        margin-left: 4px;
        padding: 1px 5px;
    }

    .left-panel .customer-list {
        flex: 1;
        overflow-y: auto;
        padding: 10px 12px;
        -webkit-overflow-scrolling: touch;
        padding-bottom: calc(72px + env(safe-area-inset-bottom, 0px));
    }

    .left-panel .customer-item {
        padding: 14px;
        border-radius: 12px;
        margin-bottom: 10px;
        background: white;
        border: 1px solid transparent;
        box-shadow: 0 1px 3px rgba(0,0,0,0.05);
    }

    .left-panel .customer-name {
        font-size: 16px;
        font-weight: 600;
        margin-bottom: 4px;
    }

    .left-panel .customer-phone {
        font-size: 13px;
        color: var(--text-secondary, #666);
        margin-bottom: 8px;
    }

    .left-panel .customer-info {
        font-size: 12px;
        color: var(--text-secondary, #888);
        margin-bottom: 8px;
    }

    .left-panel .customer-tags {
        display: flex;
        gap: 6px;
        flex-wrap: wrap;
    }

    .left-panel .customer-tags .tag {
        font-size: 11px;
        padding: 3px 8px;
        border-radius: 10px;
    }

    /* 空状态 */
    .left-panel .customer-list:empty::after {
        content: '暂无客户，点击上方"+ 添加"按钮';
        display: block;
        text-align: center;
        padding: 60px 20px;
        color: var(--text-secondary, #999);
        font-size: 14px;
    }

    /* ---------- 统计卡片 ---------- */
    .left-panel .panel-footer {
        padding: 10px 12px;
        background: white;
        border-top: 1px solid var(--border, #e0e0e0);
        flex-shrink: 0;
    }

    .left-panel .stats-cards {
        display: grid;
        grid-template-columns: repeat(3, 1fr);
        gap: 8px;
    }

    .left-panel .stat-card {
        border-radius: 10px;
        padding: 10px 4px;
        text-align: center;
        color: white;
        min-height: 58px;
        display: flex;
        flex-direction: column;
        align-items: center;
        justify-content: center;
    }

    .left-panel .stat-card-value {
        font-size: 18px;
        font-weight: 700;
        line-height: 1.2;
    }

    .left-panel .stat-card-label {
        font-size: 11px;
        opacity: 0.95;
        margin-top: 3px;
        white-space: nowrap;
    }

    /* ---------- 中间通话区 ---------- */
    .center-panel {
        border-right: none;
        background: var(--bg-main, #f5f5f5);
    }

    .center-panel .call-header {
        padding: 12px;
        background: white;
        border-bottom: 1px solid var(--border, #e0e0e0);
        display: flex;
        flex-direction: column;
        align-items: stretch;
        gap: 12px;
    }

    .center-panel .call-info {
        justify-content: space-between;
        width: 100%;
        gap: 12px;
    }

    .center-panel .call-controls {
        display: flex;
        gap: 10px;
        width: 100%;
    }

    .center-panel .call-controls .call-btn {
        flex: 1;
        justify-content: center;
    }

    .center-panel .prediction-area,
    .center-panel .scene-hint,
    .center-panel #sceneHint {
        border-radius: 12px;
    }

    .center-panel .call-timer-large {
        font-size: 32px;
    }

    /* 通话按钮区触摸友好 */
    .call-controls button,
    #startCallBtn,
    #endCallBtn {
        min-height: 48px;
        min-width: 48px;
        font-size: 14px;
        padding: 10px 18px;
        border-radius: 24px;
    }

    .transcript-content {
        font-size: 15px;
        line-height: 1.6;
        padding: 12px;
        min-height: 120px;
    }

    .realtime-text {
        background: #E3F2FD;
        border-left: 4px solid #1565C0;
        border-radius: 12px;
        padding: 12px 15px;
        margin-bottom: 12px;
        color: #0D47A1;
        font-size: 15px;
        line-height: 1.6;
        min-height: 24px;
    }

    .transcript-actions {
        display: none;
    }

    /* ---------- 右侧AI推荐区 ---------- */
    .right-panel {
        overflow-y: auto;
        background: var(--bg-main, #f5f5f5);
        padding: 12px;
        -webkit-overflow-scrolling: touch;
        padding-bottom: calc(72px + env(safe-area-inset-bottom, 0px));
    }

    .right-panel .ai-answer-card {
        margin-bottom: 10px;
        padding: 12px;
        border-radius: 12px;
        background: white;
        box-shadow: 0 1px 3px rgba(0,0,0,0.05);
    }

    /* ---------- 弹窗适配 ---------- */
    .modal {
        z-index: 2000;
        padding: 0;
        align-items: flex-end;
    }

    .modal.show {
        display: flex;
    }

    .modal-content {
        width: 100%;
        max-width: 100%;
        max-height: 85vh;
        margin: 0;
        border-radius: 16px 16px 0 0;
        padding: 16px 16px calc(16px + env(safe-area-inset-bottom, 0px)) 16px;
        overflow-y: auto;
        -webkit-overflow-scrolling: touch;
        background: white;
        box-sizing: border-box;
    }

    .scene-select-content,
    .tactics-library-content,
    .biz-knowledge-content,
    .tactics-detail-content,
    .tactic-edit-content,
    .biz-knowledge-detail-content,
    .biz-knowledge-edit-content,
    .report-modal-content,
    .import-tactics-content {
        width: calc(100vw - 16px) !important;
        max-width: calc(100vw - 16px) !important;
        max-height: calc(100vh - 32px);
        margin: 8px;
        border-radius: 16px;
        overflow: hidden;
    }
+
+    .scene-select-body,
+    .tactics-library-body,
+    .biz-knowledge-body,
+    .report-modal-body {
+        overflow-y: auto;
+        -webkit-overflow-scrolling: touch;
+    }

    .modal-header {
        padding: 0 0 12px 0;
        margin-bottom: 12px;
        border-bottom: 1px solid var(--border, #eee);
        display: flex;
        justify-content: space-between;
        align-items: center;
    }

    .modal-header span {
        font-size: 17px;
        font-weight: 600;
    }

    .modal-close {
        width: 32px;
        height: 32px;
        font-size: 22px;
        display: flex;
        align-items: center;
        justify-content: center;
        border-radius: 50%;
        background: var(--bg-light, #f5f5f5);
        border: none;
    }

    .form-group {
        margin-bottom: 10px;
    }

    .form-label {
        font-size: 13px;
        margin-bottom: 4px;
        color: var(--text-secondary, #666);
    }

    .form-input,
    .form-select {
        width: 100%;
        height: 42px;
        padding: 0 12px;
        font-size: 15px;
        border-radius: 10px;
        border: 1px solid var(--border, #ddd);
        background: var(--bg-light, #f8f9fa);
        box-sizing: border-box;
    }

    .form-row {
        display: flex;
        gap: 10px;
        margin-bottom: 0;
    }

    .form-row .form-group {
        flex: 1;
        min-width: 0;
    }

    .form-actions {
        position: sticky;
        bottom: 0;
        background: white;
        padding: 10px 0 8px 0;
        margin-top: 6px;
        display: flex;
        gap: 10px;
        border-top: 1px solid var(--border, #eee);
        z-index: 10;
    }

    .form-actions .btn {
        flex: 1;
        height: 42px;
        font-size: 15px;
        border-radius: 10px;
        display: flex;
        align-items: center;
        justify-content: center;
    }

    /* 弹窗表单最后留出按钮空间 */
    .modal-content form {
        padding-bottom: 10px;
    }

    /* ---------- 通用触摸优化 ---------- */
    button,
    .btn,
    .add-btn,
    .search-input,
    .filter-tab,
    .customer-item,
    .mobile-tab {
        min-height: 44px;
    }

    input[type="text"],
    input[type="search"],
    input[type="tel"],
    input[type="number"],
    textarea,
    select {
        font-size: 16px !important;
    }

    /* 隐藏手机端不适用的元素 */
    .desktop-only {
        display: none !important;
    }

    /* 滚动优化 */
    * {
        -webkit-overflow-scrolling: touch;
    }

    /* 防止文字选择（手机端体验更好） */
    .top-bar,
    .mobile-tab-bar,
    .call-controls,
    .filter-tabs,
    .stats-cards {
        -webkit-user-select: none;
        user-select: none;
    }

    /* ---------- 预判问题区 ---------- */
    .prediction-item {
        padding: 10px 34px 10px 10px !important;
        min-height: 56px;
    }

    .prediction-item > div:first-child {
        align-items: flex-start !important;
    }

    .prediction-item span:last-of-type {
        flex: 1;
        padding-right: 4px;
        word-break: break-all;
        line-height: 1.5;
        font-size: 13px;
        display: block;
    }

    .copy-single-btn {
        right: 6px !important;
        top: 10px !important;
        transform: none !important;
        width: 28px;
        height: 28px;
        display: flex;
        align-items: center;
        justify-content: center;
        font-size: 14px;
        border-radius: 6px;
        background: rgba(0,0,0,0.04);
    }

    /* Toast 提示居中 */
    .toast {
        left: 50% !important;
        right: auto !important;
        transform: translateX(-50%) !important;
        max-width: 90vw;
        font-size: 14px;
        padding: 12px 18px;
        border-radius: 10px;
    }
}

/* ============ 小屏手机优化（375px 以下） ============ */
@media screen and (max-width: 375px) {
    .top-bar-left .app-title {
        font-size: 13px;
    }

    .left-panel .stats-cards {
        grid-template-columns: repeat(3, 1fr);
        gap: 6px;
    }

    .left-panel .stat-card-value {
        font-size: 16px;
    }

    .left-panel .stat-card-label {
        font-size: 10px;
    }

    .left-panel .filter-tab {
        padding: 0 10px;
        font-size: 11px;
    }

    .mobile-tab {
        font-size: 10px;
    }

    .mobile-tab-icon {
        font-size: 18px;
    }
}

/* ============ 平板适配（769px ~ 1024px） ============ */
@media screen and (max-width: 1024px) and (min-width: 769px) {
    .left-panel {
        width: 240px;
    }

    .right-panel {
        flex: 1;
    }
}
