/* --- Reset & Base --- */
html, body {
  margin: 0;
  padding: 0;
  height: 100%;
  width: 100%;
  background: rgba(10, 30, 50, 0.6);
  color: white;
  font-family: sans-serif;
  overflow: hidden;
}

/* --- Layout Grid --- */
#viewer {
  display: grid;
  grid-template-rows: auto auto 1fr;
  grid-template-columns: auto 1fr auto;
  grid-template-areas:
    "title title title"
    "actions actions actions"
    "image image image";
  height: 100%;
  width: 100%;
}

/* --- Title --- */
#title-container {
  grid-area: title;
  padding: 10px;
  background: rgba(255, 255, 255, 0.3);
  text-align: center;
}
#leuchte-number {
  font-size: 1.5em;
  font-weight: bold;
}
#leuchte-name {
  font-size: 1.2em;
  margin-top: 4px;
}

/* --- Actions --- */
#actions-container {
  grid-area: actions;
  padding: 10px;
  display: flex;
  flex-direction: row;
  gap: 15px;
  justify-content: flex-end;
  align-items: center;
  background: rgba(255, 255, 255, 0.1);
}
.action-button {
  background: rgba(255, 255, 255, 0.6);
  border: none;
  color: black;
  padding: 0.6em 1.2em;
  font-size: 1.2em;
  cursor: pointer;
  white-space: nowrap;
}
.action-button:hover {
  background: rgba(255, 255, 255, 0.8);
}
.kaufen-button {
  background: #b3d9a2;
  color: black;
}
.aehnliche-button {
  background: #add8e6; /* light, matte blue */
  color: black;
}

/* --- Image Container --- */
#image-container {
  grid-area: image;
  position: relative;
  width: 100%;
  height: 100%;
  background: rgba(10, 30, 50, 0.2);
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
}

/* --- Image Elements --- */
#image, #preload-image {
  max-width: 100%;
  max-height: 100%;
  width: auto;
  height: auto;
  object-fit: contain;
  transition: opacity 10ms ease;
  position: absolute;
  top: 0; left: 0; right: 0; bottom: 0;
  margin: auto;
}
.image-front { z-index: 1; opacity: 1; }
.image-back { z-index: 0; opacity: 0; pointer-events: none; }

/* --- Spinner & Error --- */
#loading-spinner, #error-symbol {
  position: absolute;
  font-size: 3em;
  z-index: 3;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
}
#loading-spinner { display: none; }
#error-symbol { display: none; color: red; }

/* --- Navigation Overlay Buttons --- */
.overlay-button {
  position: absolute;
  background: rgba(255, 255, 255, 0);
  border: none;
  color: white;
  font-size: 2em;
  padding: 0.3em 0.6em;
  cursor: pointer;
  z-index: 5;
  transition: background 0.2s;
}
.overlay-button:hover {
  background: rgba(0, 0, 0, 0.4);
}
.top-left { top: 10px; left: 10px; }
.top-right { top: 10px; right: 10px; }
.left-middle { bottom: 25%; left: 10px; }
.right-middle { bottom: 25%; right: 10px; }

/* --- Image Bottom Buttons --- */
#image-corner-buttons {
  position: absolute;
  bottom: 10px;
  left: 10px;
  display: flex;
  gap: 10px;
  z-index: 6;
}
.image-action-button {
  background: rgba(255, 255, 255, 0.25);
  border: none;
  font-size: 1em;
  padding: 0.5em 1em;
  cursor: pointer;
  transition: background 0.2s;
}
.image-action-button:hover {
  background: rgba(255, 255, 255, 0.45);
}

/* --- Info Overlay --- */
#info-overlay {
  position: absolute;
  top: 0;
  left: 0;
  background: rgba(150, 160, 180, 1);
  color: black;
  width: 100%;
  height: 100%;
  z-index: 10;
  display: none;
  flex-direction: column;
  align-items: center;
  justify-content: flex-start;
  overflow-y: auto;
  padding: 1em;
  box-sizing: border-box;
}
#info-overlay .info-text {
  max-width: 600px;
  text-align: center;
  font-size: 1.2em;
  margin: 2em 0 1em;
}
#info-ok-button {
  background-color: #b3d9a2;
  background: #b3d9a2;
  border: none;
  padding: 0.6em 1.2em;
  font-size: 1em;
  cursor: pointer;
  margin-bottom: 2em;
}
#info-ok-button:hover {
  background: #b3d9a2;
}

