:root {
  --strava-orange: #fc4c02;
  --primary-color: #007bff;
  --secondary-color: #6c757d;
  --success-color: #28a745;
  --danger-color: #dc3545;
  --light-gray: #f8f9fa;
  --dark-gray: #343a40;
  --text-color: #212529;
  --card-bg: #ffffff;
  --card-border-color: #e9ecef;
  --shadow: 0 4px 6px rgba(0, 0, 0, 0.1);
  --border-radius: 8px;
}

body {
  font-family: 'Roboto', sans-serif;
  margin: 0;
  background-color: var(--light-gray);
  color: var(--text-color);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

.app-header {
  background-color: var(--strava-orange);
  color: white;
  padding: 1rem;
  display: flex;
  justify-content: space-between;
  align-items: center;
  box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
}

.app-header h1 {
  margin: 0;
  font-size: 1.75rem;
}

.app-header #logoutBtn {
  background-color: var(--secondary-color);
  color: white;
  border: none;
  padding: 0.5rem 1rem;
  border-radius: var(--border-radius);
  cursor: pointer;
  font-size: 0.9rem;
  font-weight: bold;
  transition:
    background-color 0.2s ease-in-out,
    transform 0.1s ease-in-out;
}

h2 {
  color: var(--dark-gray);
  margin-top: 0;
  border-bottom: 1px solid var(--card-border-color);
  padding-bottom: 0.5rem;
  margin-bottom: 1rem;
}

.container {
  max-width: 900px;
  margin: 2rem auto;
  padding: 0 1rem;
}

.card {
  background-color: var(--card-bg);
  padding: 1.5rem;
  border-radius: var(--border-radius);
  box-shadow: var(--shadow);
  margin-bottom: 2rem;
}

.auth-container {
  text-align: center;
}

.controls {
  display: flex;
  flex-wrap: wrap;
  gap: 1.5rem;
  align-items: center;
}

.control-group {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  flex-grow: 1;
}

.controls label {
  font-weight: bold;
  font-size: 0.9rem;
}

.controls input[type='text'],
.controls select {
  padding: 0.75rem;
  border: 1px solid #ccc;
  border-radius: var(--border-radius);
  font-size: 1rem;
  width: 100%;
  box-sizing: border-box;
}

.btn {
  background-color: var(--secondary-color);
  color: white;
  border: none;
  padding: 0.75rem 1.5rem;
  border-radius: var(--border-radius);
  cursor: pointer;
  font-size: 1rem;
  font-weight: bold;
  transition:
    background-color 0.2s ease-in-out,
    transform 0.1s ease-in-out;
}

.btn:hover {
  /* No transform */
}

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

.btn-primary {
  background-color: var(--strava-orange);
}

.btn-primary:hover {
  background-color: #e64400;
}

.btn-success {
  background-color: var(--success-color);
}

.btn-success:hover {
  background-color: #218838;
}

#map {
  height: 450px;
  width: 100%;
  border-radius: var(--border-radius);
}

#loading-overlay {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background-color: rgba(255, 255, 255, 0.8);
  display: flex;
  justify-content: center;
  align-items: center;
  z-index: 1000;
}

.spinner {
  border: 8px solid #f3f3f3;
  border-top: 8px solid var(--strava-orange);
  border-radius: 50%;
  width: 60px;
  height: 60px;
  animation: spin 1.5s linear infinite;
}

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

.hidden {
  display: none !important;
}

#error-container {
  color: var(--danger-color);
  background-color: #f8d7da;
  border: 1px solid #f5c6cb;
  padding: 1rem;
  border-radius: var(--border-radius);
  margin-bottom: 1.5rem;
}

#gradient-chart,
#default-segment-chart {
  width: 100%;
  overflow-x: auto;
  padding: 1rem 0;
}

/* Responsive Design */
@media (max-width: 768px) {
  .controls {
    flex-direction: column;
    align-items: stretch;
  }

  .btn {
    width: 100%;
  }

  #logoutBtn {
    width: auto; /* ログアウトボタンは横幅を自動に保つ */
  }

  .chart-controls {
    flex-direction: column;
    align-items: flex-start;
    gap: 1rem;
    width: 100%;
  }

  .chart-controls-left {
    flex-direction: column;
    align-items: flex-start;
    width: 100%;
    gap: 1rem;
  }

  .chart-controls .control-group {
    flex-direction: column;
    align-items: flex-start;
    width: 100%;
  }

  .chart-controls .control-group select {
    width: 100%;
  }

  .chart-controls .btn {
    padding: 0.5rem 1rem;
    font-size: 0.9rem;
  }

  .chart-controls .mode-buttons {
    width: 100%;
    display: grid;
    grid-template-columns: 1fr 1fr;
  }

  .chart-controls .mode-buttons .btn {
    width: 100%;
  }

  #downloadSvgBtn {
    width: 100%;
  }
}

