/* ════════════════════════════════════════════════════════════════
   路线广场 — 样式
   与 view.css 风格一致，品牌色 #e94560
   ════════════════════════════════════════════════════════════════ */

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

body, html {
    height: 100%;
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
    overflow: hidden;
}

#app {
    display: block;
    height: 100vh;
    width: 100vw;
    overflow: hidden;
    position: relative;
}

/* ── 导航栏 ── */
.navbar {
    position: absolute;
    top: 0; left: 0; right: 0;
    height: 48px;
    background: rgba(255,255,255,0.95);
    backdrop-filter: blur(8px);
    z-index: 1000;
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 16px;
    box-shadow: 0 1px 6px rgba(0,0,0,0.08);
}

.navbar-brand {
    font-size: 1rem;
    font-weight: 600;
    color: #333;
    display: flex;
    align-items: center;
    gap: 6px;
}

.navbar-brand span { color: #e94560; }

.navbar-actions {
    display: flex;
    align-items: center;
    gap: 12px;
}

#headerActionBtn {
    padding: 4px 12px;
    font-size: 0.8rem;
    background: #fff;
    border: 1px solid #ddd;
    border-radius: 16px;
    cursor: pointer;
    color: #555;
    transition: all 0.2s;
}
#headerActionBtn:hover {
    border-color: #e94560;
    color: #e94560;
}
#headerActionBtn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

#createTripBtn {
    padding: 4px 14px;
    font-size: 0.8rem;
    background: #e94560;
    border: 1px solid #e94560;
    border-radius: 16px;
    cursor: pointer;
    color: #fff;
    font-weight: 500;
    transition: all 0.2s;
}
#createTripBtn:hover {
    background: #d63a52;
    border-color: #d63a52;
}
#createTripBtn:active {
    transform: scale(0.97);
}

/* ── 创建路线下拉（hover/点击展开两种方式） ── */
.create-trip-wrap {
    position: relative;
}
.create-menu {
    position: absolute;
    top: calc(100% + 8px);
    right: 0;
    min-width: 248px;
    background: #fff;
    border: 1px solid #eee;
    border-radius: 12px;
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.12);
    padding: 6px;
    z-index: 1000;
    opacity: 0;
    visibility: hidden;
    transform: translateY(-6px);
    transition: opacity 0.18s, transform 0.18s, visibility 0.18s;
}
.create-trip-wrap:hover .create-menu,
.create-trip-wrap:focus-within .create-menu,
.create-trip-wrap.open .create-menu {
    opacity: 1;
    visibility: visible;
    transform: translateY(0);
}
.create-menu-item {
    display: flex;
    align-items: flex-start;
    gap: 10px;
    width: 100%;
    text-align: left;
    background: none;
    border: none;
    border-radius: 8px;
    padding: 10px;
    cursor: pointer;
    transition: background 0.15s;
}
.create-menu-item:hover {
    background: #fdeef1;
}
.create-menu-item:focus-visible {
    outline: 2px solid #e94560;
    outline-offset: -2px;
}
.cmi-icon {
    font-size: 1.2rem;
    line-height: 1.2;
}
.cmi-text {
    display: flex;
    flex-direction: column;
}
.cmi-title {
    font-size: 0.85rem;
    font-weight: 600;
    color: #333;
}
.cmi-desc {
    font-size: 0.72rem;
    color: #999;
    margin-top: 2px;
}

/* ── 路线搜索框 ── */
.route-search {
    flex: 1;
    max-width: 440px;
    margin: 0 16px;
    display: flex;
    align-items: center;
    gap: 4px;
    background: #f5f5f7;
    border: 1px solid #e3e3e8;
    border-radius: 18px;
    padding: 2px 4px 2px 12px;
    transition: border-color 0.2s, box-shadow 0.2s;
}
.route-search:focus-within {
    border-color: #e94560;
    box-shadow: 0 0 0 3px rgba(233, 69, 96, 0.12);
}
#routeSearchInput {
    flex: 1;
    min-width: 0;
    border: none;
    outline: none;
    background: transparent;
    font-size: 0.85rem;
    color: #333;
    padding: 6px 0;
}
#routeSearchInput::placeholder { color: #aaa; }
#routeSearchBtn,
#routeSearchClear {
    border: none;
    background: transparent;
    cursor: pointer;
    font-size: 0.9rem;
    line-height: 1;
    padding: 6px 8px;
    border-radius: 14px;
    color: #888;
    transition: background 0.15s, color 0.15s;
}
#routeSearchBtn:hover { background: #e94560; color: #fff; }
#routeSearchClear:hover { background: #ddd; color: #333; }

