/* ==========================================================================
   2026 新疆自驾交互路书 - 样式设计系统
   设计理念：还原经典美观的卡片长滚动风格，融合极其克制的无噪编辑表单
   ========================================================================== */

/* 核心变量定义 */
:root {
    --bg-main: #f8fafc;
    --bg-card: #ffffff;
    --bg-header: #1a202c;
    --text-primary: #1e293b;
    --text-secondary: #475569;
    --text-light: #94a3b8;
    --border-color: #cbd5e1;
    --focus-ring: #3b82f6;
    
    /* 语义化色系 */
    --color-primary: #2b6cb0;     /* 路线蓝色 */
    --color-primary-light: #ebf8ff;
    --color-success: #2f855a;     /* 玩法绿色 */
    --color-success-light: #f0fff4;
    --color-warning: #c53030;     /* 避坑红色 */
    --color-warning-light: #fff5f5;
    --color-warning-border: #feb2b2;
    --color-accent: #d69e2e;      /* 中转/住宿黄色 */
    --color-accent-light: #fefcbf;

    --font-sans: 'Outfit', 'Noto Sans SC', -apple-system, sans-serif;
}

/* 基础重置 */
* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

body {
    font-family: var(--font-sans);
    background-color: var(--bg-main);
    color: var(--text-primary);
    line-height: 1.6;
    overflow-x: hidden;
}

/* ==========================================================================
   1. 顶栏导航区 (Header)
   ========================================================================== */
.app-header {
    height: 70px;
    background-color: var(--bg-header);
    color: #ffffff;
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0 24px;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
    z-index: 1010;
    position: relative;
}

.header-left {
    display: flex;
    align-items: center;
    gap: 12px;
}

.icon-car {
    font-size: 28px;
}

.brand-title h1 {
    font-size: 18px;
    font-weight: 700;
}

.brand-title p {
    font-size: 12px;
    color: var(--text-light);
}

.header-stats {
    display: flex;
    align-items: center;
    gap: 20px;
}

.stat-item {
    display: flex;
    flex-direction: column;
    text-align: right;
}

.stat-label {
    font-size: 10px;
    color: var(--text-light);
    letter-spacing: 0.5px;
}

.stat-value {
    font-size: 16px;
    font-weight: 700;
    font-family: 'Outfit', sans-serif;
    color: #ffffff;
}

.stat-unit {
    font-size: 11px;
    color: var(--text-light);
}

.global-actions {
    display: flex;
    gap: 8px;
    margin-left: 10px;
}

/* 通用按钮 */
.btn {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 6px 12px;
    border-radius: 6px;
    font-size: 12px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s ease;
    border: 1px solid transparent;
}

.btn-secondary {
    background-color: #2d3748;
    color: #ffffff;
    border-color: #4a5568;
}

.btn-secondary:hover {
    background-color: #4a5568;
}

.btn-danger {
    background-color: #742a2a;
    color: #fff5f5;
    border-color: #9b2c2c;
}

.btn-danger:hover {
    background-color: #9b2c2c;
}

.btn-primary {
    background-color: #2b6cb0;
    color: #ffffff;
    border-color: #2b6cb0;
}

.btn-primary:hover {
    background-color: #2c5282;
}

.btn-small {
    padding: 4px 8px;
    font-size: 11px;
}

/* ==========================================================================
   2. 双栏布局结构 (Layout Container)
   ========================================================================== */
.app-container {
    display: flex;
    height: calc(100vh - 70px);
    overflow: hidden;
}

/* 左栏：日程滚动区 (与原版完全一致) */
.itinerary-panel {
    width: 55%;
    height: 100%;
    overflow-y: auto;
    padding: 24px;
    background-color: var(--bg-main);
}

.itinerary-panel::-webkit-scrollbar {
    width: 6px;
}
.itinerary-panel::-webkit-scrollbar-track {
    background: var(--bg-main);
}
.itinerary-panel::-webkit-scrollbar-thumb {
    background: #cbd5e1;
    border-radius: 3px;
}

