/* ===========================================================================
   base.css —— 复位与通用组件：按钮、输入、卡片、抽屉、提示、加载。
   =========================================================================== */

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

html, body {
    margin: 0;
    padding: 0;
    height: 100%;
}

body {
    background: var(--bg);
    color: var(--text);
    font-family: var(--font);
    font-size: var(--fs-base);
    line-height: 1.55;
    -webkit-font-smoothing: antialiased;
    -webkit-tap-highlight-color: transparent;
}

h1, h2, h3, h4, h5 {
    margin: 0;
    font-weight: 600;
    line-height: 1.3;
}

h1 { font-size: var(--fs-xl); letter-spacing: -0.02em; }
h2 { font-size: var(--fs-lg); }
h3 { font-size: var(--fs-md); }
h4 { font-size: var(--fs-base); }

p { margin: 0 0 var(--sp-3); }

a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }

img { max-width: 100%; display: block; }

button, input, select, textarea {
    font: inherit;
    color: inherit;
}

[hidden] { display: none !important; }

.muted { color: var(--muted); }
.mono { font-family: var(--font-num); font-size: var(--fs-xs); }
.sr-only {
    position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px;
    overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0;
}

/* ---------------------------------------------------------------- 按钮 */

.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: var(--sp-2);
    min-height: 34px;
    padding: 0 var(--sp-3);
    border: 1px solid var(--line);
    border-radius: var(--radius-sm);
    background: var(--surface);
    color: var(--text);
    font-size: var(--fs-sm);
    font-weight: 500;
    cursor: pointer;
    transition: background var(--dur) var(--ease), border-color var(--dur) var(--ease),
        color var(--dur) var(--ease);
    white-space: nowrap;
}

.btn:hover { background: var(--surface-2); border-color: var(--line-strong); }
.btn:active { background: var(--surface-3); }
.btn[disabled], .btn.is-disabled {
    opacity: 0.5;
    cursor: not-allowed;
    pointer-events: none;
}

.btn-primary {
    background: var(--accent);
    border-color: var(--accent);
    color: #fff;
}
.btn-primary:hover { background: var(--accent-hover); border-color: var(--accent-hover); }

.btn-ghost { background: transparent; border-color: transparent; color: var(--text-2); }
.btn-ghost:hover { background: var(--surface-2); color: var(--text); }

.btn-danger { color: var(--danger); border-color: var(--line); }
.btn-danger:hover { background: var(--danger-soft); border-color: var(--danger); }

.btn-sm { min-height: 28px; padding: 0 var(--sp-2); font-size: var(--fs-xs); }
.btn-lg { min-height: 42px; padding: 0 var(--sp-4); font-size: var(--fs-base); }
.btn-block { width: 100%; }

.icon-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 34px;
    height: 34px;
    border: 1px solid transparent;
    border-radius: var(--radius-sm);
    background: transparent;
    color: var(--text-2);
    cursor: pointer;
    transition: background var(--dur) var(--ease), color var(--dur) var(--ease);
}
.icon-btn:hover { background: var(--surface-2); color: var(--text); }
.icon-btn.is-active { background: var(--accent-soft); color: var(--accent); }
.icon-btn[disabled] { opacity: 0.35; cursor: not-allowed; pointer-events: none; }

.icon { width: 18px; height: 18px; flex: none; stroke-width: 1.6; }
.icon-sm { width: 15px; height: 15px; }

/* ---------------------------------------------------------------- 表单 */

.field { margin-bottom: var(--sp-4); }
.field > label {
    display: block;
    margin-bottom: var(--sp-2);
    font-size: var(--fs-sm);
    font-weight: 500;
    color: var(--text-2);
}
.field-hint { margin-top: var(--sp-1); font-size: var(--fs-xs); color: var(--muted); }

.input, .select, .textarea {
    width: 100%;
    min-height: 36px;
    padding: var(--sp-2) var(--sp-3);
    border: 1px solid var(--line);
    border-radius: var(--radius-sm);
    background: var(--surface);
    transition: border-color var(--dur) var(--ease), box-shadow var(--dur) var(--ease);
}
.textarea { min-height: 84px; resize: vertical; line-height: 1.6; }
.input:focus, .select:focus, .textarea:focus {
    outline: none;
    border-color: var(--accent);
    box-shadow: 0 0 0 3px var(--accent-soft);
}
.input::placeholder, .textarea::placeholder { color: var(--muted); }

