/* 通用样式：重置盒模型，字体等 */
body {
    font-family: 'Helvetica Neue', Helvetica, Arial, sans-serif;
    line-height: 1.6;
    margin: 0; /* 确保body没有默认外边距 */
    padding: 20px; /* 默认内边距 */
    background-color: #f4f7f6;
    color: #333;
    -webkit-font-smoothing: antialiased; /* 字体平滑 */
}

.container {
    max-width: 960px; /* 限制内容区域最大宽度 */
    margin: 30px auto; /* 居中显示，顶部增加间距 */
    padding: 30px;
    background-color: #fff;
    border-radius: 8px; /* 圆角边框 */
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.08); /* 柔和的阴影 */
}

h1 {
    text-align: center;
    color: #2c3e50;
    margin-bottom: 30px;
    font-size: 2.2em; /* 标题稍大 */
}

/* 筛选器容器样式 */
.filters {
    display: flex; /* 使用 Flexbox 布局 */
    flex-wrap: wrap; /* 允许在小屏幕上换行 */
    gap: 20px; /* 筛选器组之间的间距 */
    margin-bottom: 25px; /* 筛选器与搜索框之间的间距 */
    justify-content: flex-start; /* 筛选器靠左对齐 */
    align-items: center; /* 垂直居中对齐 */
}

.filter-group {
    display: flex;
    align-items: center;
    gap: 10px; /* 标签和选择框之间的间距 */
}

.filter-group label {
    font-size: 1em;
    color: #555;
    font-weight: bold;
    white-space: nowrap; /* 防止标签换行 */
}

.filter-group select {
    padding: 8px 12px;
    border: 1px solid #dcdfe6;
    border-radius: 6px;
    font-size: 1em;
    background-color: #fff;
    cursor: pointer;
    outline: none;
    transition: border-color 0.3s ease;
}

.filter-group select:hover,
.filter-group select:focus {
    border-color: #409eff;
}

/* 搜索框容器样式 */
.search-inputs {
    display: flex; /* 使用 Flexbox */
    gap: 15px; /* 两个搜索框之间的间距 */
    margin-bottom: 30px; /* 搜索框与结果区域的间距 */
    flex-wrap: wrap; /* 允许在小屏幕上换行 */
}

/* 单个搜索框样式 - 通用设置 */
.search-inputs input[type="text"] {
    flex: 1; /* 每个搜索框平均分配可用空间 */
    min-width: 250px; /* 确保每个搜索框不会过窄 */
    padding: 12px 10px;
    border: 1px solid #dcdfe6;
    border-radius: 6px;
    font-size: 1.1em;
    box-sizing: border-box;
    transition: border-color 0.3s ease, box-shadow 0.3s ease;
}

.search-inputs input[type="text"]:focus {
    border-color: #409eff;
    box-shadow: 0 0 0 3px rgba(64, 158, 255, 0.2); 
    outline: none;
}

/* 清空按钮样式 */
#clearFiltersButton {
    display: block; /* 让按钮独占一行 */
    width: auto; /* 宽度自适应内容 */
    padding: 10px 20px;
    margin: 20px auto 30px auto; /* 居中显示，并提供上下间距 */
    background-color: #f44336; /* 显眼的红色 */
    color: white;
    border: none;
    border-radius: 6px;
    font-size: 1.1em;
    cursor: pointer;
    transition: background-color 0.3s ease, transform 0.1s ease;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
}

#clearFiltersButton:hover {
    background-color: #d32f2f; /* 悬停时颜色变深 */
    transform: translateY(-1px); /* 轻微上浮效果 */
}

#clearFiltersButton:active {
    background-color: #c62828; /* 点击时颜色更深 */
    transform: translateY(0); /* 按下效果 */
}

/* 结果显示区域样式 */
#results {
    margin-top: 20px;
}

/* 表格基本样式 */
table {
    width: 100%; /* 表格宽度占满其父容器 */
    border-collapse: collapse; /* 合并单元格边框 */
    margin-top: 20px;
    background-color: #fff;
    min-width: fit-content; /* 让表格根据其内容宽度自适应最小宽度 */
}

/* 表头样式 */
th {
    background-color: rgba(0, 0, 0, 0.8); /* 将背景色设置为 80% 的黑色 */
    color: #ffffff; /* 确保文字是白色以便清晰显示 */
    font-weight: bold;
    padding: 12px 15px;
    text-align: left; /* 默认左对齐，将被下方特定样式覆盖 */
    border-bottom: 2px solid #e0e6ea; /* 表头底边线 */
    white-space: nowrap; /* 防止表头文字换行 */
}

/* 设置标题行前三列文字居中 */
table th:nth-child(1), /* 医院列的标题 */
table th:nth-child(2), /* 科室列的标题 */
table th:nth-child(3) { /* 医生列的标题 */
    text-align: center; /* 文字居中 */
}

/* 表格单元格样式 */
td {
    padding: 10px 15px;
    border-bottom: 1px solid #eee; /* 单元格底边线 */
    vertical-align: top; /* 内容顶部对齐 */
}

/* 间隔行背景填充粉色 */
tbody tr:nth-child(odd) {
    background-color: #ffe0f0; /* 柔和的粉色 */
}

/* 偶数行背景设置为白色 */
tbody tr:nth-child(even) {
    background-color: #ffffff;
}

