/* ==========================================================================
   Strava Route Exporter - Modern Sport Stylesheet
   ========================================================================== */

:root {
  --primary: #FC5200; /* Strava signature orange */
  --primary-hover: #E34800;
  --primary-light: #FFF1EB;
  --primary-glow: rgba(252, 82, 0, 0.25);
  
  --bg-color: #F7F8FA;
  --card-bg: #FFFFFF;
  --text-main: #242428;
  --text-muted: #65676B;
  --text-sub: #8C8E94;
  --border-color: #E2E4E8;
  --border-hover: #D0D3D9;
  
  --success: #10B981;
  --success-bg: #ECFDF5;
  --info: #3B82F6;
  --info-bg: #EFF6FF;
  --warning: #F59E0B;
  --warning-bg: #FFFBEB;
  --danger: #EF4444;
  
  --radius-sm: 8px;
  --radius-md: 12px;
  --radius-lg: 16px;
  --shadow-sm: 0 1px 3px rgba(0,0,0,0.06), 0 1px 2px rgba(0,0,0,0.04);
  --shadow-md: 0 4px 6px -1px rgba(0,0,0,0.07), 0 2px 4px -1px rgba(0,0,0,0.04);
  --shadow-lg: 0 10px 15px -3px rgba(0,0,0,0.08), 0 4px 6px -2px rgba(0,0,0,0.04);
  --font-sans: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --font-mono: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
}

* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

body {
  font-family: var(--font-sans);
  background-color: var(--bg-color);
  color: var(--text-main);
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
  min-height: 100vh;
}

.app-container {
  max-width: 900px;
  margin: 0 auto;
  padding: 24px 16px 64px 16px;
}

/* ==========================================================================
   Header
   ========================================================================== */
.header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 24px;
  padding-bottom: 20px;
  border-bottom: 1px solid var(--border-color);
  flex-wrap: wrap;
  gap: 16px;
}

.logo-wrapper {
  display: flex;
  align-items: center;
  gap: 16px;
}

/* ==========================================================================
   Brand Logo (Option B - Garmin / Strava Minimalist Athletic Style)
   ========================================================================== */
.brand-logo {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  text-decoration: none;
  user-select: none;
  flex-shrink: 0;
  transition: transform 0.15s ease;
}

.brand-icon {
  width: 40px;
  height: 40px;
  border-radius: 11px;
  background: linear-gradient(135deg, #FC5200 0%, #E11D48 100%);
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 4px 12px rgba(252, 82, 0, 0.28);
  flex-shrink: 0;
  transition: transform 0.2s ease, box-shadow 0.2s ease;
}

.brand-logo:hover .brand-icon {
  transform: translateY(-1px) scale(1.04);
  box-shadow: 0 6px 16px rgba(252, 82, 0, 0.38);
}

.brand-name {
  display: flex;
  align-items: baseline;
  letter-spacing: -0.6px;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  font-weight: 900;
  font-size: 23px;
  line-height: 1;
}

.brand-route {
  color: var(--text-main);
}

.brand-hub {
  color: #FC5200;
  margin-left: 1px;
}

.header-divider {
  width: 1px;
  height: 28px;
  background-color: var(--border-color);
  margin: 0 2px;
  flex-shrink: 0;
}

.logo-text h1 {
  font-size: 19px;
  font-weight: 800;
  color: var(--text-main);
  letter-spacing: -0.3px;
  line-height: 1.25;
}

.subtitle {
  font-size: 13px;
  color: var(--text-muted);
  margin-top: 3px;
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 6px;
}

.platform-pill {
  display: inline-flex;
  align-items: center;
  font-weight: 600;
  font-size: 12px;
  color: var(--text-secondary);
}

.platform-dot {
  display: inline-block;
  width: 7px;
  height: 7px;
  border-radius: 50%;
  margin-right: 5px;
}

.dot-strava {
  background-color: #FC5200;
  box-shadow: 0 0 5px rgba(252, 82, 0, 0.6);
}

.dot-igp {
  background-color: #E11D48;
  box-shadow: 0 0 5px rgba(225, 29, 72, 0.6);
}

.dot-xingzhe {
  background-color: #0284C7;
  box-shadow: 0 0 5px rgba(2, 132, 199, 0.6);
}

.dot-sep {
  color: #D1D5DB;
  font-size: 12px;
}

/* ==========================================================================
   Relay Status Pill (Header 右上角免登录状态徽章)
   ========================================================================== */
.status-pill {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 5px 12px;
  border-radius: 9999px;
  font-size: 12px;
  font-weight: 600;
  cursor: default;
  border: 1px solid var(--border-color);
  background: white;
  user-select: none;
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.05);
}

