/* ==========================================================================
   Gene Synthesis Design Tool —— 样式（genesyn.html）

   结构：基础 → 顶部 → 步骤条 → 主体 → 表格 → 按钮 → 卡片 →
         页脚 → 弹层 → 窄屏

   配色与尺度全部来自 tokens.css（与后台同一套品牌色）。
   ========================================================================== */

@import url("tokens.css");

/* ---------------------------------------------------------------- 基础 */

*,
*::before,
*::after {
    box-sizing: border-box;
}

body {
    margin: 0;
    padding: 0;
    background-color: var(--canvas);
    color: var(--ink);
    font-family: var(--font-ui);
    font-size: 14px;
    line-height: 1.55;
    -webkit-font-smoothing: antialiased;
}

a {
    color: var(--brand);
    text-decoration: none;
}

a:hover {
    color: var(--brand-dark);
}

::selection {
    background: var(--brand-tint);
    color: var(--brand-dark);
}

/* ---------------------------------------------------------------- 顶部 */

.header {
    background: var(--surface);
    color: var(--ink);
    padding: 0;
    border-bottom: 1px solid var(--line);
    display: block;
}

.header-container {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
    padding: 12px 24px;
}

.brand-section {
    display: flex;
    align-items: center;
    gap: 12px;
    min-width: 0;
}

.logo-wrapper {
    display: flex;
    align-items: center;
}

.brand-logo {
    height: 34px;
    width: auto;
    display: block;
}

.brand-text {
    min-width: 0;
}

.brand-title {
    margin: 0;
    font-size: 20px;
    font-weight: 600;
    line-height: 1.3;
    color: var(--ink);
}

.brand-subtitle {
    margin: 2px 0 0;
    font-size: 12.5px;
    color: var(--ink-subtle);
    letter-spacing: 0.02em;
}

.header-actions {
    display: flex;
    align-items: center;
    gap: 10px;
}

.help-btn {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 8px 14px;
    background: var(--surface);
    color: var(--brand);
    border: 1px solid var(--brand-tint);
    border-radius: var(--radius-sm);
    font-size: 13px;
    font-weight: 600;
    cursor: pointer;
    transition: background-color 0.15s ease, border-color 0.15s ease;
}

.help-btn:hover {
    background: var(--brand-soft);
    border-color: var(--brand);
}

.help-btn svg {
    flex-shrink: 0;
}

.help-btn-link {
    color: inherit;
    text-decoration: none;
}

/* 旧版头部的零散元素（保留以免遗漏） */
.logo {
    display: flex;
    align-items: center;
}

.logo img {
    height: 30px;
    margin-right: 10px;
}

.user-actions {
    display: flex;
    align-items: center;
}

.user-actions a {
    color: var(--brand);
    margin-left: 15px;
    text-decoration: none;
}

.cart-icon {
    position: relative;
}

/* ---------------------------------------------------------------- 步骤条 */

.progress-nav {
    position: relative;
    padding: 22px 0 26px;
    background: var(--brand);
}

.progress-nav::before {
    display: none;
}

.nav-container {
    padding: 0 24px;
}

.progress-steps {
    display: flex;
    align-items: stretch;
    justify-content: center;
    gap: 18px;
    flex-wrap: wrap;
}

.step {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 14px 22px;
    background: rgb(255 255 255 / 10%);
    border: 1px solid rgb(255 255 255 / 28%);
    border-radius: var(--radius);
    transition: background-color 0.15s ease, border-color 0.15s ease;
}

.step.active {
    background: var(--surface);
    border-color: var(--surface);
    box-shadow: var(--shadow-md);
}

.step.active::before {
    display: none;
}

.step-icon {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 44px;
    height: 44px;
    border-radius: 50%;
    background: rgb(255 255 255 / 16%);
    color: #fff;
    flex-shrink: 0;
}

.step.active .step-icon {
    background: var(--brand-soft);
    color: var(--brand);
}