/* 右栏：地图区 */
.map-panel {
    width: 45%;
    height: 100%;
    position: relative;
    border-left: 2px solid #e2e8f0;
}

#map-container {
    width: 100%;
    height: 100%;
    z-index: 10;
}

/* 地图信息条 */
.map-overlay-info {
    position: absolute;
    bottom: 20px;
    left: 20px;
    z-index: 500;
    background: rgba(255, 255, 255, 0.95);
    border: 1px solid #cbd5e1;
    padding: 8px 16px;
    border-radius: 6px;
    font-size: 13px;
    font-weight: 600;
    color: var(--text-primary);
    box-shadow: 0 4px 10px rgba(0, 0, 0, 0.08);
}

/* ==========================================================================
   3. 通用卡片及全局预警 (Cards)
   ========================================================================== */
.card {
    background: var(--bg-card);
    border: 1px solid #e2e8f0;
    border-radius: 8px;
    padding: 20px;
    margin-bottom: 20px;
    box-shadow: 0 2px 5px rgba(0, 0, 0, 0.02);
}

.global-alert {
    border-left: 5px solid var(--color-warning);
    background-color: var(--color-warning-light);
    border-color: var(--color-warning-border);
}

.alert-badge {
    background-color: var(--color-warning);
    color: #ffffff;
    padding: 4px 10px;
    border-radius: 4px;
    font-size: 12.5px;
    font-weight: 700;
}

.warning-list {
    margin-top: 12px;
    list-style: none;
}

.warning-list li {
    font-size: 13px;
    margin-bottom: 8px;
    position: relative;
    padding-left: 18px;
    color: #2d3748;
}

.warning-list li::before {
    content: "•";
    color: var(--color-warning);
    font-weight: bold;
    font-size: 18px;
    position: absolute;
    left: 4px;
    top: -2px;
}

/* ==========================================================================
   4. 精美自驾日程卡片 (Day Section Card)
   ========================================================================== */
.day-section {
    background: var(--bg-card);
    border: 1px solid #e2e8f0;
    border-radius: 10px;
    padding: 24px;
    margin-bottom: 24px;
    box-shadow: 0 4px 10px rgba(0, 0, 0, 0.03);
    transition: all 0.25s ease;
    cursor: pointer; /* 点击卡片可激活地图 */
}

.day-section.active {
    border-color: var(--color-primary);
    box-shadow: 0 4px 15px rgba(43, 108, 176, 0.08);
}

.day-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    border-bottom: 2px solid #f1f5f9;
    padding-bottom: 12px;
    margin-bottom: 20px;
}

.day-header-left {
    display: flex;
    align-items: center;
    gap: 12px;
}

.day-badge {
    background-color: var(--color-primary);
    color: white;
    font-family: 'Outfit', sans-serif;
    font-size: 13px;
    font-weight: 800;
    padding: 3px 10px;
    border-radius: 20px;
}

.day-title {
    font-size: 17px;
    font-weight: 800;
    color: var(--text-primary);
}

.day-header-right {
    display: flex;
    align-items: center;
    gap: 12px;
}

.day-brief-stats {
    font-size: 12.5px;
    color: var(--text-secondary);
    font-family: 'Outfit', sans-serif;
}

.day-summary-text {
    font-size: 13.5px;
    color: var(--text-secondary);
    margin-bottom: 20px;
    background-color: #f8fafc;
    padding: 10px 14px;
    border-left: 3px solid #cbd5e1;
    border-radius: 0 4px 4px 0;
}

/* ==========================================================================
   5. 点对点路线流向图 (Flowchart)
   ========================================================================== */
.route-flow {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 8px 4px;
    margin-bottom: 20px;
    background-color: #f8fafc;
    padding: 12px;
    border-radius: 8px;
    border: 1px solid #e2e8f0;
}

