/**
 * 前端广告位 / 自助投放弹窗
 * 设计约束：任何广告单元都是「块级、宽度 100%、高度自适应」，
 * 不参与父级 flex/grid 的伸缩，避免插入后挤压原有布局。
 */

.ls-ad {
    --ls-ad-accent: #5fb878;
    --ls-ad-accent-dark: #46955e;
    position: relative;
    display: block;
    width: 100%;
    max-width: 100%;
    box-sizing: border-box;
    margin: 12px 0;
    border-radius: 10px;
    background: #fff;
    overflow: hidden;
    box-shadow: 0 1px 2px rgba(15, 34, 24, .06), 0 8px 24px -18px rgba(15, 34, 24, .35);
    line-height: 1.5;
    text-align: left;
}

.ls-ad * {
    box-sizing: border-box;
}

.ls-ad__link {
    display: block;
    color: inherit;
    text-decoration: none;
}

.ls-ad__media {
    display: block;
    width: 100%;
    background: #f3f6f4;
}

.ls-ad__media img {
    display: block;
    width: 100%;
    height: auto;
    max-height: 220px;
    object-fit: cover;
}

.ls-ad__body {
    display: block;
    padding: 10px 14px 12px;
}

.ls-ad__title {
    display: block;
    font-size: 15px;
    font-weight: 600;
    color: #1f2d26;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.ls-ad__desc {
    display: block;
    margin-top: 3px;
    font-size: 12px;
    color: #7b8b83;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.ls-ad__tag {
    position: absolute;
    top: 8px;
    left: 8px;
    padding: 1px 7px;
    border-radius: 999px;
    background: rgba(17, 24, 20, .55);
    color: #fff;
    font-size: 11px;
    letter-spacing: .5px;
    backdrop-filter: blur(4px);
    pointer-events: none;
}

.ls-ad__close {
    position: absolute;
    top: 6px;
    right: 6px;
    width: 22px;
    height: 22px;
    border: 0;
    border-radius: 50%;
    background: rgba(17, 24, 20, .45);
    color: #fff;
    font-size: 15px;
    line-height: 20px;
    cursor: pointer;
    opacity: 0;
    transition: opacity .2s ease;
}

.ls-ad:hover .ls-ad__close {
    opacity: 1;
}

.ls-ad__close:hover {
    background: rgba(17, 24, 20, .72);
}

