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

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    min-height: 100vh;
    color: #333;
    /* 防止移动端缩放 */
    -webkit-text-size-adjust: 100%;
    /* 优化触摸滚动 */
    -webkit-overflow-scrolling: touch;
}

.container {
    max-width: 1200px;
    margin: 0 auto;
    padding: 20px;
    min-height: 100vh;
    display: flex;
    flex-direction: column;
}

/* 顶部导航栏 */
.header {
    background: rgba(255, 255, 255, 0.95);
    backdrop-filter: blur(10px);
    border-radius: 16px;
    padding: 24px;
    margin-bottom: 20px;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.1);
    text-align: center;
}

.title {
    font-size: 2.5rem;
    font-weight: 700;
    color: #2d3748;
    margin-bottom: 8px;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 12px;
    flex-wrap: wrap;
}

.icon {
    font-size: 2.2rem;
}

.subtitle {
    color: #718096;
    font-size: 1.1rem;
    font-weight: 400;
}

/* 演示版标记 */
.demo-badge {
    background: #ed8936;
    color: white;
    font-size: 0.6rem;
    padding: 4px 8px;
    border-radius: 12px;
    margin-left: 8px;
    font-weight: 600;
}

/* 控制面板 */
.controls {
    background: rgba(255, 255, 255, 0.95);
    backdrop-filter: blur(10px);
    border-radius: 16px;
    padding: 20px;
    margin-bottom: 20px;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.1);
    display: flex;
    gap: 16px;
    align-items: center;
    flex-wrap: wrap;
}

.search-box {
    flex: 1;
    min-width: 280px;
    position: relative;
    display: flex;
    gap: 8px;
}

#searchInput {
    flex: 1;
    padding: 14px 16px;
    border: 2px solid #e2e8f0;
    border-radius: 12px;
    font-size: 16px;
    transition: all 0.3s ease;
    background: white;
    /* 移动端优化 */
    -webkit-appearance: none;
    outline: none;
    min-height: 48px; /* 触摸友好的高度 */
}

#searchInput:focus {
    border-color: #667eea;
    box-shadow: 0 0 0 3px rgba(102, 126, 234, 0.1);
}

/* 移动端输入框优化 */
#searchInput::placeholder {
    color: #a0aec0;
    opacity: 1;
}

.search-btn {
    padding: 14px 16px;
    background: #667eea;
    color: white;
    border: none;
    border-radius: 12px;
    cursor: pointer;
    font-size: 16px;
    transition: all 0.3s ease;
    min-width: 48px;
    min-height: 48px;
    display: flex;
    align-items: center;
    justify-content: center;
    /* 触摸反馈 */
    -webkit-tap-highlight-color: transparent;
}

.search-btn:hover {
    background: #5a67d8;
    transform: translateY(-1px);
}

.search-btn:active {
    transform: translateY(0);
    background: #4c51bf;
}

.control-buttons {
    display: flex;
    gap: 12px;
    flex-wrap: wrap;
}

.btn {
    padding: 14px 20px;
    border: none;
    border-radius: 12px;
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s ease;
    display: flex;
    align-items: center;
    gap: 6px;
    min-height: 48px; /* 触摸友好 */
    white-space: nowrap;
    /* 触摸反馈 */
    -webkit-tap-highlight-color: transparent;
    user-select: none;
}

.btn-primary {
    background: #48bb78;
    color: white;
}

.btn-primary:hover {
    background: #38a169;
    transform: translateY(-1px);
}

.btn-primary:active {
    transform: translateY(0);
    background: #2f855a;
}

.btn-secondary {
    background: #ed8936;
    color: white;
}

.btn-secondary:hover {
    background: #dd6b20;
    transform: translateY(-1px);
}

.btn-secondary:active {
    transform: translateY(0);
    background: #c05621;
}

/* 地图容器 */
.map-container {
    flex: 1;
    position: relative;
    background: white;
    border-radius: 16px;
    overflow: hidden;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.1);
    min-height: 60vh; /* 移动端优化 */
}

