/* 全局变量 */
:root {
    --primary-color: #2196F3;
    --primary-dark: #1976D2;
    --secondary-color: #4CAF50;
    --secondary-dark: #388E3C;
    --accent-color: #FFC107;
    --text-primary: #333333;
    --text-secondary: #666666;
    --text-light: #FFFFFF;
    --background-light: #FFFFFF;
    --background-gray: #F5F5F5;
    --border-color: #E0E0E0;
    --shadow-sm: 0 2px 4px rgba(0,0,0,0.1);
    --shadow-md: 0 4px 8px rgba(0,0,0,0.12);
    --shadow-lg: 0 8px 16px rgba(0,0,0,0.16);
    --border-radius-sm: 4px;
    --border-radius-md: 8px;
    --border-radius-lg: 12px;
    --font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    --font-size-sm: 12px;
    --font-size-md: 14px;
    --font-size-lg: 16px;
    --font-size-xl: 18px;
    --spacing-xs: 4px;
    --spacing-sm: 8px;
    --spacing-md: 12px;
    --spacing-lg: 16px;
    --spacing-xl: 20px;
}

/* 全局样式 */
body {
    margin: 0;
    padding: 0;
    font-family: var(--font-family);
    color: var(--text-primary);
    background-color: var(--background-gray);
}

#map {
    width: 100vw;
    height: 100vh;
    margin-top: 80px;
}

/* 搜索面板样式 */
.search-panel {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    background: var(--background-light);
    padding: var(--spacing-md) var(--spacing-lg);
    border-radius: 0;
    box-shadow: var(--shadow-md);
    z-index: 1000;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.3s ease;
    margin: 0;
}

.search-panel:hover {
    box-shadow: var(--shadow-lg);
    transform: translateY(-2px);
}

.search-panel input {
    padding: var(--spacing-md);
    border: 1px solid var(--border-color);
    border-radius: var(--border-radius-sm);
    margin-right: var(--spacing-sm);
    width: 300px;
    max-width: 70%;
    font-family: var(--font-family);
    font-size: var(--font-size-md);
    transition: border-color 0.3s ease;
}

.search-panel input:focus {
    outline: none;
    border-color: var(--primary-color);
    box-shadow: 0 0 0 2px rgba(33, 150, 243, 0.1);
}

.search-panel button {
    background: linear-gradient(135deg, var(--primary-color), var(--primary-dark));
    color: var(--text-light);
    border: none;
    padding: var(--spacing-md) var(--spacing-lg);
    border-radius: var(--border-radius-sm);
    cursor: pointer;
    font-family: var(--font-family);
    font-size: var(--font-size-md);
    font-weight: 500;
    transition: all 0.3s ease;
}

.search-panel button:hover {
    background: linear-gradient(135deg, var(--primary-dark), #1565C0);
    transform: translateY(-1px);
}

/* 控制面板样式 */
.control-panel {
    position: absolute;
    top: var(--spacing-lg);
    left: var(--spacing-lg);
    background: var(--background-light);
    padding: var(--spacing-xl);
    border-radius: var(--border-radius-md);
    box-shadow: var(--shadow-md);
    z-index: 1000;
    max-width: 320px;
    transition: all 0.3s ease;
}

.control-panel:hover {
    box-shadow: var(--shadow-lg);
}

.control-panel-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: var(--spacing-lg);
}

.control-panel-header h3 {
    margin: 0;
    font-size: var(--font-size-xl);
    font-weight: 600;
    color: var(--text-primary);
}

.control-panel form div {
    margin-bottom: var(--spacing-lg);
}

.control-panel label {
    display: block;
    margin-bottom: var(--spacing-sm);
    font-weight: 500;
    font-size: var(--font-size-md);
    color: var(--text-primary);
}

.control-panel input,
.control-panel textarea,
.control-panel select {
    width: 100%;
    padding: var(--spacing-md);
    border: 1px solid var(--border-color);
    border-radius: var(--border-radius-sm);
    font-family: var(--font-family);
    font-size: var(--font-size-md);
    transition: border-color 0.3s ease;
    box-sizing: border-box;
}