.step-content {
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.step-title {
    font-size: 15px;
    font-weight: 600;
    color: #fff;
}

.step.active .step-title {
    color: var(--brand);
}

.step-description {
    font-size: 11.5px;
    letter-spacing: 0.03em;
    color: rgb(255 255 255 / 76%);
}

.step.active .step-description {
    color: var(--ink-muted);
}

.step-connector {
    display: flex;
    align-items: center;
    gap: 6px;
}

.connector-line {
    width: 40px;
    height: 1px;
    background: rgb(255 255 255 / 35%);
}

.connector-arrow {
    color: rgb(255 255 255 / 55%);
}

.step.active+.step-connector .connector-arrow {
    color: #fff;
}

/* ---------------------------------------------------------------- 主体 */

.main-content {
    width: clamp(786px, 90%, 1600px);
    margin: 0 auto;
    padding: 24px;
    padding-bottom: 100px;
}

.page-title {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-bottom: 16px;
    font-size: 17px;
    font-weight: 600;
    color: var(--ink);
}

.page-title img {
    height: 24px;
}

.action-buttons {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    margin-bottom: 18px;
}

.service-options {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
}

.service-option {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 10px 14px;
    background: var(--surface);
    border: 1px solid var(--line);
    border-radius: var(--radius);
    cursor: pointer;
    transition: background-color 0.15s ease, border-color 0.15s ease;
}

.service-option:hover {
    background: var(--brand-soft);
    border-color: var(--brand-tint);
}

.service-option img {
    height: 20px;
}

/* ---------------------------------------------------------------- 表格 */

.table-scroll {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    border-radius: var(--radius);
    margin-bottom: 16px;
}

.table-scroll .gene-table {
    min-width: 780px;
    margin-bottom: 0;
}

.gene-table,
.cart-table {
    width: 100%;
    background: var(--surface);
    border: 1px solid var(--line);
    border-radius: var(--radius);
    overflow: hidden;
    box-shadow: none;
}

.gene-table th,
.cart-table th {
    padding: 10px 12px;
    text-align: left;
    vertical-align: middle;
    background: var(--surface-2);
    color: var(--ink-muted);
    font-size: 12.5px;
    font-weight: 600;
    white-space: nowrap;
    border-bottom: 1px solid var(--line);
}

.gene-table td,
.cart-table td {
    padding: 10px 12px;
    vertical-align: middle;
    border-bottom: 1px solid var(--line-soft);
}

.gene-table tbody tr:last-child td,
.cart-table tbody tr:last-child td {
    border-bottom: none;
}

.gene-table tbody tr:hover td,
.cart-table tbody tr:hover td {
    background: var(--brand-soft);
}

.gene-table input[type="text"],
.gene-table input[type="number"],
.gene-table select,
.codon-optimization-controls select,
.add-rows-control input[type="number"] {
    width: 100%;
    min-width: 120px;
    height: 30px;
    padding: 0 8px;
    color: var(--ink);
    background: var(--surface);
    border: 1px solid var(--line);
    border-radius: var(--radius-sm);
    font-size: 13px;
    transition: border-color 0.15s ease, box-shadow 0.15s ease;
}

.gene-table input[type="text"]:focus,
.gene-table input[type="number"]:focus,
.gene-table select:focus,
.codon-optimization-controls select:focus,
.add-rows-control input[type="number"]:focus {
    border-color: var(--brand);
    outline: none;
    box-shadow: 0 0 0 3px var(--ring);
}

.gene-table select {
    min-width: 140px;
    padding: 0 6px;
    font-size: 12.5px;
}

.gene-table input[type="checkbox"],
.cart-table input[type="checkbox"] {
    width: 16px;
    height: 16px;
    margin: 0;
    accent-color: var(--brand);
    cursor: pointer;
}

/* 序列输入用等宽，便于按碱基对齐 */
.gene-table input.sequence-input {
    font-family: var(--font-mono);
    font-size: 12.5px;
}

.gene-table input.sequence-input:focus {
    border-color: var(--brand);
    box-shadow: 0 0 0 3px var(--ring);
}

/* ---------------------------------------------------------------- 表格下方操作 */

.pagination {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: space-between;
    gap: 10px 16px;
    margin: 12px 0 24px;
    color: var(--ink-muted);
    font-size: 13px;
}

.pagination-controls {
    display: flex;
    align-items: center;
    gap: 6px;
}

.pagination-controls span {
    color: var(--ink-muted);
}

.table-actions {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 10px;
}

.table-controls {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 10px;
}

.add-rows-control {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    font-size: 13px;
    color: var(--ink);
}

.add-rows-control input[type="number"] {
    width: 70px;
}

.add-rows-control label {
    color: var(--ink);
    font-weight: 600;
}

/* ---------------------------------------------------------------- 按钮 */

.action-button {
    padding: 8px 15px;
    background: var(--surface);
    color: var(--ink);
    border: 1px solid var(--line);
    border-radius: var(--radius-sm);
    font-size: 13px;
    font-weight: 500;
    cursor: pointer;
    transition: background-color 0.15s ease, border-color 0.15s ease, color 0.15s ease;
}

.action-button:hover {
    background: var(--brand-soft);
    border-color: var(--brand-tint);
    color: var(--brand);
}

.action-button.active {
    background: var(--brand);
    border-color: var(--brand);
    color: #fff;
    font-weight: 600;
}

.action-button.active:hover {
    background: var(--brand-dark);
    border-color: var(--brand-dark);
}

.delete-button {
    padding: 8px 14px;
    background: var(--surface);
    color: var(--danger);
    border: 1px solid var(--danger-line);
    border-radius: var(--radius-sm);
    font-size: 13px;
    font-weight: 600;
    cursor: pointer;
    transition: background-color 0.15s ease, border-color 0.15s ease;
}

.delete-button:hover {
    background: var(--danger-bg);
    border-color: var(--danger);
    color: var(--danger);
}

.add-button {
    padding: 8px 16px;
    background: var(--brand);
    color: #fff;
    border: 1px solid var(--brand);
    border-radius: var(--radius-sm);
    font-size: 13px;
    font-weight: 600;
    cursor: pointer;
    transition: background-color 0.15s ease, border-color 0.15s ease;
}

.add-button:hover {
    background: var(--brand-dark);
    border-color: var(--brand-dark);
}

.footer button,
.continue-button-container button {
    padding: 9px 20px;
    background: var(--brand);
    color: #fff;
    border: 1px solid var(--brand);
    border-radius: var(--radius-sm);
    font-size: 13px;
    font-weight: 600;
    cursor: pointer;
    transition: background-color 0.15s ease, border-color 0.15s ease;
}

.footer button:hover,
.continue-button-container button:hover {
    background: var(--brand-dark);
    border-color: var(--brand-dark);
}

.continue-button-container {
    margin-top: 20px;
    text-align: center;
}

/* ---------------------------------------------------------------- 密码子优化 */

.codon-optimization-box {
    margin-bottom: 20px;
    padding: 20px;
    background: var(--surface);
    border: 1px solid var(--line);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-sm);
}