.status-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  display: inline-block;
  flex-shrink: 0;
  transition: all 0.3s ease;
}

/* 状态：检测中 */
.status-pill.status-checking {
  background: #F3F4F6;
  border-color: #E5E7EB;
  color: #6B7280;
}
.status-pill.status-checking .status-dot {
  background: #9CA3AF;
  animation: pulse-dot 1.5s infinite;
}

/* 状态：支持免登录 (绿色) */
.status-pill.status-online {
  background: #ECFDF5;
  border-color: #A7F3D0;
  color: #047857;
}
.status-pill.status-online .status-dot {
  background: #10B981;
  box-shadow: 0 0 0 0 rgba(16, 185, 129, 0.6);
  animation: green-pulse 2s infinite;
}

/* 状态：中转失效 (红色) */
.status-pill.status-offline {
  background: #FEF2F2;
  border-color: #FECACA;
  color: #B91C1C;
}
.status-pill.status-offline .status-dot {
  background: #EF4444;
  box-shadow: 0 0 0 0 rgba(239, 68, 68, 0.6);
  animation: red-pulse 2s infinite;
}

@keyframes green-pulse {
  0% {
    box-shadow: 0 0 0 0 rgba(16, 185, 129, 0.7);
  }
  70% {
    box-shadow: 0 0 0 6px rgba(16, 185, 129, 0);
  }
  100% {
    box-shadow: 0 0 0 0 rgba(16, 185, 129, 0);
  }
}

@keyframes red-pulse {
  0% {
    box-shadow: 0 0 0 0 rgba(239, 68, 68, 0.7);
  }
  70% {
    box-shadow: 0 0 0 6px rgba(239, 68, 68, 0);
  }
  100% {
    box-shadow: 0 0 0 0 rgba(239, 68, 68, 0);
  }
}

@keyframes pulse-dot {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.3; }
}

/* ==========================================================================
   Alerts
   ========================================================================== */
.alert-box {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 14px 18px;
  border-radius: var(--radius-md);
  margin-bottom: 24px;
  font-size: 14px;
}

.alert-info {
  background-color: #FC52000D;
  border: 1px solid #FC520033;
  color: #923400;
}

.alert-icon {
  font-size: 20px;
  flex-shrink: 0;
}

.alert-content {
  flex-grow: 1;
}

.alert-content a {
  color: var(--primary);
  font-weight: 600;
  text-decoration: underline;
}

/* ==========================================================================
   Cards
   ========================================================================== */
.card {
  background: var(--card-bg);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-sm);
  border: 1px solid var(--border-color);
  margin-bottom: 24px;
  overflow: hidden;
  transition: box-shadow 0.2s ease, border-color 0.2s ease;
}

.card:hover {
  box-shadow: var(--shadow-md);
  border-color: var(--border-hover);
}

.card-header {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 18px 24px;
  border-bottom: 1px solid var(--border-color);
  background-color: #FAFAFB;
}

.card-header h2 {
  font-size: 17px;
  font-weight: 700;
  color: var(--text-main);
  flex-grow: 1;
}

.step-num {
  width: 26px;
  height: 26px;
  border-radius: 50%;
  background: var(--primary);
  color: white;
  font-size: 14px;
  font-weight: 700;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.step-sm {
  width: 20px;
  height: 20px;
  font-size: 12px;
}

.card-body {
  padding: 24px;
}

/* ==========================================================================
   Input Section
   ========================================================================== */
.input-group {
  display: flex;
  gap: 12px;
  margin-bottom: 14px;
}

.url-input {
  flex: 1;
  min-width: 0; /* 关键：防止 Flex 子项溢出容器 */
  padding: 14px 18px;
  font-size: 15px;
  border: 2px solid var(--border-color);
  border-radius: var(--radius-md);
  background: #FFF;
  color: var(--text-main);
  transition: all 0.2s ease;
}

.url-input:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 3px var(--primary-glow);
}

#parseBtn {
  flex-shrink: 0;
  white-space: nowrap;
}

.input-actions {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
}