.control-panel input:focus,
.control-panel textarea:focus,
.control-panel select:focus {
    outline: none;
    border-color: var(--primary-color);
    box-shadow: 0 0 0 2px rgba(33, 150, 243, 0.1);
}

.control-panel textarea {
    resize: vertical;
    min-height: 100px;
}

.control-panel button {
    background: linear-gradient(135deg, var(--secondary-color), var(--secondary-dark));
    color: var(--text-light);
    border: none;
    padding: var(--spacing-md) var(--spacing-xl);
    border-radius: var(--border-radius-sm);
    cursor: pointer;
    font-family: var(--font-family);
    font-size: var(--font-size-md);
    font-weight: 500;
    transition: all 0.3s ease;
    width: 100%;
    margin-top: var(--spacing-md);
}

.control-panel button:hover {
    background: linear-gradient(135deg, var(--secondary-dark), #2E7D32);
    transform: translateY(-1px);
}

.control-panel button:disabled {
    background: var(--border-color);
    cursor: not-allowed;
    transform: none;
}

/* 提示文本样式 */
.hint {
    color: var(--text-secondary);
    font-size: var(--font-size-sm);
    margin: 0 0 var(--spacing-md) 0;
    line-height: 1.4;
}

/* 图片预览样式 */
.image-preview {
    margin-top: var(--spacing-md);
    max-height: 180px;
    overflow: hidden;
    border-radius: var(--border-radius-sm);
    border: 1px solid var(--border-color);
    background-color: var(--background-gray);
    display: flex;
    align-items: center;
    justify-content: center;
}

.image-preview img {
    max-width: 100%;
    max-height: 180px;
    transition: transform 0.3s ease;
}

.image-preview img:hover {
    transform: scale(1.02);
}

/* 线索详情弹窗样式 */
.clue-popup {
    max-width: 320px;
    font-family: var(--font-family);
}

.clue-popup h4 {
    margin-top: 0;
    margin-bottom: var(--spacing-sm);
    font-size: var(--font-size-lg);
    font-weight: 600;
    color: var(--text-primary);
}

.clue-popup .clue-type {
    display: inline-block;
    padding: var(--spacing-xs) var(--spacing-md);
    background: rgba(33, 150, 243, 0.1);
    color: var(--primary-color);
    border-radius: 16px;
    font-size: var(--font-size-sm);
    font-weight: 500;
    margin-bottom: var(--spacing-md);
}

.clue-popup .clue-description {
    margin-bottom: var(--spacing-lg);
    line-height: 1.5;
    color: var(--text-secondary);
}

.clue-popup .clue-files {
    margin-top: var(--spacing-lg);
}

.clue-popup .clue-file {
    margin-bottom: var(--spacing-md);
    padding: var(--spacing-sm);
    background: var(--background-gray);
    border-radius: var(--border-radius-sm);
    transition: all 0.3s ease;
}

.clue-popup .clue-file:hover {
    background: rgba(33, 150, 243, 0.05);
    transform: translateY(-1px);
}

.clue-popup .clue-file img {
    max-width: 100%;
    max-height: 180px;
    border-radius: var(--border-radius-sm);
    box-shadow: var(--shadow-sm);
    transition: all 0.3s ease;
}

.clue-popup .clue-file img:hover {
    box-shadow: var(--shadow-md);
    transform: scale(1.02);
}

.clue-popup .clue-file button {
    margin-top: var(--spacing-sm);
    background: var(--primary-color);
    color: var(--text-light);
    border: none;
    padding: var(--spacing-xs) var(--spacing-md);
    border-radius: var(--border-radius-sm);
    cursor: pointer;
    font-family: var(--font-family);
    font-size: var(--font-size-sm);
    font-weight: 500;
    transition: all 0.3s ease;
}

.clue-popup .clue-file button:hover {
    background: var(--primary-dark);
    transform: translateY(-1px);
}

.clue-popup .clue-actions {
    margin-top: var(--spacing-lg);
    display: flex;
    gap: var(--spacing-sm);
}

.clue-popup .clue-actions button {
    flex: 1;
    padding: var(--spacing-sm) var(--spacing-md);
    border: none;
    border-radius: var(--border-radius-sm);
    cursor: pointer;
    font-family: var(--font-family);
    font-size: var(--font-size-sm);
    font-weight: 500;
    transition: all 0.3s ease;
}

.clue-popup .clue-actions button:first-child {
    background: linear-gradient(135deg, var(--secondary-color), var(--secondary-dark));
    color: var(--text-light);
}

.clue-popup .clue-actions button:first-child:hover {
    transform: translateY(-1px);
}

.clue-popup .clue-actions button:last-child {
    background: linear-gradient(135deg, #F44336, #D32F2F);
    color: var(--text-light);
}

.clue-popup .clue-actions button:last-child:hover {
    transform: translateY(-1px);
}

/* 搜索结果高亮 */
.search-highlight {
    animation: pulse 1.5s infinite;
}

@keyframes pulse {
    0% { box-shadow: 0 0 0 0 rgba(76, 175, 80, 0.4); }
    70% { box-shadow: 0 0 0 12px rgba(76, 175, 80, 0); }
    100% { box-shadow: 0 0 0 0 rgba(76, 175, 80, 0); }
}

/* 自定义图标样式 */
.custom-marker-icon {
    display: flex !important;
    align-items: center !important;
    justify-content: center !important;
    border-radius: 50% !important;
    color: var(--text-light) !important;
    font-weight: bold !important;
    font-size: 20px !important;
    box-shadow: var(--shadow-md) !important;
    transition: all 0.3s ease !important;
    width: 35px !important;
    height: 35px !important;
    z-index: 1000 !important;
    position: relative !important;
    pointer-events: auto !important;
}

.custom-marker-icon:hover {
    transform: scale(1.05) !important;
    box-shadow: var(--shadow-lg) !important;
}

/* 确保图标内部元素显示在最上层 */
.custom-marker-icon div {
    z-index: 1001 !important;
    position: relative !important;
    display: flex !important;
    align-items: center !important;
    justify-content: center !important;
}

/* Leaflet图标容器样式 */
.leaflet-marker-icon {
    z-index: 1000 !important;
    position: relative !important;
    pointer-events: auto !important;
}

/* 确保图标不被地图瓦片覆盖 */
.leaflet-pane.leaflet-marker-pane {
    z-index: 650 !important;
}

/* 确保标记图层显示在最上层 */
.leaflet-pane#leaflet-pane-markers {
    z-index: 650 !important;
}

/* 懒加载图片样式 */
.lazy-load {
    opacity: 0;
    transform: translateY(10px);
    transition: opacity 0.5s ease, transform 0.5s ease;
}

.lazy-load.loaded {
    opacity: 1;
    transform: translateY(0);
}

/* 页面加载动画 */
@keyframes fadeIn {
    from {
        opacity: 0;
        transform: translateY(20px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* 元素进入动画 */
.fade-in {
    animation: fadeIn 0.6s ease forwards;
}

/* 按钮点击动画 */
@keyframes buttonClick {
    0% {
        transform: scale(1);
    }
    50% {
        transform: scale(0.95);
    }
    100% {
        transform: scale(1);
    }
}

button:active {
    animation: buttonClick 0.3s ease;
}

/* 弹窗动画 */
@keyframes popupIn {
    from {
        opacity: 0;
        transform: scale(0.9);
    }
    to {
        opacity: 1;
        transform: scale(1);
    }
}

.clue-popup {
    animation: popupIn 0.3s ease;
}

/* 线索标记动画 */
@keyframes markerPulse {
    0% {
        transform: scale(1);
        opacity: 1;
    }
    50% {
        transform: scale(1.1);
        opacity: 0.8;
    }
    100% {
        transform: scale(1);
        opacity: 1;
    }
}

.custom-div-icon {
    animation: markerPulse 2s infinite;
}

/* 线索连线动画 */
@keyframes lineDraw {
    from {
        stroke-dasharray: 1000;
        stroke-dashoffset: 1000;
    }
    to {
        stroke-dasharray: 1000;
        stroke-dashoffset: 0;
    }
}

/* 搜索结果动画 */
@keyframes searchHighlight {
    0% {
        box-shadow: 0 0 0 0 rgba(33, 150, 243, 0.4);
        transform: scale(1);
    }
    50% {
        box-shadow: 0 0 0 8px rgba(33, 150, 243, 0);
        transform: scale(1.02);
    }
    100% {
        box-shadow: 0 0 0 0 rgba(33, 150, 243, 0);
        transform: scale(1);
    }
}

.search-highlight {
    animation: searchHighlight 2s infinite;
}

/* 表单提交动画 */
@keyframes submitLoading {
    0% {
        transform: rotate(0deg);
    }
    100% {
        transform: rotate(360deg);
    }
}

/* 加载中动画 */
.loading-spinner {
    display: inline-block;
    width: 20px;
    height: 20px;
    border: 2px solid rgba(255, 255, 255, 0.3);
    border-radius: 50%;
    border-top-color: #fff;
    animation: submitLoading 1s ease-in-out infinite;
}

/* 成功提示动画 */
@keyframes successPulse {
    0% {
        transform: scale(1);
        box-shadow: 0 0 0 0 rgba(76, 175, 80, 0.4);
    }
    70% {
        transform: scale(1.05);
        box-shadow: 0 0 0 10px rgba(76, 175, 80, 0);
    }
    100% {
        transform: scale(1);
        box-shadow: 0 0 0 0 rgba(76, 175, 80, 0);
    }
}

.success-animation {
    animation: successPulse 0.6s ease;
}

/* 错误提示动画 */
@keyframes errorShake {
    0%, 100% {
        transform: translateX(0);
    }
    25% {
        transform: translateX(-5px);
    }
    75% {
        transform: translateX(5px);
    }
}

.error-animation {
    animation: errorShake 0.5s ease;
}

/* 平滑滚动 */
html {
    scroll-behavior: smooth;
}

/* 悬停效果增强 */
* {
    transition: all 0.3s ease;
}

/* 确保动画在所有浏览器中正常工作 */
@-webkit-keyframes fadeIn {
    from {
        opacity: 0;
        transform: translateY(20px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

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

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

/* 响应式设计 */
/* 移动设备：小于 768px */
@media (max-width: 768px) {
    /* 调整地图位置 */
    #map {
        margin-top: 100px;
        height: calc(100vh - 100px);
    }
    
    /* 调整搜索面板 */
    .search-panel {
        flex-direction: column;
        align-items: stretch;
        gap: var(--spacing-sm);
        padding: var(--spacing-sm) var(--spacing-md);
    }
    
    .search-panel input {
        width: 100%;
        max-width: 100%;
        margin-right: 0;
        padding: var(--spacing-sm);
        font-size: var(--font-size-md);
    }
    
    .search-panel button {
        width: 100%;
        padding: var(--spacing-sm) var(--spacing-md);
        font-size: var(--font-size-md);
    }
    
    /* 调整控制面板 */
    .control-panel {
        padding: var(--spacing-md);
        max-width: calc(100% - 32px);
    }
    
    .control-panel-header h3 {
        font-size: var(--font-size-md);
    }
    
    .control-panel form div {
        margin-bottom: var(--spacing-md);
    }
    
    .control-panel input,
    .control-panel textarea,
    .control-panel select {
        padding: var(--spacing-sm);
        font-size: var(--font-size-md);
    }
    
    .control-panel textarea {
        min-height: 80px;
    }
    
    .control-panel button {
        padding: var(--spacing-sm) var(--spacing-md);
        font-size: var(--font-size-md);
    }
    
    /* 调整线索弹窗 */
    .clue-popup {
        max-width: 280px;
        font-size: var(--font-size-md);
    }
    
    .clue-popup h4 {
        font-size: var(--font-size-md);
    }
    
    .clue-popup .clue-file img {
        max-height: 150px;
    }
    
    /* 调整图片预览 */
    .image-preview {
        max-height: 150px;
    }
    
    .image-preview img {
        max-height: 150px;
    }
    
    /* 调整AI助手面板 */
    .ai-assistant-panel {
        width: 90%;
        max-width: 320px;
        right: 10px;
        left: 10px;
        margin: 0 auto;
    }
    
    /* 调整按钮大小和位置 */
    .add-clue-button,
    .ai-toggle-button {
        position: fixed;
        bottom: 20px;
        z-index: 999;
    }
    
    .add-clue-button {
        left: 20px;
        padding: var(--spacing-sm) var(--spacing-md);
        font-size: var(--font-size-sm);
    }
    
    .ai-toggle-button {
        right: 20px;
        width: 50px;
        height: 50px;
        font-size: 20px;
    }
}

/* 平板设备：768px 到 1024px */
@media (min-width: 769px) and (max-width: 1024px) {
    /* 调整地图位置 */
    #map {
        margin-top: 80px;
        height: calc(100vh - 80px);
    }
    
    /* 调整搜索输入框 */
    .search-panel input {
        width: 250px;
        max-width: 60%;
    }
    
    /* 调整线索弹窗 */
    .clue-popup {
        max-width: 300px;
    }
}

/* 大屏幕设备：大于 1024px */
@media (min-width: 1025px) {
    /* 调整地图位置 */
    #map {
        margin-top: 80px;
        height: calc(100vh - 80px);
    }
    
    /* 调整搜索输入框 */
    .search-panel input {
        width: 300px;
        max-width: 50%;
    }
    
    /* 调整线索弹窗 */
    .clue-popup {
        max-width: 350px;
    }
}

/* 横屏移动设备 */
@media (max-height: 500px) {
    /* 调整地图位置和高度 */
    #map {
        margin-top: 70px;
        height: calc(100vh - 70px);
    }
    
    /* 调整搜索面板 */
    .search-panel {
        padding: var(--spacing-sm) var(--spacing-md);
    }
    
    .search-panel input {
        padding: var(--spacing-sm);
        font-size: var(--font-size-sm);
    }
    
    .search-panel button {
        padding: var(--spacing-sm);
        font-size: var(--font-size-sm);
    }
    
    /* 调整面板高度 */
    .control-panel {
        max-height: 70vh;
        overflow-y: auto;
    }
    
    /* 调整图片预览高度 */
    .image-preview {
        max-height: 100px;
    }
    
    .image-preview img {
        max-height: 100px;
    }
    
    /* 调整线索弹窗 */
    .clue-popup {
        max-height: 60vh;
        overflow-y: auto;
    }
}

/* 触摸设备优化 */
@media (hover: none) and (pointer: coarse) {
    /* 增加触摸目标大小 */
    button {
        min-height: 44px;
        min-width: 44px;
        padding: var(--spacing-md);
    }
    
    input,
    select,
    textarea {
        min-height: 44px;
        padding: var(--spacing-md);
    }
    
    /* 增加间距 */
    .control-panel form div {
        margin-bottom: var(--spacing-lg);
    }
    
    /* 移除悬停效果，添加触摸反馈 */
    *:hover {
        transform: none !important;
    }
    
    button:active {
        background-color: var(--primary-dark) !important;
        transform: scale(0.95) !important;
    }
}

/* 打印样式 */
@media print {
    /* 隐藏不必要的元素 */
    .search-panel,
    .control-panel,
    .ai-assistant-panel,
    .add-clue-button,
    .ai-toggle-button {
        display: none !important;
    }
    
    /* 调整地图大小 */
    #map {
        width: 100%;
        height: 100vh;
    }
    
    /* 调整线索弹窗 */
    .clue-popup {
        max-width: 100%;
        box-shadow: none;
        border: 1px solid #000;
    }
}
