/* ==================== 全局全屏样式 ==================== */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

html, body {
    width: 100%;
    height: 100%;
    overflow: hidden;
    position: fixed;
    top: 0;
    left: 0;
    background: #fff;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
    overflow: hidden;
    background: #fff;
}

/* ==================== 主容器 ==================== */
.app-container {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    width: 100%;
    height: 100%;
    overflow: hidden;
}

/* ==================== 地图容器 - 确保全屏 ==================== */
.map-container {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    width: 100%;
    height: 100%;
    z-index: 1;
}

#map {
    width: 100%;
    height: 100%;
    background: #fff;
}

/* 确保 Leaflet 地图容器也是全屏 */
.leaflet-container {
    width: 100%;
    height: 100%;
    background: #fff;
}

/* ==================== 顶部工具栏 ==================== */
.top-toolbar {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 12px 16px;
    background: linear-gradient(135deg, rgba(102, 126, 234, 0.95) 0%, rgba(118, 75, 162, 0.95) 100%);
    backdrop-filter: blur(10px);
    z-index: 10;
    box-shadow: 0 2px 10px rgba(0,0,0,0.1);
}

.menu-btn, .locate-btn {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    background: rgba(255,255,255,0.2);
    border: none;
    color: white;
    font-size: 20px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s;
    backdrop-filter: blur(5px);
}

.menu-btn:active, .locate-btn:active {
    transform: scale(0.95);
}

.location-info {
    color: white;
    font-size: 16px;
    font-weight: 500;
    text-shadow: 0 1px 2px rgba(0,0,0,0.2);
    text-align: center;
    flex: 1;
}

/* ==================== 控制面板 ==================== */
.control-panel {
    position: absolute;
    background: white;
    z-index: 20;
    transition: all 0.3s ease;
    box-shadow: 0 -2px 20px rgba(0,0,0,0.1);
    overflow-y: auto;
}

/* 面板手柄 */
.panel-handle {
    display: none;
    width: 40px;
    height: 4px;
    background: #ddd;
    border-radius: 2px;
    margin: 12px auto;
    cursor: pointer;
}

/* ==================== 手机端布局 (<768px) ==================== */
@media (max-width: 767px) {
    .control-panel {
        bottom: 0;
        left: 0;
        right: 0;
        max-height: 60vh;
        border-radius: 20px 20px 0 0;
        transform: translateY(85%);
    }

    .control-panel.open {
        transform: translateY(0);
    }

    .panel-handle {
        display: block;
    }

    .panel-tabs {
        display: flex;
        border-bottom: 1px solid #eee;
        padding: 0 16px;
    }

    .menu-btn {
        display: flex;
    }

    .tab-content {
        max-height: calc(60vh - 50px);
        overflow-y: auto;
    }
}

/* ==================== 平板端布局 (768px - 1024px) ==================== */
@media (min-width: 768px) and (max-width: 1024px) {
    .control-panel {
        bottom: 0;
        left: 0;
        right: 0;
        max-height: 50vh;
        border-radius: 20px 20px 0 0;
        transform: translateY(80%);
    }

    .control-panel.open {
        transform: translateY(0);
    }

    .panel-handle {
        display: block;
    }

    .panel-tabs {
        display: flex;
        border-bottom: 1px solid #eee;
        padding: 0 16px;
    }

    .menu-btn {
        display: flex;
    }
}

/* ==================== 桌面端布局 (>1024px) ==================== */
@media (min-width: 1025px) {
    .control-panel {
        top: 0;
        right: 0;
        bottom: 0;
        width: 380px;
        box-shadow: -2px 0 20px rgba(0,0,0,0.1);
        transform: translateX(0);
        border-radius: 0;
    }

    .panel-handle {
        display: none;
    }

    .panel-tabs {
        display: none;
    }

    .menu-btn {
        display: none;
    }

    .tab-content {
        display: block !important;
        padding: 20px;
        border-bottom: 1px solid #eee;
    }

    .tab-content:last-child {
        border-bottom: none;
    }

    .control-panel {
        overflow-y: auto;
    }
}

