* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: 'Noto Sans SC', 'Arial', sans-serif;
    background-color: #f8f9fa;
    color: #333;
    height: 100vh;
    overflow: hidden;
}

.layout {
    display: grid;
    grid-template-areas:
        "header header"
        "sidebar main";
    grid-template-rows: 70px 1fr;
    grid-template-columns: 240px 1fr;
    height: 100vh;
}

/* 顶部区域样式 */
.header {
    grid-area: header;
    background-color: #fff;
    box-shadow: 0 2px 4px rgba(0,0,0,0.08);
    padding: 0 30px;
    display: flex;
    align-items: center;
    border-bottom: 1px solid #eaeaea;
}

.logo {
    display: flex;
    align-items: center;
    gap: 15px;
}

.logo img {
    height: 40px;
}

.logo-text {
    font-size: 20px;
    font-weight: 600;
    color: #2c3e50;
    letter-spacing: 0.5px;
}

/* 用户头像和下拉菜单样式 */
.user-profile {
    margin-left: auto;
    position: relative;
}

.avatar-container {
    position: relative;
    cursor: pointer;
}

.user-avatar {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    object-fit: cover;
    border: 2px solid #f0f0f0;
    transition: all 0.2s ease;
}

.avatar-container:hover .user-avatar {
    border-color: #3498db;
    box-shadow: 0 0 0 3px rgba(52, 152, 219, 0.15);
}