/* 鼠标悬停时行背景变为大红色 */
tbody tr:hover {
    background-color: #ff0000 !important; /* 大红色 */
    color: #ffffff; /* 悬停时文字变为白色，增加对比度 */
    transition: background-color 0.2s ease, color 0.2s ease; /* 平滑过渡效果 */
}

/* 前三列默认宽度 80 像素，超出的内容换行显示 */
table th:nth-child(1),
table td:nth-child(1), /* 医院列 */
table th:nth-child(2),
table td:nth-child(2), /* 科室列 */
table th:nth-child(3),
table td:nth-child(3) { /* 医生列 */
    width: 80px; /* 设置固定宽度 */
    min-width: 80px; /* 确保最小宽度也是80px */
    white-space: normal; /* 允许内容换行 */
    word-wrap: break-word; /* 长单词或URL在需要时可以断开 */
}

/* 擅长列优化：分配更多宽度，使其可以自动伸缩 */
table th:nth-child(4),
table td:nth-child(4) { /* 擅长列 */
    width: auto; /* 允许自动伸缩，占用剩余空间 */
    min-width: 150px; /* 确保它至少有150px的宽度，避免过窄 */
    white-space: normal; /* 允许内容正常换行 */
    word-wrap: break-word;
}

/* 列与列之间的虚线 */
table th:not(:last-child),
table td:not(:last-child) {
    border-right: 1px dashed #cccccc; /* 虚线颜色可以根据喜好调整 */
}

/* 没有结果时的提示信息 */
p.no-results {
    text-align: center;
    color: #888;
    padding: 40px 0;
    font-size: 1.1em;
    background-color: #fafafa;
    border-radius: 6px;
    border: 1px dashed #e0e0e0;
}

/* 响应式设计：小屏幕优化 */
@media (max-width: 768px) {
    /* 核心优化：页面铺满屏幕，不留空白 */
    body {
        padding: 0; /* 移除body的内边距 */
    }

    .container {
        margin: 0; /* 移除容器的外边距 */
        padding: 15px; /* 保持容器内部内容与边缘的适当内边距 */
        max-width: 100%; /* 确保容器在小屏幕上宽度可以达到100% */
        border-radius: 0; /* 移除圆角，让边缘更硬朗，填充更满 */
        box-shadow: none; /* 移除阴影，如果想要更纯粹的铺满效果 */
    }

    h1 {
        font-size: 1.6em; /* 手机上标题字体小一点 */
        margin-bottom: 20px;
    }

    .filters {
        gap: 15px; /* 手机上筛选器间距小一点 */
        margin-bottom: 20px;
    }

    .filter-group label {
        font-size: 0.9em;
    }

    .filter-group select {
        font-size: 0.9em;
        padding: 6px 10px;
    }

    .search-inputs { /* 在小屏幕上垂直排列搜索框 */
        flex-direction: column; 
        gap: 10px;
    }

    .search-inputs input[type="text"] {
        width: 100%; /* 手机上搜索框宽度占满 */
        min-width: auto; /* 移除最小宽度限制，让其自适应 */
        font-size: 1em;
        padding: 10px 8px;
    }

    #clearFiltersButton {
        width: 100%; /* 在小屏幕上，按钮宽度占满 */
        margin: 15px 0 25px 0; /* 调整间距 */
        font-size: 1em;
        padding: 10px 15px;
    }

    /* 在小屏幕上，让表格父容器强制横向滚动 */
    #results {
        overflow-x: auto; /* 确保表格在小屏幕上可以滚动 */
        -webkit-overflow-scrolling: touch; /* 改善移动端滚动体验 */
    }

    /* 确保表格在小屏幕上也能占满可用宽度 */
    table {
        width: fit-content;
        min-width: 100%; /* 确保表格至少占满父容器的宽度 */
    }

    /* 小屏幕下前三列的宽度调整 */
    table th:nth-child(1),
    table td:nth-child(1), /* 医院列 */
    table th:nth-child(2),
    table td:nth-child(2), /* 科室列 */
    table th:nth-child(3),
    table td:nth-child(3) { /* 医生列 */
        width: 65px; /* 进一步缩小列宽，例如 65px */
        min-width: 65px; /* 保持最小宽度与设置宽度一致 */
    }

    /* 小屏幕下，擅长列的最小宽度可以再调整，确保它有足够空间 */
    table th:nth-child(4),
    table td:nth-child(4) { /* 擅长列 */
        min-width: 120px; /* 可以在小屏幕上稍微减小，或者保持 */
    }
}

/* 更小的屏幕优化，比如宽度小于480px的设备 */
@media (max-width: 480px) {
    .filters {
        flex-direction: column; /* 筛选器在极小屏幕上垂直排列 */
        align-items: flex-start;
        gap: 10px;
    }

    .filter-group {
        width: 100%; /* 筛选组宽度占满 */
        justify-content: space-between; /* 标签和选择框左右对齐 */
    }
    .filter-group select {
        flex-grow: 1; /* 选择框可以扩展 */
    }

    /* 在更小的屏幕上，可以考虑进一步缩小列宽，以便更好地适应 */
    table th:nth-child(1),
    table td:nth-child(1),
    table th:nth-child(2),
    table td:nth-child(2),
    table th:nth-child(3),
    table td:nth-child(3) {
        width: 32px; /* 进一步缩小，例如 55px */
        min-width: 32px;
    }
    table th:nth-child(4),
    table td:nth-child(4) {
        min-width: 100px; /* 擅长列也稍微缩小 */
    }
}