/* ================================================================
   MODALS / OVERLAYS
   ================================================================ */
.modal-overlay {
  position: fixed; inset: 0; background: rgba(26,32,53,0.6);
  backdrop-filter: blur(6px); z-index: 500; display: none;
  align-items: center; justify-content: center;
}
.modal-overlay.open { display: flex; }
.modal {
  display: flex;
  flex-direction: column;
  background: var(--surface); border: 1px solid var(--border); border-radius: 20px;
  width: 100%; max-width: 800px; max-height: 90vh;
  overflow: hidden;
  position: relative; box-shadow: 0 24px 80px rgba(0,0,0,0.2);
  box-sizing: border-box;
}

/* Modal Content scrolliert, Footer NICHT */
#modalContent {
  flex: 1;
  overflow-y: scroll;
  overflow-x: hidden;
  padding: 36px;
  -webkit-overflow-scrolling: touch;
}

/* Buttons/Action Area bleibt UNTEN sichtbar (scrollt NICHT mit!) */
#modalContent ~ div,
.btn-group,
.nav-buttons {
  flex-shrink: 0;
  padding: 0 36px 36px;
}

.modal-close {
  position: absolute; 
  top: 16px; 
  right: 16px; 
  background: #ffffff;
  border: 2px solid #e0e0e0;
  color: #666666; 
  width: 36px; 
  height: 36px; 
  border-radius: 50%;
  padding: 0;
  cursor: pointer; 
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.2s ease;
  box-shadow: 0 1px 3px rgba(0,0,0,0.08);
  z-index: 1000;
}
.modal-close svg {
  width: 14px;
  height: 14px;
}
.modal-close:hover { 
  background: var(--primary); 
  color: #ffffff;
  border-color: var(--primary);
  transform: rotate(90deg) scale(1.1);
  box-shadow: 0 3px 8px rgba(0,102,204,0.3);
}
.modal-title {
  font-family: var(--font-display); font-size: 26px; font-weight: 900;
  text-transform: uppercase; color: var(--primary); margin-bottom: 4px; 
  padding-right: 60px; /* Mehr Platz für Close-Button */
}
.modal-subtitle { font-size: 13px; color: var(--muted); margin-bottom: 24px; }

/* Tablet: 600px - 900px */
@media (max-width: 900px) and (min-width: 601px) {
  #modalContent {
    padding: 28px 20px;
  }
  #modalContent ~ div,
  .btn-group,
  .nav-buttons {
    padding: 0 20px 28px;
  }
  .modal {
    max-height: 85vh;
  }
  .modal-title {
    font-size: 22px;
  }
}

/* Mobile: unter 600px */
@media (max-width: 600px) {
  #modalContent {
    padding: 20px 12px;
    max-height: calc(100vh - 180px); /* Account for tab-bar + close button */
  }
  #modalContent ~ div,
  .btn-group,
  .nav-buttons {
    padding: 0 12px 20px;
  }
  .modal {
    /* Much smaller max-height on mobile to prevent overflow */
    max-height: calc(100vh - 80px);
    width: calc(100% - 20px);
    margin: 0 10px;
    border-radius: 12px;
  }
  .modal-title {
    font-size: 18px;
    margin-bottom: 8px;
  }
  .modal-subtitle {
    font-size: 12px;
    margin-bottom: 16px;
  }
  .modal-close {
    width: 32px;
    height: 32px;
    top: 12px;
    right: 12px;
  }
}
