/* ==========================================================================
   UnifiedModal — refined chrome

   Loaded app-wide from base_standardized.html and base_buchhaltung.html,
   AFTER unified-modal.css. A NEW file on purpose: static assets carry no
   content hash, so edits to unified-modal.css would not reach returning
   browsers.

   Two layers, rolled out in steps (2026-09-23):

   1. CHROME — every modal: white header with the icon in a quiet tile,
      hairline footer, cancel as a ghost, secondary outlined so only the
      primary is filled (Working Blue #2563eb, not focus blue), disabled
      reads as "not yet". Opt OUT with [data-um-classic] anywhere in the
      loaded content (convention: on the .um-title) for a modal whose own
      chrome this breaks — e.g. the red account-deletion header.

   2. FORM FIELDS + PHONE BOTTOM SHEET — still opt-IN via [data-um-refined]
      (convention: on the .um-title). Trial scope: the trip page's modals.
      These touch every input and the whole layout, so they go wide only
      after a screenshot sweep.

   Why the markers live INSIDE the content: UnifiedModal copies only the
   inner html of .um-header/.um-footer into its own shell, so a class on
   those elements is lost; scoping runs through .um-container:has(…).
   ========================================================================== */

/* ── 1. Chrome (all modals unless [data-um-classic]) ───────────────────── */

.um-container:not(:has([data-um-classic])) .um-dialog {
    border: 0;
    border-radius: 14px;
    box-shadow: 0 24px 48px -12px rgba(17, 24, 39, 0.28),
                0 0 0 1px rgba(17, 24, 39, 0.06);
}

.um-container:not(:has([data-um-classic])) .um-content {
    border-radius: 14px;
}

.um-container:not(:has([data-um-classic])) .um-header {
    min-height: 0;
    padding: 1.1rem 1.25rem 0.9rem 1.5rem;
    background: #ffffff;
    border-bottom: 1px solid #eef0f3;
}

/* .modal-title: the ~77 modals still written in Bootstrap markup
   (modal-header/-body/-footer, .btn) — UnifiedModal pours them into this
   same shell, so they get the same chrome. */
.um-container:not(:has([data-um-classic])) .um-title,
.um-container:not(:has([data-um-classic])) .um-header .modal-title {
    display: flex;
    align-items: center;
    margin: 0;
    line-height: 1.25;
    font-size: 1.0625rem;
    font-weight: 600;
    letter-spacing: -0.01em;
    color: #111827;
    gap: 0.75rem;
}

.um-container:not(:has([data-um-classic])) .um-title > i:first-child,
.um-container:not(:has([data-um-classic])) .um-header .modal-title > i:first-child {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    flex: 0 0 auto;
    width: 2rem;
    height: 2rem;
    margin: 0 !important;          /* beats Bootstrap's .me-2 utility */
    border-radius: 8px;
    background: #f3f4f6;
    color: #4b5563;
    font-size: 0.875rem;
}

.um-container:not(:has([data-um-classic])) .um-close {
    width: 2.25rem;
    height: 2.25rem;
    border-radius: 8px;
    color: #6b7280;
}

.um-container:not(:has([data-um-classic])) .um-close:hover {
    background: #f3f4f6;
    color: #111827;
}

.um-container:not(:has([data-um-classic])) .um-footer {
    min-height: 0;
    gap: 0.5rem;
    padding: 0.875rem 1.5rem;
    background: #ffffff;
    border-top: 1px solid #eef0f3;
}

.um-container:not(:has([data-um-classic])) .um-footer .um-btn,
.um-container:not(:has([data-um-classic])) .um-footer .btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    min-height: 2.5rem;
    padding: 0.5rem 1rem;
    border-radius: 8px;
    font-weight: 500;
    box-shadow: none;
    transition: background-color 0.15s ease, border-color 0.15s ease,
                color 0.15s ease;
}

/* The gap owns icon spacing: without it an icon written without .me-2
   glues to its label ("👁Vorschau"), with it .me-2 would double up. */
