/*****************************************************
 *  LaserStil – Handwerkliches Design
 *  + Optimiert für mobile Geräte
 *  + Styles für Versandauswahl
 *  + Dark‑Mode‑Unterstützung (Theme‑Switcher)
 *****************************************************/
* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}
body {
  font-family: 'Inter', sans-serif;
  background: #faf8f5;
  color: #3e3a35;
  min-height: 100vh;
  position: relative;
}

/* ========== HEADER ========== */
header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 0.8rem 1rem;
  background: #f8f4ed;
  border-bottom: 1px solid #e0d6c2;
  position: sticky;
  top: 0;
  z-index: 1000;
  flex-wrap: wrap;
  box-shadow: 0 2px 5px rgba(0,0,0,0.1);
}
.header-left,
.header-right {
  display: flex;
  gap: 0.4rem;
  align-items: center;
}
.header-right {
  flex-wrap: wrap;
  justify-content: flex-end;
}

/* Cart‑Button mit Badge */
#cartButton {
  position: relative;
}
#cartCount {
  background: #c0392b;
  color: white;
  border-radius: 50%;
  padding: 2px 6px;
  font-size: 0.7rem;
  position: absolute;
  top: -8px;
  right: -8px;
  display: none;
}

/* Allgemeine Buttons */
button {
  padding: 0.5rem 0.8rem;
  border: 1px solid #c4b89e;
  background: #fff;
  border-radius: 6px;
  cursor: pointer;
  font-size: 0.9rem;
  transition: background 0.2s;
  white-space: nowrap;
}
button:hover {
  background: #ede4d3;
}
.active-filter {
  background: #d4c5a9;
  font-weight: bold;
}

main {
  padding: 1.5rem 1rem;
}
section {
  display: none;
}
section#shop { display: block; }

/* ========== KATEGORIE‑FILTER ========== */
.kategorie-filter {
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem;
  padding: 0.8rem 0;
}
.kat-btn {
  padding: 0.35rem 0.8rem;
  border: 1px solid #ccc;
  background: #f5f0e6;
  cursor: pointer;
  border-radius: 20px;
  font-size: 0.85rem;
  transition: background 0.2s, color 0.2s;
}
.kat-btn.active-filter {
  background: #b89b7b;
  color: white;
  border-color: #b89b7b;
}

/* ========== PRODUKTGRID ========== */
.product-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
  gap: 1.2rem;
  margin-top: 1.2rem;
}
.product-card {
  background: #fff;
  border: 1px solid #e0d6c2;
  border-radius: 8px;
  padding: 1rem;
  text-align: center;
  box-shadow: 0 2px 8px rgba(0,0,0,0.05);
  transition: transform 0.2s;
}
.product-card:hover {
  transform: translateY(-4px);
  box-shadow: 0 6px 16px rgba(0,0,0,0.1);
}
.product-image {
  max-width: 100%;
  height: 150px;
  object-fit: contain;
  margin-bottom: 0.5rem;
}

/* ========== MODALS ========== */
.modal-overlay {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(0,0,0,0.5);
  display: none;
  justify-content: center;
  align-items: center;
  z-index: 10000;
}
.modal-content {
  background: white;
  border-radius: 12px;
  padding: 1.5rem;
  min-width: 280px;
  max-width: 95%;
  max-height: 90vh;
  overflow-y: auto;
  box-shadow: 0 8px 30px rgba(0,0,0,0.5);
  position: relative;
}
.modal-close {
  position: absolute;
  top: 0.5rem;
  right: 0.8rem;
  background: none;
  border: none;
  font-size: 1.5rem;
  cursor: pointer;
  color: #555;
}

/* Formulare */
input, textarea, select {
  width: 100%;
  padding: 0.5rem;
  margin: 0.3rem 0 0.8rem 0;
  border: 1px solid #ccc;
  border-radius: 6px;
  font-family: inherit;
  font-size: 1rem;
}
.btn {
  background: #3a7bd5;
  color: white;
  border: none;
  padding: 0.6rem 1.2rem;
  border-radius: 4px;
  cursor: pointer;
  font-weight: bold;
  display: inline-block;
  text-align: center;
  transition: background 0.2s;
  font-size: 1rem;
}
.btn:hover {
  background: #2e62b3;
}

