@import "./theme.css";

html,
body,
#map {
  height: 100%;
  margin: 0;
  padding: 0;
  font-family:
    -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue",
    Arial, sans-serif;
  background-color: var(--bg-color);
  color: var(--text-color);
}

.panel {
  background: var(--panel-bg);
  padding: 15px;
  border-radius: 8px;
  box-shadow: var(--panel-shadow);
  z-index: 1000;
  color: var(--text-color);
}

#coordinate-inputs {
  position: absolute;
  top: 20px;
  left: -320px; /* 默认隐藏 */
  width: 300px;
  transition: left 0.3s ease;
  background: var(--panel-bg);
  border-radius: 0 8px 8px 0;
  box-shadow: var(--panel-shadow);
}

#coordinate-inputs.expanded {
  left: 0;
}

.toggle-panel-button {
  position: absolute;
  right: -40px;
  top: 50%;
  transform: translateY(-50%);
  width: 40px;
  height: 80px;
  background-color: var(--panel-bg);
  border: none;
  border-radius: 0 8px 8px 0;
  box-shadow: var(--panel-shadow);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1000;
}

.toggle-panel-button::after {
  content: "▶";
  font-size: 16px;
  color: var(--text-color);
}

#coordinate-inputs.expanded .toggle-panel-button::after {
  content: "◀";
}

#mousecoord {
  position: absolute;
  right: 70px;
  top: 10px;
  padding: 4px 8px;
  font-size: 12px;
  line-height: 1.2;
  background: rgba(255, 255, 255, 0.8);
  border-radius: 4px;
  box-shadow: none;
  color: #1a202c;
}

[data-theme="dark"] #mousecoord {
  background: rgba(0, 0, 0, 0.8);
  color: #e2e8f0;
}

/* Keep light mode style in high contrast theme */
[data-theme="high-contrast"] #mousecoord {
  background: rgba(255, 255, 255, 0.8);
  color: #1a202c;
}

/* Hide mousecoord on touch devices */
@media (hover: none) {
  #mousecoord {
    display: none;
  }
}

/* Hide mousecoord on small screens */
@media (max-width: 768px) {
  #mousecoord {
    display: none;
  }
}

footer {
  position: absolute;
  bottom: 0;
  left: 0;
  max-width: none;
  font-size: 9px;
  background: rgba(255, 255, 255, 0.7);
  padding: 2px 4px;
  z-index: 1000;
}

footer ul {
  list-style: none;
  padding: 0;
  margin: 0;
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
}

footer li {
  margin: 0;
}

footer li:not(:last-child)::after {
  content: "|";
  margin-left: 4px;
  opacity: 0.5;
}

footer a {
  color: inherit;
  text-decoration: none;
}

footer a:hover {
  text-decoration: underline;
}

/* 移动端适配 */
@media (max-width: 768px) {
  #coordinate-inputs {
    left: -100%;
    width: 85%;
    max-width: 300px;
    border-radius: 0;
    font-size: 14px;
    padding: 12px;
    transition: left 0.3s ease;
  }

  #coordinate-inputs.expanded {
    left: 0;
  }

  .toggle-panel-button {
    width: 24px;
    height: 48px;
    right: -24px;
    transition: transform 0.3s ease;
  }

  #coordinate-inputs.expanded .toggle-panel-button {
    transform: rotate(180deg);
  }

  .panel-section {
    margin-top: 12px;
    padding-top: 12px;
  }

  .panel-section-title {
    font-size: 13px;
    margin-bottom: 8px;
  }

  .input-group {
    margin-bottom: 8px;
  }

  .input-group label {
    width: 35px;
    font-size: 13px;
  }

  .input-group input {
    width: calc(100% - 45px);
    padding: 6px 8px;
    font-size: 13px;
  }

  .input-help {
    font-size: 11px;
    margin-top: 2px;
  }

  button {
    padding: 8px 12px;
    font-size: 13px;
    min-height: 36px;
  }

  .marker-controls {
    gap: 6px;
  }

  .marker-controls button {
    padding: 6px;
    font-size: 12px;
  }

  .toggle-switch {
    width: 14px;
    height: 14px;
  }

  .toggle-label {
    font-size: 12px;
  }

  .theme-controls select {
    padding: 6px 8px;
    font-size: 13px;
  }

  .shortcuts-content {
    padding: 6px;
  }

  .shortcuts-content li {
    font-size: 12px;
    margin-bottom: 4px;
  }

  kbd {
    padding: 2px 4px;
    font-size: 11px;
  }

  .links-section ul {
    grid-template-columns: repeat(auto-fill, minmax(80px, 1fr));
    gap: 6px;
  }

  .links-section a {
    font-size: 12px;
    padding: 4px 6px;
  }
}

