/**
 * 移动端优化样式表
 * 产品溯源查验页面
 */

/* 基础变量 */
:root {
    --primary: #667eea;
    --success: #34c759;
    --success-dark: #2db84d;
    --warning: #ff9f0a;
    --warning-dark: #ff8c00;
    --text-main: #1a1a1a;
    --text-sub: #6e6e73;
    --bg-page: #f2f2f7;
    --bg-card: #ffffff;
    --border: #e5e5ea;
    --radius: 12px;
    --shadow: 0 1px 3px rgba(0, 0, 0, 0.08);
    --transition: all 0.2s ease;
}

/* 重置 */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

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

body {
    font-family: -apple-system, BlinkMacSystemFont, 'SF Pro Text', 'Segoe UI', Roboto, sans-serif;
    background: var(--bg-page);
    color: var(--text-main);
    line-height: 1.4;
    min-height: 100vh;
    -webkit-font-smoothing: antialiased;
    padding-bottom: env(safe-area-inset-bottom);
}

/* 头部 */
.header {
    background: var(--bg-card);
    padding: 12px 16px;
    text-align: center;
    border-bottom: 0.5px solid var(--border);
    position: sticky;
    top: 0;
    z-index: 100;
    backdrop-filter: saturate(180%) blur(20px);
    -webkit-backdrop-filter: saturate(180%) blur(20px);
    background: rgba(255, 255, 255, 0.85);
}

.header-title {
    font-size: 17px;
    font-weight: 600;
    color: var(--text-main);
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
}

.header-title svg {
    width: 20px;
    height: 20px;
    color: var(--success);
}

/* 主内容区 */
.main {
    padding: 16px;
    max-width: 420px;
    margin: 0 auto;
}

/* 卡片容器 */
.card {
    background: var(--bg-card);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    overflow: hidden;
}

/* 搜索卡片 */
.search-card {
    padding: 24px 20px;
}

.card-header {
    text-align: center;
    margin-bottom: 20px;
}

.card-header h2 {
    font-size: 20px;
    font-weight: 600;
    color: var(--text-main);
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
}

.card-header svg {
    width: 24px;
    height: 24px;
    color: var(--success);
}

/* 表单 */
.form {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.input-group {
    position: relative;
}

.input-group .icon {
    position: absolute;
    left: 14px;
    top: 50%;
    transform: translateY(-50%);
    color: var(--text-sub);
    pointer-events: none;
    display: flex;
    align-items: center;
}

.input-group .icon svg {
    width: 18px;
    height: 18px;
}

.input-field {
    width: 100%;
    padding: 14px 14px 14px 44px;
    font-size: 16px;
    border: 1.5px solid var(--border);
    border-radius: var(--radius);
    background: var(--bg-card);
    transition: border-color 0.2s, box-shadow 0.2s;
    -webkit-appearance: none;
    appearance: none;
}

.input-field:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(102, 126, 234, 0.15);
}

.input-field::placeholder {
    color: var(--text-sub);
}

/* 按钮 */
.btn {
    width: 100%;
    padding: 14px 20px;
    font-size: 17px;
    font-weight: 600;
    border: none;
    border-radius: var(--radius);
    cursor: pointer;
    transition: all 0.2s;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    -webkit-tap-highlight-color: transparent;
}

.btn-primary {
    background: var(--text-main);
    color: #fff;
}

.btn-primary:hover {
    background: #333;
}

.btn-primary:active {
    opacity: 0.85;
}

.btn-primary svg {
    width: 18px;
    height: 18px;
}

/* 提示区 */
.tips-box {
    margin-top: 16px;
    padding: 14px;
    background: #fafafa;
    border-radius: var(--radius);
    border: 1px solid var(--border);
}

.tips-title {
    font-size: 13px;
    font-weight: 600;
    color: var(--text-sub);
    margin-bottom: 8px;
}

.tips-box ul {
    list-style: none;
    padding: 0;
    margin: 0;
}

.tips-box li {
    font-size: 13px;
    color: var(--text-sub);
    padding: 3px 0;
    padding-left: 12px;
    position: relative;
    line-height: 1.5;
}

.tips-box li::before {
    content: '';
    position: absolute;
    left: 0;
    top: 9px;
    width: 4px;
    height: 4px;
    background: var(--primary);
    border-radius: 50%;
}

