/*
 * Polaris IMA - 2FA TOTP Enrollment styles
 * Plugin: preventivatore (shared imaway + b2b2c)
 * Phase 6 Plan 02 - TOTP-FE-01
 */

.ima-2fa-container {
    max-width: 640px;
    margin: 24px auto;
    padding: 24px;
    border: 1px solid #ddd;
    border-radius: 6px;
    background: #fff;
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
}

.ima-2fa-container h2,
.ima-2fa-container h3 {
    margin-top: 0;
    color: #222;
}

.ima-2fa-container button {
    cursor: pointer;
    background: #d4af37;
    color: #000;
    border: 1px solid #b08b1f;
    padding: 10px 18px;
    font-size: 14px;
    font-weight: 600;
    border-radius: 4px;
    transition: background 0.15s;
}

.ima-2fa-container button:hover:not(:disabled) {
    background: #c19c30;
}

.ima-2fa-container button:disabled {
    opacity: 0.55;
    cursor: not-allowed;
}

.ima-2fa-qr-wrapper {
    display: flex;
    flex-wrap: wrap;
    gap: 24px;
    align-items: flex-start;
    margin: 16px 0 24px;
    padding: 16px;
    background: #fafafa;
    border-radius: 4px;
}

.ima-2fa-qr {
    flex: 0 0 auto;
}

.ima-2fa-qr img,
.ima-2fa-qr canvas {
    max-width: 256px;
    height: auto;
    display: block;
    background: #fff;
    padding: 8px;
    border: 1px solid #eee;
}

.ima-2fa-secret-manual {
    flex: 1 1 240px;
    min-width: 220px;
}

.ima-2fa-secret-manual p {
    margin: 0 0 8px;
    font-size: 13px;
    color: #555;
}

.ima-2fa-secret-manual code {
    display: inline-block;
    font-family: "SFMono-Regular", Consolas, "Liberation Mono", Menlo, monospace;
    font-size: 1.1em;
    letter-spacing: 1px;
    padding: 8px 12px;
    background: #f5f5f5;
    border: 1px solid #e0e0e0;
    border-radius: 3px;
    word-break: break-all;
    line-height: 1.5;
}

#ima-2fa-confirm-form label {
    display: block;
    margin-bottom: 6px;
    font-weight: 600;
}

#ima-2fa-confirm-form input[type="text"] {
    font-family: monospace;
    font-size: 1.4em;
    padding: 10px 12px;
    width: 180px;
    letter-spacing: 4px;
    text-align: center;
    border: 1px solid #ccc;
    border-radius: 4px;
    margin-right: 8px;
}

.ima-2fa-error {
    color: #b00020;
    margin: 8px 0;
    font-size: 13px;
}

.ima-2fa-recovery-list {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 8px;
    padding: 0;
    margin: 16px 0;
}

.ima-2fa-recovery-list li {
    list-style: none;
    padding: 10px 14px;
    border: 1px solid #ddd;
    border-radius: 3px;
    background: #fafafa;
    font-family: "SFMono-Regular", Consolas, "Liberation Mono", Menlo, monospace;
    font-size: 1.1em;
    letter-spacing: 2px;
    text-align: center;
}

.ima-2fa-actions {
    margin: 16px 0;
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
}

.ima-2fa-actions button {
    margin-right: 0;
}

#ima-2fa-saved-checkbox {
    margin-right: 6px;
}

label[for="ima-2fa-saved-checkbox"],
.ima-2fa-container label:has(#ima-2fa-saved-checkbox) {
    display: inline-block;
    margin: 16px 0;
    font-weight: 600;
}

/*
 * Plan 03 (Phase 6) — Second-step login TOTP UI.
 * Sixcell input + channel selector + recovery input.
 */
.ima-otp-sixcell {
    display: flex;
    gap: 8px;
    justify-content: center;
    margin: 12px 0;
}

.ima-otp-cell {
    width: 40px;
    height: 48px;
    font-size: 24px;
    text-align: center;
    border: 1px solid #ddd;
    border-radius: 4px;
    font-family: monospace;
    -moz-appearance: textfield;
}

