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

body {
    font-family: 'Microsoft YaHei', Arial, sans-serif;
    height: 100vh;
    overflow: hidden;
}

/* 工具栏样式 */
#toolbar {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    padding: 10px 20px;
    display: flex;
    justify-content: flex-start; /* 整体左对齐 */
    align-items: center;
    gap: 12px; /* 缩小各区段之间的间距 */
    box-shadow: 0 2px 10px rgba(0,0,0,0.1);
    z-index: 1000;
    position: relative;
}

.toolbar {
    position: fixed;
    top: 20px;
    left: 20px;
    background: rgba(255, 255, 255, 0.95);
    padding: 15px;
    border-radius: 8px;
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.1);
    z-index: 1000;
    display: flex;
    gap: 15px;
    align-items: center;
    flex-wrap: wrap;
}

.tool-group {
    display: flex;
    gap: 5px;
    border: 1px solid #ddd;
    border-radius: 4px;
    overflow: hidden;
}

.tool-btn {
    padding: 4px 8px;
    border: none;
    background: #f8f9fa;
    cursor: pointer;
    transition: all 0.2s;
    font-size: 11px;
    white-space: nowrap;
    min-width: 50px;
}

.tool-btn:hover {
    background: #e9ecef;
}

.tool-btn.active {
    background: #007bff;
    color: white;
}

/* 弹窗中的图钉样式控件 */
.pin-style-controls {
    display: flex;
    gap: 15px;
    margin-top: 8px;
}

.pin-style-controls .control-item {
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.pin-style-controls label {
    font-size: 11px;
    color: #333;
    margin: 0;
}

/* 弹窗中的样式选择器特殊样式 */
.pin-style-controls .styled-select {
    border: 1px solid #ccc;
    background: white;
    color: #333;
    padding: 4px 8px;
}

.pin-style-controls .styled-select:focus {
    border-color: #3498db;
    box-shadow: 0 0 0 2px rgba(52, 152, 219, 0.2);
    outline: none;
}

.pin-style-controls .styled-select option {
    background: white;
    color: #333;
}

.filter-group {
    display: flex;
    gap: 10px;
    align-items: center;
    padding: 5px 10px;
    background: #f8f9fa;
    border-radius: 4px;
    border: 1px solid #ddd;
}

.filter-group label {
    font-size: 12px;
    color: #666;
    margin: 0;
}

.filter-group select {
    padding: 4px 8px;
    border: 1px solid #ccc;
    border-radius: 3px;
    font-size: 12px;
    min-width: 120px;
}

.layer-group {
    position: relative;
    display: inline-block;
}

.layer-btn {
    padding: 8px 16px;
    border: 1px solid rgba(255,255,255,0.3);
    border-radius: 6px;
    background: rgba(255,255,255,0.1);
    color: white;
    font-size: 13px;
    cursor: pointer;
    transition: all 0.2s ease;
}

.layer-btn:hover {
    background: rgba(255,255,255,0.2);
    border-color: rgba(255,255,255,0.5);
    transform: translateY(-1px);
}

.layer-dropdown {
    display: none;
    position: absolute;
    top: 100%;
    left: 0; /* 桌面端与移动端统一从按钮左边对齐，防止越界 */
    background: white;
    border: 1px solid #ddd;
    border-radius: 4px;
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.1);
    z-index: 1100; /* 提升层级，避免遮挡 */
    min-width: 180px; /* 适当增大，确保内容可见 */
    margin-top: 2px;
}

.layer-dropdown.show {
    display: block;
}

.layer-option {
    padding: 10px 15px;
    cursor: pointer;
    border-bottom: 1px solid #eee;
    font-size: 14px;
    color: #333;
    transition: background-color 0.2s;
}

.layer-option:last-child {
    border-bottom: none;
}

.layer-option:hover {
    background: #f8f9fa;
}

.layer-option.active {
    background: #007bff;
    color: white;
}

/* 工具栏区域样式 */
.toolbar-section {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 6px 0;
    border-bottom: 1px solid rgba(255,255,255,0.1);
}