.nav-login {
    font-size: 0.82rem;
    color: #e94560;
    text-decoration: none;
    padding: 4px 12px;
    border: 1px solid #e94560;
    border-radius: 16px;
    transition: background 0.2s;
}
.nav-login:hover { background: #e94560; color: #fff; }

.nav-user {
    font-size: 0.82rem;
    color: #555;
    display: flex;
    align-items: center;
    gap: 4px;
}

.nav-logout {
    font-size: 0.72rem;
    color: #e94560;
    background: none;
    border: none;
    cursor: pointer;
    padding: 0 2px;
    margin-left: 2px;
    transition: opacity 0.15s;
}
.nav-logout:hover {
    text-decoration: underline;
    opacity: 0.75;
}

/* ── 侧边栏 ── */
#sidebar {
    position: absolute;
    top: 48px;
    left: 0;
    bottom: 0;
    width: 300px;
    background: #fff;
    box-shadow: 2px 0 8px rgba(0,0,0,0.08);
    z-index: 999;
    display: flex;
    flex-direction: column;
    transition: transform 0.3s ease;
}

#sidebar.collapsed {
    transform: translateX(-300px);
}

/* ── Tab 切换栏 ── */
.tab-bar {
    display: flex;
    padding: 6px 8px;
    gap: 4px;
    background: #fafafa;
    border-bottom: 1px solid #eee;
    flex-shrink: 0;
}

.tab-btn {
    flex: 1;
    padding: 6px 0;
    font-size: 0.78rem;
    border: none;
    background: transparent;
    color: #777;
    border-radius: 6px;
    cursor: pointer;
    transition: all 0.15s;
    white-space: nowrap;
}

.tab-btn:hover {
    background: #f0f0f0;
    color: #555;
}

.tab-btn.active {
    background: #e94560;
    color: #fff;
    font-weight: 500;
}

/* ── 子 Tab 切换栏 ── */
.sub-tab-bar {
    display: flex;
    padding: 4px 8px;
    gap: 4px;
    background: #f5f5f5;
    border-bottom: 1px solid #eee;
    flex-shrink: 0;
}

.sub-tab-btn {
    flex: 1;
    padding: 4px 0;
    font-size: 0.72rem;
    border: none;
    background: transparent;
    color: #888;
    border-radius: 4px;
    cursor: pointer;
    transition: all 0.15s;
    white-space: nowrap;
}

.sub-tab-btn:hover {
    background: #eee;
    color: #666;
}

.sub-tab-btn.active {
    background: #fff;
    color: #e94560;
    font-weight: 500;
    box-shadow: 0 1px 3px rgba(0,0,0,0.1);
}

/* ── 筛选 + 排序控件 ── */
.controls {
    padding: 8px;
    background: #f5f5f5;
    border-bottom: 1px solid #eee;
    flex-shrink: 0;
}
.filters {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    margin-bottom: 8px;
}
.sorts {
    display: flex;
    align-items: center;
    gap: 6px;
}
.sorts__label {
    font-size: 0.72rem;
    color: #888;
}
.pill {
    padding: 3px 12px;
    font-size: 0.72rem;
    border: none;
    background: #fff;
    color: #666;
    border-radius: 12px;
    cursor: pointer;
    transition: all 0.15s;
    white-space: nowrap;
}
.pill:hover {
    background: #eee;
}
.pill--active {
    background: #e94560;
    color: #fff;
    font-weight: 500;
}
.sort-select {
    padding: 3px 6px;
    font-size: 0.72rem;
    border: 1px solid #ddd;
    border-radius: 6px;
    background: #fff;
    color: #555;
    cursor: pointer;
}

/* ── 状态标签 ── */
.status-tag {
    display: inline-block;
    font-size: 0.68rem;
    padding: 1px 6px;
    border-radius: 8px;
    margin-left: 4px;
    white-space: nowrap;
}

.status-pending {
    background: #fff3cd;
    color: #856404;
}

.status-published {
    background: #d4edda;
    color: #155724;
}

.status-rejected {
    background: #f8d7da;
    color: #721c24;
}

.status-unlisted {
    background: #e2e3e5;
    color: #383d41;
}

/* ── 登录提示 ── */
.login-prompt {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 40px 16px;
    text-align: center;
    color: #888;
    font-size: 0.9rem;
    gap: 12px;
}

.login-prompt-btn {
    display: inline-block;
    padding: 8px 24px;
    background: #e94560;
    color: #fff;
    text-decoration: none;
    border-radius: 20px;
    font-size: 0.85rem;
    transition: opacity 0.15s;
}
.login-prompt-btn:hover { opacity: 0.85; }

.sidebar-header {
    padding: 12px 16px;
    border-bottom: 1px solid #eee;
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-shrink: 0;
}

.sidebar-title {
    font-size: 0.95rem;
    font-weight: 600;
    color: #333;
}

