/* === Anmeldung / Benutzer (auth-ui.js) ===================================
   Passt zu app.css (Tokens --primary, --primary-light, --text-dark …).
   Mobil zuerst: Touch-Ziele ≥ 44 px, Eingaben 16 px (kein iOS-Zoom). */

/* --- Header-Knopf -------------------------------------------------------- */
.header-btn.au-chip,
.header-btn.au-login-btn {
    position: relative;
    flex-shrink: 0;
}
/* unsichtbar vergrößerte Trefferfläche (≥ 44 px) */
.header-btn.au-chip::before,
.header-btn.au-login-btn::before {
    content: '';
    position: absolute;
    inset: -4px;
}

.header-btn.au-chip {
    width: 38px;
    height: 38px;
    background: #fff;
    color: var(--primary);
    font-size: 13px;
    font-weight: 700;
    letter-spacing: .3px;
}
.header-btn.au-chip:hover { background: #eaf2f8; }
.header-btn.au-chip.au-role-admin  { box-shadow: 0 0 0 2px #F9A825; }
.header-btn.au-chip.au-role-worker { box-shadow: 0 0 0 2px #66BB6A; }
.header-btn.au-chip.au-role-viewer { box-shadow: 0 0 0 2px rgba(255,255,255,.55); }
.au-initials { line-height: 1; }

.header-btn.au-login-btn {
    width: auto;
    height: 36px;
    padding: 0 12px 0 10px;
    border-radius: 18px;
    gap: 6px;
    font-size: 13px;
    font-weight: 600;
    white-space: nowrap;
    font-family: inherit;
}
.header-btn.au-login-btn svg { width: 18px; height: 18px; }

@media (max-width: 400px) {
    .au-login-label { display: none; }
    .header-btn.au-login-btn { width: 36px; padding: 0; border-radius: 50%; }
}

/* --- Overlay + Dialog ------------------------------------------------------ */
.au-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, .5);
    z-index: 3000;                 /* über Header (1000), Panels, Editor-Sheets (2500) */
    display: none;
    align-items: center;
    justify-content: center;
    padding: 16px;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
}
.au-overlay.active { display: flex; }
.au-overlay.au-bottom { align-items: flex-end; padding: 0; }

.au-dialog {
    width: 100%;
    max-width: 400px;
    margin: auto;
    background: #fff;
    color: var(--text-dark, #2c3e50);
    border-radius: 18px;
    box-shadow: 0 12px 40px rgba(0, 0, 0, .25);
    padding: 22px 20px 16px;
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    text-align: left;
    animation: au-pop .18s ease-out;
}
.au-overlay.au-bottom .au-dialog {
    max-width: 520px;
    margin: 0 auto;
    border-radius: 18px 18px 0 0;
    padding-bottom: calc(16px + env(safe-area-inset-bottom, 0px));
}
@keyframes au-pop {
    from { transform: translateY(10px) scale(.98); opacity: 0; }
    to   { transform: none; opacity: 1; }
}
@media (prefers-reduced-motion: reduce) {
    .au-dialog { animation: none; }
}

.au-dialog h2 {
    font-size: 21px;
    color: var(--primary, #1a5276);
    margin: 0 0 4px;
}
.au-sub {
    font-size: 14px;
    color: #6b7a89;
    margin: 0 0 8px;
}
.au-reason {
    background: #eaf2f8;
    color: var(--primary, #1a5276);
    border-radius: 10px;
    padding: 10px 12px;
    font-size: 14px;
    margin: 8px 0 4px;
}

/* --- Formular -------------------------------------------------------------- */
.au-label {
    display: block;
    font-size: 14px;
    font-weight: 600;
    color: #455a64;
    margin: 14px 0 6px;
}
.au-input {
    display: block;
    width: 100%;
    min-height: 48px;
    padding: 12px 14px;
    font-size: 16px;
    font-family: inherit;
    color: var(--text-dark, #2c3e50);
    background: #fff;
    border: 1.5px solid #cfd8dc;
    border-radius: 10px;
    outline: none;
    transition: border-color .15s, box-shadow .15s;
}
.au-input:focus {
    border-color: var(--primary-light, #2980b9);
    box-shadow: 0 0 0 3px rgba(41, 128, 185, .18);
}
.au-pass-wrap { position: relative; }
.au-pass-wrap .au-input { padding-right: 56px; }
.au-eye {
    position: absolute;
    top: 0;
    right: 0;
    width: 52px;
    height: 100%;
    min-height: 48px;
    border: none;
    background: none;
    color: #607d8b;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 0 10px 10px 0;
}
.au-eye:hover, .au-eye[aria-pressed="true"] { color: var(--primary, #1a5276); }

.au-check {
    display: flex;
    align-items: center;
    gap: 12px;
    min-height: 48px;
    margin-top: 8px;
    font-size: 15px;
    cursor: pointer;
    user-select: none;
}
.au-check input {
    width: 22px;
    height: 22px;
    flex-shrink: 0;
    accent-color: var(--primary, #1a5276);
}
.au-check small { color: #78909c; font-size: 13px; }

.au-error {
    background: #fdecea;
    color: #b71c1c;
    border-radius: 10px;
    padding: 10px 12px;
    font-size: 14px;
    margin-top: 12px;
}
.au-error[hidden], .au-reason[hidden] { display: none; }

/* --- Knöpfe ------------------------------------------------------------------ */
.au-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
    width: 100%;
    min-height: 48px;
    margin-top: 10px;
    padding: 0 16px;
    border: none;
    border-radius: 12px;
    font-size: 16px;
    font-weight: 600;
    font-family: inherit;
    text-decoration: none;
    cursor: pointer;
    transition: background .15s, transform .08s;
}
.au-btn:active { transform: scale(.985); }
.au-btn-primary { background: var(--primary, #1a5276); color: #fff; margin-top: 16px; }
.au-btn-primary:hover { background: var(--primary-light, #2980b9); }
.au-btn-primary:disabled { background: #90a4ae; cursor: default; transform: none; }
.au-btn-secondary { background: #eef3f7; color: var(--primary, #1a5276); }
.au-btn-secondary:hover { background: #e1ebf2; }
.au-btn-danger { background: #fdecea; color: #c62828; }
.au-btn-danger:hover { background: #fbd9d5; }
.au-btn-ghost { background: transparent; color: #546e7a; }
.au-btn-ghost:hover { background: #f3f5f7; }

.au-hint {
    font-size: 13px;
    color: #78909c;
    text-align: center;
    margin: 8px 0 0;
}

/* --- Benutzermenü ------------------------------------------------------------ */
.au-user-head {
    display: flex;
    align-items: center;
    gap: 14px;
    margin-bottom: 6px;
}
.au-avatar {
    width: 54px;
    height: 54px;
    border-radius: 50%;
    background: var(--primary, #1a5276);
    color: #fff;
    font-size: 19px;
    font-weight: 700;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}
.au-avatar.au-role-admin  { box-shadow: 0 0 0 3px #F9A825; }
.au-avatar.au-role-worker { box-shadow: 0 0 0 3px #66BB6A; }
.au-user-info { min-width: 0; }
.au-user-name {
    font-size: 17px;
    font-weight: 700;
    overflow-wrap: anywhere;
}
.au-user-meta {
    font-size: 13px;
    color: #78909c;
    margin-top: 2px;
    overflow-wrap: anywhere;
}
.au-role-badge {
    display: inline-block;
    margin-top: 6px;
    padding: 3px 10px;
    border-radius: 12px;
    font-size: 12px;
    font-weight: 600;
}
.au-role-badge.admin  { background: #FFF8E1; color: #8D6E00; }
.au-role-badge.worker { background: #E8F5E9; color: #2E7D32; }
.au-role-badge.viewer { background: #ECEFF1; color: #546E7A; }

/* --- Hinweis-Toast --------------------------------------------------------------- */
.au-toast {
    position: fixed;
    left: 50%;
    bottom: calc(var(--bottomnav-height, 58px) + 24px);
    transform: translateX(-50%);
    max-width: calc(100% - 32px);
    background: #263238;
    color: #fff;
    padding: 12px 20px;
    border-radius: 22px;
    font-size: 15px;
    line-height: 1.35;
    text-align: center;
    z-index: 3100;
    box-shadow: 0 4px 16px rgba(0, 0, 0, .3);
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
}