.toolbar-section:last-child {
    border-bottom: none;
}

/* 标题区域 */
.title-section {
    justify-content: center;
    border-bottom: 2px solid rgba(255,255,255,0.2);
    padding: 12px 0;
}

.title-section h1 {
    font-size: clamp(18px, 2.4vw, 22px);
    font-weight: bold;
    margin: 0;
    text-shadow: 0 2px 4px rgba(0,0,0,0.3);
    white-space: normal;
    word-break: break-word;
    text-align: center;
    line-height: 1.2;
}

/* 让工具区域形成纵向布局，并将标题放到其上方 */
.tools-section {
    flex-direction: column;
    align-items: flex-start;
}
.tools-section .title-section {
    border-bottom: none; /* 避免在工具区域内重复分割线 */
    padding: 0;
    margin-bottom: 10px; /* 与“工具”保持 8-12px 间距，选 10px */
}

/* 区域标签 */
.section-label {
    font-weight: 600;
    font-size: 12px;
    color: rgba(255,255,255,0.9);
    min-width: 45px;
    text-align: right;
}

/* 控件容器 */
.filter-controls,
.style-controls {
    display: flex;
    align-items: center;
    gap: 10px;
    flex-wrap: wrap;
}

.control-item {
    display: flex;
    align-items: center;
    gap: 8px;
}

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

/* 标签和输入框样式 */
.control-item label {
    font-weight: 500;
    font-size: 11px;
    color: #333;
    white-space: nowrap;
}

/* 年份区间样式 */
.year-range .year-inputs {
    display: flex;
    align-items: center;
    gap: 6px;
}

.year-input {
    flex: 1;
    min-width: 70px;
}

.year-separator {
    color: #666;
    font-weight: 500;
    font-size: 12px;
}

.styled-input,
.styled-select {
    padding: 4px 8px;
    border: 1px solid rgba(255,255,255,0.3);
    border-radius: 4px;
    background: rgba(255,255,255,0.1);
    color: white;
    font-size: 11px;
    min-width: 100px;
    transition: all 0.2s ease;
}

/* 下拉菜单选项样式 */
.styled-select option {
    background: #2c3e50;
    color: white;
    padding: 8px;
}

.styled-select option:hover {
    background: #34495e;
}

.styled-select option:checked {
    background: #3498db;
    color: white;
}

.styled-input:focus,
.styled-select:focus {
    outline: none;
    border-color: rgba(255,255,255,0.6);
    background: rgba(255,255,255,0.15);
    box-shadow: 0 0 0 2px rgba(255,255,255,0.1);
}

.styled-input::placeholder {
    color: rgba(255,255,255,0.5);
}

/* 日期区间（三段式）样式 */
.date-range-inputs {
    display: flex;
    flex-direction: column; /* 两行显示：起始在上，结束在下 */
    gap: 10px; /* 行间距 8-12px 之间，取 10px */
    align-items: flex-start;
}
.date-group {
    display: flex;
    align-items: center;
    gap: 6px;
    width: 100%;
}
.date-group-label {
    font-weight: 600;
    color: #fff;
    min-width: 40px; /* 起始/结束标签占位，保证两行左侧对齐 */
    margin-right: 2px;
}
.date-group label {
    min-width: 20px; /* 年/月/日标签统一占位，保证控件对齐 */
    text-align: right;
}
.small-input {
    width: 52px; /* 缩小约35%（原80px）*/
    min-width: 52px;
}
.input-msg {
    margin-top: 6px;
    font-size: 12px;
    color: #ffe082;
}
.input-error {
    border-color: #ff6b6b !important;
    box-shadow: 0 0 0 2px rgba(255,107,107,0.2);
}

/* 按钮样式 */
.action-btn {
    padding: 6px 12px;
    border: none;
    border-radius: 4px;
    font-size: 11px;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s ease;
    display: inline-flex;
    align-items: center;
    gap: 4px;
    white-space: nowrap;
}

