/* style.css – 优化版本
   改进：使用CSS自定义属性统一主题，精简选择器，增强响应式与交互细节，
   保持完全兼容原有HTML结构，视觉更现代柔和。
*/
* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

:root {
    /* 颜色系统 */
    --primary: #1e6f9f;
    --primary-light: #e6f0fa;
    --primary-dark: #0a4b6e;
    --secondary: #2b3a4a;
    --success: #2b8c5e;
    --danger: #c24545;
    --bg-body: #f4f7fc;
    --bg-panel: #ffffff;
    --bg-soft: #edf2f9;
    --border-light: #dbe4ee;
    --text-dark: #1a2b3c;
    --text-medium: #3a4e62;
    --text-light: #6b7f94;
    --shadow-sm: 0 4px 12px rgba(0, 20, 40, 0.04);
    --shadow-md: 0 8px 24px rgba(0, 30, 60, 0.08);
    --shadow-lg: 0 16px 32px rgba(0, 30, 60, 0.12);

    /* 圆角 */
    --radius-sm: 12px;
    --radius-md: 20px;
    --radius-lg: 28px;
    --radius-full: 40px;

    /* 间距 */
    --space-xs: 0.5rem;
    --space-sm: 0.8rem;
    --space-md: 1.2rem;
    --space-lg: 1.8rem;
    --space-xl: 2.5rem;

    /* 字体 */
    --font-main: 'Segoe UI', Roboto, system-ui, -apple-system, sans-serif;
    --font-size-base: 1rem;
    --line-relaxed: 1.6;
}

body {
    font-family: var(--font-main);
    background: var(--bg-body);
    color: var(--text-dark);
    line-height: var(--line-relaxed);
    padding: var(--space-md);
    max-width: 1280px;
    margin: 0 auto;
}

/* 头部 */
header {
    text-align: center;
    margin-bottom: var(--space-lg);
}

header h1 {
    font-size: 2rem;
    font-weight: 500;
    color: var(--primary-dark);
    letter-spacing: 0.5px;
}

header .subtitle {
    color: var(--text-light);
    font-size: 0.95rem;
    margin-top: var(--space-xs);
}

/* 通用面板 */
.input-panel,
.detail-view {
    background: var(--bg-panel);
    border-radius: var(--radius-lg);
    padding: var(--space-lg);
    box-shadow: var(--shadow-sm);
    margin-bottom: var(--space-xl);
    transition: box-shadow 0.2s;
}

.input-panel:hover,
.detail-view:hover {
    box-shadow: var(--shadow-md);
}

/* 选项行 (盆地类型 / 柜列) */
.basin-type,
.cabinet-column {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: var(--space-md) var(--space-lg);
    margin-bottom: var(--space-lg);
}

.label {
    font-weight: 600;
    color: var(--text-medium);
    min-width: 6em;
    font-size: 0.95rem;
}

/* 胶囊选项 (共用) */
.basin-type label,
.cabinet-column label {
    display: inline-flex;
    align-items: center;
    gap: 0.4rem;
    background: var(--bg-soft);
    padding: 0.5rem 1.2rem;
    border-radius: var(--radius-full);
    font-size: 0.95rem;
    font-weight: 500;
    cursor: pointer;
    transition: background 0.2s, transform 0.1s, box-shadow 0.2s;
    border: 1px solid transparent;
    color: var(--text-medium);
}

.basin-type label:hover,
.cabinet-column label:hover {
    background: #dce5f0;
    transform: translateY(-1px);
    box-shadow: var(--shadow-sm);
}

.basin-type input[type="radio"],
.cabinet-column input[type="radio"] {
    accent-color: var(--primary);
    width: 1.1rem;
    height: 1.1rem;
    margin: 0;
}

/* 输入组 */
.input-group {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
    gap: var(--space-md);
}

.input-row {
    display: flex;
    flex-direction: column;
}

.input-row label {
    font-size: 0.9rem;
    color: var(--text-light);
    margin-bottom: 0.3rem;
    font-weight: 500;
}

.input-row label span {
    color: var(--text-light);
    font-size: 0.8rem;
    opacity: 0.8;
}

.input-row input {
    padding: 0.7rem 1.2rem;
    border: 1.5px solid var(--border-light);
    border-radius: var(--radius-md);
    font-size: var(--font-size-base);
    background: #ffffff;
    transition: border 0.2s, box-shadow 0.2s;
}

.input-row input:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 4px rgba(30, 111, 159, 0.15);
}

/* 主按钮 */
button#matchBtn {
    background: var(--primary);
    color: white;
    border: none;
    border-radius: var(--radius-full);
    padding: 1rem 2rem;
    font-size: 1.2rem;
    font-weight: 600;
    width: 100%;
    max-width: 360px;
    margin: var(--space-lg) auto 0;
    display: block;
    cursor: pointer;
    transition: background 0.2s, transform 0.15s, box-shadow 0.2s;
    box-shadow: 0 8px 18px rgba(30, 111, 159, 0.25);
    letter-spacing: 0.3px;
}

