/* Basic page layout */
body {
  font-family: Arial, sans-serif;
  margin: 0;
  background-color: #f0f0f0;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  align-items: center; /* Center the top UI horizontally */
}

#top-controls {
  margin: 20px;
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  align-items: center;
}

.input-group {
  display: flex;
  align-items: center;
  margin-right: 10px;
  white-space: nowrap;
}
.input-group label {
  margin-right: 5px;
}

#error-message {
  color: red;
  margin-bottom: 10px;
  text-align: center;
}

/*
   #bars-container:
     - Desktop: stack vertically (column).
     - Mobile: side by side (row).
*/
#bars-container {
  display: flex;
  flex-direction: column; /* desktop default */
  align-items: stretch;
  width: 90%;
  max-width: 1600px;
  margin-bottom: 20px;
}
@media (max-width: 900px) {
  #bars-container {
    flex-direction: row; /* mobile: side by side horizontally */
    align-items: flex-start;
    overflow-x: auto;
    width: 100%;
    max-width: none;
    margin: 10px;
    /* Default multiple bars: left-align them */
    justify-content: flex-start;
  }
  /* If there's exactly one bar, center it horizontally in mobile mode */
  #bars-container.single-bar-only {
    justify-content: center;
  }
}

.add-bar-button-container {
  margin: 20px 0;
  display: flex;
  justify-content: center;
}
@media (max-width: 900px) {
  .add-bar-button-container {
    margin-left: 20px;
    margin-right: 5px;
    margin-top: 15px;
    align-self: flex-start;
  }
}

#add-bar-button {
  font-size: 1.2rem;
  width: 40px;
  height: 40px;
  border-radius: 50%;
  opacity: 0.5;
  cursor: pointer;
}

@media (max-width: 900px) {
  #add-bar-button {
    font-size: 1rem;
    width: 30px;
    height: 30px;
  }
}


/* Each time-bar container */
.time-bar {
  background: #fff;
  margin: 10px auto;
  padding: 10px 40px;
  border: 1px solid #ccc;
  border-radius: 6px;
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: center;
  width: 100%;
  box-sizing: border-box;
}
@media (max-width: 900px) {
  .time-bar {
    margin: 10px;
    padding: 10px 0px;
    width: auto;
  }
}

/* The close button in the top-right corner */
.close-bar-button {
  position: absolute;
  font-family: monospace;
  right: 8px;
  background: #f7f7f7;
  color: #999;
  border: none;
  font-size: 20px;
  cursor: pointer;
}
.close-bar-button:hover {
  background: #e9e9e9;
}

.bar-controls {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  width: 100%;
  justify-content: center;
  margin-bottom: 5px;
}

.bar-controls label {
  margin-right: 5px;
}
.location-input {
  width: 30%;
  margin-right: 10px;
}
@media (max-width: 900px) {
  .location-input {
    width: 65%;
    margin-right: 30px;
  }
}

.info {
  text-align: center;
  margin: 5px 5px;
  font-size: 10px;
  color: #555;
}
@media (max-width: 900px) {
  .info {
    max-width: 250px;
    height: 140px;
  }
}

.info div {
  margin-bottom: 2px;
}

.time-line-container {
  position: relative;
  width: 100%;
  height: 100px;
  margin: 0 auto;
  box-sizing: border-box;
}
.time-line {
  position: relative;
  width: 100%;
  height: 50px;
  border: 1px solid #000;
  z-index: 1;
  margin: 0 auto;
  box-sizing: border-box;
}

.hour-marker {
  position: absolute;
  background: #000000a6;
}
.hour-label {
  position: absolute;
  font-size: 12px;
  white-space: nowrap;
  color: #555;
}
.day-night-background {
  position: absolute;
  z-index: 0;
  top: 0;
  height: 50px;
}
.day-background {
  background-color: #FFD700;
}
.morning-civil-twilight-background,
.evening-civil-twilight-background {
  background-color: #87CEEB;
}
.morning-night-background,
.evening-night-background {
  background-color: #002952;
}
.day-night-background {
  left: var(--start-percent);
  width: var(--size-percent);
}
.hour-marker {
  top: 0;
  bottom: 0;
  width: 1px;
  left: var(--position-percent);
}
.hour-label {
  top: 60px;
  transform: translateX(-50%);
  left: var(--position-percent);
  font-size: 14px;
}
.current-time-marker {
  position: absolute;
  background: red;
  top: 0;
  bottom: 0;
  width: 2px;
  left: var(--current-time-percent);
}

/* MOBILE layout for the timeline (vertical) */
@media (max-width: 900px) {
  .time-line-container {
    width: 200px;
    height: 1000px;
  }
  .time-line {
    width: 50px;
    height: 100%;
    border: 1px solid #000;
    margin: 0 auto;
  }
  .day-night-background {
    width: 50px;
    left: 50%;
    transform: translateX(-50%);
    top: var(--start-percent);
    height: var(--size-percent);
  }
  .hour-marker {
    left: 0;
    right: 0;
    height: 1px;
    top: var(--position-percent);
    width: auto;
  }
  .hour-label {
    top: var(--position-percent);
    left: 70px;
    transform: translateY(-50%);
    font-size: 14px;
    color: #555;
  }
  .current-time-marker {
    left: 0;
    right: 0;
    height: 2px;
    top: var(--current-time-percent);
    width: auto;
  }
}

/*
  A “bubble” anchored to the + button. It's hidden by default.
  No overlay/dimming. We’ll use a CSS custom property --arrow-left
  for controlling the arrow’s left offset.
*/
#new-bar-bubble {
  position: absolute;
  display: none;
  background: #fff;
  border: 1px solid #ccc;
  border-radius: 6px;
  padding: 10px;
  box-shadow: 0 2px 10px rgba(0,0,0,0.2);
  z-index: 9999;
}
#new-bar-bubble::before {
  content: "";
  position: absolute;
  width: 0;
  height: 0;
  border-left: 8px solid transparent;
  border-right: 8px solid transparent;
  border-bottom: 8px solid #fff;
  top: -8px;
  left: var(--arrow-left, 20px);
}
#new-bar-bubble input {
  width: 200px;
  margin-right: 5px;
}
#new-bar-bubble button {
  cursor: pointer;
  margin: 5px 3px 0 0;
}

/*
   The new date override area at bottom
   label: "change date:"
*/
#bottom-date-override {
  margin: 50px;
  text-align: center;
}
#bottom-date-override label {
  margin-right: 5px;
  color:#666;
}
