/* ================= 全局样式 ================= */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

:root {
    --primary-color: #2196F3;
    --primary-dark: #1976D2;
    --secondary-color: #FF9800;
    --danger-color: #F44336;
    --success-color: #4CAF50;
    --text-dark: #333;
    --text-light: #666;
    --bg-light: #f5f5f5;
    --white: #ffffff;
    --shadow: 0 2px 10px rgba(0, 0, 0, 0.1);
    --border-radius: 8px;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
    background: var(--bg-light);
    color: var(--text-dark);
    height: 100vh;
    overflow: hidden;
}

/* ================= 应用容器 ================= */
.app-container {
    display: flex;
    flex-direction: column;
    height: 100vh;
}

/* ================= 头部控制栏 ================= */
.header {
    background: var(--white);
    padding: 15px 20px;
    box-shadow: var(--shadow);
    z-index: 1000;
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-wrap: wrap;
    gap: 10px;
}

.header h1 {
    font-size: 1.5rem;
    color: var(--primary-dark);
    display: flex;
    align-items: center;
    gap: 8px;
}

.controls {
    display: flex;
    gap: 10px;
    flex-wrap: wrap;
}

/* ================= 按钮样式 ================= */
.btn {
    padding: 10px 18px;
    border: none;
    border-radius: var(--border-radius);
    cursor: pointer;
    font-size: 14px;
    font-weight: 500;
    display: inline-flex;
    align-items: center;
    gap: 6px;
    transition: all 0.3s ease;
    white-space: nowrap;
}

.btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
}

.btn:active {
    transform: translateY(0);
}

.btn-icon {
    font-size: 1.1em;
}

.btn-primary {
    background: var(--primary-color);
    color: var(--white);
}

.btn-primary:hover {
    background: var(--primary-dark);
}

.btn-secondary {
    background: var(--secondary-color);
    color: var(--white);
}

.btn-secondary:hover {
    background: #F57C00;
}

.btn-danger {
    background: var(--danger-color);
    color: var(--white);
}

.btn-danger:hover {
    background: #D32F2F;
}

.btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
    transform: none;
}

/* ================= 主内容区 ================= */
.main-content {
    display: flex;
    flex: 1;
    overflow: hidden;
    position: relative;
}

/* ================= 地图容器 ================= */
#map {
    flex: 1;
    height: 100%;
    z-index: 1;
}

/* 自定义标记样式 */
.custom-marker {
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 24px;
    filter: drop-shadow(0 2px 4px rgba(0, 0, 0, 0.3));
    transition: transform 0.2s ease;
}

.custom-marker:hover {
    transform: scale(1.2);
}

/* ================= 侧边栏 ================= */
.sidebar {
    width: 320px;
    background: var(--white);
    box-shadow: -2px 0 10px rgba(0, 0, 0, 0.1);
    display: flex;
    flex-direction: column;
    z-index: 999;
    transition: transform 0.3s ease;
}

.sidebar.collapsed {
    transform: translateX(100%);
}

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

.sidebar-header h2 {
    font-size: 1.2rem;
    color: var(--text-dark);
}

.close-btn {
    background: none;
    border: none;
    font-size: 24px;
    cursor: pointer;
    color: var(--text-light);
    width: 32px;
    height: 32px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 4px;
    transition: background 0.2s;
}

.close-btn:hover {
    background: #f0f0f0;
}

.sidebar-content {
    flex: 1;
    overflow-y: auto;
    padding: 15px;
}

/* 景点列表 */
.marker-list {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.empty-message {
    text-align: center;
    color: var(--text-light);
    padding: 30px 20px;
    font-size: 14px;
}

.marker-item {
    background: var(--bg-light);
    padding: 12px 15px;
    border-radius: var(--border-radius);
    cursor: pointer;
    transition: all 0.2s ease;
    border-left: 4px solid var(--primary-color);
}

.marker-item:hover {
    background: #e8f4fd;
    transform: translateX(4px);
}

.marker-item-header {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-bottom: 6px;
}

.marker-item-icon {
    font-size: 1.2em;
}

.marker-item-name {
    font-weight: 600;
    color: var(--text-dark);
    flex: 1;
}

.marker-item-delete {
    background: none;
    border: none;
    color: var(--text-light);
    cursor: pointer;
    font-size: 18px;
    padding: 4px;
    border-radius: 4px;
    transition: all 0.2s;
}

.marker-item-delete:hover {
    background: #ffebee;
    color: var(--danger-color);
}

.marker-item-desc {
    font-size: 13px;
    color: var(--text-light);
    margin-bottom: 6px;
}

.marker-item-coords {
    font-size: 11px;
    color: #999;
}

/* 路线信息 */
.route-info {
    padding: 15px 20px;
    border-top: 1px solid #eee;
    background: #f8f9fa;
}

.route-info h3 {
    font-size: 1rem;
    margin-bottom: 10px;
    color: var(--text-dark);
}

.stat-item {
    display: flex;
    justify-content: space-between;
    padding: 8px 0;
    font-size: 14px;
}

.stat-label {
    color: var(--text-light);
}

.stat-value {
    font-weight: 600;
    color: var(--primary-dark);
}

/* ================= 模态框 ================= */
.modal {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.5);
    z-index: 2000;
    justify-content: center;
    align-items: center;
}