button#matchBtn:hover {
    background: var(--primary-dark);
    transform: translateY(-2px);
    box-shadow: 0 12px 24px rgba(30, 111, 159, 0.35);
}

button#matchBtn:active {
    transform: translateY(0);
    box-shadow: 0 6px 12px rgba(30, 111, 159, 0.25);
}

/* 结果区域头部 */
.result-header {
    display: flex;
    flex-wrap: wrap;
    justify-content: space-between;
    align-items: center;
    margin-bottom: var(--space-md);
    font-weight: 500;
    color: var(--text-medium);
    gap: var(--space-sm);
}

.match-hint {
    font-size: 0.85rem;
    background: var(--bg-soft);
    padding: 0.3rem 1rem;
    border-radius: var(--radius-full);
    color: var(--text-medium);
}

/* 结果卡片网格 */
.result-cards {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(170px, 1fr));
    gap: var(--space-sm);
    margin-bottom: var(--space-xl);
}

.card {
    background: var(--bg-panel);
    border-radius: var(--radius-md);
    padding: 1rem 0.6rem;
    box-shadow: var(--shadow-sm);
    border: 2px solid transparent;
    transition: border 0.15s, background 0.15s, transform 0.1s, box-shadow 0.2s;
    cursor: pointer;
    display: flex;
    flex-direction: column;
    align-items: center;
    text-align: center;
}

.card:hover {
    box-shadow: var(--shadow-md);
    transform: scale(1.02);
}

.card.active {
    border-color: var(--primary);
    background: var(--primary-light);
}

.card .id {
    font-weight: 700;
    color: var(--primary-dark);
    font-size: 1.1rem;
}

.card .name {
    font-size: 0.9rem;
    color: var(--text-dark);
    margin: 0.2rem 0;
}

.card .match-badge {
    background: var(--success);
    color: white;
    border-radius: var(--radius-full);
    padding: 0.2rem 0.9rem;
    font-size: 0.8rem;
    font-weight: 600;
    margin-top: 0.4rem;
}

.card .mirror-tip {
    font-size: 0.75rem;
    color: var(--danger);
    font-weight: 500;
    background: #fae6e6;
    padding: 0.2rem 0.8rem;
    border-radius: var(--radius-full);
    margin-top: 0.3rem;
}

/* 详情视图 */
.detail-view {
    display: flex;
    flex-direction: column;
    gap: var(--space-lg);
    padding: var(--space-lg);
}

@media (min-width: 720px) {
    .detail-view {
        flex-direction: row;
    }
}

.canvas-container {
    flex: 1;
    min-width: 260px;
    background: var(--bg-soft);
    border-radius: var(--radius-lg);
    padding: var(--space-md);
    display: flex;
    align-items: center;
    justify-content: center;
}

canvas {
    width: 100%;
    height: auto;
    display: block;
    border-radius: var(--radius-md);
    background: #ffffff;
    box-shadow: inset 0 0 0 1px var(--border-light);
}

.image-container {
    flex: 1;
    background: var(--bg-soft);
    border-radius: var(--radius-lg);
    padding: var(--space-md);
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: var(--space-sm);
}

.image-container img {
    max-width: 100%;
    max-height: 240px;
    border-radius: var(--radius-md);
    box-shadow: var(--shadow-sm);
    object-fit: contain;
    background: #fff;
}

.image-info {
    text-align: center;
    width: 100%;
}

.image-info .id-name {
    font-weight: 700;
    font-size: 1.3rem;
    color: var(--primary-dark);
}

.image-info .mirror-warning {
    color: var(--danger);
    font-weight: 600;
    background: #ffe6e6;
    padding: 0.25rem 1.2rem;
    border-radius: var(--radius-full);
    display: inline-block;
    margin-top: 0.4rem;
    font-size: 0.9rem;
}

.image-info .corner-remain {
    color: var(--text-medium);
    font-size: 0.9rem;
    background: var(--bg-soft);
    padding: 0.3rem 1.2rem;
    border-radius: var(--radius-full);
    margin-top: 0.4rem;
}

/* 页脚 */
footer {
    text-align: center;
    margin-top: var(--space-xl);
    padding: var(--space-md);
    color: var(--text-light);
    font-size: 0.9rem;
    border-top: 1px solid var(--border-light);
}

/* 微调小屏 */
@media (max-width: 480px) {
    body {
        padding: var(--space-xs);
    }

    .input-panel,
    .detail-view {
        padding: var(--space-md);
    }

    .basin-type label,
    .cabinet-column label {
        padding: 0.4rem 1rem;
        font-size: 0.9rem;
    }

    .card {
        min-width: 140px;
    }

    button#matchBtn {
        max-width: 100%;
    }
}