.chart-controls {
  display: flex;
  flex-wrap: wrap; /* Allow items to wrap on smaller screens */
  gap: 10px;
  margin-bottom: 1rem;
  justify-content: space-between;
  align-items: center;
}

.chart-controls .mode-buttons {
  display: flex;
  gap: 5px;
}

.chart-controls-left {
  display: flex;
  align-items: center;
  gap: 15px; /* Adjust gap as needed */
}

.chart-controls .control-group {
  margin-bottom: 0; /* Remove bottom margin for control group within chart controls */
  flex-direction: row; /* Display label and select in a row */
  align-items: center; /* Vertically align items */
  gap: 5px; /* Space between label and select */
}

.chart-controls .control-group label {
  white-space: nowrap; /* Prevent label from wrapping */
}

.chart-controls .control-group select {
  width: auto; /* Allow select to take natural width */
  min-width: 80px; /* Ensure a minimum width */
}

.chart-controls .btn {
  color: white;
  border: none;
  padding: 0.5rem 1rem;
  border-radius: var(--border-radius);
  cursor: pointer;
  font-size: 0.9rem;
  transition: background-color 0.2s ease-in-out;
  width: auto; /* 追加 */
}

.chart-controls .btn-secondary {
  background-color: var(--secondary-color);
}

.chart-controls .btn.active {
  background-color: var(--strava-orange);
}

.chart-controls .btn:hover:not(.active) {
  background-color: #5a6268;
}

#chart-2d,
#chart-3d {
  display: none !important;
  width: 100%;
  overflow-x: auto;
  padding: 1rem 0;
  min-height: 300px; /* Ensure some height even if no content */
}

.view-container {
  display: grid;
  grid-template-columns: 1fr;
  gap: 2rem;
}

@media (max-width: 600px) {
  .app-header h1 {
    font-size: 1.25rem; /* スマートフォン用にフォントサイズを縮小 */
  }

  #loginBtn {
    font-size: 0.9rem; /* ボタンのフォントサイズを縮小 */
    padding: 0.6rem 1rem; /* パディングを調整 */
  }
}

#chartPngPreview {
  max-width: 100%;
  height: auto;
  display: block;
  margin-top: 1rem;
}

/* Tab Styles */
.tab-buttons {
  display: flex;
  margin-bottom: 0; /* No overlap needed, controls card will have the top border */
  margin-left: 15px;
}

.tab-buttons .btn {
  background-color: #e9ecef;
  color: var(--text-color);
  border: 1px solid #ccc;
  border-bottom: none; /* Active tab will have its own bottom border */
  border-radius: var(--border-radius) var(--border-radius) 0 0;
  padding: 0.75rem 1.5rem;
  cursor: pointer;
  font-weight: bold;
  transition: background-color 0.2s ease-in-out;
  margin-right: 5px; /* Space between tabs */
}

.tab-buttons .btn.active {
  background-color: var(--card-bg);
  border-color: #ccc;
  border-bottom-color: var(--card-bg); /* Hide bottom border for active tab */
  z-index: 1;
  position: relative;
}

.tab-buttons .btn:hover:not(.active) {
  background-color: #d3d7db; /* A slightly darker shade for hover */
}

.tab-content {
  /* No specific styles needed here, as the parent .controls card will handle the border */
}

/* Adjust controls layout for tabs */
.controls {
  flex-direction: column;
  align-items: stretch;
  gap: 0;
  border: 1px solid #ccc; /* Add full border to the controls card */
  border-radius: var(--border-radius);
  margin-top: -1px; /* Overlap with the tab buttons */
}

.controls .control-group {
  margin-bottom: 1rem;
}

.controls .control-group:last-of-type {
  margin-bottom: 0;
}

.controls #showRouteBtn {
  margin-top: 1rem;
  width: auto;
}

.input-and-button-group {
  display: flex;
  align-items: flex-end; /* Align items to the bottom */
  gap: 10px; /* Space between input group and button */
}

.input-and-button-group .control-group {
  flex-grow: 1; /* Allow input group to take available space */
  margin-bottom: 0; /* Remove margin from this control group */
}

.input-and-button-group #showRouteBtn {
  margin-top: 0; /* Remove top margin, alignment handled by flex */
  flex-shrink: 0; /* Prevent button from shrinking */
}


#starred-segments-container {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

#starred-segments-select {
  width: 100%;
  padding: 0.75rem;
  border: 1px solid #ccc;
  border-radius: var(--border-radius);
  font-size: 1rem;
}

.text-muted {
  color: #6c757d;
}

.form-text {
  display: block;
  margin-top: 0.25rem;
}

#default-segment-chart svg,
#chart-2d svg,
#chart-3d svg {
  max-width: 100%;
  height: auto;
  display: block;
}