/* ========== ADMIN‑TABELLE ========== */
.admin-table {
  width: 100%;
  border-collapse: collapse;
  margin: 1rem 0;
  font-size: 0.9rem;
}
.admin-table th, .admin-table td {
  padding: 0.5rem;
  border: 1px solid #ddd;
  text-align: left;
}
.admin-table th {
  background: #f0ebe0;
}

/* ========== TOAST ========== */
.toast {
  position: fixed;
  bottom: 20px;
  left: 50%;
  transform: translateX(-50%);
  background: #333;
  color: #fff;
  padding: 12px 24px;
  border-radius: 8px;
  z-index: 20000;
  opacity: 0.9;
  animation: fadein 0.3s, fadeout 0.3s 2.7s;
  max-width: 90%;
  text-align: center;
}
@keyframes fadein { from { opacity: 0; } to { opacity: 1; } }
@keyframes fadeout { from { opacity: 1; } to { opacity: 0; } }

/* Download‑Button für Bilder */
.btn-download {
    display: inline-block;
    padding: 4px 12px;
    background: #d4a373;
    color: white;
    border-radius: 5px;
    text-decoration: none;
    font-size: 0.9rem;
    margin-top: 5px;
}
.btn-download:hover {
    background: #bc8a5f;
}

/* ========== RECHNUNGSMODAL ========== */
#rechnungModalOverlay .modal-content {
  max-width: 800px;
  width: 95%;
  max-height: 90vh;
  overflow-y: auto;
  background: #fff;
  padding: 1.5rem;
  font-family: 'Inter', sans-serif;
  border-radius: 0;
}

#rechnungContent h2 {
  font-size: 1.6rem;
  margin-bottom: 0.8rem;
}

#rechnungContent p, #rechnungContent li {
  font-size: 0.95rem;
  line-height: 1.4;
}

#rechnungContent ul {
  list-style: none;
  padding: 0;
}

#rechnungContent li {
  border-bottom: 1px solid #ccc;
  padding: 0.5rem 0;
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 0.5rem;
}

/* Druckansicht */
@media print {
  body * {
    visibility: hidden;
  }
  #rechnungModalOverlay, #rechnungModalOverlay * {
    visibility: visible;
  }
  #rechnungModalOverlay {
    position: absolute;
    left: 0;
    top: 0;
    width: 100%;
    height: auto;
    background: white;
    z-index: 99999;
    padding: 2cm;
    box-sizing: border-box;
  }
  #rechnungModalOverlay .modal-close,
  #rechnungModalOverlay button {
    display: none;
  }
}

/* ========== VERSANDOPTIONEN IM CHECKOUT ========== */
#versandSelection label {
  display: block;
  margin: 0.3rem 0;
  font-size: 0.95rem;
}
#versandSelection input[type="radio"] {
  width: auto;
  margin-right: 0.5rem;
}
#versandSelection small {
  color: #666;
}

/* ========== MOBILE OPTIMIERUNG (bis 600px) ========== */
@media (max-width: 600px) {
  header {
    padding: 0.6rem 0.8rem;
  }
  .header-left button,
  .header-right button {
    padding: 0.4rem 0.6rem;
    font-size: 0.8rem;
  }
  main {
    padding: 1rem 0.5rem;
  }
  .product-grid {
    grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
    gap: 0.8rem;
  }
  .product-card {
    padding: 0.8rem;
  }
  .product-image {
    height: 120px;
  }
  .modal-content {
    width: 95%;
    padding: 1rem;
  }
  #customerLoginBtn {
    bottom: 15px;
    right: 10px;
    padding: 10px 16px;
    font-size: 0.85rem;
    border-radius: 25px;
  }
  #kontoBtn {
    bottom: 70px;
    right: 10px;
    padding: 8px 14px;
    font-size: 0.8rem;
    border-radius: 25px;
  }
  .admin-table th, .admin-table td {
    padding: 0.4rem 0.3rem;
    font-size: 0.8rem;
  }
  input, textarea, select {
    font-size: 16px;
  }
}

/* Sehr kleine Geräte (375px und kleiner) */
@media (max-width: 400px) {
  .header-left, .header-right {
    gap: 0.2rem;
  }
  .header-left button, .header-right button {
    padding: 0.3rem 0.5rem;
    font-size: 0.75rem;
  }
  .product-grid {
    grid-template-columns: 1fr 1fr;
    gap: 0.5rem;
  }
}

