// PhotoMap 插件样式

// ========================================
// 变量定义
// ========================================
$primary-color: #3498db;
$success-color: #27ae60;
$warning-color: #f39c12;
$error-color: #e74c3c;
$text-color: #2c3e50;
$light-gray: #ecf0f1;
$border-color: #bdc3c7;

// 断点定义
$mobile: 768px;
$tablet: 1024px;

// ========================================
// PhotoMap 容器样式
// ========================================
.photomap-container {
  position: relative;
  width: 100%;
  margin: 1.5rem 0;
  border-radius: 12px;
  overflow: hidden;
  box-shadow: 0 4px 20px rgba(0, 0, 0, 0.08);
  background: white;
  
  // 深色模式支持
  @media (prefers-color-scheme: dark) {
    background: #2c3e50;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.2);
  }
}

// ========================================
// 加载状态样式
// ========================================
.photomap-loading {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  min-height: 250px;
  padding: 2rem;
  background: linear-gradient(135deg, #f5f7fa 0%, #c3cfe2 100%);
  
  p {
    margin-top: 1rem;
    color: $text-color;
    font-size: 1rem;
    text-align: center;
  }
  
  @media (prefers-color-scheme: dark) {
    background: linear-gradient(135deg, #2c3e50 0%, #34495e 100%);
    
    p {
      color: #ecf0f1;
    }
  }
}

.loading-spinner {
  width: 40px;
  height: 40px;
  border: 4px solid rgba($primary-color, 0.2);
  border-top: 4px solid $primary-color;
  border-radius: 50%;
  animation: photomap-spin 1s linear infinite;
}

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

// ========================================
// 错误状态样式
// ========================================
.photomap-error {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  min-height: 200px;
  padding: 2rem;
  background: linear-gradient(135deg, #fff5f5 0%, #fed7d7 100%);
  text-align: center;
  
  .error-icon {
    font-size: 3rem;
    margin-bottom: 1rem;
    opacity: 0.8;
  }
  
  p {
    color: $error-color;
    font-size: 1rem;
    margin-bottom: 1.5rem;
    max-width: 300px;
  }
  
  @media (prefers-color-scheme: dark) {
    background: linear-gradient(135deg, #4a2c2a 0%, #5a3433 100%);
    
    p {
      color: #fed7d7;
    }
  }
}

.retry-btn {
  background: linear-gradient(135deg, $primary-color 0%, #2980b9 100%);
  color: white;
  border: none;
  padding: 0.75rem 1.5rem;
  border-radius: 25px;
  cursor: pointer;
  font-size: 0.9rem;
  font-weight: 500;
  transition: all 0.3s ease;
  box-shadow: 0 2px 10px rgba($primary-color, 0.3);
  
  &:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 15px rgba($primary-color, 0.4);
  }
  
  &:active {
    transform: translateY(0);
  }
}

// ========================================
// 地图容器样式
// ========================================
.photomap-map {
  width: 100%;
  min-height: 300px;
  position: relative;
  background: $light-gray;
  
  // 地图控件样式调整
  .maplibregl-ctrl-group {
    border-radius: 8px;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
  }
  
  .maplibregl-ctrl-zoom-in,
  .maplibregl-ctrl-zoom-out {
    background: white;
    color: $text-color;
    
    &:hover {
      background: $light-gray;
    }
  }
}

// ========================================
// 照片标记样式
// ========================================
.photo-marker {
  border-radius: 50%;
  cursor: pointer;
  border: 3px solid white;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.3);
  background-size: cover;
  background-position: center;
  transition: all 0.3s ease;
  overflow: hidden;
  
  &:hover {
    transform: scale(1.15);
    z-index: 1000;
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.4);
    border-color: $primary-color;
  }
  
  &:active {
    transform: scale(1.05);
  }
  
  // 添加一个内层遮罩，提高可访问性
  &::after {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.1);
    border-radius: 50%;
    transition: background 0.3s ease;
  }
  
  &:hover::after {
    background: rgba($primary-color, 0.2);
  }
}

// ========================================
// 照片列表样式
// ========================================
.photomap-photos {
  padding: 1.5rem;
  background: white;
  border-top: 1px solid #e1e8ed;
  
  h4 {
    margin: 0 0 1.5rem 0;
    font-size: 1.2rem;
    color: $text-color;
    font-weight: 600;
  }
  
  @media (prefers-color-scheme: dark) {
    background: #34495e;
    border-top-color: #4a6741;
    
    h4 {
      color: #ecf0f1;
    }
  }
}

.photo-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
  gap: 1.5rem;
  
  @media (max-width: $mobile) {
    grid-template-columns: repeat(auto-fill, minmax(110px, 1fr));
    gap: 1rem;
  }
}

.photo-thumbnail {
  cursor: pointer;
  border-radius: 12px;
  overflow: hidden;
  transition: all 0.3s ease;
  background: white;
  border: 1px solid #e1e8ed;
  position: relative;
  
  &:hover {
    transform: translateY(-4px);
    box-shadow: 0 8px 25px rgba(0, 0, 0, 0.15);
    border-color: $primary-color;
  }
  
  &.no-gps {
    opacity: 0.6;
    
    &::before {
      content: '📍';
      position: absolute;
      top: 0.5rem;
      right: 0.5rem;
      background: rgba($warning-color, 0.9);
      color: white;
      width: 24px;
      height: 24px;
      border-radius: 50%;
      display: flex;
      align-items: center;
      justify-content: center;
      font-size: 0.7rem;
      z-index: 2;
    }
  }
  
  img {
    width: 100%;
    height: 100px;
    object-fit: cover;
    display: block;
    transition: transform 0.3s ease;
  }
  
  &:hover img {
    transform: scale(1.05);
  }
  
  @media (max-width: $mobile) {
    img {
      height: 80px;
    }
  }
  
  @media (prefers-color-scheme: dark) {
    background: #2c3e50;
    border-color: #4a6741;
  }
}

