/* 响应式样式 */

/* 平板端 (768px-1024px) */
@media (min-width: 768px) and (max-width: 1024px) {
    .main-container {
        max-width: 1024px;
        margin: 0 auto;
    }
    
    .welcome-title { font-size: 32px; }
    .welcome-btn { padding: 16px 40px; font-size: 18px; }
    .chat-header { padding: 20px 30px; }
    .header-title { font-size: 20px; }
    .user-circle { width: 44px; height: 44px; font-size: 18px; }
    .chat-name { font-size: 18px; }
    .chat-members { font-size: 13px; }
    .chat-code { font-size: 11px; padding: 3px 10px; }
    .action-btn { padding: 16px; font-size: 18px; }
    .message { max-width: 75%; }
    .message-content { font-size: 16px; padding: 12px 16px; }
    .modal-content { max-width: 450px; }
    .modal-title { font-size: 20px; }
}

/* 电脑端 (大于1024px) */
@media (min-width: 1025px) {
    body {
        background: var(--light-bg);
    }

    .main-container {
        width: 100%;
        height: 100%;
        height: 100dvh;
        min-height: 0;
        background: white;
        border-radius: 0;
        box-shadow: none;
        overflow: hidden;
        display: flex;
        flex-direction: row;
    }

    .welcome-screen { 
        border-radius: 0;
        width: 100%;
        height: 100%;
    }

    .welcome-title { font-size: 36px; }

    .welcome-btn {
        padding: 16px 48px; font-size: 18px;
        transition: all 0.3s ease;
    }
    .welcome-btn:hover {
        transform: translateY(-2px);
        box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
    }

    /* ========== 左侧导航栏显示 ========== */
    .desktop-sidebar {
        display: flex !important;
        flex-direction: column;
        height: 100%;
    }

    /* ========== 左右分栏布局 ========== */
    #chatScreen {
        display: flex !important;
        flex-direction: row !important;
        height: 100% !important;
        min-height: 0;
    }

    #chatListPage {
        display: flex !important;
        flex-direction: column;
        width: 320px;
        min-width: 320px;
        border-right: 1px solid var(--border-color);
        height: 100% !important;
        min-height: 0;
        overflow: hidden;
    }

    #chatDetailPage {
        display: flex !important;
        flex-direction: column;
        flex: 1;
        height: 100% !important;
        min-height: 0;
        min-width: 0;
        overflow: hidden;
    }

    /* 聊天列表容器要填满剩余空间 */
    #chatListPage .chat-list-container {
        flex: 1;
        overflow-y: auto;
        min-height: 0;
    }

    /* 隐藏详情页的重复用户信息（桌面端列表页已有） */
    .desktop-hide-user {
        display: none !important;
    }

    /* 隐藏返回按钮 */
    .back-btn { display: none !important; }

    /* 输入框相对定位，保持在消息区底部 */
    #inputArea {
        position: relative !important;
        bottom: auto !important;
        left: auto !important;
        right: auto !important;
    }

    /* 消息区域填满剩余空间 */
    .messages-wrapper {
        flex: 1;
        display: flex;
        flex-direction: column;
        overflow: hidden;
        min-height: 0;
    }
    .messages-container {
        flex: 1;
        overflow-y: auto;
        min-height: 0;
    }

    .chat-header { padding: 20px 30px; }
    .header-title { font-size: 20px; }

    .user-circle {
        width: 44px; height: 44px; font-size: 18px;
        transition: transform 0.3s ease;
    }
    .user-circle:hover { transform: scale(1.05); }

    .chat-item {
        padding: 16px 20px;
        transition: background-color 0.2s ease;
    }
    .chat-item:hover { background: var(--light-bg); }

    .chat-name { font-size: 18px; }

    .action-btn {
        padding: 16px; font-size: 18px;
        transition: background-color 0.3s ease;
    }
    .action-btn:hover { background: var(--secondary-color); }

    .message { max-width: 60%; }
    .message-content { font-size: 16px; padding: 12px 18px; }

    .input-area {
        border-top: 1px solid var(--border-color);
        padding: 20px 30px;
        padding-bottom: 20px;
    }

    .input-wrapper { border-radius: 25px; }
    .message-input { font-size: 16px; }

    .send-btn {
        width: 44px; height: 44px; min-width: 44px;
        transition: background-color 0.3s ease;
    }
    .send-btn:hover:not(:disabled) { background: var(--secondary-color); }

    .menu-btn { font-size: 18px; transition: color 0.3s ease; }
    .menu-btn:hover { color: var(--secondary-color); }

    .dropdown-item {
        padding: 14px 20px;
        transition: background-color 0.2s ease;
    }

    .modal-content { max-width: 500px; }
    .modal-title { font-size: 20px; }
}
/* 手机端优化 (小于768px) */
@media (max-width: 767px) {
    #chatScreen {
        height: 100dvh;
        padding-bottom: calc(64px + var(--safe-area-inset-bottom, 0px));
    }
    
    .chat-list-page {
        overflow: hidden;
    }

    .message { max-width: 85%; }
    .chat-item { padding: 16px; }
    .action-btn { padding: 16px; }
    .user-circle { width: 40px; height: 40px; }
    .chat-list-container {
        padding-bottom: calc(84px + var(--safe-area-inset-bottom, 0px));
    }
    .bottom-actions {
        padding-bottom: calc(12px + 64px + var(--safe-area-inset-bottom, 0px));
    }
    .bottom-actions .action-btn,
    .join-options .modal-btn,
    .modal-btn[style*="width: 100%"] {
        width: 100% !important;
        margin-left: 0 !important;
        margin-right: 0 !important;
        box-sizing: border-box;
    }
    .input-area {
        position: fixed;
        left: 0;
        right: 0;
        width: 100%;
        box-sizing: border-box;
        padding: 12px 16px;
        padding-bottom: calc(12px + var(--safe-area-inset-bottom, 0px));
        bottom: calc(64px + var(--safe-area-inset-bottom, 0px));
        z-index: 2400;
    }
    .messages-container {
        padding-bottom: calc(164px + var(--safe-area-inset-bottom, 0px));
    }
    .message-input { padding: 16px; font-size: 16px; }
    .send-btn { width: 44px; height: 44px; min-width: 44px; }
    
    /* 手机端底部导航栏（微信式） */
    .desktop-sidebar {
        display: flex !important;
        position: fixed;
        left: 0;
        right: 0;
        bottom: 0;
        width: 100%;
        min-width: 0;
        height: calc(64px + var(--safe-area-inset-bottom, 0px));
        padding: 6px 0 calc(6px + var(--safe-area-inset-bottom, 0px));
        background: rgba(255, 255, 255, 0.98);
        border-right: none;
        border-top: 1px solid var(--border-color);
        box-shadow: 0 -2px 12px rgba(0, 0, 0, 0.06);
        z-index: 2500;
    }

    .sidebar-nav {
        flex-direction: row;
        justify-content: space-around;
        align-items: center;
        gap: 0;
        height: 100%;
    }

    .sidebar-item {
        width: 50%;
        height: 52px;
        border-radius: 0;
        flex-direction: column;
        gap: 4px;
        font-size: 22px;
        color: #777;
        background: transparent !important;
        box-shadow: none !important;
    }

    .sidebar-item[data-page="chat"]::after {
        content: "聊天";
    }

    .sidebar-item[data-page="community"]::after {
        content: "社区";
    }

    .sidebar-item::after {
        font-size: 12px;
        line-height: 1;
        font-weight: 500;
    }

    .sidebar-item.active {
        color: var(--primary-color);
    }

    .sidebar-item.active::before {
        display: none;
    }
}

/* 手机端小屏幕优化 (小于480px) */
@media (max-width: 479px) {
    .welcome-title { font-size: 24px; }
    .chat-header { padding: 12px 16px; }
    .chat-item { padding: 14px 12px; }
    .input-area {
        padding: 10px 12px;
        padding-bottom: calc(10px + var(--safe-area-inset-bottom, 0px));
    }
    .modal-content { width: 95%; padding: 20px; }
}

/* 超大屏幕优化 */
@media (min-width: 1921px) {
    .main-container { max-width: 100%; height: 100vh; }
}

/* 手机横屏模式优化：只处理手机端，避免电脑端 150% 缩放/低高度时出现底部空白 */
@media (max-width: 767px) and (max-height: 600px) and (orientation: landscape) {
    .main-container {
        height: 100vh;
        height: 100dvh;
    }
}