/* 针对更小屏幕的优化 */
@media (max-width: 320px) {
  #coordinate-inputs {
    left: -100%;
    width: 90%;
    max-width: 260px;
    padding: 10px;
  }

  .panel-section {
    margin-top: 10px;
    padding-top: 10px;
  }

  .input-group input {
    width: calc(100% - 40px);
  }

  .marker-controls {
    grid-template-columns: 1fr;
  }
}

.input-group {
  margin-bottom: 12px;
}

.input-group label {
  display: inline-block;
  width: 40px;
  color: var(--text-color);
  font-size: 14px;
}

.input-group input {
  width: 120px;
  padding: 6px 10px;
  border: 1px solid var(--input-border);
  border-radius: 4px;
  font-size: 14px;
  transition: border-color 0.2s;
  background: var(--panel-bg);
  color: var(--text-color);
}

.input-group input:focus {
  outline: none;
  border-color: var(--input-focus);
  box-shadow: 0 0 0 3px rgba(66, 153, 225, 0.1);
}

button {
  background-color: var(--button-bg);
  color: white;
  border: none;
  border-radius: 4px;
  padding: 8px 16px;
  font-size: 14px;
  cursor: pointer;
  transition: background-color 0.2s;
}

button:hover {
  background-color: var(--button-hover);
}

#add-marker {
  width: 100%;
  margin-bottom: 12px;
}

.controls-container {
  display: flex;
  align-items: center;
  margin-bottom: 12px;
}

.toggle-switch {
  margin-right: 10px;
  width: 16px;
  height: 16px;
}

.toggle-label {
  font-size: 14px;
  color: var(--text-color);
}

.share-button {
  width: 100%;
  background-color: var(--share-button-bg);
}

.share-button:hover {
  background-color: var(--share-button-hover);
}

.theme-controls {
  margin-top: 12px;
  padding-top: 12px;
  border-top: 1px solid var(--input-border);
}

.theme-controls select {
  width: 100%;
  padding: 6px 10px;
  border: 1px solid var(--input-border);
  border-radius: 4px;
  background: var(--panel-bg);
  color: var(--text-color);
  font-size: 14px;
  margin-top: 8px;
}

.theme-controls label {
  font-size: 14px;
  color: var(--text-color);
}

#loading-overlay {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: var(--loading-bg);
  color: var(--loading-text);
  display: none;
  justify-content: center;
  align-items: center;
  font-size: 1.2rem;
  z-index: 2000;
}

#error-message {
  position: fixed;
  top: 20px;
  left: 50%;
  transform: translateX(-50%);
  background: var(--error-bg);
  color: var(--error-text);
  padding: 12px 24px;
  border-radius: 4px;
  display: none;
  z-index: 2000;
  animation: fadeIn 0.3s ease-in-out;
}

.marker-controls {
  margin-top: 12px;
  display: flex;
  gap: 8px;
}

.marker-controls button {
  flex: 1;
  padding: 6px 12px;
  font-size: 12px;
}

@keyframes fadeIn {
  from {
    opacity: 0;
    transform: translate(-50%, -20px);
  }
  to {
    opacity: 1;
    transform: translate(-50%, 0);
  }
}