.row { display: flex; gap: var(--sp-3); flex-wrap: wrap; }
.row > * { flex: 1 1 200px; min-width: 0; }
.checkline { display: flex; align-items: center; gap: var(--sp-2); font-size: var(--fs-sm); }

/* ---------------------------------------------------------------- 容器 */

.card {
    background: var(--surface);
    border: 1px solid var(--line);
    border-radius: var(--radius);
    box-shadow: var(--shadow-1);
}
.card-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: var(--sp-3);
    padding: var(--sp-3) var(--sp-4);
    border-bottom: 1px solid var(--line);
}
.card-body { padding: var(--sp-4); }
.card-foot {
    padding: var(--sp-3) var(--sp-4);
    border-top: 1px solid var(--line);
    display: flex;
    gap: var(--sp-2);
    justify-content: flex-end;
}

.stack > * + * { margin-top: var(--sp-4); }
.divider { height: 1px; background: var(--line); margin: var(--sp-4) 0; }

.badge {
    display: inline-flex;
    align-items: center;
    padding: 1px var(--sp-2);
    border-radius: var(--radius-pill);
    background: var(--surface-2);
    color: var(--text-2);
    font-size: var(--fs-xs);
    font-weight: 500;
}
.badge-accent { background: var(--accent-soft); color: var(--accent); }
.badge-danger { background: var(--danger-soft); color: var(--danger); }

/* ------------------------------------------------------------ 抽屉/面板 */

.sheet {
    position: fixed;
    z-index: var(--z-sheet);
    background: var(--surface);
    border: 1px solid var(--line);
    border-radius: var(--radius);
    box-shadow: var(--shadow-3);
    display: flex;
    flex-direction: column;
    overflow: hidden;
    opacity: 0;
    visibility: hidden;
    transform: translateY(6px);
    transition: opacity var(--dur) var(--ease), transform var(--dur) var(--ease),
        visibility var(--dur) var(--ease);
}
.sheet.is-open { opacity: 1; visibility: visible; transform: none; }
.sheet-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: var(--sp-3) var(--sp-4);
    border-bottom: 1px solid var(--line);
    font-weight: 600;
    font-size: var(--fs-base);
}
.sheet-body { overflow: auto; padding: var(--sp-2); flex: 1; }

/* ---------------------------------------------------------------- 列表 */