.codon-optimization-box h3 {
    margin: 0 0 14px;
    color: var(--brand);
    font-size: 17px;
    font-weight: 600;
}

.codon-optimization-controls {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 16px;
    margin-bottom: 12px;
}

.organism-select {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 13px;
}

.organism-select label {
    color: var(--ink);
    font-weight: 600;
    white-space: nowrap;
}

.organism-select select {
    min-width: 160px;
}

.optimization-status {
    margin-top: 12px;
    padding: 10px 12px;
    border-radius: var(--radius-sm);
    font-size: 13px;
    line-height: 1.6;
}

.optimization-status.success {
    background: var(--success-bg);
    border: 1px solid var(--success-line);
    color: var(--success);
}

.optimization-status.error {
    background: var(--danger-bg);
    border: 1px solid var(--danger-line);
    color: var(--danger);
}

.optimization-status.loading {
    background: var(--brand-soft);
    border: 1px solid var(--brand-tint);
    color: var(--brand);
}

/* 密码子优化后的序列单元：顶部分出一条标签带，标签不再压住序列文字 */
.gene-table td.optimized-sequence {
    position: relative;
    padding-top: 34px;
    background: var(--success-bg);
    box-shadow: inset 0 0 0 1px var(--success-line);
}

.gene-table td.optimized-sequence input.sequence-input {
    background: var(--surface);
    border-color: var(--success-line);
    font-family: var(--font-mono);
    font-size: 12.5px;
    letter-spacing: 0.02em;
}

.gene-table td.optimized-sequence::after {
    content: "✓ OPTIMIZED";
    position: absolute;
    top: 7px;
    left: 12px;
    padding: 2px 10px;
    border-radius: 999px;
    background: var(--surface);
    border: 1px solid var(--success-line);
    color: var(--success);
    font-family: var(--font-ui);
    font-size: 12px;
    font-weight: 600;
    letter-spacing: 0.05em;
    line-height: 1.6;
    box-shadow: var(--shadow-sm);
}