/* ==================== 标签页样式 ==================== */
.tab-btn {
    flex: 1;
    padding: 12px 0;
    background: none;
    border: none;
    font-size: 15px;
    font-weight: 500;
    color: #999;
    cursor: pointer;
    transition: all 0.2s;
    position: relative;
}

.tab-btn.active {
    color: #667eea;
}

.tab-btn.active::after {
    content: '';
    position: absolute;
    bottom: -1px;
    left: 0;
    right: 0;
    height: 2px;
    background: #667eea;
}

.tab-content {
    display: none;
    padding: 16px;
}

.tab-content.active {
    display: block;
}

/* ==================== 快速导航条 ==================== */
.quick-nav-bar {
    position: absolute;
    bottom: 20px;
    left: 16px;
    right: 16px;
    background: white;
    border-radius: 50px;
    box-shadow: 0 4px 15px rgba(0,0,0,0.2);
    z-index: 20;
    animation: slideUp 0.3s ease;
}

@media (min-width: 1025px) {
    .quick-nav-bar {
        bottom: 30px;
        left: auto;
        right: 420px;
        min-width: 300px;
    }
}

.quick-nav-content {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 10px 16px;
    gap: 8px;
}

.quick-nav-content span {
    font-size: 13px;
    color: #333;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    flex: 1;
}

.quick-nav-content span:first-child {
    color: #28a745;
    font-weight: 500;
}

.quick-nav-content span:last-child {
    color: #dc3545;
    font-weight: 500;
}

.quick-nav-btn {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    border: none;
    color: white;
    padding: 6px 16px;
    border-radius: 30px;
    font-size: 13px;
    font-weight: 500;
    cursor: pointer;
    white-space: nowrap;
}

.close-quick-nav {
    background: none;
    border: none;
    font-size: 18px;
    color: #999;
    cursor: pointer;
    padding: 0 4px;
}

/* ==================== 表单样式 ==================== */
.input-group {
    margin-bottom: 16px;
}

.input-group label {
    display: block;
    font-size: 14px;
    font-weight: 500;
    color: #333;
    margin-bottom: 6px;
}

.input-with-btn {
    display: flex;
    gap: 8px;
}

.input-with-btn input {
    flex: 1;
    padding: 12px;
    border: 1px solid #e0e0e0;
    border-radius: 12px;
    font-size: 16px;
    background: #f8f9fa;
}

.input-with-btn input:focus {
    outline: none;
    border-color: #667eea;
    background: white;
}

.input-group input {
    width: 100%;
    padding: 12px;
    border: 1px solid #e0e0e0;
    border-radius: 12px;
    font-size: 16px;
    background: #f8f9fa;
}

.input-group input:focus {
    outline: none;
    border-color: #667eea;
    background: white;
}

.use-current-btn {
    width: 48px;
    background: #f0f0f0;
    border: none;
    border-radius: 12px;
    font-size: 18px;
    cursor: pointer;
    transition: all 0.2s;
}

.use-current-btn:active {
    transform: scale(0.95);
}