/* 错误提示 */
.alert {
    margin-top: 12px;
    padding: 12px 14px;
    background: #fff2f2;
    border: 1px solid #ffcfcf;
    border-radius: var(--radius);
    font-size: 14px;
    color: #ff3b30;
    display: flex;
    align-items: flex-start;
    gap: 8px;
}

.alert svg {
    width: 18px;
    height: 18px;
    flex-shrink: 0;
    margin-top: 1px;
}

/* 结果卡片 */
.result-card {
    margin-bottom: 16px;
}

.result-header {
    padding: 20px;
    text-align: center;
}

.result-header.success {
    background: linear-gradient(135deg, var(--success), var(--success-dark));
    color: #fff;
}

.result-header.warning {
    background: linear-gradient(135deg, var(--warning), var(--warning-dark));
    color: #fff;
}

.result-header .icon-box {
    width: 44px;
    height: 44px;
    margin: 0 auto 10px;
    background: rgba(255, 255, 255, 0.25);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
}

.result-header .icon-box svg {
    width: 26px;
    height: 26px;
}

.result-header h3 {
    font-size: 20px;
    font-weight: 600;
    margin-bottom: 4px;
}

.result-header p {
    font-size: 14px;
    opacity: 0.9;
}

/* 产品信息区 */
.product-body {
    padding: 16px;
}

.product-img {
    width: 90px;
    height: 90px;
    border-radius: 10px;
    object-fit: cover;
    margin: 0 auto 12px;
    display: block;
    background: var(--bg-page);
}

.product-title {
    font-size: 17px;
    font-weight: 600;
    text-align: center;
    margin-bottom: 14px;
    color: var(--text-main);
}

/* 信息网格 */
.info-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 8px;
    margin-bottom: 12px;
}

.info-item {
    padding: 10px 12px;
    background: var(--bg-page);
    border-radius: 8px;
}

.info-item .label {
    font-size: 11px;
    color: var(--text-sub);
    text-transform: uppercase;
    letter-spacing: 0.3px;
    margin-bottom: 2px;
}

.info-item .value {
    font-size: 14px;
    color: var(--text-main);
    font-weight: 500;
    word-break: break-all;
    line-height: 1.4;
}

/* 描述框 */
.desc-box {
    padding: 10px 12px;
    background: var(--bg-page);
    border-radius: 8px;
    margin-bottom: 14px;
}

.desc-box .label {
    font-size: 11px;
    color: var(--text-sub);
    text-transform: uppercase;
    letter-spacing: 0.3px;
    margin-bottom: 4px;
}

.desc-box .value {
    font-size: 14px;
    color: var(--text-sub);
    line-height: 1.5;
}

/* 时间线 */
.timeline-section {
    padding-top: 14px;
    border-top: 0.5px solid var(--border);
}

.timeline-title {
    font-size: 14px;
    font-weight: 600;
    color: var(--text-main);
    margin-bottom: 10px;
    display: flex;
    align-items: center;
    gap: 6px;
}

.timeline-title svg {
    width: 16px;
    height: 16px;
    color: var(--primary);
}

.timeline {
    position: relative;
    padding-left: 16px;
}

.timeline::before {
    content: '';
    position: absolute;
    left: 3px;
    top: 6px;
    bottom: 0;
    width: 1.5px;
    background: var(--border);
}

.timeline-item {
    position: relative;
    padding-bottom: 12px;
}

.timeline-item:last-child {
    padding-bottom: 0;
}

.timeline-item::before {
    content: '';
    position: absolute;
    left: -13px;
    top: 5px;
    width: 6px;
    height: 6px;
    border-radius: 50%;
    background: var(--primary);
    border: 2px solid var(--bg-card);
}

.timeline-item.warning::before {
    background: var(--warning);
}

.timeline-time {
    font-size: 11px;
    color: var(--text-sub);
    margin-bottom: 2px;
}

.timeline-text {
    font-size: 13px;
    color: var(--text-sub);
}

/* 溯源码 */
.code-box {
    margin-top: 14px;
    padding: 12px;
    background: var(--bg-page);
    border-radius: 8px;
    text-align: center;
    border: 1px dashed var(--border);
}

.code-box .label {
    font-size: 11px;
    color: var(--text-sub);
    text-transform: uppercase;
    letter-spacing: 0.3px;
    margin-bottom: 4px;
}

.code-box .value {
    font-family: 'SF Mono', Monaco, 'Consolas', monospace;
    font-size: 13px;
    color: var(--text-main);
    word-break: break-all;
    letter-spacing: 0.5px;
}

