/* ==========================================================================
   辉哥工具合集 - 共享样式（设计系统）
   ========================================================================== */

/* ---------- 1. 设计变量 ---------- */
:root {
    --brand-1: #667eea;
    --brand-2: #764ba2;
    --brand-grad: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    --green-1: #16a085;
    --green-2: #1abc9c;
    --ink: #1f2933;
    --ink-2: #2c3e50;
    --muted: #647181;
    --line: #e3e8ef;
    --line-strong: #d8dee9;
    --bg: #f4f6fb;
    --panel: #ffffff;
    --radius-lg: 18px;
    --radius: 12px;
    --radius-sm: 8px;
    --shadow-1: 0 1px 3px rgba(20, 40, 70, .08), 0 1px 2px rgba(20, 40, 70, .06);
    --shadow-2: 0 6px 24px rgba(20, 40, 70, .10);
    --shadow-brand: 0 10px 30px rgba(102, 126, 234, .30);
    --font: 'Microsoft YaHei', 'PingFang SC', 'Segoe UI', Roboto, Helvetica, Arial, sans-serif;
    --mono: 'Cascadia Mono', Consolas, 'Courier New', monospace;
}

/* ---------- 2. 基础重置 ---------- */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

html {
    -webkit-text-size-adjust: 100%;
}

body {
    font-family: var(--font);
    color: var(--ink);
    background: linear-gradient(160deg, #eef2ff 0%, #f7f8fc 45%, #eef6ff 100%);
    background-attachment: fixed;
    min-height: 100vh;
    padding: 24px 16px;
    line-height: 1.6;
}

a {
    color: var(--brand-1);
}

/* ---------- 3. 布局外壳 ---------- */
.container {
    max-width: 1120px;
    margin: 0 auto;
    background: var(--panel);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-2);
    padding: 28px;
}

.container.narrow { max-width: 560px; }
.container.mid    { max-width: 900px; }
.container.wide   { max-width: 1400px; }
.container.plain  {
    max-width: 1400px;
    background: transparent;
    box-shadow: none;
    padding: 0;
}

/* 页头：返回 + 标题 */
.page-head {
    display: flex;
    align-items: center;
    gap: 14px;
    flex-wrap: wrap;
    margin-bottom: 22px;
    padding-bottom: 16px;
    border-bottom: 1px solid var(--line);
}

.back-link {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 8px 14px;
    border-radius: 999px;
    background: #eef1fb;
    color: var(--brand-1);
    text-decoration: none;
    font-size: 14px;
    font-weight: 600;
    white-space: nowrap;
    transition: background .2s, color .2s;
}

.back-link:hover {
    background: var(--brand-1);
    color: #fff;
}

.page-title {
    font-size: 1.6em;
    color: var(--ink-2);
    font-weight: 700;
    line-height: 1.3;
}

.page-sub {
    color: var(--muted);
    font-size: .95em;
    width: 100%;
}

.title-center {
    text-align: center;
    color: var(--ink-2);
    margin-bottom: 20px;
}

/* ---------- 4. 头部 / 欢迎区（首页） ---------- */
.header {
    text-align: center;
    margin-bottom: 26px;
}

.header h1 {
    color: var(--ink-2);
    font-size: 2.2em;
    margin-bottom: 8px;
}

.header p {
    color: var(--muted);
    font-size: 1.05em;
}

.welcome-section {
    background: var(--brand-grad);
    color: #fff;
    padding: 28px 40px;
    border-radius: 20px;
    margin-bottom: 20px;
    box-shadow: var(--shadow-brand);
    display: flex;
    align-items: center;
    justify-content: space-between;
    flex-wrap: wrap;
    gap: 18px;
}

.welcome-section h1 { font-size: 2em; margin-bottom: 6px; }
.welcome-section p { font-size: 1.05em; opacity: .95; }

.stats {
    display: flex;
    align-items: center;
    gap: 28px;
}

.stat-item { text-align: center; }
.stat-number { font-size: 1.5em; font-weight: 700; display: block; }
.stat-label { font-size: .8em; opacity: .9; }

/* ---------- 5. 工具卡片网格（首页） ---------- */
.tools-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(320px, 1fr));
    gap: 22px;
    margin-top: 24px;
}