.nav-btn {
    width: 100%;
    padding: 14px;
    background: linear-gradient(135deg, #28a745 0%, #20c997 100%);
    color: white;
    border: none;
    border-radius: 12px;
    font-size: 16px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s;
    margin-top: 8px;
}

.nav-btn:active {
    transform: scale(0.98);
}

/* 搜索框 */
.search-box {
    display: flex;
    gap: 10px;
}

.search-box input {
    flex: 1;
    padding: 12px;
    border: 1px solid #e0e0e0;
    border-radius: 12px;
    font-size: 16px;
    background: #f8f9fa;
}

.search-box button {
    padding: 12px 20px;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    border: none;
    border-radius: 12px;
    font-size: 14px;
    font-weight: 500;
    cursor: pointer;
}

/* ==================== 结果卡片 ==================== */
.nav-result, .search-result {
    margin-top: 16px;
}

.nav-info-card, .info-card {
    background: #f8f9fa;
    padding: 14px;
    border-radius: 12px;
    border-left: 3px solid #28a745;
}

.info-card {
    border-left-color: #667eea;
}

.nav-route {
    font-weight: 600;
    color: #28a745;
    margin-bottom: 8px;
    font-size: 14px;
}

.nav-details {
    display: flex;
    gap: 16px;
    margin-bottom: 8px;
    font-size: 13px;
    color: #666;
}

.nav-path {
    font-size: 12px;
    color: #999;
    word-break: break-all;
    line-height: 1.4;
}

.info-title {
    font-weight: 600;
    color: #667eea;
    margin-bottom: 6px;
}

.info-desc {
    font-size: 13px;
    color: #666;
}

.error-card {
    background: #f8d7da;
    color: #721c24;
    padding: 12px;
    border-radius: 12px;
    font-size: 14px;
}

/* ==================== 建筑列表 ==================== */
.building-list-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 12px;
    font-weight: 600;
    color: #333;
}

.building-count {
    font-size: 12px;
    color: #999;
    font-weight: normal;
}