.flow-node {
    font-size: 13px;
    font-weight: 700;
    color: var(--text-primary);
    background-color: #ffffff;
    padding: 4px 10px;
    border-radius: 6px;
    border: 1px solid #cbd5e1;
}

.flow-node.start {
    border-left: 3px solid var(--color-success);
}

.flow-node.hotel {
    border-left: 3px solid var(--color-accent);
}

.flow-link {
    display: flex;
    flex-direction: column;
    align-items: center;
    padding: 0 2px;
}

.link-arrow {
    color: var(--text-light);
    font-size: 12px;
    font-weight: bold;
}

.link-info {
    font-size: 9px;
    font-weight: 700;
    color: var(--color-primary);
    background-color: #e0f2fe;
    padding: 1px 5px;
    border-radius: 10px;
    white-space: nowrap;
}

/* 经典侧边栏左边粗线 */
.section-subtitle {
    font-size: 14.5px;
    font-weight: 700;
    margin: 16px 0 8px 0;
    display: flex;
    align-items: center;
    gap: 6px;
    color: var(--text-primary);
    border-left: 3px solid var(--color-primary);
    padding-left: 8px;
}

.section-subtitle.play {
    border-left-color: var(--color-success);
}

.section-subtitle.warning {
    border-left-color: var(--color-warning);
}

/* 玩法与避坑列表 */
.list-structured {
    list-style: none;
    margin-bottom: 16px;
}

.list-structured li {
    font-size: 13.5px;
    margin-bottom: 6px;
    position: relative;
    padding-left: 18px;
    color: var(--text-secondary);
}

.list-structured li::before {
    content: "•";
    color: var(--text-light);
    font-size: 16px;
    position: absolute;
    left: 4px;
    top: -1px;
}

.list-structured li strong {
    color: var(--text-primary);
}

.alert-box {
    padding: 10px 14px;
    border-radius: 6px;
    font-size: 13px;
    margin-bottom: 10px;
    border: 1px solid transparent;
}

.alert-box.danger {
    background-color: var(--color-warning-light);
    border-color: var(--color-warning-border);
    color: var(--color-warning);
}

/* 住宿餐饮网格 */
.meta-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 12px;
    margin-top: 16px;
    border-top: 1px solid #f1f5f9;
    padding-top: 16px;
}

.meta-item {
    background-color: #f8fafc;
    padding: 8px 12px;
    border-radius: 6px;
    border: 1px solid #e2e8f0;
}

.meta-label {
    font-size: 11px;
    color: var(--text-secondary);
    font-weight: bold;
    margin-bottom: 2px;
}

.meta-value {
    font-size: 12.5px;
    font-weight: 700;
    color: var(--text-primary);
}

/* ==========================================================================
   6. 极简卡片内部可隐藏编辑器 (Card Inline Editor)
   ========================================================================== */
.card-edit-panel {
    display: none; /* 默认隐藏，点击编辑按钮后显示 */
    background-color: #f8fafc;
    border: 1.5px solid #cbd5e1;
    border-radius: 8px;
    padding: 16px;
    margin-top: 16px;
}

.card-edit-panel.active {
    display: block;
}

/* 表单框 */
.form-group {
    margin-bottom: 10px;
    display: flex;
    flex-direction: column;
    gap: 3px;
}

.form-label {
    font-size: 11px;
    font-weight: bold;
    color: var(--text-secondary);
}

.input-text, .textarea-field, .select-field {
    width: 100%;
    padding: 6px 10px;
    border-radius: 5px;
    border: 1px solid var(--border-color);
    background-color: #ffffff;
    font-family: var(--font-sans);
    font-size: 13px;
}

.input-text:focus, .textarea-field:focus, .select-field:focus {
    outline: none;
    border-color: var(--focus-ring);
}

.textarea-field {
    resize: vertical;
    min-height: 45px;
}

