/*
 * EMS Mech ID entry keypad.
 *
 * Deliberately follows the Staff Unlock keypad geometry so the two controls
 * feel like the same EMS interface.
 */

.ems-mechid-keypad-overlay[hidden] {
    display: none !important;
}

.ems-mechid-keypad-overlay {
    position: fixed;
    z-index: 30000;
    inset: 0;
    display: grid;
    place-items: center;
    box-sizing: border-box;
    padding:
        calc(12px + env(safe-area-inset-top, 0px))
        calc(12px + env(safe-area-inset-right, 0px))
        calc(12px + env(safe-area-inset-bottom, 0px))
        calc(12px + env(safe-area-inset-left, 0px));
    background: rgba(0, 0, 0, 0.78);
    backdrop-filter: blur(4px);
    -webkit-backdrop-filter: blur(4px);
}

body.ems-mechid-keypad-open {
    overflow: hidden !important;
}

.ems-mechid-keypad-dialog {
    box-sizing: border-box;
    width: min(92vw, 380px);
    max-height: min(94vh, 620px);
    padding: 12px;
    overflow: auto;
    border: 1px solid var(--panel-border, #555);
    border-radius: 10px;
    background: var(--panel-bg, #202020);
    box-shadow: 0 18px 52px rgba(0, 0, 0, 0.65);
}

.ems-mechid-keypad-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
    margin-bottom: 8px;
}

.ems-mechid-keypad-header h2 {
    margin: 0;
    font-size: 1.1rem;
}

.ems-mechid-keypad-close {
    flex: 0 0 42px;
    width: 42px;
    min-width: 42px;
    height: 42px;
    min-height: 42px;
    padding: 0;
    font-size: 1.55rem;
    line-height: 1;
}

.ems-mechid-keypad-message {
    min-height: 2.4em;
    margin: 0 0 8px;
    color: var(--text, #f2f2f2);
    font-size: 0.86rem;
    line-height: 1.25;
    text-align: center;
}

.ems-mechid-keypad-message[data-state="error"] {
    color: var(--warning, #f0bd5b);
    font-weight: 700;
}

.ems-mechid-keypad-display {
    display: grid;
    place-items: center;
    min-height: 62px;
    margin-bottom: 9px;
    border: 1px solid var(--panel-border, #555);
    border-radius: 7px;
    background: rgba(0, 0, 0, 0.3);
    font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, monospace;
    font-size: 1.8rem;
    font-weight: 700;
    letter-spacing: 0.24em;
}

.ems-mechid-keypad-grid {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 7px;
}

.ems-mechid-keypad-grid button {
    min-height: 52px;
    padding: 4px;
    border-radius: 7px;
    font-size: 1.2rem;
    font-weight: 700;
    touch-action: manipulation;
}

.ems-mechid-keypad-grid .mechid-secondary {
    font-size: 0.88rem;
}

.ems-mechid-keypad-actions {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 7px;
    margin-top: 9px;
}

.ems-mechid-keypad-actions button {
    min-height: 44px;
    padding: 5px 8px;
    font-size: 0.88rem;
    font-weight: 700;
}

.ems-mechid-keypad-actions .mechid-primary {
    background: var(--success, #2d8a52);
}

.ems-mechid-keypad-actions .mechid-primary:disabled {
    opacity: 0.6;
}

#signupTable .mech-id-lookup {
    text-align: center;
}

#signupTable .mech-id-lookup[data-mech-lookup-state="pending"] {
    border-color: #ffd84d;
}

#signupTable .mech-id-lookup[data-mech-lookup-state="complete"] {
    border-color: var(--success, #2d8a52);
}

#signupTable .mech-id-lookup[data-mech-lookup-state="error"] {
    border-color: var(--warning, #f0bd5b);
}

@media (orientation: landscape) and (max-height: 760px) {
    .ems-mechid-keypad-dialog {
        width: min(88vw, 500px);
        max-height: 96vh;
        padding: 8px;
    }

    .ems-mechid-keypad-header {
        margin-bottom: 4px;
    }

    .ems-mechid-keypad-message {
        min-height: 1.4em;
        margin-bottom: 5px;
    }

    .ems-mechid-keypad-display {
        min-height: 42px;
        margin-bottom: 5px;
        font-size: 1.45rem;
    }

    .ems-mechid-keypad-grid {
        gap: 4px;
    }

    .ems-mechid-keypad-grid button {
        min-height: 38px;
    }

    .ems-mechid-keypad-actions {
        margin-top: 5px;
    }

    .ems-mechid-keypad-actions button {
        min-height: 38px;
    }
}