#mapContainer {
    width: 100%;
    height: 100%;
    min-height: 60vh;
}

/* 加载指示器 */
.loading {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(255, 255, 255, 0.9);
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    z-index: 1000;
}

.spinner {
    width: 40px;
    height: 40px;
    border: 4px solid #e2e8f0;
    border-top: 4px solid #667eea;
    border-radius: 50%;
    animation: spin 1s linear infinite;
    margin-bottom: 16px;
}

@keyframes spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

/* 弹窗样式 */
.modal {
    display: none;
    position: fixed;
    z-index: 2000;
    left: 0;
    top: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.5);
    backdrop-filter: blur(4px);
    /* 移动端滚动优化 */
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
}

.modal-content {
    background-color: white;
    margin: 5% auto;
    padding: 0;
    border-radius: 16px;
    width: 90%;
    max-width: 500px;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.3);
    position: relative;
    animation: modalAppear 0.3s ease;
    /* 移动端优化 */
    max-height: 85vh;
    overflow: hidden;
}

@keyframes modalAppear {
    from {
        opacity: 0;
        transform: translateY(-50px) scale(0.9);
    }
    to {
        opacity: 1;
        transform: translateY(0) scale(1);
    }
}

.close {
    position: absolute;
    right: 16px;
    top: 16px;
    color: #718096;
    font-size: 24px;
    font-weight: bold;
    cursor: pointer;
    width: 40px; /* 增大触摸区域 */
    height: 40px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
    transition: all 0.3s ease;
    z-index: 10;
    /* 触摸反馈 */
    -webkit-tap-highlight-color: transparent;
}

.close:hover {
    background: #f7fafc;
    color: #2d3748;
}

.close:active {
    background: #edf2f7;
}

#libraryInfo {
    padding: 24px;
    max-height: 70vh;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
}

.library-detail h3 {
    color: #2d3748;
    font-size: 1.5rem;
    margin-bottom: 16px;
    display: flex;
    align-items: center;
    gap: 8px;
    flex-wrap: wrap;
    line-height: 1.3;
}

.library-detail p {
    margin-bottom: 12px;
    color: #4a5568;
    line-height: 1.6;
    font-size: 15px; /* 移动端友好的字体大小 */
}

.library-detail .detail-item {
    display: flex;
    align-items: flex-start;
    gap: 8px;
    margin-bottom: 12px;
}

.library-detail .detail-icon {
    margin-top: 2px;
    font-size: 16px;
    min-width: 20px;
}

.navigate-btn {
    background: #667eea;
    color: white;
    padding: 16px 24px; /* 增大触摸区域 */
    border: none;
    border-radius: 12px;
    font-size: 16px;
    font-weight: 600;
    cursor: pointer;
    width: 100%;
    margin-top: 16px;
    transition: all 0.3s ease;
    min-height: 52px;
    /* 触摸反馈 */
    -webkit-tap-highlight-color: transparent;
}

.navigate-btn:hover {
    background: #5a67d8;
    transform: translateY(-1px);
}

.navigate-btn:active {
    transform: translateY(0);
    background: #4c51bf;
}

/* 侧边栏样式 */
.sidebar {
    position: fixed;
    top: 0;
    right: -100%;
    width: 85%;
    max-width: 400px;
    height: 100vh;
    background: white;
    box-shadow: -4px 0 20px rgba(0, 0, 0, 0.1);
    transition: right 0.3s ease;
    z-index: 1500;
    display: flex;
    flex-direction: column;
    /* 移动端滚动优化 */
    overflow: hidden;
}

.sidebar.open {
    right: 0;
}

.sidebar-header {
    padding: 20px;
    border-bottom: 1px solid #e2e8f0;
    display: flex;
    justify-content: space-between;
    align-items: center;
    background: #f7fafc;
    min-height: 70px;
}

.sidebar-header h3 {
    color: #2d3748;
    font-size: 1.2rem;
}