.modal.active {
    display: flex;
}

.modal-content {
    background: var(--white);
    border-radius: 12px;
    width: 90%;
    max-width: 450px;
    max-height: 90vh;
    overflow-y: auto;
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.2);
    animation: modalSlideIn 0.3s ease;
}

@keyframes modalSlideIn {
    from {
        opacity: 0;
        transform: translateY(-20px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.modal-header {
    padding: 20px;
    border-bottom: 1px solid #eee;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.modal-header h3 {
    font-size: 1.3rem;
    color: var(--text-dark);
}

.modal-header .close-btn {
    font-size: 28px;
}

.modal-body {
    padding: 20px;
}

.modal-footer {
    padding: 15px 20px;
    border-top: 1px solid #eee;
    display: flex;
    justify-content: flex-end;
    gap: 10px;
}

/* 表单样式 */
.form-group {
    margin-bottom: 20px;
}

.form-group label {
    display: block;
    margin-bottom: 8px;
    font-weight: 500;
    color: var(--text-dark);
}

.form-group input[type="text"],
.form-group textarea {
    width: 100%;
    padding: 12px;
    border: 2px solid #e0e0e0;
    border-radius: var(--border-radius);
    font-size: 14px;
    transition: border-color 0.3s;
    font-family: inherit;
}

.form-group input[type="text"]:focus,
.form-group textarea:focus {
    outline: none;
    border-color: var(--primary-color);
}

.form-group textarea {
    resize: vertical;
    min-height: 80px;
}

/* 类型选择器 */
.type-selector {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 8px;
}

.type-option {
    display: flex;
    flex-direction: column;
    align-items: center;
    padding: 12px 8px;
    border: 2px solid #e0e0e0;
    border-radius: var(--border-radius);
    cursor: pointer;
    transition: all 0.2s;
    background: var(--white);
}

.type-option:hover {
    border-color: var(--primary-color);
    background: #f0f7ff;
}

.type-option input[type="radio"] {
    display: none;
}

.type-option input[type="radio"]:checked + span {
    color: var(--primary-color);
}

.type-option:has(input:checked) {
    border-color: var(--primary-color);
    background: #e3f2fd;
}

.type-icon {
    font-size: 24px;
    margin-bottom: 4px;
}

.type-option span:last-child {
    font-size: 12px;
    color: var(--text-light);
}

/* ================= Toast 通知 ================= */
.toast {
    position: fixed;
    bottom: 20px;
    left: 50%;
    transform: translateX(-50%) translateY(100px);
    background: #323232;
    color: var(--white);
    padding: 12px 24px;
    border-radius: 50px;
    font-size: 14px;
    z-index: 3000;
    opacity: 0;
    transition: all 0.3s ease;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
}

.toast.active {
    opacity: 1;
    transform: translateX(-50%) translateY(0);
}

.toast.success {
    background: var(--success-color);
}

.toast.error {
    background: var(--danger-color);
}

/* ================= Leaflet 自定义样式 ================= */
.leaflet-popup-content-wrapper {
    border-radius: 12px;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.15);
}

.leaflet-popup-content {
    margin: 15px;
    max-width: 280px;
}

.popup-header {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-bottom: 10px;
    padding-bottom: 10px;
    border-bottom: 1px solid #eee;
}

.popup-icon {
    font-size: 24px;
}

.popup-title {
    font-weight: 600;
    font-size: 16px;
    color: var(--text-dark);
}

.popup-desc {
    font-size: 14px;
    color: var(--text-light);
    line-height: 1.5;
    margin-bottom: 10px;
}

.popup-coords {
    font-size: 11px;
    color: #999;
    background: #f5f5f5;
    padding: 6px 10px;
    border-radius: 4px;
    display: inline-block;
}

/* ================= 响应式设计 ================= */
@media (max-width: 768px) {
    .header {
        padding: 10px 15px;
    }

    .header h1 {
        font-size: 1.2rem;
    }

    .btn {
        padding: 8px 12px;
        font-size: 13px;
    }

    .btn span:not(.btn-icon) {
        display: none;
    }

    .sidebar {
        position: absolute;
        right: 0;
        top: 0;
        height: 100%;
        transform: translateX(100%);
    }

    .sidebar.active {
        transform: translateX(0);
    }

    .type-selector {
        grid-template-columns: repeat(2, 1fr);
    }
}

/* ================= PWA 安装提示 ================= */
.install-prompt {
    position: fixed;
    bottom: 80px;
    right: 20px;
    background: var(--white);
    padding: 15px 20px;
    border-radius: 12px;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.15);
    z-index: 2500;
    display: none;
    max-width: 300px;
}

.install-prompt.active {
    display: block;
}

.install-prompt p {
    font-size: 14px;
    margin-bottom: 10px;
    color: var(--text-dark);
}

.install-prompt .buttons {
    display: flex;
    gap: 8px;
}

/* ================= 离线提示 ================= */
.offline-banner {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    background: #ff9800;
    color: white;
    text-align: center;
    padding: 10px;
    font-size: 14px;
    z-index: 4000;
    display: none;
}

.offline-banner.active {
    display: block;
}