.building-list {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.building-item {
    padding: 14px;
    background: #f8f9fa;
    border-radius: 12px;
    cursor: pointer;
    transition: all 0.2s;
    border-left: 3px solid #667eea;
}

.building-item:active {
    background: #e9ecef;
    transform: scale(0.98);
}

.building-name {
    font-weight: 600;
    color: #333;
    margin-bottom: 4px;
    font-size: 15px;
}

.building-desc {
    font-size: 12px;
    color: #999;
    line-height: 1.3;
}

/* ==================== 道路美化样式 ==================== */

/* 主干道 - 橙色实线，带阴影 */
.road-main-line {
    stroke: #f5a623;
    stroke-width: 6;
    stroke-linecap: round;
    stroke-linejoin: round;
    filter: drop-shadow(0 1px 2px rgba(0,0,0,0.2));
}

/* 主干道内线 - 黄色虚线（模拟车道线） */
.road-main-inner {
    stroke: #ffd700;
    stroke-width: 1.5;
    stroke-dasharray: 8, 6;
    stroke-linecap: round;
}

/* 次干道 - 灰色实线 */
.road-secondary-line {
    stroke: #c0c0c0;
    stroke-width: 4.5;
    stroke-linecap: round;
    stroke-linejoin: round;
}

/* 次干道内线 */
.road-secondary-inner {
    stroke: #e0e0e0;
    stroke-width: 1.5;
    stroke-dasharray: 6, 5;
}

/* 小路/连接路 - 浅蓝色虚线 */
.road-connection-line {
    stroke: #87CEEB;
    stroke-width: 2.5;
    stroke-dasharray: 5, 5;
    stroke-linecap: round;
}

/* 道路交叉点 - 圆点标记 */
.road-intersection {
    fill: #888;
    stroke: white;
    stroke-width: 1.5;
}

/* ==================== 建筑美化样式 ==================== */

/* 建筑基础样式 - 3D 效果 */
.building-rect {
    width: 34px;
    height: 34px;
    background: linear-gradient(135deg, #e8e8e8 0%, #d0d0d0 100%);
    border: 1.5px solid #666;
    border-radius: 3px;
    box-shadow: 0 3px 6px rgba(0,0,0,0.3);
    position: relative;
    transition: all 0.25s ease;
    cursor: pointer;
}

.building-rect:hover {
    transform: scale(1.08);
    z-index: 1000;
    box-shadow: 0 4px 10px rgba(0,0,0,0.4);
}

/* 建筑屋顶效果（阴影） */
.building-rect::after {
    content: '';
    position: absolute;
    top: -3px;
    left: 2px;
    right: 2px;
    height: 4px;
    background: rgba(0,0,0,0.15);
    border-radius: 2px 2px 0 0;
}

/* 教学楼 - 浅蓝色 */
.building-teaching {
    background: linear-gradient(135deg, #d4e6f1 0%, #a9cce3 100%);
    border-color: #5dade2;
}

/* 图书馆 - 棕色（书本色） */
.building-library {
    background: linear-gradient(135deg, #e8daef 0%, #d2b4de 100%);
    border-color: #a569bd;
}

/* 食堂 - 橙色（食欲色） */
.building-canteen {
    background: linear-gradient(135deg, #fdebd0 0%, #f5cba7 100%);
    border-color: #f5b041;
}

/* 体育馆 - 红色（活力色） */
.building-gym {
    background: linear-gradient(135deg, #fadbd8 0%, #f1948a 100%);
    border-color: #e74c3c;
}

/* 行政楼 - 绿色（稳重色） */
.building-admin {
    background: linear-gradient(135deg, #d5f5e3 0%, #abebc6 100%);
    border-color: #2ecc71;
}

/* 校医院 - 白色+红边 */
.building-hospital {
    background: linear-gradient(135deg, #ffffff 0%, #f5f5f5 100%);
    border-color: #e74c3c;
    border-width: 2px;
}

/* 建筑内部图标 */
.building-rect::before {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    font-size: 14px;
    font-weight: bold;
    text-shadow: 0 1px 1px rgba(255,255,255,0.5);
}

.building-teaching::before {
    content: '📚';
    font-size: 16px;
}

.building-library::before {
    content: '📖';
    font-size: 16px;
}

.building-canteen::before {
    content: '🍽️';
    font-size: 14px;
}

.building-gym::before {
    content: '⚽';
    font-size: 16px;
}

.building-admin::before {
    content: '📋';
    font-size: 14px;
}

.building-hospital::before {
    content: '🏥';
    font-size: 16px;
}

/* 建筑标签 - 更美观 */
.building-label {
    background: rgba(0, 0, 0, 0.8);
    color: white;
    font-size: 11px;
    font-weight: 500;
    padding: 3px 8px;
    border-radius: 4px;
    border: none;
    box-shadow: 0 2px 5px rgba(0,0,0,0.2);
    white-space: nowrap;
    pointer-events: none;
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
    letter-spacing: 0.5px;
}

.building-label::before {
    content: '';
    position: absolute;
    bottom: -5px;
    left: 50%;
    transform: translateX(-50%);
    width: 0;
    height: 0;
    border-left: 5px solid transparent;
    border-right: 5px solid transparent;
    border-top: 5px solid rgba(0, 0, 0, 0.8);
}

/* ==================== 路径线美化 ==================== */

/* 导航路径 - 蓝色粗线 */
.path-line {
    stroke: #3388ff;
    stroke-width: 6;
    stroke-linecap: round;
    stroke-linejoin: round;
    filter: drop-shadow(0 1px 3px rgba(51,136,255,0.5));
}

/* 路径外发光 */
.path-glow {
    stroke: #66b0ff;
    stroke-width: 12;
    stroke-linecap: round;
    stroke-linejoin: round;
    opacity: 0.3;
}

/* 路径箭头 */
.path-arrow {
    background: transparent;
    color: #3388ff;
    font-size: 14px;
    text-shadow: 0 0 2px white;
    filter: drop-shadow(0 1px 1px rgba(0,0,0,0.2));
}

/* ==================== 起点终点标记美化 ==================== */

/* 起点标记 - 绿色发光圆点 */
.start-marker {
    fill: #28a745;
    stroke: white;
    stroke-width: 2.5;
    filter: drop-shadow(0 0 6px #28a745);
    animation: pulse-green 1.5s ease infinite;
}

@keyframes pulse-green {
    0% { transform: scale(1); opacity: 1; }
    50% { transform: scale(1.15); opacity: 0.9; }
    100% { transform: scale(1); opacity: 1; }
}

/* 终点标记 - 红色发光圆点 */
.end-marker {
    fill: #dc3545;
    stroke: white;
    stroke-width: 2.5;
    filter: drop-shadow(0 0 6px #dc3545);
    animation: pulse-red 1.5s ease infinite;
}

@keyframes pulse-red {
    0% { transform: scale(1); opacity: 1; }
    50% { transform: scale(1.15); opacity: 0.9; }
    100% { transform: scale(1); opacity: 1; }
}

/* 用户位置标记 - 蓝色脉冲 */
.user-location-marker {
    fill: #2196f3;
    stroke: white;
    stroke-width: 2.5;
    filter: drop-shadow(0 0 6px #2196f3);
    animation: pulse-blue 2s ease infinite;
}

@keyframes pulse-blue {
    0% { transform: scale(1); opacity: 1; }
    50% { transform: scale(1.1); opacity: 0.9; }
    100% { transform: scale(1); opacity: 1; }
}

/* 精度圈 */
.accuracy-circle {
    fill: #2196f3;
    fill-opacity: 0.08;
    stroke: #2196f3;
    stroke-width: 1;
    stroke-dasharray: 4, 4;
}

/* ==================== 指北针美化 ==================== */
.compass-container {
    position: absolute;
    bottom: 20px;
    right: 20px;
    z-index: 20;
}

@media (min-width: 1025px) {
    .compass-container {
        bottom: 30px;
        right: 420px;
    }
}

.compass-btn {
    width: 48px;
    height: 48px;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.95);
    border: 1px solid #ddd;
    cursor: pointer;
    box-shadow: 0 2px 10px rgba(0,0,0,0.15);
    transition: all 0.2s;
    display: flex;
    align-items: center;
    justify-content: center;
    position: relative;
}

.compass-btn:active {
    transform: scale(0.95);
}

.compass-icon {
    position: relative;
    width: 40px;
    height: 40px;
}

.compass-n {
    position: absolute;
    top: 5px;
    left: 50%;
    transform: translateX(-50%);
    font-size: 12px;
    font-weight: bold;
    color: #dc3545;
    z-index: 2;
    font-family: monospace;
}

.compass-btn.rotating {
    animation: compassPulse 0.3s ease;
}

@keyframes compassPulse {
    0% { transform: scale(1); }
    50% { transform: scale(1.1); }
    100% { transform: scale(1); }
}

/* ==================== Toast 提示 ==================== */
.toast {
    position: fixed;
    bottom: 100px;
    left: 50%;
    transform: translateX(-50%);
    background: rgba(0,0,0,0.8);
    color: white;
    padding: 10px 20px;
    border-radius: 30px;
    font-size: 14px;
    z-index: 1000;
    animation: fadeInOut 2s ease forwards;
    white-space: nowrap;
    backdrop-filter: blur(10px);
}

@media (min-width: 1025px) {
    .toast {
        bottom: 30px;
        left: 50%;
    }
}

@keyframes fadeInOut {
    0% { opacity: 0; transform: translateX(-50%) translateY(20px); }
    15% { opacity: 1; transform: translateX(-50%) translateY(0); }
    85% { opacity: 1; transform: translateX(-50%) translateY(0); }
    100% { opacity: 0; transform: translateX(-50%) translateY(-20px); }
}

@keyframes slideUp {
    from {
        transform: translateY(100px);
        opacity: 0;
    }
    to {
        transform: translateY(0);
        opacity: 1;
    }
}

/* ==================== 滚动条 ==================== */
::-webkit-scrollbar {
    width: 6px;
    height: 6px;
}

::-webkit-scrollbar-track {
    background: #f1f1f1;
    border-radius: 3px;
}

::-webkit-scrollbar-thumb {
    background: #ccc;
    border-radius: 3px;
}

::-webkit-scrollbar-thumb:hover {
    background: #999;
}

/* ==================== 桌面端适配 ==================== */
@media (min-width: 1025px) {
    .building-rect {
        width: 38px;
        height: 38px;
    }

    .building-rect::before {
        font-size: 16px;
    }

    .building-label {
        font-size: 12px;
        padding: 4px 10px;
    }

    .road-main-line {
        stroke-width: 7;
    }

    .road-secondary-line {
        stroke-width: 5;
    }
}