.close-btn {
    background: none;
    border: none;
    font-size: 24px;
    cursor: pointer;
    color: #718096;
    width: 40px; /* 增大触摸区域 */
    height: 40px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
    transition: all 0.3s ease;
    /* 触摸反馈 */
    -webkit-tap-highlight-color: transparent;
}

.close-btn:hover {
    background: #e2e8f0;
    color: #2d3748;
}

.close-btn:active {
    background: #cbd5e0;
}

.sidebar-content {
    flex: 1;
    overflow-y: auto;
    padding: 16px;
    -webkit-overflow-scrolling: touch;
}

.library-item {
    padding: 18px; /* 增大触摸区域 */
    border-radius: 12px;
    margin-bottom: 12px;
    background: #f7fafc;
    cursor: pointer;
    transition: all 0.3s ease;
    border: 2px solid transparent;
    /* 触摸反馈 */
    -webkit-tap-highlight-color: transparent;
}

.library-item:hover {
    background: #edf2f7;
    border-color: #667eea;
    transform: translateY(-1px);
}

.library-item:active {
    transform: translateY(0);
    background: #e2e8f0;
}

.library-item h4 {
    color: #2d3748;
    font-size: 1.1rem;
    margin-bottom: 8px;
    line-height: 1.3;
}

.library-item p {
    color: #718096;
    font-size: 0.9rem;
    line-height: 1.4;
    margin-bottom: 4px;
}

/* 用户位置信息 */
.user-location {
    position: fixed;
    bottom: 20px;
    left: 20px;
    right: 20px;
    background: rgba(255, 255, 255, 0.95);
    backdrop-filter: blur(10px);
    padding: 12px 16px;
    border-radius: 12px;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.1);
    z-index: 1000;
    font-size: 14px;
    color: #4a5568;
    text-align: center;
    display: none;
    max-width: 300px;
    margin: 0 auto;
}

/* 底部信息 */
.footer {
    margin-top: 20px;
    text-align: center;
    color: rgba(255, 255, 255, 0.8);
    font-size: 0.9rem;
    padding: 0 10px;
}

/* 图书馆标记样式 */
.library-marker {
    background: #667eea;
    color: white;
    padding: 8px 12px;
    border-radius: 20px;
    font-size: 12px;
    font-weight: 600;
    box-shadow: 0 4px 12px rgba(102, 126, 234, 0.4);
    border: 2px solid white;
    cursor: pointer;
    transition: all 0.3s ease;
    white-space: nowrap;
    max-width: 120px;
    overflow: hidden;
    text-overflow: ellipsis;
}

.library-marker:hover {
    background: #5a67d8;
    transform: scale(1.1);
}

.library-marker.active {
    background: #48bb78;
    animation: pulse 2s infinite;
}

@keyframes pulse {
    0% {
        box-shadow: 0 4px 12px rgba(72, 187, 120, 0.4);
    }
    50% {
        box-shadow: 0 4px 20px rgba(72, 187, 120, 0.8);
    }
    100% {
        box-shadow: 0 4px 12px rgba(72, 187, 120, 0.4);
    }
}

/* 响应式设计 - 平板 */
@media (max-width: 768px) {
    .container {
        padding: 16px;
    }
    
    .title {
        font-size: 2.2rem;
        gap: 8px;
    }
    
    .controls {
        flex-direction: column;
        align-items: stretch;
        padding: 16px;
    }
    
    .search-box {
        min-width: unset;
        width: 100%;
    }
    
    .control-buttons {
        justify-content: center;
        gap: 8px;
    }
    
    .btn {
        flex: 1;
        min-width: 120px;
        justify-content: center;
    }
    
    .modal-content {
        width: 95%;
        margin: 8% auto;
        max-height: 80vh;
    }
    
    #libraryInfo {
        padding: 20px;
        max-height: 65vh;
    }
    
    .map-container {
        min-height: 50vh;
    }
    
    #mapContainer {
        min-height: 50vh;
    }
}