.ima-otp-cell::-webkit-outer-spin-button,
.ima-otp-cell::-webkit-inner-spin-button {
    -webkit-appearance: none;
    margin: 0;
}

.ima-otp-cell:focus {
    border-color: #0073aa;
    outline: 2px solid rgba(0, 115, 170, 0.2);
}

.ima-otp-channel-selector label {
    display: block;
    padding: 8px;
    cursor: pointer;
    user-select: none;
}

.ima-otp-channel-selector input[type="radio"] {
    margin-right: 8px;
    vertical-align: middle;
}

#ima-otp-recovery-input {
    font-family: "SFMono-Regular", Consolas, "Liberation Mono", Menlo, monospace;
    font-size: 18px;
    letter-spacing: 2px;
    text-transform: uppercase;
}

.ima-otp-error {
    color: #c33;
    padding: 8px;
    background: #fee;
    border-left: 4px solid #c33;
    margin: 8px 0;
}

/* Print: isolate only recovery codes when user clicks "Stampa" */
@media print {
    body * {
        visibility: hidden;
    }
    .ima-2fa-recovery-list,
    .ima-2fa-recovery-list * {
        visibility: visible;
    }
    .ima-2fa-recovery-list {
        position: absolute;
        top: 0;
        left: 0;
        width: 100%;
        display: grid;
        grid-template-columns: repeat(2, 1fr);
        gap: 12px;
        padding: 24px;
    }
    .ima-2fa-recovery-list li {
        font-size: 14pt;
        border: 1px solid #000;
        background: #fff;
    }
}

/* Plan 04 task 1 (TOTP-FE-03 remainder): link fallback cross-canale OTP. */
.ima-otp-fallback-links {
    margin-top: 16px;
    padding-top: 12px;
    border-top: 1px solid #eee;
    font-size: 0.9em;
}
.ima-otp-fallback-links p {
    margin: 0 0 8px;
    color: #666;
}
.ima-otp-switch-channel {
    display: inline-block;
    margin-right: 12px;
    color: #0073aa;
    text-decoration: underline;
    cursor: pointer;
}
.ima-otp-switch-channel:hover {
    color: #005d8a;
}
.ima-otp-switch-channel.disabled {
    color: #999;
    cursor: wait;
}

/* Plan 05 (TOTP-FE-04): management panel + modal styles. */
.ima-2fa-active-badge {
    display: inline-block;
    padding: 2px 10px;
    background: #28a745;
    color: #fff;
    border-radius: 3px;
    font-size: 0.85em;
    font-weight: 600;
    vertical-align: middle;
    margin: 0 6px;
}

.ima-2fa-preferred-channel {
    margin-top: 20px;
    padding-top: 16px;
    border-top: 1px solid #eee;
}
.ima-2fa-radio-group {
    display: flex;
    flex-wrap: wrap;
    gap: 16px;
    margin: 12px 0 8px;
}
.ima-2fa-radio-label {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    cursor: pointer;
    font-weight: 500;
}
.ima-2fa-radio-label input[type="radio"] {
    margin: 0;
}
.ima-2fa-preferred-status {
    margin-top: 8px;
    font-size: 0.9em;
}
.ima-2fa-preferred-status--ok {
    color: #2d6a32;
}
.ima-2fa-preferred-status--err {
    color: #b00020;
}

.ima-2fa-actions-list {
    margin-top: 20px;
    padding-top: 16px;
    border-top: 1px solid #eee;
}
.ima-2fa-actions-list button {
    margin-right: 10px;
    margin-bottom: 8px;
}

.button-danger,
.ima-2fa-container .button-danger {
    background: #dc3545 !important;
    color: #fff !important;
    border-color: #c82333 !important;
}
.button-danger:hover:not(:disabled),
.ima-2fa-container .button-danger:hover:not(:disabled) {
    background: #c82333 !important;
}

