/**
 * /styles/modal-stack.css
 * 
 * Styles für Modal-Stack-System
 * - Nur oberstes Modal ist interaktiv
 * - Darunter liegende sind visuell "gesperrt"
 */

/* ═══════════════════════════════════════════════════════════════════════════
   BODY - Scroll Lock wenn Modal offen
   ═══════════════════════════════════════════════════════════════════════════ */

body.modal-open {
  overflow: hidden;
  /* Verhindert iOS Bounce */
  position: fixed;
  width: 100%;
}

/* ═══════════════════════════════════════════════════════════════════════════
   MODAL OVERLAY - Backdrop
   ═══════════════════════════════════════════════════════════════════════════ */

.modal-overlay {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(0, 0, 0, 0.5);
  display: none;  /* Wird von JS auf flex gesetzt */
  justify-content: center;
  align-items: center;
  backdrop-filter: blur(4px);
  -webkit-backdrop-filter: blur(4px);
  
  /* Transition für smooth open/close */
  opacity: 0;
  transition: opacity 0.2s ease;
}

.modal-overlay.modal-active {
  opacity: 1;
}

/* ═══════════════════════════════════════════════════════════════════════════
   MODAL CONTENT - Die eigentliche Box
   ═══════════════════════════════════════════════════════════════════════════ */

.modal-content {
  background: white;
  border-radius: 16px;
  padding: 24px;
  max-width: 500px;
  width: 90%;
  max-height: 90vh;
  overflow-y: auto;
  
  /* Animation */
  transform: translateY(-20px) scale(0.95);
  transition: transform 0.25s cubic-bezier(0.16, 1, 0.3, 1);
  
  /* Shadow */
  box-shadow: 
    0 25px 50px -12px rgba(0, 0, 0, 0.25),
    0 0 0 1px rgba(255, 255, 255, 0.1);
}

.modal-active .modal-content {
  transform: translateY(0) scale(1);
}

/* Verschiedene Größen */
.modal-content.small { max-width: 400px; }
.modal-content.medium { max-width: 600px; }
.modal-content.large { max-width: 800px; }
.modal-content.fullscreen { 
  max-width: 95vw; 
  max-height: 95vh;
  width: 95vw;
  height: 95vh;
}

/* ═══════════════════════════════════════════════════════════════════════════
   GLASSMORPHISM VARIANT
   ═══════════════════════════════════════════════════════════════════════════ */

.modal-content.glass {
  background: rgba(255, 255, 255, 0.85);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  border: 1px solid rgba(255, 255, 255, 0.3);
}

/* Dark Overlay für Glassmorphism */
.modal-overlay.glass-overlay {
  background: rgba(0, 0, 0, 0.3);
  backdrop-filter: blur(8px);
}

/* ═══════════════════════════════════════════════════════════════════════════
   MODAL HEADER
   ═══════════════════════════════════════════════════════════════════════════ */

.modal-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 20px;
  padding-bottom: 16px;
  border-bottom: 1px solid var(--color-border);
}

.modal-header h3 {
  margin: 0;
  font-size: 1.25rem;
  font-weight: 600;
  color: var(--color-text);
}

.modal-close {
  background: none;
  border: none;
  font-size: 1.5rem;
  color: #9ca3af;
  cursor: pointer;
  padding: 4px 8px;
  border-radius: 6px;
  transition: all 0.15s;
  line-height: 1;
}

.modal-close:hover {
  background: #f3f4f6;
  color: #4b5563;
}

/* ═══════════════════════════════════════════════════════════════════════════
   MODAL BODY
   ═══════════════════════════════════════════════════════════════════════════ */

.modal-body {
  color: var(--color-text-light);
  line-height: 1.6;
}

/* ═══════════════════════════════════════════════════════════════════════════
   MODAL FOOTER / ACTIONS
   ═══════════════════════════════════════════════════════════════════════════ */

.modal-footer,
.modal-actions {
  display: flex;
  justify-content: flex-end;
  gap: 12px;
  margin-top: 24px;
  padding-top: 16px;
  border-top: 1px solid var(--color-border);
}

/* ═══════════════════════════════════════════════════════════════════════════
   STACKED MODALS - Visueller Effekt
   ═══════════════════════════════════════════════════════════════════════════ */

/* Wenn mehrere Modals offen sind, werden die unteren leicht abgedunkelt */
.modal-overlay:not(:last-of-type) {
  /* Nicht das oberste Modal */
}

/* Pointer-Events nur für oberstes Modal */
.modal-overlay {
  pointer-events: auto;
}

.modal-overlay .modal-content {
  pointer-events: auto;
}

/* ═══════════════════════════════════════════════════════════════════════════
   FOCUS STYLES - Accessibility
   ═══════════════════════════════════════════════════════════════════════════ */