.photo-info {
  padding: 0.75rem;
  
  .photo-alt {
    display: block;
    font-weight: 600;
    color: $text-color;
    margin-bottom: 0.5rem;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    font-size: 0.9rem;
  }
  
  .gps-info {
    color: #7f8c8d;
    font-family: 'SF Mono', 'Monaco', 'Inconsolata', 'Roboto Mono', monospace;
    font-size: 0.75rem;
    letter-spacing: 0.5px;
  }
  
  .no-gps-label {
    color: $warning-color;
    font-size: 0.75rem;
    font-weight: 500;
  }
  
  @media (prefers-color-scheme: dark) {
    .photo-alt {
      color: #ecf0f1;
    }
    
    .gps-info {
      color: #95a5a6;
    }
  }
}

// ========================================
// PhotoSwipe 自定义样式
// ========================================
.pswp {
  --pswp-bg: rgba(0, 0, 0, 0.9);
  --pswp-placeholder-bg: #222;
  
  .pswp__top-bar {
    background: linear-gradient(to bottom, rgba(0, 0, 0, 0.7), transparent);
  }
  
  .pswp__button {
    background: rgba(255, 255, 255, 0.1);
    border-radius: 50%;
    
    &:hover {
      background: rgba(255, 255, 255, 0.2);
    }
  }
}

// ========================================
// 无障碍访问样式
// ========================================
.photomap-container {
  // 为屏幕阅读器提供更好的支持
  [role="button"] {
    cursor: pointer;
  }
  
  // 聚焦状态
  .photo-marker:focus,
  .photo-thumbnail:focus,
  .retry-btn:focus {
    outline: 2px solid $primary-color;
    outline-offset: 2px;
  }
  
  // 高对比度模式支持
  @media (prefers-contrast: high) {
    .photo-marker {
      border-width: 4px;
    }
    
    .photo-thumbnail {
      border-width: 2px;
    }
  }
}

// ========================================
// 动画和过渡效果
// ========================================
.photomap-container {
  // 淡入动画
  animation: photomap-fade-in 0.5s ease-out;
}

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

// 照片网格的交错动画
.photo-grid .photo-thumbnail {
  animation: photomap-slide-up 0.6s ease-out;
  animation-fill-mode: both;
  
  @for $i from 1 through 20 {
    &:nth-child(#{$i}) {
      animation-delay: #{$i * 0.1}s;
    }
  }
}

@keyframes photomap-slide-up {
  from {
    opacity: 0;
    transform: translateY(30px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

// ========================================
// 打印样式
// ========================================
@media print {
  .photomap-container {
    break-inside: avoid;
    box-shadow: none;
    border: 1px solid #ccc;
  }
  
  .photomap-map {
    min-height: 200px;
    background: #f9f9f9;
    display: flex;
    align-items: center;
    justify-content: center;
    
    &::after {
      content: '地图内容（打印时不可见）';
      color: #666;
      font-style: italic;
    }
  }
  
  .photo-grid {
    grid-template-columns: repeat(4, 1fr);
    gap: 1rem;
  }
  
  .photo-thumbnail {
    box-shadow: none;
    border: 1px solid #ccc;
  }
}

// 地图容器包装器
.photomap-map-wrapper {
  position: relative;
  overflow: hidden;
  border-radius: 8px;
}

// 地图类型切换器
.photomap-map-type-switcher {
  position: absolute;
  top: 10px;
  right: 10px;
  z-index: 1000;
  
  .map-type-buttons {
    display: flex;
    flex-direction: column;
    gap: 4px;
    background: rgba(255, 255, 255, 0.95);
    backdrop-filter: blur(10px);
    border-radius: 8px;
    padding: 8px;
    box-shadow: 0 2px 12px rgba(0, 0, 0, 0.15);
    
    .map-type-btn {
      display: flex;
      align-items: center;
      gap: 6px;
      padding: 8px 12px;
      border: none;
      background: transparent;
      border-radius: 6px;
      cursor: pointer;
      transition: all 0.2s ease;
      font-size: 0.85rem;
      color: #555;
      min-width: 80px;
      
      &:hover {
        background: rgba($primary-color, 0.1);
        color: $primary-color;
      }
      
      &.active {
        background: $primary-color;
        color: white;
        box-shadow: 0 2px 4px rgba($primary-color, 0.3);
      }
      
      .map-type-icon {
        font-size: 1rem;
        display: flex;
        align-items: center;
        justify-content: center;
        width: 20px;
      }
      
      .map-type-label {
        font-weight: 500;
        white-space: nowrap;
      }
    }
  }
  
  // 深色模式支持
  @media (prefers-color-scheme: dark) {
    .map-type-buttons {
      background: rgba(45, 55, 72, 0.95);
      
      .map-type-btn {
        color: #e2e8f0;
        
        &:hover {
          background: rgba(66, 153, 225, 0.2);
          color: #4299e1;
        }
        
        &.active {
          background: #4299e1;
          color: white;
        }
      }
    }
  }
  
  // 移动端适配
  @media (max-width: $mobile) {
    right: 5px;
    top: 5px;
    
    .map-type-buttons {
      padding: 6px;
      gap: 3px;
      
      .map-type-btn {
        padding: 6px 10px;
        font-size: 0.8rem;
        min-width: 70px;
        
        .map-type-icon {
          font-size: 0.9rem;
          width: 18px;
        }
      }
    }
  }
}