/* 返回按钮 */
.back-link {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 4px;
    width: 100%;
    max-width: 180px;
    margin: 16px auto;
    padding: 12px 20px;
    font-size: 15px;
    font-weight: 500;
    color: var(--text-sub);
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    cursor: pointer;
    transition: all 0.2s;
    text-decoration: none;
    -webkit-tap-highlight-color: transparent;
}

.back-link:hover {
    background: #fafafa;
}

.back-link:active {
    opacity: 0.7;
}

.back-link svg {
    width: 16px;
    height: 16px;
}

/* 底部 */
.footer {
    text-align: center;
    padding: 24px 16px 16px;
    color: var(--text-sub);
    font-size: 12px;
}

.footer p {
    margin-bottom: 3px;
}

/* 辅助类 */
.text-center {
    text-align: center;
}

.hide {
    display: none !important;
}

/* 小屏幕优化 - iPhone SE / 小屏手机 */
@media (max-width: 374px) {
    .main {
        padding: 12px;
    }

    .search-card {
        padding: 20px 16px;
    }

    .card-header {
        margin-bottom: 18px;
    }

    .card-header h2 {
        font-size: 18px;
    }

    .card-header svg {
        width: 22px;
        height: 22px;
    }

    .input-field {
        padding: 12px 12px 12px 40px;
        font-size: 15px;
    }

    .input-group .icon {
        left: 12px;
    }

    .input-group .icon svg {
        width: 16px;
        height: 16px;
    }

    .tips-box {
        padding: 12px;
    }

    .tips-box li {
        font-size: 12px;
    }

    .product-body {
        padding: 14px;
    }

    .product-img {
        width: 80px;
        height: 80px;
    }

    .product-title {
        font-size: 16px;
    }

    .info-grid {
        grid-template-columns: 1fr;
    }

    .info-item {
        padding: 8px 10px;
    }
}

/* 大屏手机优化 - Plus / Pro Max */
@media (min-width: 430px) {
    .main {
        padding: 20px;
    }

    .search-card {
        padding: 28px 24px;
    }

    .card-header {
        margin-bottom: 24px;
    }

    .card-header h2 {
        font-size: 22px;
    }

    .card-header svg {
        width: 26px;
        height: 26px;
    }

    .product-body {
        padding: 20px;
    }

    .product-img {
        width: 110px;
        height: 110px;
    }

    .product-title {
        font-size: 18px;
        margin-bottom: 16px;
    }

    .info-grid {
        gap: 10px;
        margin-bottom: 14px;
    }

    .info-item {
        padding: 12px 14px;
    }

    .timeline-section {
        padding-top: 16px;
    }
}

/* iPhone X / 刘海屏安全区域 */
@supports (padding-bottom: env(safe-area-inset-bottom)) {
    .footer {
        padding-bottom: calc(16px + env(safe-area-inset-bottom));
    }
}

/* 平板横屏 */
@media (min-width: 768px) and (max-width: 1024px) {
    .main {
        max-width: 480px;
        padding: 24px;
    }

    .search-card {
        padding: 32px 28px;
    }
}

/* 深色模式支持 */
@media (prefers-color-scheme: dark) {
    :root {
        --text-main: #f5f5f7;
        --text-sub: #98989d;
        --bg-page: #000000;
        --bg-card: #1c1c1e;
        --border: #38383a;
        --shadow: none;
    }

    .tips-box {
        background: #2c2c2e;
        border-color: #38383a;
    }

    .info-item,
    .desc-box,
    .code-box {
        background: #2c2c2e;
    }

    .timeline::before {
        background: #38383a;
    }

    .timeline-item::before {
        border-color: #1c1c1e;
    }

    .header {
        background: rgba(28, 28, 30, 0.85);
        border-color: #38383a;
    }

    .alert {
        background: rgba(255, 59, 48, 0.15);
        border-color: rgba(255, 59, 48, 0.3);
    }

    .back-link {
        background: #1c1c1e;
        border-color: #38383a;
    }

    .back-link:hover {
        background: #2c2c2e;
    }
}

/* 打印样式 */
@media print {
    body {
        background: #fff;
        color: #000;
    }

    .header,
    .footer,
    .tips-box,
    .back-link {
        display: none;
    }

    .card {
        box-shadow: none;
        border: 1px solid #ddd;
    }
}