.um-container:not(:has([data-um-classic])) .um-footer .um-btn > i,
.um-container:not(:has([data-um-classic])) .um-footer .btn > i {
    margin-left: 0 !important;
    margin-right: 0 !important;
}

.um-container:not(:has([data-um-classic])) .um-footer .um-btn-primary,
.um-container:not(:has([data-um-classic])) .um-footer .btn-primary {
    background: #2563eb;
    border-color: #2563eb;
    color: #ffffff;
}

.um-container:not(:has([data-um-classic])) .um-footer .um-btn-primary:hover:not(:disabled),
.um-container:not(:has([data-um-classic])) .um-footer .btn-primary:hover:not(:disabled) {
    background: #1d4ed8;
    border-color: #1d4ed8;
}

.um-container:not(:has([data-um-classic])) .um-footer .um-btn-secondary,
.um-container:not(:has([data-um-classic])) .um-footer .btn-secondary {
    background: #ffffff;
    border-color: #d1d5db;
    color: #1f2937;
}

.um-container:not(:has([data-um-classic])) .um-footer .um-btn-secondary:hover:not(:disabled),
.um-container:not(:has([data-um-classic])) .um-footer .btn-secondary:hover:not(:disabled) {
    background: #f9fafb;
    border-color: #9ca3af;
}

/* Cancel is a way out, not an action: a ghost. */
.um-container:not(:has([data-um-classic])) .um-footer .um-btn[data-modal-action="close"],
.um-container:not(:has([data-um-classic])) .um-footer .btn[data-modal-action="close"],
.um-container:not(:has([data-um-classic])) .um-footer [data-um-close].um-btn,
.um-container:not(:has([data-um-classic])) .um-footer [data-um-close].btn {
    background: transparent;
    border-color: transparent;
    color: #4b5563;
}

.um-container:not(:has([data-um-classic])) .um-footer .um-btn[data-modal-action="close"]:hover,
.um-container:not(:has([data-um-classic])) .um-footer .btn[data-modal-action="close"]:hover,
.um-container:not(:has([data-um-classic])) .um-footer [data-um-close].um-btn:hover,
.um-container:not(:has([data-um-classic])) .um-footer [data-um-close].btn:hover {
    background: #f3f4f6;
    color: #111827;
}

/* "Zurück" and any other backward step sit apart, on the left. */
.um-container:not(:has([data-um-classic])) .um-footer [data-um-back] {
    margin-right: auto;
}

.um-container:not(:has([data-um-classic])) .um-footer .um-btn:disabled,
.um-container:not(:has([data-um-classic])) .um-footer .btn:disabled {
    background: #f3f4f6;
    border-color: #f3f4f6;
    color: #9ca3af;
    opacity: 1;
    cursor: not-allowed;
}

.um-container:not(:has([data-um-classic])) .um-footer .um-btn:focus-visible,
.um-container:not(:has([data-um-classic])) .um-footer .btn:focus-visible {
    outline: 2px solid #3b82f6;
    outline-offset: 2px;
}

.um-container:not(:has([data-um-classic])) .um-footer .um-btn:focus:not(:focus-visible),
.um-container:not(:has([data-um-classic])) .um-footer .btn:focus:not(:focus-visible) {
    outline: none;
}

@media (max-width: 768px) {
    /* Phones stack the footer (unified-modal.css); cancel drops to a quiet
       last row instead of heading the stack. */
    .um-container:not(:has([data-um-classic])) .um-footer .um-btn[data-modal-action="close"],
    .um-container:not(:has([data-um-classic])) .um-footer .btn[data-modal-action="close"],
    .um-container:not(:has([data-um-classic])) .um-footer [data-um-close] {
        order: 10;
    }

    .um-container:not(:has([data-um-classic])) .um-footer [data-um-back] {
        margin-right: 0;
    }
}

/* ── 2. Opt-in: tighter body, text-only footer buttons, form fields,
         phone bottom sheet ([data-um-refined]) ─────────────────────────── */