/* 用户姓名头像样式 */
.user-name-avatar {
    min-width: 40px;
    height: 40px;
    border-radius: 20px;
    background-color: #3498db;
    color: white;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 500;
    font-size: 14px;
    border: 2px solid #f0f0f0;
    transition: all 0.2s ease;
    cursor: pointer;
    padding: 0 12px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.avatar-container:hover .user-name-avatar {
    border-color: #3498db;
    box-shadow: 0 0 0 3px rgba(52, 152, 219, 0.15);
}

.dropdown-menu {
    position: absolute;
    top: 50px;
    right: 0;
    background-color: #fff;
    border-radius: 4px;
    box-shadow: 0 5px 15px rgba(0,0,0,0.1);
    width: 150px;
    opacity: 0;
    visibility: hidden;
    transform: translateY(-10px);
    transition: all 0.3s ease;
    z-index: 1000;
}

.avatar-container:hover .dropdown-menu {
    opacity: 1;
    visibility: visible;
    transform: translateY(0);
}

/* 点击显示下拉菜单 */
.dropdown-menu.show {
    opacity: 1;
    visibility: visible;
    transform: translateY(0);
}

.dropdown-item {
    display: block;
    padding: 12px 15px;
    color: #333;
    text-decoration: none;
    font-size: 14px;
    border-bottom: 1px solid #f0f0f0;
    transition: all 0.2s ease;
}

.dropdown-item:last-child {
    border-bottom: none;
}

.dropdown-item:hover {
    background-color: #f8f9fa;
    color: #3498db;
}

/* 侧边栏样式 */
.sidebar {
    grid-area: sidebar;
    background-color: #fff;
    box-shadow: 1px 0 3px rgba(0,0,0,0.05);
    padding: 20px 0;
    border-right: 1px solid #eaeaea;
}

.menu-item {
    display: flex;
    align-items: center;
    padding: 14px 20px;
    cursor: pointer;
    transition: all 0.2s ease;
    gap: 12px;
    margin: 4px 10px;
    border-radius: 6px;
    position: relative;
    color: #5a6268;
}

.menu-item:hover {
    background-color: #f1f5f9;
    color: #3498db;
}

.menu-item.active {
    background-color: #e6f2ff;
    color: #3498db;
    font-weight: 500;
}

.menu-item.active::before {
    content: '';
    position: absolute;
    left: -10px;
    top: 50%;
    transform: translateY(-50%);
    width: 3px;
    height: 20px;
    background-color: #3498db;
    border-radius: 2px;
}

.menu-icon {
    font-size: 18px;
    width: 24px;
    text-align: center;
}

.menu-text {
    font-size: 15px;
    font-weight: 400;
    letter-spacing: 0.3px;
}

/* 主要内容区域样式 */
.main-content {
    grid-area: main;
    padding: 25px 30px;
    overflow-y: auto;
    background-color: #f8f9fa;
}

/* 表格样式 */
.data-table {
    width: 100%;
    border-collapse: separate;
    border-spacing: 0;
    background-color: #fff;
    border-radius: 8px;
    overflow: hidden;
    box-shadow: 0 0 15px rgba(0,0,0,0.05);
}

.data-table th,
.data-table td {
    padding: 14px 20px;
    text-align: left;
    border-bottom: 1px solid #eaeaea;
    color: #333;
}

.data-table th {
    background-color: #f8f9fa;
    font-weight: 600;
    color: #2c3e50;
    font-size: 14px;
    letter-spacing: 0.3px;
}

.data-table tr:last-child td {
    border-bottom: none;
}

.data-table tr:hover {
    background-color: #f8f9fa;
}

/* 按钮样式 */
.start-btn {
    padding: 8px 16px;
    background-color: transparent;
    color: #333;
    border: 1px solid #ccc;
    border-radius: 4px;
    cursor: pointer;
    transition: all 0.2s ease;
    font-weight: 500;
    letter-spacing: 0.3px;
    font-size: 14px;
}

.start-btn:hover {
    background-color: #f5f5f5;
    border-color: #999;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
}

.start-btn:active {
    transform: translateY(1px);
}

/* 内容区域显示控制 */
.tab-content {
    display: none;
}

.tab-content.active {
    display: block;
    animation: fadeIn 0.3s ease;
}

@keyframes fadeIn {
    from {
        opacity: 0;
        transform: translateY(5px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/*搜尋框样式 */
.search-container {
    display: flex;
    margin-bottom: 20px;
    max-width: 500px;
}

.search-input {
    flex: 1;
    padding: 10px 15px;
    border: 1px solid #ddd;
    border-radius: 4px 0 0 4px;
    font-size: 14px;
    outline: none;
    transition: border-color 0.2s;
    margin-right: 10px;
}

.search-input:focus {
    border-color: #3498db;
    box-shadow: 0 0 0 2px rgba(52, 152, 219, 0.2);
}

.search-btn {
    padding: 10px 20px;
    background-color: #3498db;
    color: white;
    border: none;
    border-radius: 0 4px 4px 0;
    cursor: pointer;
    transition: background-color 0.2s;
}

.search-btn:hover {
    background-color: #2980b9;
}

.refresh-btn {
    padding: 10px 15px;
    background-color: transparent;
    color: #333;
    border: 1px solid #ccc;
    border-radius: 4px;
    cursor: pointer;
    transition: all 0.2s ease;
    font-weight: 500;
    font-size: 14px;
    display: flex;
    align-items: center;
    justify-content: center;
    margin-left: 5px;
}

.refresh-btn:hover {
    background-color: #f5f5f5;
    border-color: #999;
}

.section-title {
    margin-bottom: 20px;
    color: #2c3e50;
    font-size: 20px;
    font-weight: 600;
}

.text-center {
    text-align: center;
}

/* 手機端頂部菜單基礎樣式 */
.mobile-menu {
    display: none; /* 默認隱藏，只在手機端顯示 */
    background-color: #fff;
    border-bottom: 1px solid #eaeaea;
    padding: 10px 15px;
    gap: 10px;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    box-shadow: 0 2px 4px rgba(0,0,0,0.05);
    margin-bottom: 20px; /* 與下方內容保持間距 */
    border-radius: 6px; /* 添加圓角 */
}

.mobile-menu-item {
    display: flex;
    align-items: center;
    padding: 8px 16px;
    cursor: pointer;
    transition: all 0.2s ease;
    gap: 8px;
    border-radius: 20px;
    background-color: #f8f9fa;
    color: #5a6268;
    white-space: nowrap;
    font-size: 14px;
    border: 1px solid #e9ecef;
    min-width: fit-content;
}

.mobile-menu-item:hover {
    background-color: #e9ecef;
}

.mobile-menu-item.active {
    background-color: #3498db;
    color: white;
    border-color: #3498db;
    box-shadow: 0 2px 8px rgba(52, 152, 219, 0.3);
}

.mobile-menu-icon {
    font-size: 16px;
}

/* 響應式設計 - 手機端適配 */
@media (max-width: 768px) {
    /* 調整整體佈局 */
    .layout {
        grid-template-areas:
            "header"
            "main";
        grid-template-rows: 70px 1fr;
        grid-template-columns: 1fr;
    }

    /* 隱藏側邊欄 */
    .sidebar {
        display: none;
    }

    /* 顯示手機端頂部菜單 */
    .mobile-menu {
        display: flex;
        margin-bottom: 15px; /* 手機端減少間距 */
    }



    /* 調整主要內容區域 */
    .main-content {
        padding: 15px;
        overflow-x: hidden;
    }

    /* 調整標題樣式 */
    .section-title {
        font-size: 18px;
        margin-bottom: 15px;
        text-align: center;
    }

    /* 調整搜索容器 */
    .search-container {
        flex-direction: column;
        gap: 10px;
        margin-bottom: 15px;
        max-width: 100%;
    }

    .search-input {
        border-radius: 4px;
        margin-right: 0;
        font-size: 16px; /* 防止iOS縮放 */
    }

    .search-btn {
        border-radius: 4px;
        padding: 12px 20px;
        font-size: 16px;
    }

    .refresh-btn {
        padding: 12px 20px;
        font-size: 16px;
        border-radius: 4px;
    }

        /* 調整表格樣式 */
    .data-table {
        font-size: 14px;
        border-radius: 6px;
        width: 100%; /* 確保表格寬度為100% */
        table-layout: fixed; /* 使用固定表格佈局 */
    }
    
    .data-table th,
    .data-table td {
        padding: 10px 8px; /* 減少padding以適應小屏幕 */
        word-wrap: break-word; /* 允許文字換行 */
        overflow: hidden;
        text-overflow: ellipsis;
    }

    /* 調整分頁控件 */
    .pagination-container {
        flex-direction: column;
        gap: 15px;
        align-items: stretch;
        margin-top: 15px;
    }

    .pagination-info {
        text-align: center;
        font-size: 13px;
    }

    .pagination-controls {
        justify-content: center;
        flex-wrap: wrap;
        gap: 8px;
    }

    .pagination-btn {
        padding: 10px 16px;
        font-size: 14px;
        min-width: 80px;
    }

    .pagination-pages {
        margin: 0 5px;
        flex-wrap: wrap;
        justify-content: center;
    }

    .page-number {
        padding: 8px 12px;
        min-width: 35px;
        font-size: 14px;
    }

    /* 調整按鈕樣式 */
    .view-btn, .start-btn {
        padding: 6px 12px;
        font-size: 12px;
        min-width: 60px;
    }

    /* 調整角色標籤 */
    .role-badge {
        padding: 3px 6px;
        font-size: 11px;
    }
}

/* 隱藏手機端菜單在PC端 */
@media (min-width: 769px) {
    .mobile-menu {
        display: none;
    }
}

/* 超小屏幕適配 */
@media (max-width: 480px) {
    .main-content {
        padding: 10px;
    }
    
    .section-title {
        font-size: 16px;
        margin-bottom: 12px;
    }
    
    .search-container {
        gap: 8px;
        margin-bottom: 12px;
    }
    
    .search-input,
    .search-btn,
    .refresh-btn {
        padding: 10px 15px;
        font-size: 14px;
    }
    
    .data-table th,
    .data-table td {
        padding: 6px 6px; /* 進一步減少padding */
        font-size: 12px; /* 減少字體大小 */
    }
    
    /* 超小屏幕的表格列寬度調整 */
    .data-table th:nth-child(1), .data-table td:nth-child(1) {
        width: 20%; /* 標題列 */
    }
    
    .data-table th:nth-child(2), .data-table td:nth-child(2) {
        width: 35%; /* 內容預覽列 */
    }
    
    .data-table th:nth-child(3), .data-table td:nth-child(3) {
        width: 25%; /* AI角色列 */
    }
    
    .data-table th:nth-child(4), .data-table td:nth-child(4) {
        width: 20%; /* 操作列 */
    }
    
    .pagination-btn {
        padding: 8px 12px;
        font-size: 13px;
        min-width: 70px;
    }
    
    .page-number {
        padding: 6px 10px;
        min-width: 30px;
        font-size: 13px;
    }
    
    .mobile-menu {
        padding: 8px 12px;
        gap: 8px;
    }
    
    .mobile-menu-item {
        padding: 6px 12px;
        font-size: 13px;
    }
}

/* 表格響應式處理 */
@media (max-width: 768px) {
    .data-table {
        width: 100%; /* 表格寬度設為100%，適配屏幕寬度 */
        min-width: auto; /* 移除最小寬度限制 */
    }
    
    .data-table-container {
        overflow-x: visible; /* 移除橫向滾動 */
        border-radius: 6px;
        box-shadow: 0 0 15px rgba(0,0,0,0.05);
    }
    
    /* 調整表格列寬度為百分比 */
    .data-table th:nth-child(1), /* 標題列 */
    .data-table td:nth-child(1) {
        width: 25%;
        min-width: auto;
        max-width: none;
    }
    
    .data-table th:nth-child(2), /* 內容預覽列 */
    .data-table td:nth-child(2) {
        width: 40%;
        min-width: auto;
        max-width: none;
    }
    
    .data-table th:nth-child(3), /* AI角色列 */
    .data-table td:nth-child(3) {
        width: 20%;
        min-width: auto;
        max-width: none;
    }
    
    .data-table th:nth-child(4), /* 操作列 */
    .data-table td:nth-child(4) {
        width: 15%;
        min-width: auto;
        max-width: none;
    }
}

/* 對話記錄表格響應式處理 */
@media (max-width: 768px) {
    .data-table th:nth-child(1), /* 對話ID列 */
    .data-table td:nth-child(1) {
        width: 15%;
        min-width: auto;
        max-width: none;
    }
    
    .data-table th:nth-child(2), /* 案例ID列 */
    .data-table td:nth-child(2) {
        width: 15%;
        min-width: auto;
        max-width: none;
    }
    
    .data-table th:nth-child(3), /* 案例標題列 */
    .data-table td:nth-child(3) {
        width: 35%;
        min-width: auto;
        max-width: none;
    }
    
    .data-table th:nth-child(4), /* 更新時間列 */
    .data-table td:nth-child(4) {
        width: 25%;
        min-width: auto;
        max-width: none;
    }
    
    .data-table th:nth-child(5), /* 評分列 */
    .data-table td:nth-child(5) {
        width: 10%;
        min-width: auto;
        max-width: none;
    }
}

/* 触摸友好样式 */
@media (max-width: 768px) {
    /* 确保按钮有足够的触摸区域 */
    button, 
    .view-btn, 
    .start-btn,
    .pagination-btn,
    .page-number,
    .mobile-menu-item {
        min-height: 44px; /* iOS推荐的最小触摸区域 */
        min-width: 44px;
    }
    
    /* 表格行触摸优化 */
    .clickable-row {
        min-height: 44px;
    }
    
    /* 搜索输入框触摸优化 */
    .search-input {
        min-height: 44px;
        font-size: 16px; /* 防止iOS缩放 */
    }
    
    /* 分页控件触摸优化 */
    .pagination-controls {
        gap: 12px; /* 增加按钮间距，防止误触 */
    }
    
    /* 表格容器触摸滚动优化 */
    .data-table-container {
        -webkit-overflow-scrolling: touch;
        scrollbar-width: thin;
        scrollbar-color: #c1c1c1 #f1f1f1;
    }
    
    /* Webkit滚动条样式 */
    .data-table-container::-webkit-scrollbar {
        height: 8px;
    }
    
    .data-table-container::-webkit-scrollbar-track {
        background: #f1f1f1;
        border-radius: 4px;
    }
    
    .data-table-container::-webkit-scrollbar-thumb {
        background: #c1c1c1;
        border-radius: 4px;
    }
    
    .data-table-container::-webkit-scrollbar-thumb:hover {
        background: #a8a8a8;
    }
} 