/* Skip navigation for accessibility */
.skip-nav {
  position: absolute;
  top: -40px;
  left: 0;
  background: var(--button-bg);
  color: white;
  padding: 8px;
  z-index: 2000;
  transition: top 0.2s;
}

.skip-nav:focus {
  top: 0;
}

/* Focus styles for accessibility */
:focus-visible {
  outline: 2px solid var(--input-focus);
  outline-offset: 2px;
}

.controls-container input[type="checkbox"]:focus-visible + label {
  outline: 2px solid var(--input-focus);
  outline-offset: 2px;
}

/* 调整缩放控件样式以匹配面板 */
.leaflet-control-zoom {
  margin-top: 20px !important;
  margin-right: 20px !important;
  border: none !important;
  box-shadow: var(--panel-shadow) !important;
}

.leaflet-control-zoom a {
  background-color: var(--panel-bg) !important;
  color: var(--text-color) !important;
  border: 1px solid var(--input-border) !important;
}

.leaflet-control-zoom a:hover {
  background-color: var(--button-hover) !important;
  color: white !important;
}

.leaflet-control-zoom-in {
  border-top-left-radius: 0 !important;
  border-bottom: none !important;
}

.leaflet-control-zoom-out {
  border-bottom-left-radius: 0 !important;
}

.input-help {
  display: block;
  font-size: 12px;
  color: var(--text-color);
  opacity: 0.8;
  margin-top: 4px;
}

.keyboard-shortcuts {
  margin-top: 12px;
  border-top: 1px solid var(--input-border);
  padding-top: 12px;
}

.help-button {
  width: 100%;
  background-color: transparent;
  border: 1px solid var(--input-border);
  color: var(--text-color);
}

.help-button:hover {
  background-color: var(--button-hover);
  color: var(--bg-color);
}

.shortcuts-content {
  margin-top: 8px;
  padding: 8px;
  border: 1px solid var(--input-border);
  border-radius: 4px;
  background-color: var(--panel-bg);
}

.shortcuts-content ul {
  list-style: none;
  padding: 0;
  margin: 0;
}

.shortcuts-content li {
  margin-bottom: 6px;
  font-size: 13px;
}

kbd {
  display: inline-block;
  padding: 2px 4px;
  font-size: 12px;
  font-family: monospace;
  line-height: 1;
  color: var(--text-color);
  background-color: var(--bg-color);
  border: 1px solid var(--input-border);
  border-radius: 3px;
  box-shadow: 0 1px 1px var(--panel-shadow);
  margin: 0 2px;
}

/* 移动端优化 */
@media (max-width: 768px) {
  #coordinate-inputs {
    max-width: calc(100% - 40px);
    margin: 20px;
  }

  .input-group input {
    width: calc(100% - 60px);
  }

  #mousecoord {
    right: 20px;
    left: 20px;
    text-align: center;
  }

  footer {
    max-width: calc(100% - 40px);
  }

  .shortcuts-content li {
    margin-bottom: 8px;
  }

  kbd {
    padding: 4px 6px;
    font-size: 14px;
  }
}

/* 触摸设备优化 */
@media (hover: none) {
  button {
    padding: 12px 20px;
  }

  .input-group input {
    padding: 8px 12px;
  }

  select {
    padding: 8px 12px;
  }
}

/* 高对比度模式下的按钮文字颜色 */
[data-theme="high-contrast"] button {
  color: black;
  border: 2px solid white;
}

[data-theme="high-contrast"] button:hover {
  color: black;
}

[data-theme="high-contrast"] .help-button {
  color: white;
  border: 2px solid white;
  background-color: transparent;
}

[data-theme="high-contrast"] .help-button:hover {
  background-color: yellow;
  color: black;
  border-color: yellow;
}

[data-theme="high-contrast"] select {
  background-color: black;
  color: white;
  border: 2px solid white;
}

[data-theme="high-contrast"] select:focus {
  border-color: yellow;
}

[data-theme="high-contrast"] input {
  background-color: black;
  color: white;
  border: 2px solid white;
}

[data-theme="high-contrast"] input:focus {
  border-color: yellow;
}