.action-btn.primary {
    background: linear-gradient(135deg, #007bff, #0056b3);
    color: white;
    box-shadow: 0 2px 4px rgba(0,123,255,0.3);
}

.action-btn.primary:hover {
    background: linear-gradient(135deg, #0056b3, #004085);
    transform: translateY(-1px);
    box-shadow: 0 4px 8px rgba(0,123,255,0.4);
}

.action-btn.secondary {
    background: rgba(255,255,255,0.1);
    color: white;
    border: 1px solid rgba(255,255,255,0.3);
}

.action-btn.secondary:hover {
    background: rgba(255,255,255,0.2);
    border-color: rgba(255,255,255,0.5);
    transform: translateY(-1px);
}

/* 城市名称开关已移除 */

/* 工具按钮样式 */
.tool-btn {
    padding: 8px 16px;
    border: 1px solid rgba(255,255,255,0.3);
    border-radius: 6px;
    background: rgba(255,255,255,0.1);
    color: white;
    font-size: 13px;
    cursor: pointer;
    transition: all 0.2s ease;
}

.tool-btn:hover {
    background: rgba(255,255,255,0.2);
    border-color: rgba(255,255,255,0.5);
    transform: translateY(-1px);
}

.tool-btn.active {
    background: linear-gradient(135deg, #28a745, #1e7e34);
    border-color: #28a745;
    box-shadow: 0 2px 4px rgba(40,167,69,0.3);
}

/* 工具组样式 */
.tool-group {
    display: flex;
    align-items: center;
    gap: 6px; /* 压缩按钮间距，紧凑但不重叠 */
}

/* 地图样式 */
#map {
    height: calc(100vh - 70px);
    width: 100%;
}

/* 图钉工具模式下的地图光标 */
#map.pin-mode {
    cursor: crosshair !important;
}

#map.select-mode {
    cursor: default;
}

/* 坐标悬浮提示框 */
.coords-tooltip {
    position: absolute;
    z-index: 3000;
    padding: 6px 8px;
    border-radius: 4px;
    background: rgba(0,0,0,0.75);
    color: #fff;
    font-size: 12px;
    box-shadow: 0 2px 6px rgba(0,0,0,0.25);
    pointer-events: none; /* 不影响主流程操作 */
    user-select: none;
    white-space: nowrap;
}

.coords-tooltip.error {
    background: rgba(200,0,0,0.85);
}

/* 弹窗样式 */
.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(5px);
}

.modal-content {
    background-color: #fefefe;
    margin: 5% auto;
    padding: 30px;
    border: none;
    border-radius: 15px;
    width: 90%;
    max-width: 500px;
    max-height: 80vh;
    overflow-y: auto;
    box-shadow: 0 10px 30px rgba(0,0,0,0.3);
    animation: modalSlideIn 0.3s ease;
}

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

.close {
    color: #aaa;
    float: right;
    font-size: 28px;
    font-weight: bold;
    cursor: pointer;
    transition: color 0.3s ease;
}

.close:hover,
.close:focus {
    color: #667eea;
}

.modal h2 {
    color: #333;
    margin-bottom: 20px;
    font-size: 1.5em;
}

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

.form-group label {
    display: block;
    margin-bottom: 5px;
    font-weight: 500;
    color: #555;
}

.form-group input,
.form-group textarea {
    width: 100%;
    padding: 10px;
    border: 2px solid #e1e1e1;
    border-radius: 8px;
    font-size: 14px;
    transition: border-color 0.3s ease;
    font-family: inherit;
}

.form-group input:focus,
.form-group textarea:focus {
    outline: none;
    border-color: #667eea;
    box-shadow: 0 0 0 3px rgba(102, 126, 234, 0.1);
}

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

.form-buttons {
    display: flex;
    gap: 10px;
    justify-content: flex-end;
    margin-top: 25px;
}

.form-buttons button {
    padding: 10px 20px;
    border: none;
    border-radius: 8px;
    cursor: pointer;
    font-size: 14px;
    font-weight: 500;
    transition: all 0.3s ease;
}

