/* ==================================================================
 * 车牌预览页样式
 * 路径：/license-plate.html
 * 依赖 common.css 的 --c-* 设计变量，自动适配暗色模式
 * 说明：页面前缀统一使用 lp-，避免与广告拦截通用规则冲突
 * ================================================================== */

/* ---------- 页面容器 ---------- */
.lp-wrap {
    width: 100%;
    max-width: 100%;
    margin: 0 auto;
    padding: 14px 12px 28px;
}

@media (min-width: 769px) {
    .lp-wrap {
        max-width: 1000px;
        padding: 24px 16px 56px;
    }
}

/* ---------- 主卡片 ---------- */
.lp-card {
    background: var(--c-surface);
    border: 1px solid var(--c-border);
    border-radius: 18px;
    box-shadow: var(--shadow);
    padding: 16px;
    display: flex;
    flex-direction: column;
}

@media (min-width: 769px) {
    .lp-card {
        padding: 26px 28px 24px;
    }
}

/* ---------- 顶部栏 ---------- */
.lp-topbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
    margin-bottom: 16px;
}

.lp-back {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    flex: 0 0 auto;
    width: 38px;
    height: 38px;
    border-radius: 12px;
    background: var(--c-bg);
    color: var(--c-text);
    font-size: 15px;
    transition: background-color 0.2s ease, transform 0.12s ease;
}
.lp-back:hover { background: var(--c-primary-light); color: var(--c-primary); }
.lp-back:active { transform: scale(0.94); }

.lp-title {
    flex: 1 1 auto;
    text-align: center;
    font-size: 17px;
    font-weight: 800;
    color: var(--c-text);
    letter-spacing: 0.02em;
}

.lp-badge {
    flex: 0 0 auto;
    padding: 5px 10px;
    border-radius: 999px;
    background: var(--c-bg);
    color: var(--c-text-3);
    font-size: 11px;
    font-weight: 500;
    white-space: nowrap;
}

/* ---------- 输入区 ---------- */
.lp-input-row {
    display: flex;
    flex-direction: column;
    gap: 10px;
    margin-bottom: 14px;
}

@media (min-width: 640px) {
    .lp-input-row {
        flex-direction: row;
        align-items: stretch;
    }
}

.lp-input {
    flex: 1 1 auto;
    width: 100%;
    min-width: 0;
    padding: 13px 16px;
    background: var(--c-bg);
    border: 2px solid transparent;
    border-radius: 14px;
    color: var(--c-text);
    font-size: 20px;
    font-weight: 800;
    letter-spacing: 0.3em;
    text-align: center;
    text-transform: uppercase;
    outline: none;
    transition: background-color 0.2s ease, border-color 0.2s ease, box-shadow 0.2s ease;
}
.lp-input::placeholder {
    color: var(--c-text-3);
    font-size: 14px;
    font-weight: 500;
    letter-spacing: 0.04em;
    text-transform: none;
}
.lp-input:focus {
    background: var(--c-surface);
    border-color: var(--c-primary);
    box-shadow: 0 0 0 4px var(--c-primary-light);
}

.lp-reset {
    flex: 0 0 auto;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    padding: 13px 22px;
    background: var(--c-bg);
    border: 2px solid transparent;
    border-radius: 14px;
    color: var(--c-text-2);
    font-size: 14px;
    font-weight: 700;
    transition: background-color 0.2s ease, transform 0.12s ease;
}
.lp-reset:hover { background: var(--c-primary-light); color: var(--c-primary); }
.lp-reset:active { transform: scale(0.97); }

/* ---------- 预览区 ---------- */
.lp-preview-box {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 100%;
    min-height: 190px;
    padding: 10px;
    margin-bottom: 14px;
    background: var(--c-bg-2);
    border: 1px solid var(--c-border);
    border-radius: 14px;
}

@media (min-width: 769px) {
    .lp-preview-box {
        min-height: 280px;
        padding: 18px;
    }
}

.lp-canvas-wrap {
    position: relative;
    display: flex;
    align-items: center;
    justify-content: center;
    width: 100%;
    min-height: 170px;
}

.lp-canvas-wrap canvas {
    display: block;
    width: auto;
    height: auto;
    max-width: 100%;
    max-height: 100%;
    object-fit: contain;
    background: #ffffff;
    border-radius: 8px;
}

.lp-hint {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: 100%;
    padding: 0 20px;
    color: var(--c-text-3);
    font-size: 14px;
    line-height: 1.6;
    text-align: center;
    pointer-events: none;
    user-select: none;
}
.lp-hint.is-error {
    color: var(--c-danger);
    font-weight: 700;
}
.lp-hint.is-hidden {
    display: none;
}

