/* ===========================================================
   常用收货地址（地址簿）
   手机：从底部升起的抽屉式面板（圆角、可滚动、独立遮罩）
   桌面：居中卡片弹窗
   由 js/adr-book.js 生成 DOM，页面只需引这一个 css + 一个 js
   =========================================================== */

.adr-book {
    position: fixed;
    top: 0;
    right: 0;
    bottom: 0;
    left: 0;
    z-index: 9999;
    display: none;
    font-family: -apple-system, BlinkMacSystemFont, "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", "Helvetica Neue", sans-serif;
    -webkit-font-smoothing: antialiased;
    -webkit-tap-highlight-color: transparent;
}

.adr-book.is-open {
    display: block;
}

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

/* 遮罩 */
.adr-mask {
    position: absolute;
    top: 0;
    right: 0;
    bottom: 0;
    left: 0;
    background: rgba(9, 18, 20, .46);
    -webkit-backdrop-filter: blur(2px);
    backdrop-filter: blur(2px);
    opacity: 0;
    transition: opacity .26s ease;
}

.adr-book.is-open .adr-mask {
    opacity: 1;
}

/* 面板本体 */
.adr-sheet {
    position: absolute;
    left: 50%;
    bottom: 0;
    display: flex;
    flex-direction: column;
    width: 100%;
    max-width: 520px;
    max-height: 90vh;
    padding-bottom: env(safe-area-inset-bottom);
    background: #fff;
    border-radius: 22px 22px 0 0;
    box-shadow: 0 -12px 40px rgba(8, 22, 26, .22);
    overflow: hidden;
    transform: translate3d(-50%, 100%, 0);
    transition: transform .34s cubic-bezier(.28, .86, .34, 1);
}

.adr-book.is-open .adr-sheet {
    transform: translate3d(-50%, 0, 0);
}

/* 顶部把手（手机手感） */
.adr-sheet::before {
    content: "";
    display: block;
    width: 38px;
    height: 4px;
    margin: 8px auto 0;
    border-radius: 2px;
    background: #e2e7e5;
    flex: none;
}

/* ---------- 头部 ---------- */
.adr-head {
    flex: none;
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 8px 16px 10px;
}

.adr-title {
    margin: 0;
    font-size: 16.5px;
    font-weight: 600;
    letter-spacing: .2px;
    color: #16211e;
}

.adr-x {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 32px;
    height: 32px;
    margin-right: -4px;
    padding: 0;
    border: 0;
    border-radius: 50%;
    background: #f3f5f4;
    color: #6d7a76;
    cursor: pointer;
    transition: background-color .18s ease, color .18s ease;
}

.adr-x svg {
    width: 15px;
    height: 15px;
    fill: none;
    stroke: currentColor;
    stroke-width: 2.2;
    stroke-linecap: round;
}

.adr-x:active {
    background: #e8ecea;
    color: #16211e;
}

.adr-book.has-form .adr-x {
    /* 表单里也保留关闭按钮，避免用户找不到退出的地方 */
    display: flex;
}

/* ---------- 内容区 ---------- */
.adr-body {
    flex: 1 1 auto;
    min-height: 0;
    padding: 2px 16px 4px;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
    overscroll-behavior: contain;
}

/* 列表 / 表单 二选一 */
.adr-book:not(.has-form) .adr-form {
    display: none;
}

.adr-book.has-form .adr-list-wrap {
    display: none;
}

/* 操作提示 */
.adr-tip {
    margin: 0 0 9px 2px;
    font-size: 12px;
    line-height: 1.4;
    color: #9aa6a2;
}

.adr-book.has-form .adr-tip,
.adr-book.is-empty .adr-tip {
    display: none;
}

/* ---------- 地址卡片 ---------- */
.adr-list {
    margin: 0;
    padding: 0;
    list-style: none;
}

.adr-card {
    position: relative;
    margin-bottom: 10px;
    padding: 12px 14px 6px;
    border: 1px solid #e8ecea;
    border-radius: 14px;
    background: #fff;
    cursor: pointer;
    transition: border-color .18s ease, background-color .18s ease, transform .12s ease;
}

.adr-card:active {
    background: #f6faf9;
    border-color: #cfe3e0;
    transform: scale(.995);
}

.adr-card-top {
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: 2px 8px;
    margin-bottom: 5px;
}