/* 行 hover 不要盖掉「已优化」的底色 */
.gene-table tbody tr:hover td.optimized-sequence {
    background: var(--success-bg);
}

/* ---------------------------------------------------------------- 上传序列 */

.upload-box {
    margin-bottom: 20px;
    padding: 20px;
    background: var(--surface);
    border: 1px solid var(--line);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-sm);
}

.upload-container {
    max-width: 600px;
    margin: 0 auto;
}

.upload-header {
    text-align: center;
    margin-bottom: 16px;
}

.upload-header h3 {
    margin: 0 0 6px;
    color: var(--brand);
    font-size: 17px;
    font-weight: 600;
}

.upload-header p {
    margin: 0;
    color: var(--ink-muted);
    font-size: 13px;
}

.upload-area {
    padding: 28px 20px;
    text-align: center;
    background: var(--surface-2);
    border: 1px dashed var(--brand-tint);
    border-radius: var(--radius);
    cursor: pointer;
    transition: background-color 0.15s ease, border-color 0.15s ease;
}

.upload-area:hover {
    background: var(--brand-soft);
}

.upload-area.highlight {
    background: var(--brand-soft);
    border-color: var(--brand);
}

.upload-area p {
    margin: 8px 0 0;
    color: var(--ink-muted);
    font-size: 13px;
}

.file-label {
    display: inline-block;
    padding: 8px 16px;
    background: var(--brand);
    color: #fff;
    border-radius: var(--radius-sm);
    font-size: 13px;
    font-weight: 600;
    cursor: pointer;
}

.upload-info {
    margin-top: 12px;
    color: var(--ink-subtle);
    font-size: 12.5px;
    text-align: center;
}

.file-info {
    margin-top: 12px;
    padding: 10px 12px;
    background: var(--surface-2);
    border: 1px solid var(--line);
    border-radius: var(--radius-sm);
    font-size: 13px;
}

.file-info p {
    margin: 4px 0;
    color: var(--ink-muted);
}

/* ---------------------------------------------------------------- 页脚 */

.footer {
    position: fixed;
    left: 0;
    right: 0;
    bottom: 0;
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 12px;
    padding: 12px 20px;
    background: var(--surface);
    border-top: 1px solid var(--line);
    box-shadow: none;
    z-index: 50;
}

/* ---------------------------------------------------------------- 载体选择器 */

.vector-selector {
    position: fixed;
    inset: 0;
    z-index: 1000;
    display: none;
    align-items: center;
    justify-content: center;
    background: var(--scrim);
}

.vector-selector-content {
    width: min(880px, 92vw);
    max-height: 84vh;
    display: flex;
    flex-direction: column;
    background: var(--surface);
    border: 1px solid var(--line);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-md);
    overflow: hidden;
}

.vector-selector-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 16px 20px;
    border-bottom: 1px solid var(--line);
}

.vector-selector-header h3 {
    margin: 0;
    font-size: 17px;
    font-weight: 600;
    color: var(--ink);
}

.close-vector-selector {
    width: 30px;
    height: 30px;
    border: none;
    border-radius: var(--radius-sm);
    background: transparent;
    color: var(--ink-muted);
    font-size: 20px;
    line-height: 1;
    cursor: pointer;
    transition: background-color 0.15s ease, color 0.15s ease;
}

.close-vector-selector:hover {
    background: var(--brand-soft);
    color: var(--brand);
}

.vector-selector-body {
    display: flex;
    min-height: 0;
    flex: 1;
}

.vector-categories,
.vector-names {
    padding: 16px;
    overflow-y: auto;
}

.vector-categories {
    width: 220px;
    border-right: 1px solid var(--line);
    background: var(--surface-2);
}

.vector-names {
    flex: 1;
    min-width: 0;
}

.vector-categories h4,
.vector-names h4 {
    margin: 0 0 10px;
    font-size: 12.5px;
    font-weight: 600;
    color: var(--ink-muted);
}

.vector-search {
    margin-bottom: 12px;
}

.vector-search input {
    width: 100%;
    height: 32px;
    padding: 0 10px;
    color: var(--ink);
    background: var(--surface);
    border: 1px solid var(--line);
    border-radius: var(--radius-sm);
    font-size: 13px;
    transition: border-color 0.15s ease, box-shadow 0.15s ease;
}

.vector-search input:focus {
    border-color: var(--brand);
    outline: none;
    box-shadow: 0 0 0 3px var(--ring);
}