/* 景点坐标编辑器 */
.node-edit-row {
    background: #ffffff;
    border: 1px solid #e2e8f0;
    border-radius: 6px;
    padding: 12px;
    margin-bottom: 10px;
}

.node-grid {
    display: grid;
    grid-template-columns: 2fr 1fr 1fr 1.2fr;
    gap: 8px;
    margin-bottom: 8px;
}

.node-ctrls {
    display: flex;
    justify-content: flex-end;
    gap: 4px;
}

.node-location-tools {
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: 6px;
    margin: 8px 0 10px;
}

.coord-status {
    flex: 1 1 220px;
    min-width: 180px;
    font-size: 11px;
    color: var(--text-secondary);
}

.coord-status.pending {
    color: var(--color-primary);
    font-weight: 700;
}

.coord-status.success {
    color: var(--color-success);
    font-weight: 700;
}

.coord-status.error {
    color: var(--color-warning);
    font-weight: 700;
}

#map-container.map-pick-active {
    cursor: crosshair;
}

.coordinate-preview-marker {
    background: transparent;
    border: none;
}

.coordinate-preview-dot {
    width: 22px;
    height: 22px;
    border-radius: 50%;
    background: #2b6cb0;
    border: 3px solid #ffffff;
    box-shadow: 0 0 0 3px rgba(43, 108, 176, 0.3), 0 3px 8px rgba(0, 0, 0, 0.25);
}

/* 列表编辑器 */
.list-edit-row {
    display: grid;
    grid-template-columns: 1fr auto;
    gap: 6px;
    margin-bottom: 6px;
}

.btn-add-item {
    width: 100%;
    background-color: #ffffff;
    border: 1.5px dashed var(--border-color);
    color: var(--text-secondary);
    justify-content: center;
    margin-top: 4px;
}

.grid-2col {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 12px;
}

/* ==========================================================================
   7. 弹出遮罩灯箱 (Lightbox)
   ========================================================================== */
.lightbox-overlay {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.85);
    z-index: 2000;
    justify-content: center;
    align-items: center;
    padding: 20px;
}

.lightbox-content {
    background-color: var(--bg-card);
    width: 100%;
    max-width: 900px;
    border-radius: 8px;
    overflow: hidden;
    position: relative;
    display: flex;
    flex-direction: column;
    max-height: 90vh;
}

.lightbox-close {
    position: absolute;
    top: 15px;
    right: 20px;
    font-size: 30px;
    font-weight: bold;
    color: var(--text-secondary);
    cursor: pointer;
    z-index: 10;
}

.lightbox-title {
    padding: 18px 24px;
    font-size: 15px;
    font-weight: bold;
    border-bottom: 1px solid #cbd5e1;
    background-color: #f8fafc;
}

.lightbox-body {
    flex-grow: 1;
    overflow: auto;
    display: flex;
    justify-content: center;
    align-items: center;
    padding: 20px;
    background-color: #edf2f7;
}

.lightbox-body img {
    max-width: 100%;
    max-height: 60vh;
    object-fit: contain;
    border-radius: 4px;
}

.lightbox-footer {
    padding: 12px 24px;
    font-size: 11px;
    color: var(--text-secondary);
    background-color: #f8fafc;
    border-top: 1px solid #cbd5e1;
}

/* ==========================================================================
   8. 移动端自适应 (Mobile Layout)
   ========================================================================== */