.list { display: flex; flex-direction: column; }
.list-item {
    display: flex;
    align-items: center;
    gap: var(--sp-3);
    padding: var(--sp-3);
    border-radius: var(--radius-sm);
    cursor: pointer;
    transition: background var(--dur) var(--ease);
}
.list-item:hover { background: var(--surface-2); }
.list-item.is-active { background: var(--accent-soft); }
.list-item-main { flex: 1; min-width: 0; }
.list-item-title {
    font-weight: 500;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
.list-item-sub { font-size: var(--fs-xs); color: var(--muted); }

/* ---------------------------------------------------------------- 提示 */

/* ------------------------------------------------------ 地点候选列表 */

/* 查看页顶栏搜索、管理端起点/终点/途经点/选点弹窗共用 */
.search-list {
    position: absolute;
    top: calc(100% + 6px);
    left: 0;
    right: 0;
    z-index: var(--z-sheet, 600);
    max-height: 320px;
    overflow: auto;
    background: var(--surface);
    border: 1px solid var(--line);
    border-radius: var(--radius);
    box-shadow: var(--shadow-3);
}
.search-item {
    padding: var(--sp-2) var(--sp-3);
    cursor: pointer;
    border-bottom: 1px solid var(--line);
}
.search-item:last-child { border-bottom: 0; }
.search-item:hover, .search-item.is-active { background: var(--surface-2); }
.search-item-title { font-size: var(--fs-sm); }
.search-item-sub { font-size: var(--fs-xs); color: var(--muted); }

/* ------------------------------------------------------------ 图钉标记 */

/* 详情行：查看页照片详情、管理端概览共用 */
.detail-row { padding: var(--sp-2) 0; border-bottom: 1px solid var(--line); }
.detail-row dt { font-size: var(--fs-xs); color: var(--muted); margin-bottom: 2px; }
.detail-row dd { margin: 0; font-size: var(--fs-sm); word-break: break-all; }

/* 用于地图上标示地点：外层描白边（含尖角），内层成钉形 */
.pin-outline {
    filter: drop-shadow(0 0 1.2px #fff) drop-shadow(0 0 1.2px #fff)
            drop-shadow(0 0 1.2px #fff) drop-shadow(0 2px 3px rgba(0, 0, 0, 0.35));
}
.pin-body {
    display: flex;
    align-items: flex-start;
    justify-content: center;
    box-sizing: border-box;
    width: 22px;
    height: 30px;
    padding-top: 4px;
    background: var(--pin, var(--accent));
    color: #fff;
    font-size: 11px;
    font-weight: 600;
    line-height: 1.4;
    clip-path: polygon(0 0, 100% 0, 100% 68%, 50% 100%, 0 68%);
}
.pin-body.is-large {
    width: 28px;
    height: 38px;
    padding-top: 6px;
    font-size: var(--fs-xs);
}

/* ---------------------------------------------------------------- 提示 */

.toast-wrap {
    position: fixed;
    right: var(--sp-4);
    /* --dock-h：右下角常驻的上传进度卡占住的高度，避免提示把它盖住 */
    bottom: calc(var(--sp-4) + var(--safe-bottom) + var(--dock-h, 0px));
    z-index: var(--z-toast);
    display: flex;
    flex-direction: column;
    gap: var(--sp-2);
    align-items: flex-end;
    pointer-events: none;
}
.toast {
    max-width: 340px;
    padding: var(--sp-2) var(--sp-4);
    border: 1px solid var(--line);
    border-radius: var(--radius-sm);
    background: var(--surface);
    box-shadow: var(--shadow-2);
    font-size: var(--fs-sm);
    animation: toast-in var(--dur) var(--ease);
}
.toast-error { border-color: var(--danger); color: var(--danger); }
.toast-ok { border-color: var(--accent); }
@keyframes toast-in { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; } }

.empty {
    padding: var(--sp-6) var(--sp-4);
    text-align: center;
    color: var(--muted);
    font-size: var(--fs-sm);
}

.loading-box {
    display: flex;
    align-items: center;
    gap: var(--sp-3);
    color: var(--muted);
    font-size: var(--fs-sm);
}
.spinner {
    width: 16px;
    height: 16px;
    border: 2px solid var(--line-strong);
    border-top-color: var(--accent);
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ---------------------------------------------------------------- 弹层 */

.modal {
    position: fixed;
    inset: 0;
    z-index: var(--z-modal);
    display: flex;
    align-items: center;
    justify-content: center;
    padding: var(--sp-4);
    background: var(--overlay);
    opacity: 0;
    visibility: hidden;
    transition: opacity var(--dur) var(--ease), visibility var(--dur) var(--ease);
}
.modal.is-open { opacity: 1; visibility: visible; }
.modal-panel {
    width: min(720px, 100%);
    max-height: min(86vh, 900px);
    display: flex;
    flex-direction: column;
    background: var(--surface);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-3);
    overflow: hidden;
}
.modal-panel.is-wide { width: min(1040px, 100%); }
.modal-panel.is-narrow { width: min(420px, 100%); }
.modal-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: var(--sp-4);
    border-bottom: 1px solid var(--line);
}
.modal-body { padding: var(--sp-4); overflow: auto; flex: 1; }
.modal-foot {
    display: flex;
    justify-content: flex-end;
    gap: var(--sp-2);
    padding: var(--sp-3) var(--sp-4);
    border-top: 1px solid var(--line);
}

/* ------------------------------------------------------------ 滚动条 */

* { scrollbar-width: thin; scrollbar-color: var(--line-strong) transparent; }
*::-webkit-scrollbar { width: 8px; height: 8px; }
*::-webkit-scrollbar-thumb {
    background: var(--line-strong);
    border-radius: var(--radius-pill);
}
*::-webkit-scrollbar-track { background: transparent; }

@media (prefers-reduced-motion: reduce) {
    * { animation-duration: 0.01ms !important; transition-duration: 0.01ms !important; }
}