.form-buttons button[type="submit"],
#editBtn {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
}

.form-buttons button[type="submit"]:hover,
#editBtn:hover {
    transform: translateY(-2px);
    box-shadow: 0 5px 15px rgba(102, 126, 234, 0.4);
}

.form-buttons button[type="button"],
#deleteBtn,
#closeDetailBtn {
    background: #f8f9fa;
    color: #6c757d;
    border: 1px solid #dee2e6;
}

.form-buttons button[type="button"]:hover,
#closeDetailBtn:hover {
    background: #e9ecef;
}

#deleteBtn {
    background: #dc3545;
    color: white;
    border: 1px solid #dc3545;
}

#deleteBtn:hover {
    background: #c82333;
    transform: translateY(-2px);
}

/* 详情内容样式 */
#detailContent {
    margin: 20px 0;
}

#detailContent h3 {
    color: #667eea;
    margin-bottom: 10px;
}

#detailContent p {
    margin-bottom: 10px;
    line-height: 1.6;
}

#detailContent .detail-item {
    background: #f8f9fa;
    padding: 10px;
    border-radius: 8px;
    margin-bottom: 10px;
}

#detailContent .detail-label {
    font-weight: bold;
    color: #555;
    display: inline-block;
    min-width: 80px;
}

/* 多选标签样式 */
.tag-selector {
    border: 2px solid #e1e1e1;
    border-radius: 8px;
    padding: 15px;
    background: #f8f9fa;
}

.available-tags {
    margin-bottom: 15px;
}

.available-tags::before {
    content: "可选标签:";
    display: block;
    font-weight: 500;
    color: #555;
    margin-bottom: 8px;
    font-size: 14px;
}

.tag-item {
    display: inline-block;
    padding: 6px 12px;
    margin: 3px;
    background: white;
    border: 2px solid #dee2e6;
    border-radius: 20px;
    cursor: pointer;
    font-size: 13px;
    transition: all 0.2s ease;
    user-select: none;
}

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

.tag-item.selected {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    border-color: #667eea;
}

.selected-tags {
    border-top: 1px solid #dee2e6;
    padding-top: 15px;
    min-height: 50px;
}

.selected-tags-label {
    font-weight: 500;
    color: #555;
    margin-bottom: 8px;
    font-size: 14px;
}

.selected-tags-list {
    min-height: 30px;
}

.selected-tag {
    display: inline-block;
    padding: 6px 12px;
    margin: 3px;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    border-radius: 20px;
    cursor: pointer;
    font-size: 13px;
    transition: all 0.2s ease;
    user-select: none;
    position: relative;
}