/* Modal overlay + content (Plan 05). */
.ima-2fa-modal {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.55);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 9999;
    padding: 16px;
}
.ima-2fa-modal[hidden] {
    display: none;
}
.ima-2fa-modal-content {
    background: #fff;
    padding: 24px;
    border-radius: 8px;
    max-width: 520px;
    width: 100%;
    max-height: 90vh;
    overflow-y: auto;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.25);
}
.ima-2fa-modal-content h3 {
    margin-top: 0;
}
.ima-2fa-modal-content label {
    display: block;
    margin-top: 14px;
    font-weight: 600;
}
.ima-2fa-modal-content input[type="password"],
.ima-2fa-modal-content input[type="text"] {
    width: 100%;
    padding: 10px;
    margin-top: 6px;
    box-sizing: border-box;
    border: 1px solid #ccc;
    border-radius: 4px;
    font-size: 15px;
}
.ima-2fa-modal-content input:focus {
    outline: 2px solid #d4af37;
    outline-offset: 1px;
    border-color: #d4af37;
}
.ima-2fa-modal-actions {
    margin-top: 20px;
    display: flex;
    gap: 8px;
    justify-content: flex-end;
    flex-wrap: wrap;
}
.ima-2fa-modal-content .ima-2fa-error {
    color: #b00020;
    margin-top: 10px;
    font-size: 0.95em;
}

/* === Phase 8 Plan 05 (TRUSTED-03) - Trusted Devices self-service === */
.ima-trusted-devices {
    max-width: 900px;
    margin: 24px 0;
    font-size: 15px;
}
.ima-trusted-devices h2 {
    margin-top: 0;
    margin-bottom: 8px;
}
.ima-trusted-help {
    color: #555;
    font-size: 14px;
    margin-bottom: 16px;
}
.ima-trusted-loading {
    color: #888;
    font-style: italic;
    padding: 16px 0;
}
.ima-trusted-error {
    color: #b00020;
    background: #fdecea;
    border: 1px solid #f5c2c0;
    padding: 12px 16px;
    border-radius: 4px;
    margin: 12px 0;
}
.ima-trusted-empty {
    color: #555;
    padding: 24px;
    text-align: center;
    background: #f9f9f9;
    border: 1px dashed #ccc;
    border-radius: 4px;
}
.ima-trusted-table {
    width: 100%;
    border-collapse: collapse;
    margin-top: 8px;
}
.ima-trusted-table th,
.ima-trusted-table td {
    padding: 10px 12px;
    border-bottom: 1px solid #e0e0e0;
    text-align: left;
    vertical-align: middle;
}
.ima-trusted-table th {
    background: #f5f5f5;
    font-weight: 600;
    font-size: 14px;
}
.ima-trusted-badge-current {
    display: inline-block;
    background: #d4af37;
    color: #fff;
    padding: 2px 8px;
    border-radius: 3px;
    font-size: 12px;
    margin-left: 6px;
}
.ima-trusted-revoke-one,
.ima-trusted-revoke-all {
    background: #b00020;
    color: #fff;
    border: 1px solid #8a0019;
    padding: 6px 14px;
    border-radius: 3px;
    cursor: pointer;
    font-size: 14px;
}
.ima-trusted-revoke-one:hover:not([disabled]),
.ima-trusted-revoke-all:hover:not([disabled]) {
    background: #8a0019;
}
.ima-trusted-revoke-one[disabled],
.ima-trusted-revoke-all[disabled] {
    opacity: 0.6;
    cursor: not-allowed;
}
.ima-trusted-revoke-all {
    margin-top: 16px;
}
.ima-trusted-modal-confirm .ima-2fa-modal-content h3 {
    margin-top: 0;
}
.ima-trusted-modal-text {
    margin: 12px 0;
    color: #333;
}
.ima-2fa-cross-link {
    margin-top: 16px;
}
.ima-2fa-cross-link a {
    color: #0073aa;
    text-decoration: none;
}
.ima-2fa-cross-link a:hover {
    text-decoration: underline;
}
.ima-2fa-divider {
    margin: 24px 0 8px;
    border: 0;
    border-top: 1px solid #e0e0e0;
}