/* 空位：广告招租 */
.ls-ad--empty {
    border: 1px dashed #c9d8cf;
    background:
        linear-gradient(135deg, rgba(95, 184, 120, .06), rgba(95, 184, 120, 0) 45%),
        repeating-linear-gradient(45deg, #fbfdfc, #fbfdfc 12px, #f6faf8 12px, #f6faf8 24px);
    box-shadow: none;
}

.ls-ad__rent {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 4px;
    width: 100%;
    min-height: 92px;
    padding: 16px 14px;
    border: 0;
    background: transparent;
    cursor: pointer;
    font-family: inherit;
    text-align: center;
    transition: background .2s ease;
}

.ls-ad__rent:hover {
    background: rgba(95, 184, 120, .06);
}

.ls-ad__rent-badge {
    display: inline-flex;
    align-items: center;
    padding: 2px 10px;
    border-radius: 999px;
    background: rgba(95, 184, 120, .14);
    color: var(--ls-ad-accent-dark, #46955e);
    font-size: 11px;
    letter-spacing: 1px;
}

.ls-ad__rent-main {
    font-size: 15px;
    font-weight: 600;
    color: #2a3a32;
}

.ls-ad__rent-meta {
    font-size: 12px;
    color: #8a9a92;
}

.ls-ad__rent:hover .ls-ad__rent-main {
    color: var(--ls-ad-accent-dark, #46955e);
}

/* 特定位置微调：帖子/文章内页略微收紧，与正文节奏一致 */
.ls-ad--bbs_post_top,
.ls-ad--article_top {
    margin: 4px 0 18px;
}

.ls-ad--bbs_post_bottom,
.ls-ad--article_bottom {
    margin: 18px 0 4px;
}

/* ------------------------------------------------------------------ */
/* 投放弹窗                                                            */
/* ------------------------------------------------------------------ */

.ls-ad-modal[hidden] {
    display: none !important;
}

.ls-ad-modal {
    position: fixed;
    inset: 0;
    z-index: 100000;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 24px 16px;
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "Microsoft YaHei", sans-serif;
}

/* 弹窗内统一 border-box：否则内容区 padding 会把 flex 子项撑出面板，
   在 .ls-ad-modal__body 上产生横向滚动条 */
.ls-ad-modal *,
.ls-ad-modal *::before,
.ls-ad-modal *::after {
    box-sizing: border-box;
}

.ls-ad-modal__mask {
    position: absolute;
    inset: 0;
    background: rgba(12, 22, 17, .55);
    backdrop-filter: blur(3px);
    animation: lsAdFade .18s ease;
}

.ls-ad-modal__panel {
    position: relative;
    width: 100%;
    max-width: 620px;
    max-height: min(88vh, 860px);
    display: flex;
    flex-direction: column;
    border-radius: 16px;
    background: #fff;
    box-shadow: 0 30px 80px -20px rgba(0, 0, 0, .45);
    overflow: hidden;
    animation: lsAdPop .22s cubic-bezier(.2, .9, .3, 1.2);
}

@keyframes lsAdFade {
    from { opacity: 0; }
    to { opacity: 1; }
}

@keyframes lsAdPop {
    from { opacity: 0; transform: translateY(14px) scale(.98); }
    to { opacity: 1; transform: none; }
}

.ls-ad-modal__head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    padding: 16px 20px;
    border-bottom: 1px solid #eef2f0;
}

.ls-ad-modal__title {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 16px;
    font-weight: 700;
    color: #1f2d26;
}

.ls-ad-modal__title i {
    color: #5fb878;
}

.ls-ad-modal__close {
    width: 30px;
    height: 30px;
    border: 0;
    border-radius: 50%;
    background: #f2f5f3;
    color: #6b7c73;
    font-size: 20px;
    line-height: 1;
    cursor: pointer;
    transition: background .15s ease, color .15s ease;
}

.ls-ad-modal__close:hover {
    background: #e6ece9;
    color: #33443b;
}

.ls-ad-modal__tabs {
    display: flex;
    gap: 6px;
    padding: 10px 20px 0;
    border-bottom: 1px solid #eef2f0;
}

.ls-ad-modal__tabs button {
    position: relative;
    padding: 8px 14px 12px;
    border: 0;
    background: transparent;
    color: #6b7c73;
    font-size: 14px;
    cursor: pointer;
    font-family: inherit;
}

.ls-ad-modal__tabs button.is-on {
    color: #2a3a32;
    font-weight: 600;
}

.ls-ad-modal__tabs button.is-on::after {
    content: "";
    position: absolute;
    left: 12px;
    right: 12px;
    bottom: -1px;
    height: 2px;
    border-radius: 2px;
    background: #5fb878;
}

.ls-ad-modal__body {
    flex: 1;
    overflow-y: auto;
    padding: 18px 20px 22px;
    -webkit-overflow-scrolling: touch;
}

.ls-ad-login {
    padding: 28px 10px;
    text-align: center;
    color: #5c6b63;
    font-size: 14px;
    line-height: 1.8;
}

/* 表单 */
.ls-ad-form__row {
    display: flex;
    gap: 14px;
    margin-bottom: 14px;
}

.ls-ad-form__label {
    flex: 0 0 78px;
    padding-top: 9px;
    font-size: 13px;
    color: #4b5b53;
    text-align: right;
}

.ls-ad-form__control {
    flex: 1;
    min-width: 0;
}

.ls-ad-input {
    width: 100%;
    height: 38px;
    padding: 0 12px;
    border: 1px solid #dfe7e3;
    border-radius: 8px;
    background: #fbfdfc;
    color: #22312a;
    font-size: 13px;
    font-family: inherit;
    outline: none;
    transition: border-color .15s ease, box-shadow .15s ease, background .15s ease;
}

.ls-ad-input:focus {
    border-color: #5fb878;
    background: #fff;
    box-shadow: 0 0 0 3px rgba(95, 184, 120, .15);
}

.ls-ad-input--sm {
    height: 34px;
    font-size: 12px;
}

select.ls-ad-input {
    appearance: none;
    background-image: url("data:image/svg+xml;charset=utf-8,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='8'%3E%3Cpath fill='%236b7c73' d='M6 8 0 0h12z'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 12px center;
    padding-right: 32px;
}

.ls-ad-slot-tip {
    margin: 6px 0 0;
    font-size: 12px;
    color: #8a9a92;
    line-height: 1.6;
}

/* 投放方式卡片 */
.ls-ad-plans {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 8px;
}

.ls-ad-plan {
    position: relative;
    cursor: pointer;
}

.ls-ad-plan input {
    position: absolute;
    opacity: 0;
    pointer-events: none;
}

.ls-ad-plan__box {
    display: flex;
    flex-direction: column;
    gap: 3px;
    padding: 10px 8px;
    border: 1px solid #dfe7e3;
    border-radius: 10px;
    background: #fbfdfc;
    text-align: center;
    transition: border-color .15s ease, background .15s ease, box-shadow .15s ease;
}

.ls-ad-plan__box b {
    font-size: 13px;
    font-weight: 600;
    color: #2a3a32;
}

.ls-ad-plan__box i {
    font-style: normal;
    font-size: 12px;
    color: #7b8b83;
}

.ls-ad-plan input:checked + .ls-ad-plan__box {
    border-color: #5fb878;
    background: rgba(95, 184, 120, .08);
    box-shadow: 0 0 0 2px rgba(95, 184, 120, .16);
}

.ls-ad-plan input:checked + .ls-ad-plan__box b {
    color: #35804d;
}

/* 数量 */
.ls-ad-qty {
    display: inline-flex;
    align-items: center;
    gap: 6px;
}

.ls-ad-qty .ls-ad-input {
    width: 72px;
    height: 34px;
    text-align: center;
    -moz-appearance: textfield;
}

.ls-ad-qty .ls-ad-input::-webkit-outer-spin-button,
.ls-ad-qty .ls-ad-input::-webkit-inner-spin-button {
    -webkit-appearance: none;
    margin: 0;
}

.ls-ad-qty__btn {
    width: 30px;
    height: 30px;
    border: 1px solid #dfe7e3;
    border-radius: 8px;
    background: #fff;
    color: #4b5b53;
    font-size: 16px;
    line-height: 1;
    cursor: pointer;
}

.ls-ad-qty__btn:hover {
    border-color: #5fb878;
    color: #35804d;
}

.ls-ad-qty__unit {
    font-size: 12px;
    color: #7b8b83;
}

/* 图片上传 */
.ls-ad-upload {
    display: flex;
    gap: 12px;
    padding: 10px;
    border: 1px dashed #d8e3dd;
    border-radius: 10px;
    background: #fbfdfc;
}

.ls-ad-upload__preview {
    position: relative;
    flex: 0 0 132px;
    height: 74px;
    border-radius: 8px;
    background: #eef3f0;
    overflow: hidden;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
}

.ls-ad-upload__preview img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.ls-ad-upload__hint {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 4px;
    color: #93a49a;
    font-size: 12px;
}

.ls-ad-upload__hint i {
    font-size: 18px;
}

.ls-ad-upload__side {
    flex: 1;
    min-width: 0;
    display: flex;
    flex-direction: column;
    gap: 7px;
    align-items: flex-start;
}

.ls-ad-upload__meta,
.ls-ad-upload__note {
    margin: 0;
    font-size: 11px;
    color: #8a9a92;
    line-height: 1.5;
}

.ls-ad-upload__side .ls-ad-input {
    width: 100%;
}

/* 结算区 */
.ls-ad-summary {
    margin: 4px 0 16px;
    padding: 12px 14px;
    border-radius: 10px;
    background: linear-gradient(135deg, rgba(95, 184, 120, .09), rgba(95, 184, 120, .02));
    border: 1px solid rgba(95, 184, 120, .18);
}

.ls-ad-summary__line {
    display: flex;
    align-items: center;
    justify-content: space-between;
    font-size: 13px;
    color: #4b5b53;
    line-height: 2;
}

.ls-ad-summary__line b {
    color: #22312a;
    font-weight: 600;
}

.ls-ad-summary__line:first-child b {
    color: #35804d;
}

.ls-ad-summary__line--muted {
    color: #8a9a92;
    font-size: 12px;
}

.ls-ad-summary__line--muted b {
    color: #7b8b83;
    font-weight: 500;
}

.ls-ad-summary__tip {
    margin: 6px 0 0;
    font-size: 12px;
    color: #8a6d3b;
    line-height: 1.6;
}

.ls-ad-form__actions {
    display: flex;
    gap: 10px;
}

.ls-ad-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    height: 38px;
    padding: 0 20px;
    border: 1px solid transparent;
    border-radius: 9px;
    font-size: 14px;
    font-family: inherit;
    text-decoration: none;
    cursor: pointer;
    transition: transform .12s ease, box-shadow .15s ease, background .15s ease;
}

.ls-ad-btn:active {
    transform: translateY(1px);
}

.ls-ad-btn--primary {
    flex: 1;
    background: linear-gradient(135deg, #6bc98a, #4ea86a);
    color: #fff;
    box-shadow: 0 8px 18px -10px rgba(78, 168, 106, .9);
}

.ls-ad-btn--primary:hover {
    background: linear-gradient(135deg, #63c283, #46995f);
}

.ls-ad-btn--primary[disabled] {
    opacity: .6;
    cursor: not-allowed;
}

.ls-ad-btn--ghost {
    background: #fff;
    border-color: #dfe7e3;
    color: #4b5b53;
}

.ls-ad-btn--ghost:hover {
    border-color: #5fb878;
    color: #35804d;
}

/* 我的广告 */
.ls-ad-mine__loading {
    padding: 30px 0;
    text-align: center;
    color: #93a49a;
    font-size: 13px;
}

.ls-ad-mine__empty {
    padding: 40px 0;
    text-align: center;
    color: #93a49a;
    font-size: 13px;
}

.ls-ad-mine__item {
    padding: 12px 14px;
    border: 1px solid #eef2f0;
    border-radius: 10px;
    margin-bottom: 10px;
}

.ls-ad-mine__top {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
}

.ls-ad-mine__title {
    font-size: 14px;
    font-weight: 600;
    color: #22312a;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.ls-ad-badge {
    flex: none;
    padding: 1px 8px;
    border-radius: 999px;
    font-size: 11px;
    line-height: 18px;
}

.ls-ad-badge--active { background: rgba(95, 184, 120, .14); color: #35804d; }
.ls-ad-badge--pending { background: rgba(230, 162, 60, .16); color: #a86a12; }
.ls-ad-badge--paused { background: rgba(120, 130, 125, .14); color: #5c6b63; }
.ls-ad-badge--expired { background: rgba(120, 130, 125, .1); color: #8a9a92; }
.ls-ad-badge--rejected { background: rgba(214, 74, 74, .12); color: #b23b3b; }

.ls-ad-mine__meta {
    margin-top: 6px;
    font-size: 12px;
    color: #8a9a92;
    line-height: 1.8;
}

.ls-ad-mine__stats {
    display: flex;
    gap: 16px;
    margin-top: 8px;
    padding-top: 8px;
    border-top: 1px dashed #eef2f0;
    font-size: 12px;
    color: #6b7c73;
}

.ls-ad-mine__stats b {
    color: #22312a;
    font-weight: 600;
}

/* 窄屏 */
@media (max-width: 640px) {
    .ls-ad-modal {
        padding: 0;
        align-items: flex-end;
    }

    .ls-ad-modal__panel {
        max-width: 100%;
        max-height: 92vh;
        border-radius: 16px 16px 0 0;
    }

    .ls-ad-modal__body {
        padding: 14px 14px 20px;
    }

    .ls-ad-form__row {
        display: block;
        margin-bottom: 12px;
    }

    .ls-ad-form__label {
        display: block;
        padding: 0 0 6px;
        text-align: left;
    }

    .ls-ad-plans {
        grid-template-columns: 1fr;
    }

    .ls-ad-plan__box {
        flex-direction: row;
        align-items: center;
        justify-content: space-between;
        padding: 10px 12px;
    }

    .ls-ad-upload {
        flex-direction: column;
    }

    .ls-ad-upload__preview {
        flex: none;
        width: 100%;
        height: 96px;
    }

    .ls-ad__media img {
        max-height: 160px;
    }

    .ls-ad__rent {
        min-height: 78px;
        padding: 12px 10px;
    }

    .ls-ad__rent-main {
        font-size: 14px;
    }
}

/* 深色面板兼容（后台弹层/夜间模式） */
body.jinsom-panel-dark .ls-ad-modal__panel,
body.dark .ls-ad-modal__panel {
    background: #1e2521;
}

body.jinsom-panel-dark .ls-ad-modal__title,
body.dark .ls-ad-modal__title,
body.jinsom-panel-dark .ls-ad__title,
body.dark .ls-ad__title {
    color: #e8efe9;
}

body.jinsom-panel-dark .ls-ad-input,
body.dark .ls-ad-input {
    background: #262e29;
    border-color: #3a453e;
    color: #e8efe9;
}

/* ------------------------------------------------------------------
 * 移动端 H5（Framework7 页面片段）
 * 片段通过 AJAX 插入 .page-content，广告单元必须自适应窄屏、不撑破列表。
 * ------------------------------------------------------------------ */
.ls-ad--mobile {
    margin: 10px 12px;
    width: auto;
    border-radius: 8px;
}

.ls-ad--mobile .ls-ad__media img {
    max-height: 160px;
    object-fit: cover;
}

.ls-ad--mobile .ls-ad__body {
    padding: 8px 12px 10px;
}

.ls-ad--mobile .ls-ad__title {
    font-size: 14px;
}

.ls-ad--mobile .ls-ad__desc {
    font-size: 11px;
}

.ls-ad--mobile.ls-ad--empty .ls-ad__rent,
.ls-ad--mobile .ls-ad__rent {
    min-height: 64px;
    padding: 10px;
}

.ls-ad--mobile .ls-ad__rent-main {
    font-size: 13px;
}

.ls-ad--mobile .ls-ad__rent-meta {
    font-size: 11px;
    word-break: break-all;
    white-space: normal;
}

/* 官方兜底素材：投放按钮不与广告内容抢宽度 */
.ls-ad--fallback > .ls-ad__rent {
    position: absolute;
    right: 8px;
    bottom: 8px;
    width: auto;
    min-height: 0;
    margin: 0;
    padding: 4px 10px;
    border: 0;
    border-radius: 999px;
    background: rgba(255, 255, 255, .92);
    color: #2b6b40;
    font-size: 12px;
    cursor: pointer;
}