.selected-tag:hover {
    background: linear-gradient(135deg, #5a6fd8 0%, #6a4190 100%);
    transform: translateY(-1px);
}

.selected-tag::after {
    content: "×";
    margin-left: 6px;
    font-weight: bold;
    opacity: 0.8;
}

.selected-tag:hover::after {
    opacity: 1;
}

/* 自定义图钉样式 */
.custom-pin {
    transition: all 0.3s ease;
}

.custom-pin:hover {
    transform: scale(1.1);
}

/* 圆形图钉 */
.pin-circle {
    width: 14px;
    height: 14px;
    border: 2px solid white;
    border-radius: 50%;
    box-shadow: 0 3px 10px rgba(0,0,0,0.3);
}

/* 方形图钉 */
.pin-square {
    width: 14px;
    height: 14px;
    border: 2px solid white;
    border-radius: 3px;
    box-shadow: 0 3px 10px rgba(0,0,0,0.3);
}

/* 三角形图钉 */
.pin-triangle {
    width: 0;
    height: 0;
    border-left: 8px solid transparent;
    border-right: 8px solid transparent;
    border-bottom: 14px solid;
    border-top: none;
    box-shadow: 0 3px 10px rgba(0,0,0,0.3);
    position: relative;
}

.pin-triangle::after {
    content: '';
    position: absolute;
    top: 2px;
    left: -6px;
    width: 0;
    height: 0;
    border-left: 6px solid transparent;
    border-right: 6px solid transparent;
    border-bottom: 11px solid white;
}

/* 菱形图钉 */
.pin-diamond {
    width: 12px;
    height: 12px;
    border: 2px solid white;
    transform: rotate(45deg);
    box-shadow: 0 3px 10px rgba(0,0,0,0.3);
}

.custom-pin:hover .pin-circle,
.custom-pin:hover .pin-square,
.custom-pin:hover .pin-triangle,
.custom-pin:hover .pin-diamond {
    box-shadow: 0 5px 20px rgba(0,0,0,0.5);
}

/* 响应式设计 */
@media (max-width: 768px) {
    #toolbar {
        flex-direction: column;
        gap: 10px;
        padding: 15px;
    }
    
    .toolbar-section {
        width: 100%;
        justify-content: flex-start; /* 移动端也保持左对齐 */
    }
    
    .modal-content {
        margin: 10% auto;
        padding: 20px;
        width: 95%;
    }
    
    #map {
        height: calc(100vh - 120px);
    }
    /* 移动端优化标题字号与换行 */
    .title-section h1 {
        font-size: clamp(17px, 4.5vw, 20px);
        max-width: 92vw;
    }

    /* 移动端确保下拉菜单不越界 */
    .layer-dropdown {
        left: 0; /* 移动端不偏移，避免越界 */
        right: auto;
        min-width: unset;
        width: auto;
        max-width: calc(100vw - 24px);
    }
}

    /* 移动端适配更易读的宽度（略增至56px，便于触控） */
    .small-input {
        width: 56px;
        min-width: 56px;
    }
}

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

@keyframes spin {
    to { transform: rotate(360deg); }
}

/* ---- 多笔记弹窗外观与动画 ---- */
.leaflet-popup.note-popup .leaflet-popup-content-wrapper {
    box-shadow: 0 8px 24px rgba(0,0,0,0.2);
    border-radius: 8px;
    animation: notePopupIn 0.3s ease;
}

.leaflet-popup.note-popup .leaflet-popup-tip {
    box-shadow: 0 8px 24px rgba(0,0,0,0.2);
}

@keyframes notePopupIn {
    from { opacity: 0; transform: translateY(8px); }
    to { opacity: 1; transform: translateY(0); }
}

/* 覆盖Leaflet的淡入淡出速度为300ms，保证关闭动画接近要求 */
.leaflet-fade-anim .leaflet-popup {
    transition: opacity 0.3s ease;
}

/* 城市/国家名称标注样式已移除 */

/* --- 表单分区与标题计数 --- */
fieldset.form-section {
  border: 1px solid #ddd;
  border-radius: 6px;
  padding: 10px 12px;
  margin-bottom: 12px;
}
fieldset.form-section legend {
  padding: 0 6px;
  font-weight: 600;
  color: #333;
}
.title-input-wrap {
  display: flex;
  align-items: center;
  gap: 8px;
}
.char-counter {
  font-size: 12px;
  color: #666;
}

/* --- 标签徽章 --- */
.tag-badge {
  display: inline-block;
  padding: 2px 8px;
  margin: 0 6px 6px 0;
  background: #eef3ff;
  color: #3856d6;
  border: 1px solid #c9d5ff;
  border-radius: 999px;
  font-size: 12px;
  line-height: 18px;
}

/* --- 弹窗正文动画与按钮 --- */
.popup-details {
  overflow: hidden;
  max-height: 0;
  transition: max-height 300ms ease;
}
.popup-actions {
  margin-top: 8px;
  display: flex;
  gap: 8px;
}
.btn-expand, .btn-collapse {
  cursor: pointer;
  padding: 4px 8px;
  border: 1px solid #ddd;
  border-radius: 4px;
  background: #fff;
  font-size: 12px;
}
.btn-expand:hover, .btn-collapse:hover {
  background: #f5f5f5;
}
@media (max-width: 768px) {
  .btn-expand, .btn-collapse {
    padding: 8px 12px;
  }
}