.adr-name {
    font-size: 15px;
    font-weight: 600;
    color: #16211e;
    max-width: 100%;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.adr-tel {
    font-size: 13px;
    color: #5f6c68;
    font-variant-numeric: tabular-nums;
}

.adr-tag {
    flex: none;
    padding: 1px 6px;
    border-radius: 5px;
    background: rgba(28, 143, 137, .1);
    color: #1c8f89;
    font-size: 10.5px;
    line-height: 1.5;
}

.adr-addr {
    font-size: 12.5px;
    line-height: 1.6;
    color: #6b7874;
    overflow-wrap: anywhere;
    word-break: normal;
}

.adr-ops {
    display: flex;
    justify-content: flex-end;
    gap: 2px;
    margin: 2px -6px -2px 0;
}

.adr-op {
    padding: 7px 9px;
    border: 0;
    border-radius: 8px;
    background: transparent;
    color: #8a9691;
    font-size: 12.5px;
    font-family: inherit;
    line-height: 1;
    cursor: pointer;
}

.adr-op:active {
    background: #f0f3f2;
}

.adr-op.del {
    color: #cf5b4d;
}

/* ---------- 空状态 ---------- */
.adr-empty {
    display: none;
    padding: 34px 10px 26px;
    text-align: center;
}

.adr-book.is-empty .adr-empty {
    display: block;
}

.adr-empty svg {
    width: 54px;
    height: 54px;
    margin-bottom: 10px;
    fill: none;
    stroke: #cfdad7;
    stroke-width: 1.6;
    stroke-linecap: round;
    stroke-linejoin: round;
}

.adr-empty p {
    margin: 0 0 4px;
    font-size: 14px;
    font-weight: 600;
    color: #55625e;
}

.adr-empty span {
    font-size: 12.5px;
    color: #93a09b;
}

/* ---------- 表单 ---------- */
.adr-field {
    display: block;
    margin-bottom: 12px;
}

.adr-field>span {
    display: block;
    margin: 0 0 6px 2px;
    font-size: 12.5px;
    color: #7d8a86;
}

.adr-field input,
.adr-field textarea {
    display: block;
    width: 100%;
    padding: 11px 12px;
    border: 1px solid #e2e7e5;
    border-radius: 12px;
    background: #f7f9f8;
    color: #16211e;
    font-size: 15px;
    font-family: inherit;
    line-height: 1.45;
    outline: none;
    transition: border-color .18s ease, background-color .18s ease, box-shadow .18s ease;
    -webkit-appearance: none;
    appearance: none;
}

.adr-field textarea {
    min-height: 76px;
    padding: 10px 12px;
    resize: none;
}

.adr-field input::placeholder,
.adr-field textarea::placeholder {
    color: #b3bdb9;
    font-size: 13.5px;
}

.adr-field input:focus,
.adr-field textarea:focus {
    background: #fff;
    border-color: #1c8f89;
    box-shadow: 0 0 0 3px rgba(28, 143, 137, .12);
}

.adr-field.is-bad input,
.adr-field.is-bad textarea {
    border-color: #e0857a;
    background: #fff8f7;
}

.adr-err {
    display: none;
    margin: -2px 2px 10px;
    font-size: 12.5px;
    line-height: 1.5;
    color: #cf5b4d;
}

.adr-err.on {
    display: block;
}

.adr-actions {
    display: flex;
    gap: 10px;
    margin: 4px 0 6px;
}

.adr-btn {
    flex: 1 1 0;
    height: 44px;
    border: 0;
    border-radius: 12px;
    font-size: 15px;
    font-weight: 600;
    font-family: inherit;
    cursor: pointer;
    transition: transform .12s ease, opacity .18s ease;
}

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

.adr-btn.primary {
    background: linear-gradient(135deg, #1c8f89, #17a89f);
    color: #fff;
    box-shadow: 0 6px 16px rgba(28, 143, 137, .24);
}

.adr-btn.ghost {
    background: #f2f4f3;
    color: #5f6c68;
}

/* ---------- 底部按钮 ---------- */
.adr-foot {
    flex: none;
    padding: 10px 16px 14px;
    border-top: 1px solid #f1f4f3;
    background: #fff;
}

.adr-add {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    width: 100%;
    height: 46px;
    border: 1px dashed #c8d3d0;
    border-radius: 14px;
    background: #fafbfb;
    color: #1c8f89;
    font-size: 14.5px;
    font-weight: 600;
    font-family: inherit;
    cursor: pointer;
    transition: background-color .18s ease, border-color .18s ease;
}

.adr-add:active {
    background: #f2f8f7;
    border-color: #9fcac6;
}

.adr-add svg {
    width: 15px;
    height: 15px;
    fill: none;
    stroke: currentColor;
    stroke-width: 2.2;
    stroke-linecap: round;
}

/* 表单状态下底部按钮换文案 */
.adr-book.has-form .adr-foot {
    display: none;
}

/* ---------- 轻提示 ---------- */
/* 提示条出现时，给内容留出高度，避免盖住最后一条地址 */
.adr-book.show-toast .adr-body {
    padding-bottom: 52px;
}

.adr-toast {
    position: absolute;
    left: 50%;
    bottom: 84px;
    display: flex;
    align-items: center;
    gap: 4px;
    max-width: 88%;
    padding: 9px 8px 9px 14px;
    border-radius: 10px;
    background: rgba(22, 33, 30, .92);
    color: #fff;
    font-size: 13px;
    line-height: 1.3;
    white-space: nowrap;
    opacity: 0;
    transform: translate3d(-50%, 8px, 0);
    pointer-events: none;
    transition: opacity .22s ease, transform .22s ease;
}

.adr-toast.on {
    opacity: 1;
    transform: translate3d(-50%, 0, 0);
    pointer-events: auto;
}

.adr-toast .undo {
    padding: 3px 8px;
    border: 0;
    border-radius: 7px;
    background: rgba(255, 255, 255, .14);
    color: #7fe0d8;
    font-size: 13px;
    font-weight: 600;
    font-family: inherit;
    cursor: pointer;
}

/* ---------- 桌面端：居中卡片 ---------- */
@media (min-width: 641px) {

    .adr-sheet {
        top: 50%;
        bottom: auto;
        width: 440px;
        max-height: 82vh;
        border-radius: 16px;
        box-shadow: 0 24px 60px rgba(8, 22, 26, .28);
        opacity: 0;
        transform: translate3d(-50%, -46%, 0);
        transition: transform .26s ease, opacity .26s ease;
    }

    .adr-book.is-open .adr-sheet {
        opacity: 1;
        transform: translate3d(-50%, -50%, 0);
    }

    .adr-sheet::before {
        display: none;
    }

    .adr-head {
        padding: 16px 18px 10px;
    }

    .adr-body {
        padding: 2px 18px 4px;
    }

    .adr-foot {
        padding: 12px 18px 16px;
    }

    .adr-toast {
        bottom: 80px;
    }

    .adr-card:hover {
        border-color: #cfe3e0;
    }
}

/* 打开面板时锁住页面滚动 */
body.adr-lock {
    overflow: hidden;
}