/* ==========================================================================
   Buttons
   ========================================================================== */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 12px 20px;
  font-size: 14px;
  font-weight: 600;
  border-radius: var(--radius-md);
  border: none;
  cursor: pointer;
  transition: all 0.15s ease-in-out;
  text-decoration: none;
  white-space: nowrap;
}

.btn:disabled {
  opacity: 0.72;
  cursor: wait;
  pointer-events: none;
  transform: none !important;
}

.btn-primary {
  background-color: var(--primary);
  color: white;
  box-shadow: 0 2px 4px var(--primary-glow);
}

.btn-primary:hover {
  background-color: var(--primary-hover);
  transform: translateY(-1px);
}

.btn-primary:active {
  transform: translateY(0);
}

.btn-secondary {
  background-color: #F0F2F5;
  color: var(--text-main);
}

.btn-secondary:hover {
  background-color: #E4E6EB;
}

.btn-ghost {
  background: transparent;
  color: var(--text-muted);
}

.btn-ghost:hover {
  color: var(--danger);
  background-color: #FEE2E2;
}

.btn-sm {
  padding: 7px 14px;
  font-size: 13px;
  border-radius: var(--radius-sm);
}

.btn-outline-white {
  background: white;
  color: var(--primary);
  border: 1px solid var(--primary);
}

.btn-outline-white:hover {
  background: var(--primary-light);
}

/* ==========================================================================
   Result Card & Grid
   ========================================================================== */
.status-badge {
  font-size: 12px;
  padding: 3px 8px;
  border-radius: 12px;
  font-weight: 600;
}

.status-badge.success {
  background: var(--success-bg);
  color: var(--success);
}

.route-display-grid {
  display: grid;
  grid-template-columns: 320px 1fr;
  gap: 24px;
}

@media (max-width: 768px) {
  .route-display-grid {
    grid-template-columns: 1fr;
  }
}

.route-map-wrapper {
  position: relative;
  border-radius: var(--radius-md);
  overflow: hidden;
  border: 1px solid var(--border-color);
  background: #EBF0F5;
  aspect-ratio: 1 / 1; /* 1:1 正方形比例，与 Strava 官方静态地图原始比例 100% 完美贴合 */
  display: flex;
  align-items: center;
  justify-content: center;
}

.route-map-img {
  width: 100%;
  height: 100%;
  object-fit: cover; /* 1:1 地图天然 100% 撑满正方形卡片，路线完整不裁切，无任何黑边/空隙 */
  display: block;
  cursor: zoom-in;
  transition: transform 0.25s ease;
}

.route-map-img:hover {
  transform: scale(1.02);
}

.route-map-overlay {
  position: absolute;
  bottom: 8px;
  left: 8px;
  z-index: 3;
}

.route-map-tag {
  background: rgba(0, 0, 0, 0.65);
  color: #FFF;
  font-size: 11px;
  padding: 2px 8px;
  border-radius: 4px;
}

.route-info-wrapper {
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.route-title {
  font-size: 20px;
  font-weight: 700;
  color: var(--text-main);
  line-height: 1.35;
}

.route-meta-list {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(130px, 1fr));
  gap: 12px;
  padding: 12px;
  background: #F9FAFB;
  border-radius: var(--radius-md);
  border: 1px solid var(--border-color);
}