#vector-categories-list,
#vector-names-list {
    margin: 0;
    padding: 0;
    list-style: none;
}

#vector-categories-list li,
#vector-names-list li {
    padding: 8px 10px;
    border-radius: var(--radius-sm);
    font-size: 13px;
    color: var(--ink);
    cursor: pointer;
    transition: background-color 0.15s ease, color 0.15s ease;
}

#vector-categories-list li:hover,
#vector-names-list li:hover {
    background: var(--brand-soft);
    color: var(--brand);
}

#vector-categories-list li.active {
    background: var(--brand-soft);
    color: var(--brand);
    font-weight: 600;
}

.vector-name-input {
    width: 100%;
    height: 32px;
    padding: 0 10px;
    color: var(--ink);
    background: var(--surface);
    border: 1px solid var(--line);
    border-radius: var(--radius-sm);
    font-size: 13px;
}

/* ---------------------------------------------------------------- 提示弹窗 */

.custom-alert {
    position: fixed;
    inset: 0;
    z-index: 2000;
    display: none;
    align-items: center;
    justify-content: center;
    background: var(--scrim);
}

.custom-alert-content {
    width: min(440px, 92vw);
    background: var(--surface);
    border: 1px solid var(--line);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-md);
    overflow: hidden;
    animation: alertFadeIn 0.15s ease-out;
}

@keyframes alertFadeIn {
    from {
        opacity: 0;
        transform: translateY(6px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.custom-alert-header {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 16px 18px 10px;
}

.custom-alert-icon {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 28px;
    height: 28px;
    border-radius: 50%;
    background: var(--brand-soft);
    color: var(--brand);
    flex-shrink: 0;
}

.custom-alert-title {
    flex: 1;
    margin: 0;
    font-size: 15px;
    font-weight: 600;
    color: var(--ink);
}

.custom-alert-close {
    width: 28px;
    height: 28px;
    border: none;
    border-radius: var(--radius-sm);
    background: transparent;
    color: var(--ink-muted);
    font-size: 17px;
    line-height: 1;
    cursor: pointer;
}

.custom-alert-close:hover {
    background: var(--brand-soft);
    color: var(--brand);
}

.custom-alert-body {
    padding: 0 18px 14px;
}

.custom-alert-body p {
    margin: 0;
    color: var(--ink-muted);
    font-size: 13px;
    line-height: 1.6;
}

.custom-alert-footer {
    display: flex;
    justify-content: flex-end;
    gap: 10px;
    padding: 12px 18px 16px;
}

.custom-alert-btn {
    padding: 8px 18px;
    background: var(--brand);
    color: #fff;
    border: 1px solid var(--brand);
    border-radius: var(--radius-sm);
    font-size: 13px;
    font-weight: 600;
    cursor: pointer;
    transition: background-color 0.15s ease, border-color 0.15s ease;
}

.custom-alert-btn:hover {
    background: var(--brand-dark);
    border-color: var(--brand-dark);
}

/* ---------------------------------------------------------------- 窄屏 */

@media (max-width: 768px) {
    .header-container {
        flex-wrap: wrap;
        gap: 10px;
        padding: 12px 16px;
    }

    .brand-title {
        font-size: 17px;
    }

    .progress-nav {
        padding: 16px 0 18px;
    }

    .nav-container {
        padding: 0 16px;
    }

    .progress-steps {
        justify-content: flex-start;
        gap: 10px;
    }

    .step {
        padding: 12px 16px;
    }

    .step-connector {
        display: none;
    }

    /* 原布局用 clamp(786px, 90%, …) 定宽，手机上会把内容顶出屏幕 */
    .main-content {
        width: auto;
        max-width: 100%;
        padding: 16px 12px 120px;
    }

    .pagination {
        justify-content: flex-start;
    }

    .codon-optimization-controls {
        flex-wrap: wrap;
        gap: 10px;
    }

    .codon-optimization-controls .organism-select {
        width: 100%;
    }

    .codon-optimization-controls .organism-select select {
        width: 100%;
        min-width: 0;
    }

    .vector-selector-body {
        flex-direction: column;
    }

    .vector-categories {
        width: 100%;
        border-right: none;
        border-bottom: 1px solid var(--line);
        max-height: 160px;
    }

    .footer {
        padding: 10px 12px;
    }
}