/* ========== PRODUKT-GALERIE ========== */
.gallery-zoom-container {
    position: relative;
    overflow: hidden;
    width: 100%;
    max-height: 60vh;
    margin-bottom: 1rem;
}
.gallery-main-image {
    width: 100%;
    height: auto;
    display: block;
    transition: transform 0.3s ease;
    cursor: zoom-in;
}
.gallery-thumbnails {
    display: flex;
    gap: 0.5rem;
    justify-content: center;
    margin-top: 0.5rem;
}
.gallery-thumb {
    width: 50px;
    height: 50px;
    object-fit: cover;
    border: 2px solid transparent;
    border-radius: 4px;
    cursor: pointer;
    transition: border-color 0.2s;
}
.gallery-thumb.active,
.gallery-thumb:hover {
    border-color: #3a7bd5;
}
.gallery-nav {
    display: flex;
    justify-content: space-between;
    margin-top: 0.5rem;
}
.gallery-nav button {
    padding: 0.3rem 0.8rem;
    font-size: 1.2rem;
}
/* Galerie‑Hauptbild begrenzen */
#galleryContent img {
  max-height: 70vh;        /* maximal 70 % der Bildschirmhöhe */
  width: auto;             /* Breite automatisch anpassen */
  object-fit: contain;     /* vollständig sichtbar, ohne Verzerrung */
}

/* ========== DARK MODE ========== */
html.dark body {
  background: #121212;
  color: #e0d6c2;
}

html.dark header {
  background: #1a1a1a;
  border-bottom-color: #444;
}

html.dark button {
  background: #2a2a2a;
  color: #e0d6c2;
  border-color: #555;
}
html.dark button:hover {
  background: #3a3a3a;
}

html.dark .kat-btn {
  background: #2a2a2a;
  color: #ccc;
  border-color: #555;
}
html.dark .kat-btn.active-filter {
  background: #b89b7b;
  color: white;
}

html.dark .product-card {
  background: #1e1e1e;
  border-color: #444;
  color: #e0d6c2;
}

html.dark .modal-content {
  background: #222;
  color: #ddd;
}

html.dark input,
html.dark textarea,
html.dark select {
  background: #333;
  color: #eee;
  border-color: #555;
}

html.dark .btn {
  background: #3a7bd5;
  color: white;
}
html.dark .btn:hover {
  background: #2e62b3;
}

html.dark .admin-table th {
  background: #2a2a2a;
  color: #e0d6c2;
}
html.dark .admin-table td {
  border-color: #444;
}

html.dark #rechnungModalOverlay .modal-content {
  background: #222;
  color: #ddd;
}

html.dark footer {
  background: #1a1a1a;
  color: #aaa;
}

html.dark .toast {
  background: #555;
  color: #fff;
}

html.dark #versandSelection small {
  color: #aaa;
}
.material-grid {
  display: flex;
  flex-wrap: wrap;
  gap: 1.5rem;
  justify-content: center;
  margin-top: 1rem;
}

.material-card {
  background: var(--card-bg, #fff);
  border: 1px solid #d4a373;
  border-radius: 12px;
  padding: 1rem;
  text-align: center;
  cursor: pointer;
  width: 200px;
  transition: transform 0.2s, box-shadow 0.2s;
}

.material-card:hover {
  transform: translateY(-4px);
  box-shadow: 0 4px 12px rgba(0,0,0,0.1);
}

.material-card img {
  width: 100%;
  height: 120px;
  object-fit: cover;
  border-radius: 8px;
  margin-bottom: 0.5rem;
}
/* Sichtbare Fokus‑Indikatoren für alle interaktiven Elemente */
:focus-visible {
  outline: 3px solid #d4a373;
  outline-offset: 2px;
}

/* Für den Dark Mode die Farbe etwas heller setzen */
.dark :focus-visible {
  outline-color: #f0c27b;
}

/* ========== GRAVUR-EDITOR ========== */
#gravurSvgContainer {
  user-select: none;
  max-width: 700px;
  margin: 1rem auto;
  border: 2px dashed #d4a373;
  border-radius: 8px;
  overflow: hidden;
  background: #f5f0e6;
}

#gravurSvg text.selectable,
#gravurSvg image.selectable {
  cursor: move;
}

#gravurSvg text.selectable.selected,
#gravurSvg image.selectable.selected {
  outline: 2px dashed #3a7bd5;
  outline-offset: 2px;
}

html.dark #gravurSvgContainer {
  background: #1a1a1a;
  border-color: #555;
}