/*
 * Passkey settings panel.
 *
 * Self-contained on purpose. The panel is a shortcode that can be dropped on any
 * page, but .mels-btn, .form-control and .form-group are only defined inside the
 * dashboard stylesheets, which are not loaded on an ordinary WordPress page. Rely
 * on them and the panel renders as an unstyled list with invisible-looking
 * buttons, so every rule the panel needs is defined here under its own scope.
 */

.mels-passkey-settings,
.mels-passkey-second-factor {
    max-width: 520px;
    margin: 0 auto 20px;
    font-family: inherit;
    color: #1e293b;
    line-height: 1.5;
}

.mels-passkey-second-factor {
    max-width: 420px;
}

.mels-passkey-settings h3 {
    margin: 0 0 6px;
    font-size: 18px;
    font-weight: 600;
    color: #1e293b;
}

.mels-passkey-intro {
    margin: 0 0 16px;
    font-size: 14px;
    color: #64748b;
}

/* Only shown on the standalone /passkeys page. The dashboard tabs pass
   heading => false, because the tab already has a title of its own. */

.mels-passkey-heading {
    margin: 0 0 8px;
    font-size: 18px;
    font-weight: 600;
    color: #1e293b;
}

/* The reassurance under the password field. It has to read as part of the form
   and not as body copy, which is why it is muted and small. */

.mels-passkey-help {
    margin: 6px 0 0;
    font-size: 12px;
    line-height: 1.5;
    color: #64748b;
}

/* Credential list */

.mels-passkey-list {
    list-style: none;
    margin: 0 0 20px;
    padding: 0;
    border: 1px solid #e2e8f0;
    border-radius: 10px;
    overflow: hidden;
}

.mels-passkey-item,
.mels-passkey-empty {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    padding: 12px 14px;
    border-bottom: 1px solid #e2e8f0;
}

.mels-passkey-item:last-child {
    border-bottom: 0;
}

.mels-passkey-empty {
    display: block;
    color: #64748b;
    font-size: 14px;
    background: #f8fafc;
}

.mels-passkey-item-detail {
    display: flex;
    flex-direction: column;
    min-width: 0;
}

.mels-passkey-item-label {
    font-size: 14px;
    font-weight: 600;
    color: #1e293b;
    /* A long device label must not push the Remove button off the row. */
    overflow-wrap: anywhere;
}

.mels-passkey-item-meta {
    font-size: 12px;
    color: #64748b;
}

/* Add-a-passkey form */

.mels-passkey-add {
    padding: 16px 14px;
    background: #f8fafc;
    border: 1px solid #e2e8f0;
    border-radius: 10px;
}

.mels-passkey-add .form-group {
    margin: 0 0 12px;
}

.mels-passkey-add label {
    display: block;
    margin-bottom: 5px;
    font-size: 13px;
    font-weight: 600;
    color: #334155;
}

.mels-passkey-add .form-control,
.mels-passkey-add input[type="text"] {
    display: block;
    width: 100%;
    max-width: 320px;
    padding: 8px 11px;
    font-size: 14px;
    font-family: inherit;
    color: #1e293b;
    background: #ffffff;
    border: 1px solid #cbd5e1;
    border-radius: 6px;
    box-sizing: border-box;
}

.mels-passkey-add .form-control:focus,
.mels-passkey-add input[type="text"]:focus {
    outline: 2px solid #3b82f6;
    outline-offset: 1px;
    border-color: #3b82f6;
}

/* Buttons. The .mels-btn family is dashboard-only, so the panel declares its
   own rather than rendering browser-default buttons. */

.mels-passkey-settings button,
.mels-passkey-second-factor button {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 7px;
    padding: 9px 16px;
    font-size: 14px;
    font-weight: 600;
    font-family: inherit;
    line-height: 1.2;
    color: #ffffff;
    background: #4f46e5;
    border: 1px solid transparent;
    border-radius: 6px;
    cursor: pointer;
    transition: background-color 0.15s ease;
}

.mels-passkey-settings button:hover,
.mels-passkey-second-factor button:hover {
    background: #4338ca;
}

.mels-passkey-settings button:focus-visible,
.mels-passkey-second-factor button:focus-visible {
    outline: 2px solid #1e293b;
    outline-offset: 2px;
}

.mels-passkey-settings button[disabled],
.mels-passkey-second-factor button[disabled] {
    opacity: 0.6;
    cursor: not-allowed;
}

.mels-passkey-remove {
    flex-shrink: 0;
    background: #ffffff !important;
    color: #b91c1c !important;
    border-color: #fecaca !important;
    padding: 6px 12px !important;
    font-size: 13px !important;
}

.mels-passkey-remove:hover {
    background: #fef2f2 !important;
    color: #991b1b !important;
}

.mels-passkey-settings button.mels-btn-block,
.mels-passkey-second-factor button.mels-btn-block {
    width: 100%;
}

.mels-passkey-add button {
    width: 100%;
    max-width: 320px;
}

/* The enrol button is always rendered. When the browser cannot run a ceremony
   the script disables it and fills in .mels-passkey-support-notice, rather than
   hiding the control - a form you can fill in but never submit looks broken,
   and gives no hint that anything is missing. */

.mels-passkey-add button:disabled,
.mels-passkey-second-factor button:disabled {
    opacity: 0.55;
    cursor: not-allowed;
}

.mels-passkey-support-notice {
    margin: 10px 0 0;
    padding: 10px 12px;
    font-size: 13px;
    line-height: 1.5;
    color: #92400e;
    background: #fffbeb;
    border: 1px solid #fcd34d;
    border-radius: 8px;
}

.mels-passkey-support-notice[hidden] {
    display: none;
}

/* Second factor: replaces the password form once the password is accepted. */

.mels-passkey-second-factor-title {
    margin: 0 0 6px;
    font-size: 17px;
    font-weight: 600;
    color: #1e293b;
}

.mels-passkey-second-factor-help {
    margin: 0 0 18px;
    font-size: 14px;
    color: #475569;
}

/* The way out, for the user who cannot reach their phone. Without the passkey
   being optional there is no other route, so this cannot be tucked away. */

.mels-passkey-second-factor-recovery {
    margin-top: 20px;
    padding-top: 16px;
    border-top: 1px solid #e2e8f0;
}

.mels-passkey-second-factor-recovery p {
    margin: 0 0 12px;
    font-size: 13px;
    color: #64748b;
}

.mels-passkey-second-factor-restart button {
    margin-top: 0;
}

/* Status line: both outcomes and errors, styled by the script's class. */

.mels-passkey-status {
    margin: 12px 0 0;
    min-height: 1.2em;
    font-size: 13px;
    color: #475569;
}

.mels-passkey-status.is-error {
    color: #b91c1c;
}

.mels-passkey-status.is-success {
    color: #15803d;
}

.mels-passkey-unavailable {
    max-width: 520px;
    margin: 0 auto 20px;
    padding: 12px 14px;
    font-size: 14px;
    color: #92400e;
    background: #fffbeb;
    border: 1px solid #fde68a;
    border-radius: 8px;
}

@media (max-width: 480px) {
    .mels-passkey-item {
        flex-direction: column;
        align-items: flex-start;
    }

    .mels-passkey-add .form-control,
    .mels-passkey-add input[type="text"],
    .mels-passkey-add button {
        max-width: 100%;
    }
}