@media (max-width: 991px) {
    .app-header {
        height: auto;
        flex-direction: column;
        padding: 12px 16px;
        gap: 12px;
        align-items: stretch;
    }
    
    .header-stats {
        flex-wrap: wrap;
        gap: 10px;
        justify-content: space-between;
    }
    
    .global-actions {
        width: 100%;
        margin-left: 0;
        flex-wrap: wrap;
    }

    .global-actions .btn {
        flex-grow: 1;
        justify-content: center;
    }

    .app-container {
        flex-direction: column;
        height: auto;
        overflow: visible;
    }
    
    /* 移动端地图吸顶 */
    .map-panel {
        width: 100%;
        height: 35vh;
        order: 1;
        position: sticky;
        top: 0;
        z-index: 100;
        border-left: none;
        border-bottom: 2px solid #cbd5e1;
    }
    
    /* 移动端日程在下方正常流式滚动 */
    .itinerary-panel {
        width: 100%;
        height: auto;
        order: 2;
        overflow-y: visible;
        padding: 16px;
    }
    
    .day-section {
        padding: 16px;
    }
    
    .node-grid {
        grid-template-columns: 1fr;
        gap: 8px;
    }
    
    .grid-2col {
        grid-template-columns: 1fr;
        gap: 10px;
    }
}

/* ==========================================================================
   9. 行程卡片起点与终点标识里程碑 (Day Milestones)
   ========================================================================== */
.day-milestones {
    display: flex;
    align-items: center;
    justify-content: space-between;
    background: linear-gradient(135deg, rgba(241, 245, 249, 0.9) 0%, rgba(226, 232, 240, 0.55) 100%);
    border: 1px solid rgba(203, 213, 225, 0.6);
    border-radius: 8px;
    padding: 10px 16px;
    margin-bottom: 18px;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    box-shadow: inset 0 1px 2px rgba(255, 255, 255, 0.8), 0 2px 4px rgba(0, 0, 0, 0.02);
}

.day-section:hover .day-milestones {
    border-color: var(--color-primary);
    box-shadow: 0 4px 10px rgba(43, 108, 176, 0.08);
    transform: translateY(-1px);
}

.milestone-item {
    display: flex;
    align-items: center;
    gap: 10px;
    flex: 1;
}

.milestone-item.prev-start {
    justify-content: flex-start;
}

.milestone-item.today-end {
    justify-content: flex-end;
    text-align: right;
}

.milestone-icon {
    font-size: 14px;
    display: flex;
    align-items: center;
    justify-content: center;
    width: 28px;
    height: 28px;
    border-radius: 50%;
    background-color: #ffffff;
    box-shadow: 0 2px 5px rgba(0, 0, 0, 0.05);
}

.prev-start .milestone-icon {
    border: 1.5px solid var(--color-success);
    color: var(--color-success);
}

.today-end .milestone-icon {
    border: 1.5px solid var(--color-accent);
    color: var(--color-accent);
}

.milestone-text {
    display: flex;
    flex-direction: column;
}

.milestone-label {
    font-size: 9.5px;
    font-weight: 700;
    color: var(--text-light);
    letter-spacing: 0.5px;
    margin-bottom: 2px;
}

.milestone-value {
    font-size: 13px;
    font-weight: 800;
    color: var(--text-primary);
}

.prev-start .milestone-value {
    color: var(--color-success);
}

.today-end .milestone-value {
    color: var(--color-accent);
}

.milestone-line-connector {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    padding: 0 10px;
}

.milestone-line-connector .line-dot {
    width: 5px;
    height: 5px;
    border-radius: 50%;
    background-color: var(--text-light);
    opacity: 0.5;
}

.milestone-line-connector .line-arrow {
    color: var(--text-light);
    font-size: 12px;
    font-weight: bold;
    opacity: 0.7;
    animation: pulseArrow 2s infinite ease-in-out;
}

@keyframes pulseArrow {
    0%, 100% { transform: translateX(0); opacity: 0.5; }
    50% { transform: translateX(3px); opacity: 1; }
}

/* 极小屏幕微调 */
@media (max-width: 480px) {
    .day-milestones {
        flex-direction: column;
        align-items: stretch;
        gap: 8px;
        padding: 10px 12px;
    }
    .milestone-line-connector {
        display: none;
    }
    .milestone-item.today-end {
        justify-content: flex-start;
        text-align: left;
    }
}