.tool-card {
    background: var(--panel);
    border-radius: var(--radius);
    padding: 24px;
    box-shadow: var(--shadow-1);
    transition: transform .25s ease, box-shadow .25s ease;
    border-left: 4px solid var(--brand-1);
    display: flex;
    flex-direction: column;
}

.tool-card:hover {
    transform: translateY(-6px);
    box-shadow: 0 14px 34px rgba(0, 0, 0, .13);
}

.tool-card h3 {
    color: var(--ink-2);
    margin-bottom: 10px;
    font-size: 1.35em;
    display: flex;
    align-items: center;
    gap: 10px;
}

.tool-card p {
    color: var(--muted);
    margin-bottom: 20px;
    line-height: 1.6;
    font-size: .95em;
    flex: 1 1 auto;
}

.category-title {
    color: var(--ink-2);
    margin: 44px 0 8px;
    padding-bottom: 12px;
    border-bottom: 3px solid var(--brand-1);
    font-size: 1.5em;
}

.footer {
    text-align: center;
    margin-top: 56px;
    padding: 28px;
    color: var(--muted);
    font-size: .9em;
    border-top: 1px solid var(--line);
}

.footer a { color: var(--brand-1); text-decoration: none; }
.footer a:hover { text-decoration: underline; }

/* ---------- 6. 按钮 ---------- */
.btn {
    padding: 12px 22px;
    border: none;
    border-radius: var(--radius-sm);
    font-size: 16px;
    font-weight: 600;
    font-family: inherit;
    cursor: pointer;
    transition: all .22s ease;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    text-decoration: none;
    line-height: 1.2;
}

.btn:disabled { opacity: .55; cursor: not-allowed; }

.btn-primary {
    background: var(--brand-grad);
    color: #fff;
}
.btn-primary:hover { transform: translateY(-2px); box-shadow: var(--shadow-brand); }