/* ---------- 控件区 ---------- */
.lp-controls {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.lp-control-row {
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: 8px 10px;
    width: 100%;
}

.lp-control-label {
    flex: 0 0 auto;
    min-width: 72px;
    color: var(--c-text-3);
    font-size: 13px;
    font-weight: 500;
}

.lp-seg {
    display: inline-flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 4px;
    max-width: 100%;
    padding: 4px;
    background: var(--c-bg);
    border-radius: 999px;
}

.lp-seg-btn {
    min-width: 0;
    padding: 6px 14px;
    border-radius: 999px;
    color: var(--c-text-2);
    font-size: 12px;
    font-weight: 700;
    line-height: 1.4;
    white-space: nowrap;
    transition: background-color 0.18s ease, color 0.18s ease, box-shadow 0.18s ease;
}
.lp-seg-btn:hover { color: var(--c-primary); }
.lp-seg-btn.is-active {
    background: var(--c-primary-light);
    color: var(--c-primary);
    box-shadow: 0 1px 2px rgba(0, 0, 0, 0.06);
}

/* 字体选项数量较多，允许更紧凑的排布 */
.lp-seg-font .lp-seg-btn {
    padding: 6px 12px;
    font-size: 11.5px;
}

.lp-brand-input {
    width: 170px;
    max-width: 100%;
    padding: 7px 13px;
    background: var(--c-surface);
    border: 2px solid transparent;
    border-radius: 999px;
    color: var(--c-text);
    font-size: 13px;
    font-weight: 700;
    letter-spacing: 0.04em;
    outline: none;
    transition: border-color 0.2s ease, box-shadow 0.2s ease;
}
.lp-brand-input::placeholder {
    color: var(--c-text-3);
    font-weight: 500;
}
.lp-brand-input:focus {
    border-color: var(--c-primary);
    box-shadow: 0 0 0 3px var(--c-primary-light);
}

/* ---------- 操作按钮 ---------- */
.lp-actions {
    display: flex;
    flex-direction: column;
    gap: 10px;
    margin-top: 16px;
}

@media (min-width: 640px) {
    .lp-actions {
        flex-direction: row;
    }
}

.lp-btn {
    flex: 1 1 0;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 14px 16px;
    border-radius: 14px;
    font-size: 14px;
    font-weight: 800;
    transition: background-color 0.2s ease, box-shadow 0.2s ease, transform 0.12s ease;
}
.lp-btn:active { transform: scale(0.98); }
.lp-btn:disabled {
    opacity: 0.4;
    cursor: not-allowed;
    transform: none;
}
.lp-btn:disabled:hover { box-shadow: none; }

.lp-btn-secondary {
    background: var(--c-bg);
    color: var(--c-text);
}
.lp-btn-secondary:hover:not(:disabled) { background: var(--c-primary-light); color: var(--c-primary); }

.lp-btn-primary {
    background: linear-gradient(135deg, var(--c-primary) 0%, #2f54eb 100%);
    color: #ffffff;
    box-shadow: 0 6px 16px rgba(24, 144, 255, 0.22);
}
.lp-btn-primary:hover:not(:disabled) {
    background: linear-gradient(135deg, var(--c-primary-dark) 0%, #1d39c4 100%);
    box-shadow: 0 8px 20px rgba(24, 144, 255, 0.28);
}

/* ---------- 提示 ---------- */
.lp-tips {
    margin-top: 14px;
    text-align: center;
    color: var(--c-text-3);
    font-size: 11px;
    font-weight: 500;
    line-height: 1.7;
}
.lp-tips .lp-version {
    display: block;
    margin-top: 2px;
    color: var(--c-text-3);
    opacity: 0.75;
    font-size: 10px;
}

/* ---------- 免责声明 ---------- */
.lp-disclaimer {
    margin-top: 14px;
    padding: 12px 14px;
    background: var(--c-bg-2);
    border: 1px dashed var(--c-border);
    border-radius: 12px;
    color: var(--c-text-3);
    font-size: 11px;
    line-height: 1.8;
}
.lp-disclaimer p { margin: 0; }

/* ---------- 预览弹窗 ---------- */
.lp-modal {
    position: fixed;
    top: 0;
    right: 0;
    bottom: 0;
    left: 0;
    z-index: 1000;
    display: none;
    align-items: center;
    justify-content: center;
    padding: 16px;
}
.lp-modal.is-open { display: flex; }

.lp-modal-mask {
    position: absolute;
    top: 0;
    right: 0;
    bottom: 0;
    left: 0;
    background: rgba(15, 23, 42, 0.6);
    -webkit-backdrop-filter: blur(3px);
    backdrop-filter: blur(3px);
}

.lp-modal-dialog {
    position: relative;
    z-index: 1;
    max-width: 94vw;
    max-height: 90vh;
    overflow: auto;
    overscroll-behavior: contain;
    padding: 14px;
    background: var(--c-surface);
    border-radius: 18px;
    box-shadow: var(--shadow-lg);
}
.lp-modal-dialog:focus { outline: none; }

.lp-modal-img {
    display: block;
    width: auto;
    max-width: 100%;
    max-height: 66vh;
    margin: 0 auto;
    object-fit: contain;
    background: #ffffff;
    border-radius: 12px;
}

.lp-modal-actions {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 12px;
    margin-top: 14px;
}

.lp-modal-btn {
    padding: 10px 24px;
    border-radius: 12px;
    font-size: 14px;
    font-weight: 700;
    transition: background-color 0.2s ease, color 0.2s ease;
}
.lp-modal-btn-close {
    background: var(--c-bg);
    color: var(--c-text-2);
}
.lp-modal-btn-close:hover { background: var(--c-primary-light); color: var(--c-primary); }

.lp-modal-btn-download {
    background: linear-gradient(135deg, var(--c-primary) 0%, #2f54eb 100%);
    color: #ffffff;
}
.lp-modal-btn-download:hover { background: linear-gradient(135deg, var(--c-primary-dark) 0%, #1d39c4 100%); }

/* ---------- 暗色微调 ---------- */
html[data-theme="dark"] .lp-preview-box,
html[data-theme="dark"] .lp-disclaimer {
    background: var(--c-bg);
}
html[data-theme="dark"] .lp-seg,
html[data-theme="dark"] .lp-input,
html[data-theme="dark"] .lp-reset {
    background: var(--c-bg);
}
html[data-theme="dark"] .lp-input:focus,
html[data-theme="dark"] .lp-brand-input {
    background: var(--c-surface);
}
html[data-theme="dark"] .lp-btn-secondary:hover:not(:disabled) {
    background: var(--c-primary-light);
}

/* ---------- 移动端：预览弹窗改为底部抽屉 ---------- */
@media (max-width: 767px) {
    .lp-modal {
        align-items: flex-end;
        padding: 0;
    }
    .lp-modal-dialog {
        width: 100%;
        max-width: 100%;
        max-height: 88vh;
        padding: 16px 16px calc(16px + env(safe-area-inset-bottom, 0px));
        border-radius: 18px 18px 0 0;
        animation: lp-sheet-up 0.24s ease-out;
    }
    .lp-modal-img {
        max-height: 60vh;
    }
    .lp-modal-actions {
        position: sticky;
        bottom: 0;
        padding-top: 12px;
        background: var(--c-surface);
    }
}

@keyframes lp-sheet-up {
    from { transform: translateY(18%); opacity: 0.6; }
    to   { transform: translateY(0); opacity: 1; }
}

/* ---------- 移动端适配（≤480px） ---------- */
@media (max-width: 480px) {
    .lp-control-label {
        width: 100%;
        margin-bottom: -2px;
    }

    .lp-seg {
        width: 100%;
        border-radius: 20px;
    }

    .lp-seg-btn {
        padding: 6px 11px;
        font-size: 11px;
    }

    .lp-seg-font .lp-seg-btn {
        padding: 6px 10px;
        font-size: 11px;
    }

    /* 非字体控件行：标签与选项同排，按钮组横向滚动，节省纵向空间 */
    .lp-control-row-inline .lp-control-label {
        width: auto;
        margin-bottom: 0;
    }
    .lp-control-row-inline .lp-seg {
        flex: 1 1 auto;
        width: auto;
        flex-wrap: nowrap;
        justify-content: flex-start;
        background: transparent;
        padding: 0;
        border-radius: 0;
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
    }
    .lp-control-row-inline .lp-seg::-webkit-scrollbar {
        display: none;
    }
    .lp-control-row-inline .lp-seg-btn {
        flex: 0 0 auto;
    }
    .lp-control-row-inline .lp-brand-input {
        flex: 1 1 auto;
        width: 100%;
        min-width: 0;
    }

    .lp-brand-input {
        flex: 1 1 auto;
        width: 100%;
    }

    .lp-badge {
        padding: 4px 8px;
        font-size: 10px;
    }

    .lp-title {
        font-size: 16px;
    }
}

/* ---------- 超窄屏（≤360px） ---------- */
@media (max-width: 360px) {
    .lp-seg-btn {
        padding: 5px 9px;
        font-size: 10.5px;
    }
    .lp-seg-font .lp-seg-btn {
        padding: 5px 8px;
        font-size: 10.5px;
    }
}

/* ---------- 减少动效偏好 ---------- */
@media (prefers-reduced-motion: reduce) {
    .lp-back,
    .lp-input,
    .lp-reset,
    .lp-seg-btn,
    .lp-btn,
    .lp-modal-btn {
        transition: none;
    }
    .lp-modal-dialog {
        animation: none;
    }
}