.modal-content :focus-visible {
  outline: 2px solid var(--color-primary);
  outline-offset: 2px;
}

.modal-content button:focus-visible,
.modal-content input:focus-visible,
.modal-content select:focus-visible {
  outline: 2px solid var(--color-primary);
  outline-offset: 2px;
}

/* ═══════════════════════════════════════════════════════════════════════════
   DETAIL-MODAL SHARED - Styles für LocationDetails + KontaktDetails
   ═══════════════════════════════════════════════════════════════════════════ */

/* Header Actions (Edit/Delete/Close Buttons) */
.header-actions {
  display: flex;
  align-items: center;
  gap: 8px;
}

.header-btn {
  width: 36px;
  height: 36px;
  border: 1px solid #e5e7eb;
  border-radius: 8px;
  background: #fff;
  cursor: pointer;
  font-size: 1rem;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.2s;
}

.header-btn:hover {
  background: #f3f4f6;
}

.header-btn.edit-btn:hover {
  border-color: #3b82f6;
  color: #3b82f6;
}

.header-btn.edit-btn.save-mode {
  background: #3b82f6;
  border-color: #3b82f6;
  color: #fff;
}

.header-btn.delete-btn:hover {
  border-color: #ef4444;
  color: #ef4444;
}

/* Detail-Modal Close Button (mit Border) */
.location-details-modal-content .modal-close-btn,
.kontakt-details-modal-content .modal-close-btn {
  background: #fff;
  border: 1px solid #e5e7eb;
  font-size: 1.3rem;
  cursor: pointer;
  color: #6b7280;
  width: 36px;
  height: 36px;
  border-radius: 8px;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.2s;
}

.location-details-modal-content .modal-close-btn:hover,
.kontakt-details-modal-content .modal-close-btn:hover {
  background: #e5e7eb;
  color: #1f2937;
}

/* Info Grid */
.info-grid {
  display: flex;
  flex-direction: column;
}

.info-row {
  display: flex;
  align-items: center;
  padding: 8px 0;
  border-bottom: 1px solid #f3f4f6;
}

.info-row:last-child {
  border-bottom: none;
}

.info-row .info-label {
  font-size: 0.85rem;
  color: #6b7280;
  font-weight: 500;
  flex-shrink: 0;
}

.info-row .info-value {
  flex: 1;
  font-size: 0.9rem;
  color: #1f2937;
}

.info-link {
  color: #3b82f6;
  text-decoration: none;
}

.info-link:hover {
  text-decoration: underline;
}

/* Editierbare Input-Felder */
.info-input {
  flex: 1;
  padding: 6px 10px;
  border: 1px solid #3b82f6;
  border-radius: 6px;
  font-size: 0.9rem;
  background: #f0f7ff;
  outline: none;
}

.info-input:focus {
  box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.2);
}

/* Section Blocks */
.section-block {
  margin-bottom: 20px;
  border-radius: 10px;
  overflow: hidden;
  border: 1px solid #e5e7eb;
}

.section-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 12px 16px;
  font-weight: 600;
  font-size: 0.9rem;
  color: #fff;
}

.section-header.orange {
  background: linear-gradient(135deg, #f97316, #ea580c);
}

.section-header.green {
  background: linear-gradient(135deg, #22c55e, #16a34a);
}

.section-header.brand {
  background: linear-gradient(135deg, var(--color-primary), var(--color-primary-dark));
}

.section-header.blue {
  background: linear-gradient(135deg, #3b82f6, #2563eb);
}

.section-header span {
  display: flex;
  align-items: center;
  gap: 8px;
}

/* Add Button (in Section Headers) */
.btn-add {
  padding: 6px 14px;
  background: #fff;
  color: #374151;
  border: none;
  border-radius: 6px;
  font-size: 0.8rem;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s;
}

.btn-add:hover {
  background: #f3f4f6;
}

/* Empty Message */
.empty-message {
  text-align: center;
  color: #9ca3af;
  padding: 20px;
  margin: 0;
  font-size: 0.9rem;
}

/* ═══════════════════════════════════════════════════════════════════════════
   RESPONSIVE
   ═══════════════════════════════════════════════════════════════════════════ */

@media (max-width: 640px) {
  .modal-content {
    width: 95%;
    max-height: 85vh;
    padding: 16px;
    border-radius: 12px;
  }
  
  .modal-content.large,
  .modal-content.fullscreen {
    width: 100%;
    max-width: 100%;
    height: 100%;
    max-height: 100%;
    border-radius: 0;
  }
  
  .modal-header h3 {
    font-size: 1.1rem;
  }
  
  .modal-footer {
    flex-direction: column;
  }
  
  .modal-footer button {
    width: 100%;
  }
}