/* base-converter-tool.css */

/* ============================== */
/* 通用页面布局和返回按钮样式 */
/* ============================== */
.tool-page-main {
    display: flex;
    flex-direction: column; /* 垂直堆叠子元素 */
    align-items: center; /* 水平居中所有子元素 */
    padding: 20px;
    background-color: #f0f2f5; /* 添加背景色以匹配之前的设计 */
    min-height: calc(100vh - var(--header-height) - var(--footer-height, 50px)); /* 确保内容区高度足够 */
    box-sizing: border-box;
}

.back-to-home {
    max-width: 800px; /* 调整为与新的工具容器宽度一致 */
    width: 100%;
    margin-bottom: 25px; /* 与下方工具容器的间距 */
    margin-left: auto;
    margin-right: auto;
    text-align: left; /* 返回按钮靠左 */
    padding: 0 20px; /* 内部边距，使内容不紧贴边缘 */
    box-sizing: border-box; /* 确保内边距不增加总宽度 */
}

.back-btn {
    display: inline-flex;
    align-items: center;
    background-color: #6c757d; /* 灰色背景 */
    color: #fff;
    padding: 10px 18px;
    border-radius: 8px;
    text-decoration: none; /* 移除下划线 */
    font-weight: bold;
    font-size: 1em;
    transition: background-color 0.3s ease, transform 0.2s ease; /* 过渡效果 */
    border: none;
    cursor: pointer;
    box-shadow: 0 2px 5px rgba(0, 0, 0, 0.1);
}

.back-btn:hover {
    background-color: #5a6268; /* 悬停时颜色变深 */
    transform: translateY(-2px); /* 悬停时上浮效果 */
}

.back-btn i {
    margin-right: 8px; /* 图标与文本间距 */
    font-size: 1.1em;
}

/* ============================== */
/* 进制转换器工具容器样式 */
/* ============================== */
.base-converter-tool-container {
    background-color: #ffffff; /* 白色背景 */
    padding: 30px;
    border-radius: 12px;
    box-shadow: 0 6px 20px rgba(0, 0, 0, 0.15); /* 阴影效果 */
    max-width: 800px; /* 调整为新的工具容器的最大宽度 */
    width: 100%; /* 确保在小屏幕上也能占据可用宽度 */
    text-align: center; /* 内部文本及行内块元素居中 */
    margin: 0 auto; /* 容器自身居中 */
    box-sizing: border-box;
    display: flex; /* 使用 Flexbox 布局内部元素 */
    flex-direction: column; /* 垂直堆叠 */
    gap: 20px; /* 元素之间的间距 */
}


/* ============================== */
/* 源进制选择区域样式 (新布局) */
/* ============================== */
.source-base-selector-group {
    display: flex;
    flex-wrap: wrap; /* 允许在小屏幕上换行 */
    align-items: center;
    justify-content: space-between; /* 元素之间均匀分布 */
    gap: 15px;
    padding-bottom: 15px;
    border-bottom: 1px solid #eee; /* 底部细线分隔 */
}

.radio-bases {
    display: flex;
    flex-wrap: wrap;
    gap: 15px;
    align-items: center;
}

.radio-bases label {
    font-size: 1em;
    color: #34495e;
    cursor: pointer;
    display: flex;
    align-items: center;
}

.radio-bases input[type="radio"] {
    margin-right: 5px;
    accent-color: #007bff; /* 设置单选按钮的强调色 */
}

.more-bases-select {
    display: flex;
    align-items: center;
    gap: 5px;
}

.more-bases-select label {
    font-weight: bold;
    color: #34495e;
}

#moreFromBase {
    padding: 8px 12px;
    border: 1px solid #ced4da;
    border-radius: 5px;
    font-size: 1em;
    color: #495057;
    transition: border-color 0.3s ease, box-shadow 0.3s ease;
    /* 移除浏览器默认样式，并添加自定义下拉箭头 */
    appearance: none;
    -webkit-appearance: none;
    -moz-appearance: none;
    background-image: url('data:image/svg+xml;charset=US-ASCII,%3Csvg%20xmlns%3D%22http%3A%2F%2Fwww.w3.org%2F2000%2Fsvg%22%20width%3D%22292.4%22%20height%3D%22292.4%22%3E%3Cpath%20fill%3D%22%23007bff%22%20d%3D%22M287%2069.9a14.7%2014.7%200%200%200-14.7%200L146.2%20196.4%2020.2%2069.9A14.7%2014.7%200%200%200%200%2084.7l146.2%20146.2a14.7%2014.7%200%200%200%2021%200L287%2084.7A14.7%2014.7%200%200%200%20287%2069.9z%22%2F%3E%3C%2Fsvg%3E');
    background-repeat: no-repeat;
    background-position: right 10px center;
    background-size: 12px auto;
    padding-right: 30px; /* 为自定义箭头留出空间 */
}
#moreFromBase:focus {
    border-color: #007bff;
    box-shadow: 0 0 0 0.2rem rgba(0, 123, 255, 0.25);
    outline: none;
}