[data-theme="high-contrast"] .toggle-switch {
  accent-color: yellow;
}

/* 动画效果 */
.panel {
  transition: transform 0.2s ease-in-out;
}

.panel:hover {
  transform: translateY(-2px);
}

button {
  transition: all 0.2s ease-in-out;
}

button:active {
  transform: scale(0.98);
}

/* 错误提示容器样式 */
.error-container {
  position: fixed;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  max-width: 400px;
  width: 90%;
  padding: 20px;
  background-color: var(--panel-bg);
  border: 2px solid var(--error-bg);
  z-index: 2000;
}

.error-container h3 {
  color: var(--error-text);
  margin-top: 0;
  margin-bottom: 15px;
}

.error-container ul {
  margin: 10px 0;
  padding-left: 20px;
}

.error-container li {
  margin: 5px 0;
  color: var(--text-color);
}

.error-container button {
  margin-top: 15px;
  width: 100%;
  padding: 10px;
  background-color: var(--button-bg);
  color: white;
  border: none;
  border-radius: 4px;
  cursor: pointer;
}

.error-container button:hover {
  background-color: var(--button-hover);
}

@media (max-width: 768px) {
  .error-container {
    width: calc(100% - 40px);
    margin: 20px;
  }
}

.keyboard-shortcuts {
  margin-top: 12px;
  border-top: 1px solid var(--input-border);
  padding-top: 12px;
}

.links-section {
  margin-top: 12px;
  border-top: 1px solid var(--input-border);
  padding-top: 12px;
}

.links-section ul {
  list-style: none;
  padding: 0;
  margin: 0;
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(120px, 1fr));
  gap: 8px;
}

.links-section li {
  margin: 0;
}

.links-section a {
  display: block;
  color: var(--link-color);
  text-decoration: none;
  font-size: 13px;
  padding: 4px 8px;
  border-radius: 4px;
  background: rgba(0, 0, 0, 0.05);
  transition: all 0.2s ease;
}

[data-theme="dark"] .links-section a {
  background: rgba(255, 255, 255, 0.05);
}

.links-section a:hover {
  text-decoration: none;
  background: rgba(0, 0, 0, 0.1);
  color: var(--link-hover);
}

[data-theme="dark"] .links-section a:hover {
  background: rgba(255, 255, 255, 0.1);
}

.shortcuts-content {
  background: var(--bg-color);
  border: 1px solid var(--input-border);
  border-radius: 4px;
  padding: 8px;
  margin-top: 8px;
}

.shortcuts-content ul {
  list-style: none;
  padding: 0;
  margin: 0;
}

.shortcuts-content li {
  margin-bottom: 6px;
  font-size: 13px;
}

.shortcuts-content li:last-child {
  margin-bottom: 0;
}

footer {
  display: none;
}

/* 分享图片相关样式 */
#share-image-button {
  background-color: var(--share-button-bg);
}

#share-image-button:hover {
  background-color: var(--share-button-hover);
}

.watermark {
  position: absolute;
  bottom: 10px;
  right: 10px;
  font-size: 12px;
  color: var(--text-color);
  background-color: rgba(255, 255, 255, 0.8);
  padding: 4px 8px;
  border-radius: 4px;
  z-index: 1000;
}