.sidebar-count {
    font-size: 0.75rem;
    color: #999;
    background: #f5f5f5;
    padding: 2px 8px;
    border-radius: 10px;
}

/* ── 路线列表 ── */
#tripList {
    flex: 1;
    overflow-y: auto;
    padding: 8px;
}

.trip-card {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px 12px;
    margin-bottom: 4px;
    border-radius: 8px;
    cursor: pointer;
    transition: background 0.15s;
    border: 1px solid transparent;
}

.trip-card:hover {
    background: #f8f8f8;
}

.trip-card.active {
    background: #fef2f4;
    border-color: #e94560;
}

.trip-card .color-dot {
    width: 10px;
    height: 10px;
    border-radius: 50%;
    flex-shrink: 0;
}

.trip-card .card-index {
    width: 22px;
    height: 22px;
    border-radius: 50%;
    flex-shrink: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    color: #fff;
    font-size: 0.7rem;
    font-weight: 700;
}

.trip-card .card-info {
    flex: 1;
    min-width: 0;
}

.trip-card .card-name {
    font-size: 0.88rem;
    font-weight: 500;
    color: #333;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.trip-card .card-name .author-tag {
    font-size: 0.74rem;
    font-weight: 400;
    color: #999;
}

.badge-own {
    display: inline-block;
    margin-left: 6px;
    padding: 1px 6px;
    font-size: 0.7rem;
    font-weight: 500;
    color: #e94560;
    background: #fdeef1;
    border: 1px solid #f5c2cd;
    border-radius: 4px;
    vertical-align: middle;
}

.badge-collect, .badge-like {
    display: inline-block;
    margin-left: 6px;
    padding: 1px 6px;
    font-size: 0.7rem;
    font-weight: 500;
    border-radius: 4px;
    vertical-align: middle;
}
.badge-collect {
    color: #e94560;
    background: #fdeef1;
    border: 1px solid #f5c2cd;
}
.badge-like {
    color: #d98a00;
    background: #fff5e6;
    border: 1px solid #f5d9a8;
}

.trip-card .card-meta {
    font-size: 0.72rem;
    color: #999;
    margin-top: 2px;
    display: flex;
    gap: 8px;
}