.input-value-wrapper {
    display: flex;
    align-items: center;
    gap: 10px;
    flex-grow: 1; /* 允许输入框和按钮占据更多空间 */
    justify-content: flex-end; /* 将内容推向右侧 */
    min-width: 200px; /* 最小宽度，防止过小 */
}

#inputValue {
    padding: 10px 15px;
    border: 1px solid #ced4da;
    border-radius: 5px;
    font-size: 1.1em;
    color: #34495e;
    flex-grow: 1; /* 允许输入框填满可用空间 */
    max-width: 200px; /* 限制输入框的最大宽度 */
    box-sizing: border-box; /* 包含内边距和边框在总宽度内 */
}
#inputValue:focus {
    border-color: #007bff;
    box-shadow: 0 0 0 0.2rem rgba(0, 123, 255, 0.25);
    outline: none;
}

.convert-btn {
    padding: 10px 20px;
    background-color: #007bff;
    color: white;
    border: none;
    border-radius: 5px;
    cursor: pointer;
    font-size: 1.1em;
    transition: background-color 0.3s ease, transform 0.2s ease;
    box-shadow: 0 2px 5px rgba(0, 123, 255, 0.2);
}
.convert-btn:hover {
    background-color: #0056b3;
    transform: translateY(-1px);
}
.convert-btn:active {
    transform: translateY(0);
    box-shadow: none;
}


/* ============================== */
/* 转换结果表格样式 (新布局) */
/* ============================== */
.conversion-table-container {
    width: 100%;
    max-height: 500px; /* 限制表格最大高度，出现滚动条 */
    overflow-y: auto; /* 允许垂直滚动 */
    border: 1px solid #e9ecef;
    border-radius: 8px;
    box-shadow: inset 0 1px 3px rgba(0,0,0,0.05); /* 内部阴影 */
}

.conversion-results-table {
    width: 100%;
    border-collapse: collapse; /* 移除单元格之间的间距 */
    text-align: left;
    font-family: 'Consolas', 'Monaco', monospace; /* 等宽字体更适合显示代码和数字 */
    font-size: 0.95em;
}

.conversion-results-table thead {
    background-color: #e9ecef;
    position: sticky; /* 表头在滚动时保持固定 */
    top: 0;
    z-index: 10; /* 确保表头在滚动内容之上 */
}

.conversion-results-table th {
    padding: 12px 15px;
    border-bottom: 1px solid #dee2e6;
    color: #34495e;
    font-weight: bold;
}

.conversion-results-table tbody tr {
    transition: background-color 0.2s ease; /* 行背景色过渡效果 */
}

.conversion-results-table tbody tr:nth-child(even) {
    background-color: #f8f9fa; /* 斑马条纹效果 */
}

.conversion-results-table tbody tr:hover {
    background-color: #f0f0f0; /* 鼠标悬停效果 */
}

.conversion-results-table td {
    padding: 10px 15px;
    border-bottom: 1px solid #dee2e6;
    color: #495057;
    vertical-align: top; /* 垂直对齐到顶部，适用于长解释文本 */
}

.conversion-results-table tr.placeholder-row td {
    text-align: center;
    font-style: italic;
    color: #6c757d;
    padding: 20px;
}

.result-input-field {
    width: 100%;
    padding: 8px 10px;
    border: 1px solid #ced4da;
    border-radius: 4px;
    background-color: #fff;
    font-family: 'Consolas', 'Monaco', monospace;
    font-size: 0.95em;
    color: #34495e;
    box-sizing: border-box; /* 包含内边距和边框 */
    -webkit-user-select: all; /* 允许用户点击选择全部内容 */
    -moz-user-select: all;
    user-select: all;
    cursor: text; /* 鼠标变为文本选择光标 */
}

/* 高亮显示行 */
.conversion-results-table tr.source-base-row {
    background-color: #e6f7ff; /* 源进制行背景色 */
    font-weight: bold;
}

.conversion-results-table tr.common-base-row {
    background-color: #f2f7ff; /* 其他常用进制（非源进制）的背景色 */
}

.conversion-results-table tr.error-message td {
    color: #dc3545; /* 错误信息文字颜色 */
    font-weight: bold;
    text-align: center;
    background-color: #f8d7da; /* 浅红色背景 */
    padding: 15px;
}


