/* FCC 1.5.0 – zentrale Wizard- und Mobile-Modal-UX */
:root{
  --fcc-mobile-header-bottom:76px;
  --fcc-wizard-accent:#18a3a1;
  --fcc-wizard-dark:#013e57;
  --fcc-wizard-border:#d8e7e9;
  --fcc-wizard-soft:#f2f8f8;
}

/* FCC 1.6.5 – Echtes Drag&Drop für alle Datei-Upload-Zonen (nicht nur Klick).
   Der native <input type=file> aus Blazors <InputFile> wird unsichtbar über
   die komplette Zone gelegt, damit der Browser Drops direkt darauf zulässt -
   ohne eigenen JS-Datei-Transfer-Code. .drag-over wird per Blazor-State
   (dragenter/dragleave) gesetzt und liefert die visuelle Rückmeldung. */
.csv-upload-zone,.fcc-dropzone{position:relative}
.csv-upload-zone input[type=file],.fcc-dropzone input[type=file]{
  position:absolute;inset:0;width:100%;height:100%;
  opacity:0;cursor:pointer;
}
.csv-upload-zone.drag-over,.fcc-dropzone.drag-over{
  border-color:var(--fcc-wizard-accent)!important;
  background:rgba(24,163,161,.09)!important;
}

.fcc-auto-wizard{position:relative;min-width:0}
.fcc-wizard-stepper{
  display:flex;gap:8px;align-items:flex-start;overflow-x:auto;scrollbar-width:none;
  margin:2px 0 20px;padding:4px 2px 8px;
}
.fcc-wizard-stepper::-webkit-scrollbar{display:none}
.fcc-wizard-step{
  flex:1 0 110px;min-width:110px;border:0;background:transparent;color:#6c7d82;
  display:grid;grid-template-columns:30px 1fr;grid-template-rows:auto auto;column-gap:8px;
  text-align:left;padding:6px 4px;cursor:pointer;border-radius:10px;
}
.fcc-wizard-step:hover{background:rgba(24,163,161,.07)}
.fcc-wizard-step .fcc-wizard-number{
  grid-row:1/3;width:30px;height:30px;border-radius:50%;display:grid;place-items:center;
  border:1px solid #b9d1d4;background:#fff;color:var(--fcc-wizard-dark);font-weight:800;
}
.fcc-wizard-step strong{font-size:13px;line-height:1.2;color:inherit;white-space:nowrap;overflow:hidden;text-overflow:ellipsis}
.fcc-wizard-step small{font-size:10px;color:#8a999d;line-height:1.2;margin-top:2px}
.fcc-wizard-step.active{color:var(--fcc-wizard-dark);background:rgba(24,163,161,.09)}
.fcc-wizard-step.active .fcc-wizard-number,
.fcc-wizard-step.done .fcc-wizard-number{background:var(--fcc-wizard-accent);border-color:var(--fcc-wizard-accent);color:#fff}
.fcc-wizard-step.done{color:#467276}

[data-fcc-wizard-step]{transition:opacity .12s ease}
[data-fcc-wizard-step][hidden]{display:none!important}
.fcc-wizard-section-active{animation:fccWizardIn .14s ease}
@keyframes fccWizardIn{from{opacity:.55;transform:translateY(3px)}to{opacity:1;transform:none}}

.fcc-wizard-controls{
  display:flex;justify-content:flex-end;align-items:center;gap:10px;
  margin-top:18px;padding-top:14px;border-top:1px solid var(--fcc-wizard-border);
}
.fcc-wizard-controls button{
  min-height:44px;border-radius:11px;padding:10px 18px;font-weight:800;border:1px solid #cbdcdf;
}
.fcc-wizard-prev{background:#eef4f5;color:var(--fcc-wizard-dark)}
.fcc-wizard-next{background:var(--fcc-wizard-accent)!important;color:#fff!important;border-color:var(--fcc-wizard-accent)!important}
.fcc-auto-wizard:not(.fcc-wizard-final) .fcc-wizard-final-action{display:none!important}

/* Bestehende lange FCC-Formulare kompakt halten */
.calculator-form-panel,.vertrag-form-panel,.einsatz-form-panel{scroll-margin-top:90px}
.fcc-auto-wizard .form-section-title{margin-top:4px!important}
.fcc-auto-wizard .form-grid{margin-bottom:2px}

/* Mobile: Modals niemals mehr unter dem festen FCC-Header verschwinden lassen. */
@media(max-width:760px){
  .receipt-overlay,
  .docs-modal-overlay,
  .appointment-modal-overlay,
  .calendar-day-modal-overlay,
  .calendar-detail-overlay,
  .calendar-delete-overlay,
  .document-editor-overlay,
  .document-preview-overlay,
  .vertrag-detail-overlay,
  .vertrag-document-overlay,
  .vertrag-pdf-overlay,
  .vertrag-save-preview-overlay,
  .fcc-mail-overlay,
  .fcc-delete-overlay,
  .doc-settings-overlay,
  .subdialog-overlay,
  .admin-overlay,
  .fcc-notification-detail-overlay{
    position:fixed!important;
    top:var(--fcc-mobile-header-bottom)!important;
    right:0!important;bottom:0!important;left:0!important;
    height:auto!important;min-height:0!important;
    padding:8px 8px calc(8px + env(safe-area-inset-bottom))!important;
    align-items:flex-start!important;justify-content:center!important;
    overflow:hidden!important;
  }

  .receipt-modal,
  .docs-modal,
  .appointment-modal,
  .calendar-day-modal,
  .calendar-detail-modal,
  .calendar-delete-dialog,
  .document-editor-dialog,
  .document-preview-dialog,
  .vertrag-detail-dialog,
  .vertrag-document-dialog,
  .vertrag-pdf-dialog,
  .vertrag-save-preview-dialog,
  .fcc-mail-modal,
  .fcc-delete-dialog,
  .doc-settings-dialog,
  .subdialog,
  .admin-modal,
  .fcc-notification-detail-modal{
    width:min(100%,680px)!important;
    max-width:calc(100vw - 16px)!important;
    max-height:calc(100dvh - var(--fcc-mobile-header-bottom) - 12px - env(safe-area-inset-bottom))!important;
    height:auto!important;margin:0 auto!important;
    display:flex!important;flex-direction:column!important;
    overflow:hidden!important;border-radius:18px!important;
  }

  .modal-head,.docs-modal-head,.appointment-form-header,.calendar-day-modal-header,
  .vertrag-document-dialog-header,.doc-settings-dialog-head,.subdialog-head,
  .document-editor-dialog>header,.fcc-mail-modal>header,.admin-modal>header{
    position:sticky!important;top:0!important;z-index:15!important;flex:0 0 auto!important;
    background:#fff!important;
  }

  .docs-modal-body,.calendar-day-modal-body,.vertrag-document-dialog-body,
  .receipt-modal>.form-grid,.appointment-modal form,
  .document-editor-dialog .document-editor-body,
  .fcc-mail-modal .fcc-mail-form,.admin-modal .admin-modal-body{
    min-height:0!important;overflow-y:auto!important;overscroll-behavior:contain!important;
    -webkit-overflow-scrolling:touch;
  }

  .modal-actions,.docs-modal-footer,.appointment-form-actions,.calendar-day-modal-footer,
  .doc-settings-dialog-actions,.subdialog-actions,
  .vertrag-save-preview-dialog .modal-actions{
    position:sticky!important;bottom:0!important;z-index:14!important;flex:0 0 auto!important;
    background:#fff!important;padding-bottom:max(12px,env(safe-area-inset-bottom))!important;
  }

  .receipt-modal>.form-grid{display:grid!important;grid-template-columns:1fr!important;padding:14px 16px!important}
  .receipt-modal .modal-head{padding:14px 16px!important}
  .receipt-modal .modal-actions{padding:12px 16px!important}

  .fcc-wizard-stepper{margin-bottom:10px;padding-bottom:5px}
  .fcc-wizard-step{flex-basis:92px;min-width:92px;grid-template-columns:26px 1fr;column-gap:6px;padding:5px 3px}
  .fcc-wizard-step .fcc-wizard-number{width:26px;height:26px;font-size:12px}
  .fcc-wizard-step strong{font-size:11px}
  .fcc-wizard-step small{display:none}
  .fcc-wizard-controls{position:sticky;bottom:0;z-index:12;background:#fff;margin:10px -2px -2px;padding:10px 2px calc(8px + env(safe-area-inset-bottom))}
  .fcc-wizard-controls button{flex:1;min-width:0;min-height:48px;padding:10px}
  .fcc-auto-wizard .form-grid{grid-template-columns:1fr!important;gap:10px!important}
  .fcc-auto-wizard input,.fcc-auto-wizard select,.fcc-auto-wizard textarea{max-width:100%!important;width:100%!important;min-width:0!important;font-size:16px!important}
  .fcc-auto-wizard textarea{max-height:180px}
}

/* FCC 1.5.3 – Mobile UI Recovery
   Narrow, predictable rules. Existing desktop and document wizard stay untouched. */
@media (max-width:760px){
  /* Auto-wizards: compact progress dots. Long labels no longer get squeezed into 3–5 columns. */
  .fcc-auto-wizard .fcc-wizard-stepper{
    display:flex!important;align-items:center!important;justify-content:space-between!important;
    gap:8px!important;width:100%!important;max-width:100%!important;
    margin:2px 0 14px!important;padding:4px 2px 10px!important;overflow:visible!important;
  }
  .fcc-auto-wizard .fcc-wizard-step{
    flex:1 1 0!important;min-width:0!important;width:auto!important;
    display:flex!important;align-items:center!important;justify-content:center!important;
    padding:4px 0!important;background:transparent!important;overflow:visible!important;
  }
  .fcc-auto-wizard .fcc-wizard-step .fcc-wizard-number{
    flex:0 0 30px!important;width:30px!important;height:30px!important;font-size:12px!important;
  }
  .fcc-auto-wizard .fcc-wizard-step strong,
  .fcc-auto-wizard .fcc-wizard-step small{display:none!important}
  .fcc-auto-wizard .fcc-wizard-step.active .fcc-wizard-number{
    box-shadow:0 0 0 4px rgba(24,163,161,.13)!important;
  }

  /* Every auto-wizard action has one geometry. No half-width Weiter/Zurück buttons. */
  .fcc-auto-wizard .fcc-wizard-controls{
    position:static!important;display:flex!important;flex-direction:column!important;
    align-items:stretch!important;gap:10px!important;width:100%!important;max-width:none!important;
    margin:16px 0 0!important;padding:14px 0 0!important;box-sizing:border-box!important;
    background:#fff!important;border-top:1px solid var(--fcc-wizard-border)!important;
  }
  .fcc-auto-wizard .fcc-wizard-controls button{
    display:flex!important;align-items:center!important;justify-content:center!important;
    width:100%!important;max-width:none!important;min-width:0!important;height:48px!important;
    flex:0 0 48px!important;margin:0!important;padding:0 16px!important;box-sizing:border-box!important;
  }
  .fcc-auto-wizard .fcc-wizard-next{order:1!important}
  .fcc-auto-wizard .fcc-wizard-prev{order:2!important}
  .fcc-auto-wizard .fcc-wizard-prev[style*="visibility: hidden"]{display:none!important}

  /* Final form actions use the same dimensions, but only inside wizard forms. */
  .fcc-auto-wizard .form-actions,
  .fcc-auto-wizard .appointment-form-actions{
    display:flex!important;flex-direction:column!important;align-items:stretch!important;
    gap:10px!important;width:100%!important;margin-top:10px!important;
  }
  .fcc-auto-wizard .form-actions button,
  .fcc-auto-wizard .appointment-form-actions button{
    width:100%!important;max-width:none!important;min-width:0!important;min-height:48px!important;
    margin:0!important;box-sizing:border-box!important;justify-content:center!important;
  }

  /* Form geometry: same width, no Safari overflow. */
  .fcc-auto-wizard,.fcc-auto-wizard form,.fcc-auto-wizard .form-grid,
  .fcc-auto-wizard .form-field,.appointment-form-grid,.appointment-form-grid>*{
    width:100%!important;max-width:100%!important;min-width:0!important;box-sizing:border-box!important;
  }
  .fcc-auto-wizard input,.fcc-auto-wizard select,.fcc-auto-wizard textarea,
  .appointment-form-grid input,.appointment-form-grid select,.appointment-form-grid textarea{
    display:block!important;width:100%!important;max-width:100%!important;min-width:0!important;
    box-sizing:border-box!important;margin-left:0!important;margin-right:0!important;font-size:16px!important;
  }

  /* Admin / Rollen & Rechte: modal owns the scroll, not the page behind it. */
  .admin-overlay{
    position:fixed!important;top:var(--fcc-mobile-header-bottom)!important;right:0!important;bottom:0!important;left:0!important;
    height:auto!important;padding:0!important;align-items:stretch!important;overflow:hidden!important;
    overscroll-behavior:contain!important;
  }
  .admin-modal{
    width:100%!important;max-width:none!important;height:100%!important;max-height:100%!important;
    min-height:0!important;margin:0!important;border-radius:0!important;overflow:hidden!important;
    display:flex!important;flex-direction:column!important;
  }
  .admin-header{position:relative!important;flex:0 0 auto!important;z-index:3!important}
  .admin-body{
    flex:1 1 auto!important;min-height:0!important;overflow-y:auto!important;overflow-x:hidden!important;
    -webkit-overflow-scrolling:touch!important;overscroll-behavior:contain!important;
    padding:18px 16px calc(30px + env(safe-area-inset-bottom))!important;
  }

  /* Receipt upload: top/header is always visible; only content scrolls. */
  .receipt-overlay{
    position:fixed!important;top:var(--fcc-mobile-header-bottom)!important;right:0!important;bottom:0!important;left:0!important;
    height:auto!important;padding:8px!important;display:flex!important;align-items:flex-start!important;
    justify-content:center!important;overflow:hidden!important;overscroll-behavior:contain!important;
  }
  .receipt-modal{
    width:100%!important;max-width:680px!important;height:100%!important;max-height:100%!important;
    min-height:0!important;margin:0!important;padding:0!important;border-radius:16px!important;
    display:flex!important;flex-direction:column!important;overflow:hidden!important;
  }
  .receipt-modal>.modal-head{
    flex:0 0 auto!important;padding:16px 18px 10px!important;background:#fff!important;z-index:3!important;
  }
  .receipt-modal>.form-grid{
    flex:1 1 auto!important;min-height:0!important;overflow-y:auto!important;overflow-x:hidden!important;
    -webkit-overflow-scrolling:touch!important;overscroll-behavior:contain!important;
    display:grid!important;grid-template-columns:1fr!important;padding:8px 18px 18px!important;
  }
  .receipt-modal>.modal-actions{
    flex:0 0 auto!important;display:flex!important;flex-direction:column!important;gap:10px!important;
    width:100%!important;margin:0!important;padding:12px 18px calc(12px + env(safe-area-inset-bottom))!important;
    box-sizing:border-box!important;background:#fff!important;border-top:1px solid #e1eaec!important;
  }
  .receipt-modal>.modal-actions button{width:100%!important;max-width:none!important;min-height:48px!important;margin:0!important}
  .receipt-modal>.modal-actions .primary{order:1!important}
  .receipt-modal>.modal-actions button:not(.primary){order:2!important}

  /* Objects: preserve the working card conversion without touching unrelated tables. */
  .object-panel{width:100%!important;max-width:100%!important;min-width:0!important;overflow:hidden!important;padding:14px!important;box-sizing:border-box!important}
  .object-table{width:100%!important;min-width:0!important;overflow:visible!important}
  .object-table-header{display:none!important}
  .object-row{
    display:grid!important;grid-template-columns:minmax(0,1fr) 42px!important;gap:9px 12px!important;
    width:100%!important;min-width:0!important;margin:0 0 12px!important;padding:15px!important;
    border:1px solid #e1eaed!important;border-radius:14px!important;background:#fff!important;box-sizing:border-box!important;
  }
  .object-row>div:not(.object-actions),.object-row>span{
    grid-column:1!important;min-width:0!important;max-width:100%!important;white-space:normal!important;overflow-wrap:anywhere!important;
  }
  .object-actions{grid-column:2!important;grid-row:1!important;align-self:start!important}
  .object-form-panel,.calculator-form-panel,.vertrag-form-panel,.einsatz-form-panel{
    width:100%!important;max-width:100%!important;min-width:0!important;box-sizing:border-box!important;
    padding:16px!important;overflow:hidden!important;
  }
}



/* FCC 1.5.3 contract action alignment */
.fcc-wizard-cancel {
  background:#eef4f5!important;
  color:var(--fcc-wizard-dark)!important;
}

@media (min-width:761px){
  .vertrag-form-panel.fcc-auto-wizard .fcc-wizard-controls{
    display:flex!important;
    justify-content:flex-end!important;
    align-items:center!important;
    gap:10px!important;
  }
  .vertrag-form-panel.fcc-auto-wizard .fcc-wizard-controls button{
    width:132px!important;
    min-width:132px!important;
    max-width:132px!important;
    min-height:46px!important;
    display:inline-flex!important;
    align-items:center!important;
    justify-content:center!important;
    margin:0!important;
  }
  .vertrag-form-panel.fcc-auto-wizard .fcc-wizard-prev[style*="visibility: hidden"]{
    display:none!important;
  }
  .vertrag-form-panel.fcc-auto-wizard:not(.fcc-wizard-final) .form-actions{
    display:none!important;
  }
  .vertrag-form-panel.fcc-auto-wizard.fcc-wizard-final .form-actions{
    display:flex!important;
    justify-content:flex-end!important;
    margin-top:12px!important;
  }
  .vertrag-form-panel.fcc-auto-wizard.fcc-wizard-final .form-actions .fcc-primary-button{
    min-width:274px!important;
    min-height:46px!important;
  }
}

@media (max-width:760px){
  .vertrag-form-panel.fcc-auto-wizard .fcc-wizard-cancel{order:3!important;}
  .vertrag-form-panel.fcc-auto-wizard:not(.fcc-wizard-final) .form-actions{display:none!important;}
}

/* FCC 1.6.2 – Mail-Wizard: Abbrechen/E-Mail senden erst im letzten Schritt zeigen,
   sonst stehen auf jedem Schritt vier Buttons gleichzeitig da. */
.fcc-mail-modal.fcc-auto-wizard:not(.fcc-wizard-final) .fcc-mail-footer{
  display:none!important;
}

/* FCC 1.6.4 – Einheitliche Abstände für ALLE Wizards/Modals: Wenn die
   Weiter/Zurück-Steuerung als direktes Kind eines "...-modal" Elements landet
   (statt im eigenen Formular, das schon eigenes Padding hat), bekommt sie
   überall dasselbe seitliche und untere Padding wie der restliche Dialoginhalt.
   Betrifft aktuell fcc-mail-modal und receipt-modal, gilt automatisch auch für
   jeden künftigen "*-modal"-Wizard. */
[class$="-modal"] > .fcc-wizard-controls{
  padding:18px 26px 26px!important;
  margin:0!important;
  box-sizing:border-box!important;
}
@media (max-width:760px){
  [class$="-modal"] > .fcc-wizard-controls{
    padding:16px 20px calc(20px + env(safe-area-inset-bottom))!important;
  }
}

/* FCC 1.6.1 – Hintergrund darf nie mehr mitscrollen, solange ein Modal/Wizard offen ist.
   Wird zentral von js/fcc-wizard-system.js gesetzt/entfernt, sobald irgendein
   *-overlay/*-backdrop Element im DOM erscheint bzw. verschwindet. */
html.fcc-scroll-locked,
body.fcc-scroll-locked{
  position:fixed!important;
  inset:0!important;
  width:100%!important;
  overflow:hidden!important;
  overscroll-behavior:none!important;
}