/* ── 路线详情面板（选中线路时在列表上方展示的紧凑摘要卡，不独占侧栏） ── */
#tripDetail {
    flex-shrink: 0;
    max-height: 55%;
    overflow-y: auto;
    padding: 0;
    border-bottom: 1px solid #eee;
    /* 复用地图选中线路色：淡底 + 左侧同色竖条；无 --trip 时兜底浅蓝 */
    background: #f8fbff; /* 兜底（不支持 color-mix 的浏览器） */
    background: color-mix(in srgb, var(--trip, #2196f3) 8%, #ffffff);
    border-left: 4px solid var(--trip, #2196f3);
    --trip-fg: var(--trip, #2196f3);
}

.back-btn {
    display: block;
    width: 100%;
    padding: 10px 16px;
    background: none;
    border: none;
    border-bottom: 1px solid #eee;
    font-size: 0.85rem;
    color: var(--trip-fg, #e94560);
    cursor: pointer;
    text-align: left;
    transition: background 0.15s;
}
.back-btn:hover { background: #fef2f4; }
.back-btn:hover { background: color-mix(in srgb, var(--trip, #e94560) 12%, #ffffff); }

.detail-content {
    padding: 16px;
}

.detail-name {
    font-size: 1.1rem;
    font-weight: 600;
    color: var(--trip-fg, #333);
    margin-bottom: 8px;
}

.detail-meta {
    display: flex;
    gap: 12px;
    margin-bottom: 12px;
    font-size: 0.8rem;
    color: #666;
}

.detail-desc {
    font-size: 0.85rem;
    color: #555;
    line-height: 1.6;
    margin-bottom: 12px;
}

.detail-regions {
    display: flex;
    flex-wrap: wrap;
    gap: 4px;
    margin-bottom: 16px;
}

.detail-regions .region-tag {
    font-size: 0.7rem;
    background: #f0f0f0;
    color: #888;
    padding: 2px 8px;
    border-radius: 10px;
}

.detail-link {
    display: inline-block;
    font-size: 0.85rem;
    color: var(--trip-fg, #e94560);
    text-decoration: none;
    padding: 6px 0;
    font-weight: 500;
    transition: opacity 0.15s;
}
.detail-link:hover { opacity: 0.7; }

/* ── 详情操作按钮（我的路线） ── */
.detail-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    margin-top: 8px;
}

.detail-actions .action-btn {
    font-size: 0.78rem;
    padding: 5px 12px;
    border: 1px solid #ddd;
    border-radius: 14px;
    background: #fff;
    color: #555;
    cursor: pointer;
    transition: all 0.15s;
    white-space: nowrap;
}

.detail-actions .action-btn:hover {
    border-color: #e94560;
    color: #e94560;
    background: #fef2f4;
}

.detail-actions .action-btn.danger {
    border-color: #e94560;
    color: #e94560;
}
.detail-actions .action-btn.danger:hover {
    background: #e94560;
    color: #fff;
}

/* ── Loading / 空状态 ── */
.loading-state, .empty-state, .error-state {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 40px 16px;
    color: #999;
    font-size: 0.85rem;
    text-align: center;
    height: 100%;
}

.spinner {
    width: 32px;
    height: 32px;
    border: 3px solid #eee;
    border-top-color: #e94560;
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
    margin-bottom: 12px;
}
@keyframes spin { to { transform: rotate(360deg); } }

.error-state button {
    margin-top: 12px;
    padding: 6px 20px;
    background: #e94560;
    color: #fff;
    border: none;
    border-radius: 16px;
    cursor: pointer;
    font-size: 0.85rem;
}

/* ── 地图容器 ── */
#map {
    position: absolute;
    top: 48px;
    left: 300px;
    right: 0;
    bottom: 0;
    z-index: 1;
    transition: left 0.3s ease;
}

#sidebar.collapsed ~ #map {
    left: 0;
}

.map-loading {
    position: absolute;
    top: 0; left: 0; right: 0; bottom: 0;
    z-index: 500;
    background: rgba(255,255,255,0.6);
    display: flex;
    align-items: center;
    justify-content: center;
}

/* ── 侧边栏切换按钮 ── */
#sidebarToggleBtn {
    position: absolute;
    top: 56px;
    left: 300px;
    z-index: 1001;
    background: #fff;
    border: none;
    width: 28px;
    height: 28px;
    border-radius: 50%;
    box-shadow: 0 2px 6px rgba(0,0,0,0.15);
    cursor: pointer;
    font-size: 0.8rem;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: left 0.3s ease;
    color: #666;
}

#sidebar.collapsed ~ #sidebarToggleBtn {
    left: 12px;
}

/* ── 地图控件 ── */
.map-controls {
    position: absolute;
    top: 56px;
    right: 12px;
    z-index: 999;
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.layer-btn {
    width: 36px;
    height: 36px;
    border: none;
    background: #fff;
    border-radius: 50%;
    cursor: pointer;
    font-size: 1rem;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 2px 6px rgba(0,0,0,0.15);
    transition: transform 0.2s, background 0.2s;
}

.layer-btn:hover { transform: scale(1.05); }
.layer-btn.active { background: #e94560; }

/* ── 底栏信息 ── */
.footer-info {
    position: absolute;
    bottom: 8px;
    left: 50%;
    transform: translateX(-50%);
    background: rgba(255,255,255,0.85);
    backdrop-filter: blur(4px);
    padding: 4px 14px;
    border-radius: 12px;
    font-size: 0.7rem;
    color: #999;
    z-index: 500;
    white-space: nowrap;
    pointer-events: none;
}

/* ICP 备案号链接（底栏本身 pointer-events:none，链接单独放开点击） */
.footer-info .icp-link {
    pointer-events: auto;
    margin-left: 8px;
    color: #999;
    text-decoration: none;
}

.footer-info .icp-link:hover {
    color: #666;
    text-decoration: underline;
}

/* ── 地图永久标签（路线名） ── */
.trip-label {
    background: rgba(255,255,255,0.92) !important;
    border: none !important;
    border-radius: 4px !important;
    box-shadow: 0 2px 6px rgba(0,0,0,0.18) !important;
    color: #333 !important;
    font-size: 0.78rem !important;
    font-weight: 500 !important;
    padding: 2px 8px !important;
    white-space: nowrap;
    pointer-events: none;
}

.trip-label::before {
    border-top-color: rgba(255,255,255,0.92) !important;
}

/* ── Leaflet 弹窗微调 ── */
.trip-popup h3 {
    font-size: 0.95rem;
    color: #e94560;
    margin-bottom: 2px;
}

.trip-popup p {
    font-size: 0.78rem;
    color: #666;
    margin: 1px 0;
}

.leaflet-popup-content-wrapper { border-radius: 8px; }

/* ── 响应式 ── */
@media (max-width: 768px) {
    #sidebar { width: calc(100vw - 40px); }
    #sidebar.collapsed { transform: translateX(calc(-100vw + 40px)); }
    #map { left: 0; }
    #sidebarToggleBtn { left: 8px; }
    .navbar { height: 44px; }
    .navbar-brand { font-size: 0.9rem; }
    .route-search { max-width: none; margin: 0 8px; }
}