/* ============================== */
/* 按钮组 */
/* ============================== */
.button-group {
    display: flex;
    flex-wrap: wrap; /* 允许按钮在小屏幕上换行 */
    justify-content: center;
    gap: 15px; /* 按钮间距 */
    margin-top: 10px; /* 稍作调整 */
    margin-bottom: 10px; /* 稍作调整 */
}

/* 清空按钮样式 (采用类似警告的黄色) */
.clear-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 12px 25px;
    border-radius: 25px; /* 更圆的按钮 */
    font-size: 1.05em;
    font-weight: bold;
    cursor: pointer;
    border: none;
    transition: background-color 0.3s ease, transform 0.2s ease, box-shadow 0.3s ease;
    text-decoration: none;
    color: #fff;
    min-width: 120px;
    background-color: #ffc107; /* 警告黄色 */
    box-shadow: 0 4px 10px rgba(0,0,0,0.1);
}

.clear-btn:hover {
    background-color: #e0a800; /* 悬停时颜色变深 */
    transform: translateY(-2px);
    box-shadow: 0 6px 15px rgba(0,0,0,0.2);
}

.clear-btn i {
    margin-right: 8px;
    font-size: 1.1em;
}


/* ============================== */
/* 响应式调整 */
/* ============================== */
@media (max-width: 768px) {
    .base-converter-tool-container {
        padding: 20px;
    }

    /* 源进制选择区域的响应式调整 */
    .source-base-selector-group {
        flex-direction: column;
        align-items: flex-start;
        gap: 10px;
    }

    .radio-bases {
        justify-content: flex-start;
        width: 100%;
    }

    .more-bases-select {
        width: 100%;
        justify-content: flex-start;
    }
    #moreFromBase {
        flex-grow: 1; /* 让下拉菜单在小屏幕上填满宽度 */
    }

    .input-value-wrapper {
        flex-direction: column;
        align-items: stretch; /* 让输入框和按钮拉伸 */
        width: 100%;
        justify-content: center;
        gap: 10px;
    }

    #inputValue {
        width: 100%;
        max-width: none; /* 移除最大宽度限制 */
    }

    .convert-btn {
        width: 100%;
    }

    /* 针对小屏幕上的表格样式 */
    .conversion-results-table thead {
        display: none; /* 小屏幕上隐藏表头 */
    }

    .conversion-results-table td {
        display: block; /* 使单元格垂直堆叠 */
        width: 100%;
        box-sizing: border-box;
        border-bottom: none; /* 移除堆叠单元格间的水平边框 */
        padding: 8px 15px; /* 调整填充 */
    }

    .conversion-results-table td:before {
        content: attr(data-label); /* 在单元格内容前显示列名作为标签 */
        font-weight: bold;
        display: inline-block;
        width: 60px; /* 调整标签的宽度 */
        margin-right: 10px;
        color: #666;
    }

    .conversion-results-table tr {
        border-bottom: 1px solid #dee2e6; /* 每行之间添加边框 */
        margin-bottom: 10px;
        display: block;
        padding-bottom: 10px;
    }
    .conversion-results-table tr:last-child {
        border-bottom: none; /* 最后一行没有底部边框 */
    }

    .conversion-results-table tr.placeholder-row td,
    .conversion-results-table tr.error-message td {
        display: table-cell; /* 确保占位符和错误信息仍能完整显示 */
        width: auto;
        text-align: center;
    }

    .conversion-results-table td:first-child {
        border-bottom: 1px dashed #e9ecef; /* “进制”和“结果”之间添加虚线分隔 */
    }

    .result-input-field {
        margin-top: 5px; /* 标签和输入框之间增加间距 */
    }

    /* 堆叠单元格的背景和边框高亮 */
    .conversion-results-table tr.source-base-row td,
    .conversion-results-table tr.common-base-row td {
        background-color: inherit; /* 重置单个单元格背景，让行背景生效 */
    }
    .conversion-results-table tr.source-base-row {
        background-color: #e6f7ff; /* 应用背景到整个行 */
        border-left: 5px solid #007bff;
        padding-left: 15px;
        margin-left: -20px; /* 调整以适应容器边距 */
        width: calc(100% + 40px); /* 调整宽度以覆盖全宽 */
        box-sizing: border-box;
    }
    .conversion-results-table tr.common-base-row {
        background-color: #f2f7ff;
    }

    /* 按钮组的响应式调整 */
    .button-group {
        flex-direction: column; /* 按钮垂直堆叠 */
        align-items: center; /* 按钮居中 */
    }

    .button-group button {
        width: 100%; /* 按钮宽度铺满 */
        max-width: 250px; /* 限制按钮的最大宽度 */
    }
}