.visually-hidden {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

main {
  height: 100%;
  width: 100%;
  position: relative;
}

footer {
  position: absolute;
  bottom: 0;
  left: 0;
  width: 100%;
  background: var(--panel-bg);
  padding: 8px;
  font-size: 12px;
  text-align: center;
  z-index: 1000;
}

footer p {
  margin: 0;
  color: var(--text-color);
}

footer a {
  color: var(--link-color);
  text-decoration: none;
}

footer a:hover {
  color: var(--link-hover);
  text-decoration: underline;
}

.panel-section h2 {
  font-size: 14px;
  font-weight: 600;
  margin: 0 0 12px 0;
  color: var(--text-color);
}

/* Dark mode adjustments */
[data-theme="dark"] footer {
  background: rgba(45, 55, 72, 0.9);
}

/* High contrast mode adjustments */
[data-theme="high-contrast"] footer {
  background: black;
  border-top: 1px solid white;
}

[data-theme="high-contrast"] footer a {
  color: yellow;
}

/* Mobile optimizations */
@media (max-width: 768px) {
  footer {
    font-size: 10px;
    padding: 6px;
  }

  .panel-section h2 {
    font-size: 13px;
    margin-bottom: 8px;
  }
}

.marker-time {
  margin-top: 8px;
  padding: 8px;
  background: rgba(0, 0, 0, 0.05);
  border-radius: 4px;
  font-size: 13px;
}

.time-entry {
  margin-bottom: 4px;
  padding: 4px;
  border-bottom: 1px solid rgba(0, 0, 0, 0.1);
}

.time-entry:last-child {
  margin-bottom: 0;
  border-bottom: none;
}

.timezone-name {
  font-weight: 500;
  margin-bottom: 2px;
  color: var(--text-color);
}

.time-value {
  color: var(--text-color);
  opacity: 0.9;
}

.time-entry-hover {
  margin: 2px 0;
}
.timezone-name-hover {
  font-weight: 500;
  margin-right: 4px;
}

[data-theme="dark"] .time-entry {
  border-bottom-color: rgba(255, 255, 255, 0.1);
}

[data-theme="high-contrast"] .time-entry {
  border-bottom-color: white;
}

[data-theme="dark"] .marker-time {
  background: rgba(255, 255, 255, 0.05);
}

[data-theme="high-contrast"] .marker-time {
  background: black;
  color: white;
  border: 1px solid white;
}

.marker-popup {
  font-family: "IBM Plex Mono", monospace;
  font-size: 13px;
  background: var(--panel-bg);
  color: var(--text-color);
}

.leaflet-popup-content-wrapper {
  background: var(--panel-bg);
  color: var(--text-color);
}

.leaflet-popup-tip {
  background: var(--panel-bg);
}

.coordinate-info {
  padding: 4px 0;
  color: var(--text-color);
}

.marker-time {
  margin-top: 8px;
  padding: 8px;
  background: var(--panel-bg);
  border-radius: 4px;
  font-size: 13px;
  font-family: "IBM Plex Mono", monospace;
  color: var(--text-color);
  border: 1px solid var(--input-border);
}

.time-entry {
  margin-bottom: 4px;
  padding: 4px;
  border-bottom: 1px solid var(--input-border);
}

.time-entry:last-child {
  border-bottom: none;
}

[data-theme="dark"] .leaflet-popup-content-wrapper,
[data-theme="dark"] .leaflet-popup-tip {
  background: var(--panel-bg);
  color: var(--text-color);
}

[data-theme="high-contrast"] .leaflet-popup-content-wrapper,
[data-theme="high-contrast"] .leaflet-popup-tip {
  background: black;
  color: white;
  border: 1px solid white;
}

[data-theme="high-contrast"] .marker-time {
  background: black;
  color: white;
  border: 1px solid white;
}

[data-theme="high-contrast"] .time-entry {
  border-bottom-color: white;
}

.time-entry-hover {
  margin: 2px 0;
  color: var(--text-color);
}

.timezone-name-hover {
  font-weight: 500;
  margin-right: 4px;
  color: var(--text-color);
}

.time-value-hover {
  color: var(--text-color);
}

/* 经纬度网格标签样式 */
.graticule-label {
  font-size: 10px;
  color: var(--text-color);
  text-shadow:
    -1px -1px 0 var(--bg-color),
    1px -1px 0 var(--bg-color),
    -1px 1px 0 var(--bg-color),
    1px 1px 0 var(--bg-color);
  white-space: nowrap;
  opacity: 0.8;
}

[data-theme="dark"] .graticule-label {
  text-shadow:
    -1px -1px 0 rgba(0, 0, 0, 0.8),
    1px -1px 0 rgba(0, 0, 0, 0.8),
    -1px 1px 0 rgba(0, 0, 0, 0.8),
    1px 1px 0 rgba(0, 0, 0, 0.8);
}

[data-theme="high-contrast"] .graticule-label {
  color: white;
  text-shadow:
    -1px -1px 0 black,
    1px -1px 0 black,
    -1px 1px 0 black,
    1px 1px 0 black;
  opacity: 1;
}

#mousecoord {
  background: var(--panel-bg);
  color: var(--text-color);
  border: 1px solid var(--input-border);
}