/* --- Purchase Overlay --- */
#purchase-overlay {
  position: absolute;
  top: 0;
  left: 0;
  background: rgba(10, 30, 50, 0.6);
  color: black;
  width: 100%;
  height: 100%;
  z-index: 20;
  display: none;
  justify-content: center;
  align-items: flex-start;
  overflow-y: auto;
  padding: 1em;
  box-sizing: border-box;
}
#purchase-form {
  background: white;
  padding: 1em;
  border: 1px solid #ccc;
  max-width: 360px;
  width: 100%;
  box-sizing: border-box;
  margin-top: 2em;
}
#purchase-form input {
  width: 100%;
  padding: 0.4em;
  margin-top: 0.3em;
  margin-bottom: 1em;
  box-sizing: border-box;
}
#purchase-submit {
  background: #b3d9a2;
  border: none;
  padding: 0.5em 1em;
  cursor: pointer;
}
#purchase-cancel {
  background: transparent;
  color: #333;
  border: 1px solid #999;
  padding: 0.5em 1em;
  margin-left: 0.5em;
  cursor: pointer;
}

.update-button {
  background: #ccc;
  color: black;
}
.update-button:hover {
  background: #ddd;
}

#impressum-overlay {
  position: absolute;
  top: 0;
  left: 0;
  background: rgba(240, 240, 240, 1);
  color: black;
  width: 100%;
  height: 100%;
  z-index: 15;
  display: none;
  flex-direction: column;
  align-items: center;
  justify-content: flex-start;
  overflow-y: auto;
  padding: 1em;
  box-sizing: border-box;
}

#impressum-ok-button {
  background-color: #ccc;
  border: none;
  padding: 0.6em 1.2em;
  font-size: 1em;
  cursor: pointer;
  margin: 2em 0;
}

#impressum-ok-button:hover {
  background-color: #bbb;
}


/* --- Responsive Layout --- */
@media (max-width: 768px) {
  #viewer {
    grid-template-columns: 1fr;
    grid-template-areas:
      "title"
      "actions"
      "image";
    grid-template-rows: auto auto 1fr;
  }

  #actions-container {
    justify-content: center;
    flex-wrap: wrap;
    gap: 10px;
  }

  .overlay-button {
    font-size: 1em; /* ↓ smaller arrow buttons */
    padding: 0.2em 0.4em;
  }

  .action-button {
    font-size: 1.2em; /* ↓ scaled down from 1.2em */
    padding: 0.4em 0.6em;
  }

  .image-action-button {
    font-size: 1.2em; /* ↓ scaled down from 1em */
    padding: 0.3em 0.5em;
  }

  #leuchte-number {
    font-size: 1.5em; /* ↓ from 1.5em */
  }

  #leuchte-name {
    font-size: 1.2em; /* ↓ from 1.2em */
  }

  #loading-spinner, #error-symbol {
    font-size: 1.5em; /* ↓ from 3em */
  }
}



@media (min-width: 1400px) {
  #viewer {
    display: grid;
    grid-template-columns: 1fr 560px;
    grid-template-rows: auto 1fr;
    grid-template-areas:
      "image actions"
      "image title";
    height: 100%;
    width: 100%;
  }

  /* Image fills height on the left */
  #image-container {
    grid-area: image;
    display: flex;
    align-items: center;
    justify-content: center;
    overflow: hidden;
  }

  #image, #preload-image {
    max-height: 100%;
    max-width: 100%;
    width: auto;
    height: auto;
    object-fit: contain;
  }

  /* Actions on top-right */
  #actions-container {
    grid-area: actions;
    display: flex;
    flex-direction: column;
    justify-content: flex-start;
    align-items: flex-end;
    padding: 20px;
    gap: 16px;
  }

  .action-button {
    font-size: 2em;
    width: 100%;
    text-align: right;
  }

  /* Title below actions on the right */
  #title-container {
    grid-area: title;
    padding: 20px;
    text-align: left;
  }

  #leuchte-number {
    font-size: 4em;
    font-weight: bold;
  }

  #leuchte-name {
    font-size: 2.6em;
    margin-top: 6px;
  }

  /* Corner & overlay buttons stay positioned */
  .overlay-button {
    font-size: 2em;
    padding: 0.4em 0.6em;
  }

  #image-corner-buttons {
    bottom: 20px;
    left: 20px;
    gap: 12px;
  }

  .image-action-button {
    font-size: 1em;
    padding: 0.5em 1.1em;
  }
}