.um-container:has([data-um-refined]) .um-body {
    padding: 1.25rem 1.5rem 1.5rem;
}

/* Icons in footer buttons are noise next to a clear verb. (Opt-in only: an
   icon-ONLY footer button elsewhere would render empty.) */
.um-container:has([data-um-refined]) .um-footer .um-btn > i {
    display: none;
}

/* ── Form controls ──────────────────────────────────────────────────── */

.um-container:has([data-um-refined]) .um-body label,
.um-container:has([data-um-refined]) .um-body .form-label {
    font-size: 0.8125rem;
    font-weight: 500;
    color: #374151;
    margin-bottom: 0.35rem;
}

.um-container:has([data-um-refined]) .um-body input:not([type="checkbox"]):not([type="radio"]):not([type="file"]):not([type="hidden"]),
.um-container:has([data-um-refined]) .um-body select,
.um-container:has([data-um-refined]) .um-body .ts-wrapper.single .ts-control,
.um-container:has([data-um-refined]) .um-body .ts-wrapper.multi .ts-control {
    min-height: 2.5rem;
    border-color: #d1d5db;
    border-radius: 8px;
    font-size: 0.875rem;
    color: #111827;
    background-color: #ffffff;
    box-shadow: none;
}

.um-container:has([data-um-refined]) .um-body textarea {
    border-color: #d1d5db;
    border-radius: 8px;
    font-size: 0.875rem;
    color: #111827;
}

.um-container:has([data-um-refined]) .um-body .ts-wrapper .ts-control {
    display: flex;
    align-items: center;
    padding: 0.4rem 0.75rem;
}

.um-container:has([data-um-refined]) .um-body input::placeholder,
.um-container:has([data-um-refined]) .um-body textarea::placeholder {
    color: #9ca3af;
}

.um-container:has([data-um-refined]) .um-body input:focus,
.um-container:has([data-um-refined]) .um-body select:focus,
.um-container:has([data-um-refined]) .um-body textarea:focus,
.um-container:has([data-um-refined]) .um-body .ts-wrapper.focus .ts-control {
    border-color: #3b82f6;
    box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.15);
    outline: none;
}

.um-container:has([data-um-refined]) .um-body .form-text,
.um-container:has([data-um-refined]) .um-body .help-block {
    font-size: 0.75rem;
    line-height: 1.4;
    color: #6b7280;
}

.um-container:has([data-um-refined]) .um-body .invalid-feedback {
    font-size: 0.78rem;
}

/* ── Phones: bottom sheet ───────────────────────────────────────────── */

@media (max-width: 640px) {
    .um-container:has([data-um-refined]) {
        align-items: flex-end;
        padding: 0;
    }

    .um-container:has([data-um-refined]) .um-dialog {
        width: 100%;
        max-width: 100%;
        margin: 0;
        max-height: calc(100dvh - 2.5rem);
        border-radius: 16px 16px 0 0;
    }

    .um-container:has([data-um-refined]) .um-header {
        padding: 0.9rem 0.75rem 0.75rem 1.25rem;
    }

    .um-container:has([data-um-refined]) .um-body {
        padding: 1rem 1.25rem 1.25rem;
        max-height: none;
    }

    /* Primary last = nearest the thumb; cancel shrinks to a text row. */
    .um-container:has([data-um-refined]) .um-footer {
        flex-direction: column;
        align-items: stretch;
        gap: 0.5rem;
        padding: 0.75rem 1.25rem calc(0.75rem + env(safe-area-inset-bottom, 0px));
    }

    .um-container:has([data-um-refined]) .um-footer .um-btn {
        width: 100%;
        min-height: 2.75rem;
    }

    .um-container:has([data-um-refined]) .um-footer .um-btn[data-modal-action="close"] {
        order: 10;
        min-height: 2.25rem;
    }

    .um-container:has([data-um-refined]) .um-footer [data-um-back] {
        margin-right: 0;
    }
}