/* 响应式设计 - 手机 */
@media (max-width: 480px) {
    .container {
        padding: 12px;
    }
    
    .header {
        padding: 20px 16px;
        margin-bottom: 16px;
    }
    
    .title {
        font-size: 1.8rem;
        flex-direction: column;
        gap: 8px;
        line-height: 1.2;
    }
    
    .subtitle {
        font-size: 1rem;
    }
    
    .controls {
        padding: 16px;
        margin-bottom: 16px;
        gap: 12px;
    }
    
    .search-box {
        gap: 6px;
    }
    
    #searchInput {
        padding: 12px 14px;
        font-size: 16px; /* 防止iOS缩放 */
    }
    
    .search-btn {
        padding: 12px 14px;
        min-width: 44px;
    }
    
    .control-buttons {
        gap: 8px;
    }
    
    .btn {
        padding: 12px 16px;
        font-size: 13px;
        min-height: 44px;
    }
    
    .sidebar {
        width: 100%;
        right: -100%;
    }
    
    .sidebar-header {
        padding: 16px;
        min-height: 60px;
    }
    
    .sidebar-content {
        padding: 12px;
    }
    
    .library-item {
        padding: 16px;
    }
    
    .library-item h4 {
        font-size: 1rem;
    }
    
    .library-item p {
        font-size: 0.85rem;
    }
    
    .modal-content {
        width: 98%;
        margin: 5% auto;
        border-radius: 12px;
        max-height: 85vh;
    }
    
    #libraryInfo {
        padding: 16px;
        max-height: 70vh;
    }
    
    .library-detail h3 {
        font-size: 1.3rem;
        margin-bottom: 12px;
    }
    
    .library-detail p {
        font-size: 14px;
        margin-bottom: 10px;
    }
    
    .navigate-btn {
        padding: 14px 20px;
        font-size: 15px;
        min-height: 48px;
    }
    
    .user-location {
        left: 12px;
        right: 12px;
        bottom: 12px;
        padding: 10px 12px;
        font-size: 13px;
    }
    
    .footer {
        font-size: 0.8rem;
        padding: 0 8px;
    }
    
    .map-container {
        border-radius: 12px;
        min-height: 45vh;
    }
    
    #mapContainer {
        min-height: 45vh;
    }
    
    .library-marker {
        padding: 6px 10px;
        font-size: 11px;
        max-width: 100px;
    }
}

/* 超小屏幕优化 */
@media (max-width: 360px) {
    .container {
        padding: 8px;
    }
    
    .title {
        font-size: 1.6rem;
    }
    
    .controls {
        padding: 12px;
    }
    
    .btn {
        font-size: 12px;
        padding: 10px 12px;
    }
    
    .library-marker {
        padding: 4px 8px;
        font-size: 10px;
        max-width: 80px;
    }
}

/* 自定义地图控件样式 */
.amap-logo {
    display: none !important;
}

.amap-copyright {
    display: none !important;
}

/* 高 DPI 屏幕优化 */
@media (-webkit-min-device-pixel-ratio: 2), (min-resolution: 192dpi) {
    .library-marker {
        border-width: 1px;
    }
}

/* 横屏模式优化 */
@media (orientation: landscape) and (max-height: 500px) {
    .map-container {
        min-height: 70vh;
    }
    
    #mapContainer {
        min-height: 70vh;
    }
    
    .modal-content {
        max-height: 90vh;
    }
    
    #libraryInfo {
        max-height: 75vh;
    }
}

/* 触摸设备优化 */
@media (hover: none) and (pointer: coarse) {
    .btn:hover,
    .search-btn:hover,
    .navigate-btn:hover,
    .library-item:hover,
    .close:hover,
    .close-btn:hover {
        transform: none;
        background: var(--original-bg, inherit);
    }
    
    /* 增强触摸反馈 */
    .btn:active,
    .search-btn:active,
    .navigate-btn:active {
        transform: scale(0.98);
    }
} 