[data-theme="dark"] #mousecoord {
  background: var(--panel-bg);
  color: var(--text-color);
}

[data-theme="high-contrast"] #mousecoord {
  background: black;
  color: white;
  border: 1px solid white;
}

/* 添加太阳照射范围相关样式 */
.sun-illumination {
  stroke: #ffd700; /* 金色边界线 */
  stroke-width: 3;
  stroke-dasharray: none;
  fill: rgba(0, 0, 0, 0.35); /* 夜晚区域的阴影加深 */
  transition: all 0.3s ease;
  pointer-events: none;
}

[data-theme="dark"] .sun-illumination {
  stroke: #ffd700;
  stroke-width: 3;
  stroke-dasharray: none;
  fill: rgba(0, 0, 0, 0.5); /* 暗色主题下更深的阴影 */
  transition: all 0.3s ease;
}

[data-theme="high-contrast"] .sun-illumination {
  stroke: #ffd700;
  stroke-width: 4;
  stroke-dasharray: none;
  fill: rgba(0, 0, 0, 0.7); /* 高对比度模式下最深的阴影 */
  transition: all 0.3s ease;
}

/* 保持地图底图的过渡效果 */
.leaflet-tile-container {
  transition: all 0.3s ease;
}

/* 夜晚区域的地图变暗效果增强 */
.sun-illumination ~ .leaflet-tile-container {
  filter: brightness(0.85);
}

[data-theme="dark"] .sun-illumination ~ .leaflet-tile-container {
  filter: brightness(0.75);
}

[data-theme="high-contrast"] .sun-illumination ~ .leaflet-tile-container {
  filter: brightness(0.65);
}

/* City Search Styles */
.city-search-results {
  max-height: 200px;
  overflow-y: auto;
  margin-top: 8px;
  border: 1px solid var(--input-border);
  border-radius: 4px;
  background: var(--panel-bg);
  display: none;
}

.city-search-results.active {
  display: block;
}

.city-result {
  padding: 8px 12px;
  cursor: pointer;
  border-bottom: 1px solid var(--input-border);
  transition: background-color 0.2s;
}

.city-result:last-child {
  border-bottom: none;
}

.city-result:hover {
  background-color: var(--button-bg);
  color: white;
}

.city-name {
  font-weight: 500;
  margin-bottom: 2px;
}

.city-info {
  font-size: 12px;
  opacity: 0.8;
}

[data-theme="dark"] .city-result:hover {
  background-color: var(--button-hover);
}

[data-theme="high-contrast"] .city-result:hover {
  background-color: yellow;
  color: black;
}

#city-search {
  width: 100%;
  padding: 8px 12px;
  border: 1px solid var(--input-border);
  border-radius: 4px;
  font-size: 14px;
  background: var(--panel-bg);
  color: var(--text-color);
}

#city-search:focus {
  outline: none;
  border-color: var(--input-focus);
  box-shadow: 0 0 0 3px rgba(66, 153, 225, 0.1);
}

/* Scrollbar styles for city search results */
.city-search-results::-webkit-scrollbar {
  width: 8px;
}

.city-search-results::-webkit-scrollbar-track {
  background: var(--panel-bg);
}

.city-search-results::-webkit-scrollbar-thumb {
  background: var(--input-border);
  border-radius: 4px;
}

.city-search-results::-webkit-scrollbar-thumb:hover {
  background: var(--button-bg);
}

/* Loading indicator for city search */
.city-search-loading {
  padding: 8px 12px;
  text-align: center;
  color: var(--text-color);
  font-style: italic;
}