.btn-secondary { background: #6c757d; color: #fff; }
.btn-secondary:hover { background: #5a6268; }

.btn-success { background: #28a745; color: #fff; }
.btn-success:hover { background: #218838; }

.btn-warning { background: #ffc107; color: #212529; }
.btn-warning:hover { background: #e0a800; }

.btn-danger { background: #dc3545; color: #fff; }
.btn-danger:hover { background: #c82333; }

.btn-download { background: linear-gradient(135deg, var(--green-1) 0%, var(--green-2) 100%); color: #fff; }
.btn-download:hover { filter: brightness(1.06); transform: translateY(-2px); }

/* 产品介绍（详情页入口） */
.btn-showcase {
    background: linear-gradient(135deg, #8e44ad 0%, #5b21b6 100%);
    color: #fff;
    margin-top: 10px;
}
.btn-showcase:hover { filter: brightness(1.08); transform: translateY(-2px); box-shadow: 0 10px 24px rgba(142, 68, 173, .32); }

.btn-sm {
    padding: 8px 12px;
    font-size: 14px;
    min-height: 36px;
    font-weight: 500;
}

.btn-block { width: 100%; }

.btn-group { display: flex; gap: 10px; }
.btn-group .btn { flex: 1; }

.tool-card > .btn { width: 100%; }

/* ---------- 7. 表单控件 ---------- */
label {
    display: block;
    margin: 12px 0 5px;
    color: #44515f;
    font-size: 14px;
    font-weight: 500;
}

input[type="number"],
input[type="text"],
input[type="password"],
input[type="search"],
select,
textarea {
    width: 100%;
    padding: 11px 13px;
    border: 1.5px solid var(--line-strong);
    border-radius: 10px;
    font-size: 15px;
    font-family: inherit;
    color: var(--ink);
    background: #fff;
    transition: border-color .2s, box-shadow .2s;
}

input:focus,
select:focus,
textarea:focus {
    outline: none;
    border-color: var(--brand-1);
    box-shadow: 0 0 0 3px rgba(102, 126, 234, .15);
}

input[readonly] {
    background: #f1f3f8;
    color: #44515f;
}

input[type="radio"],
input[type="checkbox"] {
    width: auto;
    accent-color: var(--brand-1);
}

textarea {
    resize: vertical;
    min-height: 120px;
    line-height: 1.6;
}

.search-area {
    display: flex;
    gap: 10px;
    margin-bottom: 18px;
    flex-wrap: wrap;
    align-items: center;
}

.search-area .btn { flex: 0 0 auto; }

.search-input { flex: 1 1 240px; }

.textarea-input {
    width: 100%;
    min-height: 110px;
    margin-bottom: 14px;
    font-size: 15px;
}

/* 表单区块（工具页两栏） */
.form-section {
    flex: 1 1 320px;
    min-width: 280px;
    padding: 4px 10px 12px;
}

.form-grid {
    display: flex;
    flex-wrap: wrap;
    gap: 8px 24px;
}

.groupbox {
    background: var(--brand-grad);
    color: #fff;
    padding: 10px 14px;
    border-radius: var(--radius-sm);
    margin: 4px 0 12px;
    text-align: center;
    font-weight: 600;
    letter-spacing: .5px;
}

/* ---------- 8. 表格 ---------- */
.table-container {
    overflow-x: auto;
    margin-top: 18px;
    -webkit-overflow-scrolling: touch;
    border-radius: var(--radius-sm);
}

table {
    width: 100%;
    border-collapse: collapse;
}

th, td {
    padding: 10px 13px;
    text-align: left;
    border-bottom: 1px solid var(--line);
    vertical-align: top;
}

th {
    background: var(--brand-grad);
    color: #fff;
    font-weight: 600;
    position: sticky;
    top: 0;
    white-space: nowrap;
    z-index: 1;
}

tbody tr:hover { background: #f6f8fd; }
tbody tr:nth-child(even) { background: #fafbfe; }
tbody tr:nth-child(even):hover { background: #eef2fb; }

.cas-number {
    font-family: var(--mono);
    font-weight: 600;
    color: #2b3a55;
    letter-spacing: .3px;
}

/* 查询结果表：操作列按钮始终横向排列，名称列可压缩换行 */
#localResultTable th:last-child,
#localResultTable td:last-child,
#onlineResultTable th:last-child,
#onlineResultTable td:last-child,
#ichemistryResultTable th:last-child,
#ichemistryResultTable td:last-child {
    white-space: nowrap;
    width: 1%;
}

#onlineResultTable td:nth-child(3),
#onlineResultTable td:nth-child(4),
#ichemistryResultTable td:nth-child(3),
#ichemistryResultTable td:nth-child(4),
#localResultTable td:nth-child(1),
#localResultTable td:nth-child(3) {
    overflow-wrap: anywhere;
    word-break: break-word;
    max-width: 240px;
}

/* ---------- 9. 标签页 ---------- */
.tabs {
    display: flex;
    gap: 4px;
    border-bottom: 2px solid var(--line);
    margin-bottom: 20px;
    flex-wrap: wrap;
}

.tab {
    padding: 12px 20px;
    cursor: pointer;
    font-size: 15px;
    font-weight: 600;
    color: var(--muted);
    border: none;
    background: none;
    font-family: inherit;
    border-bottom: 3px solid transparent;
    margin-bottom: -2px;
    transition: color .2s, border-color .2s;
}

.tab:hover { color: var(--brand-1); }

.tab.active {
    color: var(--brand-1);
    border-bottom-color: var(--brand-1);
}

.tab-content { display: none; }
.tab-content.active { display: block; }

/* ---------- 10. 状态提示 ---------- */
.status-text {
    padding: 11px 15px;
    border-radius: 10px;
    margin-bottom: 15px;
    font-weight: 600;
    font-size: 14px;
}

.status-success { background: #d4edda; color: #155724; border: 1px solid #c3e6cb; }
.status-error   { background: #f8d7da; color: #721c24; border: 1px solid #f5c6cb; }
.status-warning { background: #fff3cd; color: #856404; border: 1px solid #ffeaa7; }
.status-info    { background: #d1ecf1; color: #0c5460; border: 1px solid #bee5eb; }

/* ---------- 11. 物性面板 ---------- */
.properties-panel {
    background: #fff;
    border-radius: var(--radius);
    padding: 20px;
    margin-top: 20px;
    box-shadow: var(--shadow-1);
    border-left: 4px solid var(--brand-1);
}

.properties-panel h3 {
    color: var(--ink-2);
    margin-bottom: 15px;
    padding-bottom: 10px;
    border-bottom: 2px solid var(--brand-1);
}

.properties-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
    gap: 14px;
}

.property-item {
    background: #fff;
    padding: 12px;
    border-radius: var(--radius-sm);
    border: 1px solid var(--line);
}

.property-label {
    font-weight: 700;
    color: var(--muted);
    font-size: .88em;
    margin-bottom: 4px;
}

.property-value {
    color: var(--ink);
    word-break: break-word;
}

.ichemistry-property-item {
    display: flex;
    align-items: flex-start;
    padding: 12px 15px;
    border-bottom: 1px solid #f0f0f0;
    transition: background-color .2s;
}
.ichemistry-property-item:hover { background-color: #f8f9fa; }
.ichemistry-property-item:last-of-type { border-bottom: none; }
.ichemistry-property-icon { font-size: 24px; margin-right: 15px; min-width: 35px; text-align: center; }
.ichemistry-property-info { flex: 1; min-width: 0; }
.ichemistry-property-label {
    font-size: 12px; color: #888; margin-bottom: 4px;
    text-transform: uppercase; letter-spacing: .5px;
}
.ichemistry-property-value { font-size: 15px; color: var(--ink); line-height: 1.5; word-break: break-word; }
.ichemistry-property-link {
    text-align: center; padding: 15px; margin-top: 10px;
    background: linear-gradient(135deg, #f5f7fa 0%, #e4e8ec 100%);
    border-radius: var(--radius-sm);
}
.ichemistry-property-link a { color: #1a73e8; text-decoration: none; font-size: 14px; font-weight: 500; }
.ichemistry-property-link a:hover { text-decoration: underline; }

/* ---------- 12. 结果展示 ---------- */
.result {
    margin-top: 18px;
    padding: 18px;
    border: 1px solid var(--line);
    border-radius: var(--radius);
    background: #fff;
    box-shadow: var(--shadow-1);
}

/* ---------- 13. 动画 / 提示 ---------- */
.tooltip { position: relative; display: inline-block; }
.tooltip .tooltiptext {
    visibility: hidden; width: 120px; background-color: #333; color: #fff;
    text-align: center; border-radius: 6px; padding: 5px; position: absolute;
    z-index: 20; bottom: 125%; left: 50%; margin-left: -60px; opacity: 0; transition: opacity .3s;
}
.tooltip:hover .tooltiptext { visibility: visible; opacity: 1; }

@keyframes fadeIn {
    from { opacity: 0; transform: translateY(16px); }
    to   { opacity: 1; transform: translateY(0); }
}
.fade-in { animation: fadeIn .45s ease-out; }

.loading {
    display: inline-block; width: 20px; height: 20px;
    border: 3px solid rgba(255, 255, 255, .3); border-radius: 50%;
    border-top-color: #fff; animation: spin 1s ease-in-out infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ---------- 14. 响应式 ---------- */
@media (max-width: 768px) {
    body { padding: 12px 10px; }

    .container { padding: 16px; border-radius: 14px; }

    .header h1, .page-title { font-size: 1.5em; }

    .welcome-section {
        flex-direction: column;
        text-align: center;
        padding: 22px 20px;
    }
    .welcome-section h1 { font-size: 1.7em; }
    .stats { gap: 20px; }

    .tools-grid { grid-template-columns: 1fr; gap: 16px; }

    .category-title { font-size: 1.25em; margin-top: 34px; }

    .search-area { flex-direction: column; align-items: stretch; }
    .search-area .btn { width: 100%; min-height: 44px; }

    .tabs { flex-wrap: nowrap; overflow-x: auto; -webkit-overflow-scrolling: touch; }
    .tab { flex: 0 0 auto; padding: 10px 14px; font-size: 14px; }

    .form-section { min-width: 100%; padding: 0; }
    .form-grid { gap: 0; }

    table { font-size: 14px; }
    th, td { padding: 8px 10px; }

    th:first-child, td:first-child {
        position: sticky;
        left: 0;
        z-index: 2;
    }
    th:first-child {
        z-index: 3;
        background: var(--brand-grad);
        color: #fff;
    }
    td:first-child { background: #fff; }
    tbody tr:nth-child(even) td:first-child { background: #fafbfe; }
    tbody tr:hover td:first-child { background: #f6f8fd; }

    .btn-sm { min-width: 44px; min-height: 44px; }

    .properties-grid { grid-template-columns: 1fr; }
    .properties-panel { padding: 15px; }

    .status-text, label { font-size: 14px; }

    .page-head { gap: 10px; }
}

@media (max-width: 420px) {
    .stat-number { font-size: 1.25em; }
    .btn { font-size: 15px; padding: 11px 16px; }
}