.meta-item {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.meta-label {
  font-size: 12px;
  color: var(--text-sub);
}

.meta-value {
  font-size: 14px;
  font-weight: 600;
  color: var(--text-main);
  word-break: break-all;
}

.meta-link {
  font-size: 13px;
  color: var(--primary);
  font-weight: 600;
  text-decoration: none;
}

.meta-link:hover {
  text-decoration: underline;
}

.font-mono {
  font-family: var(--font-mono);
}

/* ==========================================================================
   Format Selection
   ========================================================================== */
.format-selection {
  margin-top: 8px;
}

.format-header {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 12px;
  font-size: 14px;
}

.format-cards {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
}

@media (max-width: 500px) {
  .format-cards {
    grid-template-columns: 1fr;
  }
}

.format-card {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  padding: 14px;
  border: 2px solid var(--border-color);
  border-radius: var(--radius-md);
  cursor: pointer;
  background: #FFF;
  transition: all 0.2s ease;
}

.format-card:hover {
  border-color: var(--border-hover);
  background-color: #FAFAFA;
}

.format-card input[type="radio"] {
  margin-top: 3px;
  accent-color: var(--primary);
  cursor: pointer;
}

.format-card.active {
  border-color: var(--primary);
  background-color: var(--primary-light);
}

.format-badge {
  font-size: 14px;
  font-weight: 700;
  color: var(--text-main);
  margin-bottom: 4px;
}

.format-desc {
  font-size: 12px;
  color: var(--text-muted);
  line-height: 1.4;
}

/* ==========================================================================
   Export Actions
   ========================================================================== */
.export-actions {
  margin-top: 12px;
}

.btn-export {
  width: 100%;
  background: linear-gradient(135deg, #FC5200 0%, #FF6B26 100%);
  color: white;
  font-size: 16px;
  padding: 15px;
  border-radius: var(--radius-md);
  box-shadow: 0 4px 12px var(--primary-glow);
}

.btn-export:hover {
  background: linear-gradient(135deg, #E34800 0%, #F55811 100%);
  box-shadow: 0 6px 16px var(--primary-glow);
  transform: translateY(-1px);
}

.btn-export:active {
  transform: translateY(0);
}

.export-icon {
  font-size: 18px;
}

.export-note {
  margin-top: 8px;
  font-size: 12px;
  color: var(--text-sub);
  text-align: center;
}


/* ==========================================================================
   Footer
   ========================================================================== */
.footer {
  text-align: center;
  margin-top: 40px;
  font-size: 13px;
  color: var(--text-sub);
}

.footer-links {
  margin-top: 6px;
}

.footer-links a {
  color: var(--primary);
  text-decoration: none;
}

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

/* ==========================================================================
   Toast Notification
   ========================================================================== */
.toast {
  position: fixed;
  bottom: 24px;
  right: 24px;
  padding: 12px 20px;
  background: #1F2937;
  color: #FFF;
  border-radius: var(--radius-md);
  font-size: 14px;
  box-shadow: var(--shadow-lg);
  z-index: 1000;
  transition: opacity 0.3s ease, transform 0.3s ease;
}

/* ==========================================================================
   Alert Variations
   ========================================================================== */
.alert-success {
  background-color: #ECFDF5;
  color: #065F46;
  border: 1px solid #A7F3D0;
}
.alert-success strong {
  color: #047857;
}
.alert-success a {
  color: #047857;
  font-weight: 600;
  text-decoration: underline;
}

.alert-warning {
  background-color: #FFFBEB;
  color: #92400E;
  border: 1px solid #FDE68A;
}
.alert-warning strong {
  color: #78350F;
}
.alert-warning a {
  color: #B45309;
  font-weight: 600;
  text-decoration: underline;
}

.hidden {
  display: none !important;
}

/* ==========================================================================
   Mobile Responsive Optimizations (<= 640px)
   ========================================================================== */
@media (max-width: 640px) {
  .app-container {
    padding: 16px 12px 48px 12px;
  }

  .header {
    flex-direction: column;
    align-items: flex-start;
    gap: 14px;
  }

  .header-divider {
    display: none;
  }

  .logo-wrapper {
    flex-direction: column;
    align-items: flex-start;
    gap: 8px;
  }

  .brand-icon {
    width: 36px;
    height: 36px;
    border-radius: 9px;
  }

  .brand-icon svg {
    width: 19px;
    height: 19px;
  }

  .brand-name {
    font-size: 21px;
  }

  .logo-text h1 {
    font-size: 16px;
  }

  .subtitle {
    font-size: 12px;
  }

  .alert-box {
    flex-direction: column;
    align-items: stretch;
    gap: 12px;
    padding: 14px 16px;
  }

  .alert-box .btn {
    width: 100%;
    text-align: center;
  }

  .card-header {
    padding: 14px 16px;
  }

  .card-body {
    padding: 16px;
  }

  /* 彻底解决手机端输入框与“解析路线”按钮挤压显示不全问题 */
  .input-group {
    flex-direction: column;
    gap: 10px;
  }

  .url-input {
    width: 100%;
    padding: 12px 14px;
    font-size: 14px;
  }

  #parseBtn {
    width: 100%;
    padding: 13px 16px;
    font-size: 15px;
    justify-content: center;
  }

  .input-actions {
    flex-direction: column;
    gap: 8px;
  }

  .input-actions .btn {
    width: 100%;
    justify-content: center;
    padding: 9px 12px;
    font-size: 13px;
  }

  .format-cards {
    grid-template-columns: 1fr;
  }

  .route-title {
    font-size: 18px;
  }

  .btn-export {
    font-size: 15px;
    padding: 14px;
  }
}
