/**
 * Weather Widget
 * 显示当前城市天气信息，悬停显示三日预报
 */

/* 天气小组件容器 */
.weather-widget {
  position: absolute;
  right: 20px;
  top: 20px;  /* 与 #m_bgctrl_wrp 保持一致 */
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 6px 12px;
  border-radius: 999px;
  background: rgba(240, 240, 240, 0.7);
  /* border: 1px solid rgba(150, 150, 150, 0.3); */
  cursor: pointer;
  opacity: 0.7;
  font-size: 11px;
  color: #333;
  z-index: 100;
  transition: all 0.25s ease;
}

body.custom-bg .weather-widget {
  right: auto;
  left: 50%;
  transform: translateX(-50%);
}

body.custom-bg .weather-popup {
  right: auto;
  left: 50%;
  margin-left: -200px;
}

.weather-widget:hover {
  opacity: 1;
  background: rgba(255, 255, 255, 0.95);
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.1);
}

/* 天气图标 */
.weather-widget-icon {
  width: 20px;
  height: 20px;
  display: flex;
  align-items: center;
  justify-content: center;
  color: white;
}

.weather-widget-icon svg,
.weather-widget-icon img {
  width: 18px;
  height: 18px;
  /* 浅色模式下保持原色 */
}

/* 城市名 */
.weather-widget-city {
  font-weight: 500;
  white-space: nowrap;
}

/* 温度 */
.weather-widget-temp {
  white-space: nowrap;
  color: #555;
}

/* 风向 */
.weather-widget-wind {
  white-space: nowrap;
  color: #888;
  font-size: 12px;
}

/* 加载中状态 */
.weather-widget.weather-loading {
  opacity: 0.6;
  pointer-events: none;
}

/* 错误/隐藏状态 */
.weather-widget.weather-hidden {
  display: none;
}

/* 加载 spinner */
.weather-loading-spinner {
  width: 16px;
  height: 16px;
  border: 2px solid #888;
  border-top-color: transparent;
  border-radius: 50%;
  animation: weather-spin 0.8s linear infinite;
}

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

/* ========== 悬浮弹窗 ========== */

.weather-popup {
  position: absolute;
  top: calc(100% + 10px);
  right: 0;
  width: 360px;
  padding: 16px;
  /* 渐变背景 */
  background: linear-gradient(135deg, rgba(255, 255, 255, 0.75) 0%, rgba(240, 245, 255, 0.75) 100%);
  border-radius: 16px;
  box-shadow: 0 8px 32px rgba(0, 0, 0, 0.15);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  opacity: 0;
  visibility: hidden;
  transform: translateY(-8px);
  transition: all 0.25s ease;
  z-index: 101;
}

.weather-widget:hover .weather-popup {
  opacity: 1;
  visibility: visible;
  transform: translateY(0);
}

/* 弹窗标题 */
.weather-popup-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 12px;
  padding-bottom: 8px;
  border-bottom: 1px solid rgba(0, 0, 0, 0.06);
}

.weather-popup-city {
  font-size: 16px;
  font-weight: 600;
  color: #222;
}

.weather-popup-update {
  font-size: 11px;
  color: #999;
}

/* 三日预报 */
.weather-forecast {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.weather-forecast-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 12px;
  background: rgba(0, 0, 0, 0.03);
  border-radius: 10px;
}

.weather-forecast-date {
  width: 95px;
  font-size: 13px;
  color: #666;
}

.weather-forecast-icon {
  width: 28px;
  height: 28px;
  display: flex;
  align-items: center;
  justify-content: center;
  /* 浅色模式下保持原色 */
}

.weather-forecast-icon svg {
  width: 24px;
  height: 24px;
}

.weather-forecast-text {
  flex: 1;
  font-size: 13px;
  color: #333;
}

.weather-forecast-temp {
  font-size: 14px;
  font-weight: 500;
  color: #222;
}

.weather-forecast-wind {
  width: 60px;
  font-size: 12px;
  color: #888;
  text-align: right;
}

/* ========== 暗色模式 ========== */

body.theme-dark .weather-widget {
  background: rgba(40, 40, 40, 0.8);
  border-color: rgba(100, 100, 100, 0.5);
  color: #e5e7eb;
}

body.theme-dark .weather-widget:hover {
  background: rgba(50, 50, 50, 0.95);
}

body.theme-dark .weather-widget-temp {
  color: #bbb;
}

body.theme-dark .weather-widget-wind {
  color: #888;
}

body.theme-dark .weather-popup {
  background: rgba(30, 30, 30, 0.9);
  box-shadow: 0 8px 32px rgba(0, 0, 0, 0.4);
}

body.theme-dark .weather-popup-city {
  color: #e5e7eb;
}

body.theme-dark .weather-popup-update {
  color: #666;
}

body.theme-dark .weather-forecast-item {
  background: rgba(255, 255, 255, 0.05);
}

body.theme-dark .weather-forecast-date {
  color: #9ca3af;
}

body.theme-dark .weather-forecast-text {
  color: #e5e7eb;
}

body.theme-dark .weather-forecast-temp {
  color: #fff;
}

body.theme-dark .weather-forecast-wind {
  color: #888;
}

/* 暗色模式下图标反色 */
body.theme-dark .weather-widget-icon img,
body.theme-dark .weather-forecast-icon img {
  filter: invert(1);
}

/* ========== 自动暗色模式 ========== */

@media (prefers-color-scheme: dark) {
  body.auto-theme .weather-widget {
    background: rgba(40, 40, 40, 0.8);
    border-color: rgba(100, 100, 100, 0.5);
    color: #e5e7eb;
  }

  body.auto-theme .weather-widget:hover {
    background: rgba(50, 50, 50, 0.95);
  }

  body.auto-theme .weather-widget-temp {
    color: #bbb;
  }

  body.auto-theme .weather-widget-wind {
    color: #888;
  }

  body.auto-theme .weather-popup {
    background: rgba(30, 30, 30, 0.75);
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.4);
  }

  body.auto-theme .weather-popup-city {
    color: #e5e7eb;
  }

  body.auto-theme .weather-popup-update {
    color: #666;
  }

  body.auto-theme .weather-forecast-item {
    background: rgba(255, 255, 255, 0.05);
  }

  body.auto-theme .weather-forecast-date {
    color: #9ca3af;
  }

  body.auto-theme .weather-forecast-text {
    color: #e5e7eb;
  }

  body.auto-theme .weather-forecast-temp {
    color: #fff;
  }

  body.auto-theme .weather-forecast-wind {
    color: #888;
  }

  /* 暗色模式下图标反色 */
  body.auto-theme .weather-widget-icon img,
  body.auto-theme .weather-forecast-icon img {
    filter: invert(1);
  }
}

/* ========== 响应式 ========== */

@media (max-width: 768px) {
  .weather-widget {
    right: 10px;
    padding: 4px 10px;
    font-size: 12px;
  }

  .weather-widget-wind {
    display: none;
  }

  .weather-popup {
    width: 280px;
    right: -10px;
  }
}

@media (max-width: 480px) {
  .weather-widget {
    display: none;
  }
}
