/*
 * Gradia POS — Biometric / Fingerprint UI
 * Covers: login page biometric button, fingerprint overlay modal,
 *         enrollment modal, manager override modal, shift clock-in
 *         modal, switch-user modal, admin settings tab panel.
 * Mobile-first, uses existing --p9-* CSS variables.
 */

/* ── Shared: fingerprint icon animation ─────────────────────── */

.grdpos-fp-icon {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 80px;
    height: 80px;
    border-radius: 50%;
    background: rgba(var(--p9-accent-rgb, 0,140,255), .12);
    margin: 0 auto 18px;
    transition: background .3s;
    flex-shrink: 0;
}

.grdpos-fp-icon svg {
    width: 40px;
    height: 40px;
    stroke: var(--p9-accent-1, #008cff);
    transition: stroke .3s;
}

.grdpos-fp-icon.scanning {
    background: rgba(var(--p9-accent-rgb, 0,140,255), .22);
    animation: grdposFpPulse 1.2s ease-in-out infinite;
}

.grdpos-fp-icon.success {
    background: rgba(22, 163, 74, .15);
}

.grdpos-fp-icon.success svg {
    stroke: #16a34a;
}

.grdpos-fp-icon.error {
    background: rgba(239, 68, 68, .15);
}

.grdpos-fp-icon.error svg {
    stroke: #ef4444;
}

@keyframes grdposFpPulse {
    0%   { box-shadow: 0 0 0 0   rgba(var(--p9-accent-rgb, 0,140,255), .4); }
    60%  { box-shadow: 0 0 0 14px rgba(var(--p9-accent-rgb, 0,140,255), 0); }
    100% { box-shadow: 0 0 0 0   rgba(var(--p9-accent-rgb, 0,140,255), 0); }
}

/* ── Shared: full-screen overlay backdrop ──────────────────── */

.grdpos-bio-overlay {
    position: fixed;
    inset: 0;
    z-index: 99990;
    background: rgba(0, 0, 0, .72);
    backdrop-filter: blur(6px);
    -webkit-backdrop-filter: blur(6px);
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 16px;
    opacity: 0;
    pointer-events: none;
    transition: opacity .22s;
}

.grdpos-bio-overlay.visible {
    opacity: 1;
    pointer-events: all;
}

/* ── Shared: modal card ─────────────────────────────────────── */

.grdpos-bio-card {
    background: var(--p9-panel, #fff);
    border-radius: 20px;
    padding: 32px 28px 28px;
    width: 100%;
    max-width: 380px;
    box-shadow: 0 24px 60px rgba(0,0,0,.28), 0 4px 16px rgba(0,0,0,.14);
    text-align: center;
    position: relative;
    transform: translateY(16px) scale(.97);
    transition: transform .22s cubic-bezier(.34,1.56,.64,1);
}

.grdpos-bio-overlay.visible .grdpos-bio-card {
    transform: translateY(0) scale(1);
}

.grdpos-bio-card-title {
    font-size: 17px;
    font-weight: 700;
    color: var(--p9-text, #0f172a);
    margin-bottom: 6px;
    line-height: 1.3;
}

.grdpos-bio-card-sub {
    font-size: 13px;
    color: var(--p9-muted, #64748b);
    margin-bottom: 22px;
    line-height: 1.5;
}

.grdpos-bio-close-btn {
    position: absolute;
    top: 14px;
    right: 14px;
    background: var(--p9-surface, #f1f5f9);
    border: none;
    border-radius: 50%;
    width: 30px;
    height: 30px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    color: var(--p9-muted, #64748b);
    font-size: 16px;
    line-height: 1;
    transition: background .15s, color .15s;
    flex-shrink: 0;
}

.grdpos-bio-close-btn:hover {
    background: #fee2e2;
    color: #ef4444;
}

/* ── Status message inside modal ────────────────────────────── */

.grdpos-bio-status {
    font-size: 13px;
    font-weight: 600;
    min-height: 20px;
    margin-bottom: 14px;
    transition: color .2s;
    color: var(--p9-muted, #64748b);
}

.grdpos-bio-status.scanning { color: var(--p9-accent-1, #008cff); }
.grdpos-bio-status.success  { color: #16a34a; }
.grdpos-bio-status.error    { color: #ef4444; }

/* ── Action buttons inside modals ───────────────────────────── */

.grdpos-bio-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    width: 100%;
    padding: 13px 18px;
    border: none;
    border-radius: 12px;
    font-size: 14px;
    font-weight: 700;
    font-family: inherit;
    cursor: pointer;
    transition: opacity .15s, transform .1s;
    margin-top: 8px;
}

.grdpos-bio-btn:active { transform: scale(.98); }

.grdpos-bio-btn-primary {
    background: linear-gradient(135deg, var(--p9-accent-1, #008cff) 0%, #000 100%);
    color: #fff;
    box-shadow: 0 4px 14px rgba(var(--p9-accent-rgb,0,140,255),.35);
}

.grdpos-bio-btn-primary:hover:not(:disabled) { opacity: .88; }
.grdpos-bio-btn-primary:disabled { opacity: .5; cursor: not-allowed; }

.grdpos-bio-btn-secondary {
    background: var(--p9-surface, #f1f5f9);
    color: var(--p9-text, #0f172a);
    border: 1.5px solid var(--p9-border, rgba(0,0,0,.08));
}

.grdpos-bio-btn-secondary:hover:not(:disabled) {
    background: var(--p9-bg, #f8fafc);
}

.grdpos-bio-btn-danger {
    background: #fee2e2;
    color: #b91c1c;
}

.grdpos-bio-btn-danger:hover { background: #fecaca; }

.grdpos-bio-divider {
    display: flex;
    align-items: center;
    gap: 10px;
    margin: 14px 0 6px;
    color: var(--p9-muted, #64748b);
    font-size: 11px;
    text-transform: uppercase;
    letter-spacing: .5px;
}

.grdpos-bio-divider::before,
.grdpos-bio-divider::after {
    content: '';
    flex: 1;
    height: 1px;
    background: var(--p9-border, rgba(0,0,0,.08));
}

/* ── Spinner inside button ──────────────────────────────────── */

.grdpos-bio-spinner {
    width: 16px;
    height: 16px;
    border: 2.5px solid rgba(255,255,255,.35);
    border-top-color: #fff;
    border-radius: 50%;
    animation: grdposBioSpin .7s linear infinite;
    flex-shrink: 0;
}

.grdpos-bio-spinner-dark {
    border-color: rgba(0,0,0,.15);
    border-top-color: var(--p9-accent-1, #008cff);
}

@keyframes grdposBioSpin {
    to { transform: rotate(360deg); }
}

/* ═══════════════════════════════════════════════════════════════
   LOGIN PAGE — fingerprint button addition
   ═══════════════════════════════════════════════════════════════ */

.grdpos-bio-login-wrap {
    margin-top: 14px;
}

.grdpos-bio-login-btn {
    width: 100%;
    padding: 13px 18px;
    border: 1.5px solid var(--p9-border, rgba(0,0,0,.12));
    border-radius: 12px;
    background: rgba(255,255,255,.08);
    color: rgba(255,255,255,.85);
    font-size: 14px;
    font-weight: 600;
    font-family: inherit;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
    transition: background .18s, border-color .18s;
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
}

.grdpos-bio-login-btn:hover {
    background: rgba(255,255,255,.14);
    border-color: rgba(255,255,255,.28);
}

.grdpos-bio-login-btn svg {
    flex-shrink: 0;
}

/* ═══════════════════════════════════════════════════════════════
   ENROLLMENT MODAL
   ═══════════════════════════════════════════════════════════════ */

#grdpos-enroll-modal .grdpos-bio-card {
    max-width: 420px;
    text-align: left;
}

.grdpos-enroll-step {
    display: none;
}

.grdpos-enroll-step.active {
    display: block;
}

.grdpos-enroll-cred-list {
    margin: 14px 0 0;
    display: flex;
    flex-direction: column;
    gap: 8px;
    max-height: 220px;
    overflow-y: auto;
}

.grdpos-enroll-cred-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
    padding: 10px 14px;
    background: var(--p9-surface, #f1f5f9);
    border-radius: 10px;
    border: 1px solid var(--p9-border, rgba(0,0,0,.07));
}

.grdpos-enroll-cred-info {
    display: flex;
    align-items: center;
    gap: 10px;
    flex: 1;
    min-width: 0;
}

.grdpos-enroll-cred-info svg {
    flex-shrink: 0;
    color: var(--p9-accent-1, #008cff);
}

.grdpos-enroll-cred-label {
    font-size: 13px;
    font-weight: 600;
    color: var(--p9-text, #0f172a);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.grdpos-enroll-cred-date {
    font-size: 11px;
    color: var(--p9-muted, #64748b);
    margin-top: 1px;
}

.grdpos-enroll-cred-remove {
    background: #fee2e2;
    border: none;
    border-radius: 8px;
    width: 30px;
    height: 30px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    color: #b91c1c;
    flex-shrink: 0;
    transition: background .15s;
}

.grdpos-enroll-cred-remove:hover { background: #fecaca; }

.grdpos-enroll-label-field {
    width: 100%;
    padding: 11px 14px;
    border: 1.5px solid var(--p9-border, rgba(0,0,0,.1));
    border-radius: 10px;
    font-size: 14px;
    font-family: inherit;
    background: var(--p9-surface, #f8fafc);
    color: var(--p9-text, #0f172a);
    outline: none;
    transition: border-color .2s;
    margin-top: 10px;
}

.grdpos-enroll-label-field:focus {
    border-color: var(--p9-accent-1, #008cff);
    box-shadow: 0 0 0 3px rgba(var(--p9-accent-rgb,0,140,255),.14);
}

.grdpos-enroll-empty {
    text-align: center;
    padding: 20px 0;
    color: var(--p9-muted, #64748b);
    font-size: 13px;
}

/* ═══════════════════════════════════════════════════════════════
   SETTINGS TAB — Biometrics panel in admin / account modal
   ═══════════════════════════════════════════════════════════════ */

.grdpos-bio-settings-panel {
    padding: 4px 0;
}

.grdpos-bio-setting-row {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 16px;
    padding: 14px 0;
    border-bottom: 1px solid var(--p9-border, rgba(0,0,0,.07));
}

.grdpos-bio-setting-row:last-child {
    border-bottom: none;
}

.grdpos-bio-setting-info {
    flex: 1;
    min-width: 0;
}

.grdpos-bio-setting-label {
    font-size: 13px;
    font-weight: 600;
    color: var(--p9-text, #0f172a);
    margin-bottom: 2px;
}

.grdpos-bio-setting-desc {
    font-size: 12px;
    color: var(--p9-muted, #64748b);
    line-height: 1.4;
}

/* Toggle switch */
.grdpos-bio-toggle {
    position: relative;
    width: 42px;
    height: 24px;
    flex-shrink: 0;
    margin-top: 2px;
}

.grdpos-bio-toggle input {
    opacity: 0;
    width: 0;
    height: 0;
    position: absolute;
}

.grdpos-bio-toggle-track {
    position: absolute;
    inset: 0;
    background: #d1d5db;
    border-radius: 24px;
    cursor: pointer;
    transition: background .2s;
}

.grdpos-bio-toggle input:checked + .grdpos-bio-toggle-track {
    background: var(--p9-accent-1, #008cff);
}

.grdpos-bio-toggle-track::after {
    content: '';
    position: absolute;
    width: 18px;
    height: 18px;
    border-radius: 50%;
    background: #fff;
    top: 3px;
    left: 3px;
    transition: transform .2s;
    box-shadow: 0 1px 4px rgba(0,0,0,.2);
}

.grdpos-bio-toggle input:checked + .grdpos-bio-toggle-track::after {
    transform: translateX(18px);
}

.grdpos-bio-toggle input:disabled + .grdpos-bio-toggle-track {
    opacity: .45;
    cursor: not-allowed;
}

/* Save button for settings */
.grdpos-bio-settings-save {
    margin-top: 18px;
    width: 100%;
    padding: 12px;
    border: none;
    border-radius: 12px;
    background: linear-gradient(135deg, var(--p9-accent-1, #008cff) 0%, #000 100%);
    color: #fff;
    font-size: 14px;
    font-weight: 700;
    font-family: inherit;
    cursor: pointer;
    transition: opacity .15s;
}

.grdpos-bio-settings-save:hover { opacity: .88; }

.grdpos-bio-settings-msg {
    font-size: 12px;
    margin-top: 8px;
    text-align: center;
    min-height: 18px;
}

.grdpos-bio-settings-msg.success { color: #16a34a; }
.grdpos-bio-settings-msg.error   { color: #ef4444; }

/* ── Admin settings tab (inside WP admin class-settings.php) ── */

.grdpos-bio-admin-wrap {
    padding: 8px 0;
}

.grdpos-bio-admin-wrap .grdpos-bio-setting-row {
    padding: 16px 0;
}

/* Staff row biometric badge */
.grdpos-bio-enrolled-badge {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    font-size: 11px;
    font-weight: 600;
    padding: 2px 8px;
    border-radius: 20px;
    background: rgba(22,163,74,.12);
    color: #15803d;
}

.grdpos-bio-not-enrolled {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    font-size: 11px;
    color: #9ca3af;
}

/* ═══════════════════════════════════════════════════════════════
   SWITCH USER MODAL — cashier list picker
   ═══════════════════════════════════════════════════════════════ */

#grdpos-switch-user-modal .grdpos-bio-card {
    max-width: 400px;
    text-align: left;
}

.grdpos-switch-user-list {
    display: flex;
    flex-direction: column;
    gap: 8px;
    max-height: 280px;
    overflow-y: auto;
    margin: 14px 0 4px;
}

.grdpos-switch-user-row {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 11px 14px;
    background: var(--p9-surface, #f1f5f9);
    border-radius: 12px;
    border: 1.5px solid var(--p9-border, rgba(0,0,0,.07));
    cursor: pointer;
    transition: border-color .15s, background .15s;
    -webkit-tap-highlight-color: transparent;
}

.grdpos-switch-user-row:hover,
.grdpos-switch-user-row:focus {
    border-color: var(--p9-accent-1, #008cff);
    background: rgba(var(--p9-accent-rgb,0,140,255),.06);
    outline: none;
}

.grdpos-switch-user-avatar {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    background: linear-gradient(135deg, var(--p9-accent-1,#008cff) 0%, #000 100%);
    display: flex;
    align-items: center;
    justify-content: center;
    color: #fff;
    font-size: 13px;
    font-weight: 700;
    flex-shrink: 0;
}

.grdpos-switch-user-name {
    font-size: 13px;
    font-weight: 600;
    color: var(--p9-text, #0f172a);
}

.grdpos-switch-user-role {
    font-size: 11px;
    color: var(--p9-muted, #64748b);
    margin-top: 1px;
}

.grdpos-switch-user-fp {
    margin-left: auto;
    flex-shrink: 0;
}

/* ═══════════════════════════════════════════════════════════════
   MOBILE RESPONSIVE
   ═══════════════════════════════════════════════════════════════ */

@media (max-width: 480px) {
    .grdpos-bio-card {
        padding: 24px 18px 20px;
        border-radius: 16px;
        max-width: 100%;
    }

    .grdpos-bio-card-title {
        font-size: 16px;
    }

    .grdpos-fp-icon {
        width: 68px;
        height: 68px;
    }

    .grdpos-fp-icon svg {
        width: 34px;
        height: 34px;
    }

    .grdpos-bio-btn {
        padding: 12px 14px;
        font-size: 13.5px;
    }

    .grdpos-enroll-cred-list,
    .grdpos-switch-user-list {
        max-height: 200px;
    }

    #grdpos-enroll-modal .grdpos-bio-card,
    #grdpos-switch-user-modal .grdpos-bio-card {
        max-width: 100%;
    }
}

/* Dark mode overrides */
.gradia-pos-dark .grdpos-bio-card {
    background: rgba(15,23,42,.96);
    border: 1px solid rgba(255,255,255,.1);
}

.gradia-pos-dark .grdpos-bio-login-btn {
    background: rgba(255,255,255,.07);
    border-color: rgba(255,255,255,.14);
    color: rgba(255,255,255,.8);
}

.gradia-pos-dark .grdpos-enroll-label-field {
    background: rgba(255,255,255,.06);
    border-color: rgba(255,255,255,.12);
    color: #e2e8f0;
}

.gradia-pos-dark .grdpos-enroll-cred-row,
.gradia-pos-dark .grdpos-switch-user-row {
    background: rgba(255,255,255,.05);
    border-color: rgba(255,255,255,.1);
}

.gradia-pos-dark .grdpos-bio-toggle-track {
    background: rgba(255,255,255,.2);
}

.gradia-pos-dark .grdpos-bio-setting-row {
    border-bottom-color: rgba(255,255,255,.07);
}

/* ================================================================
   PIN MODAL — AUTH TAB SELECTOR
   ================================================================ */
.p9-pin-auth-tabs {
    display: flex;
    background: var(--p9-surface, rgba(255,255,255,.08));
    border-radius: 12px;
    padding: 3px;
    margin: 14px 0 18px;
    gap: 3px;
}
.p9-pin-auth-tab {
    flex: 1;
    padding: 9px 10px;
    border: none;
    border-radius: 10px;
    background: transparent;
    color: var(--p9-muted, rgba(255,255,255,.5));
    font-size: 12.5px;
    font-weight: 600;
    font-family: inherit;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    transition: all .18s;
    -webkit-tap-highlight-color: transparent;
}
.p9-pin-auth-tab.active {
    background: var(--p9-accent-1, #008cff);
    color: #fff;
    box-shadow: 0 2px 8px rgba(0,140,255,.3);
}
.p9-pin-auth-tab svg { flex-shrink: 0; }

/* ── PIN modal biometric panel ─────────────────────────────── */
.p9-pin-bio-icon {
    width: 80px;
    height: 80px;
    border-radius: 50%;
    background: rgba(var(--p9-accent-rgb,0,140,255),.12);
    display: flex;
    align-items: center;
    justify-content: center;
    margin: 0 auto 12px;
    color: var(--p9-accent-1, #008cff);
    transition: background .3s;
}
.p9-pin-bio-icon.scanning {
    background: rgba(var(--p9-accent-rgb,0,140,255),.2);
    animation: grdposFpPulse 1.2s ease-in-out infinite;
}
.p9-pin-bio-icon.success { background: rgba(22,163,74,.15); color: #16a34a; }
.p9-pin-bio-icon.error   { background: rgba(239,68,68,.15); color: #ef4444; }

.p9-pin-bio-hint {
    font-size: 13px;
    color: var(--p9-muted, #64748b);
    text-align: center;
    margin-bottom: 4px;
    line-height: 1.4;
}
.p9-pin-bio-attempts {
    font-size: 12px;
    color: #ef4444;
    text-align: center;
    font-weight: 600;
    margin: 6px 0;
}
.p9-pin-bio-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 100%;
    padding: 12px 16px;
    margin-top: 10px;
    border: none;
    border-radius: 12px;
    background: linear-gradient(135deg, var(--p9-accent-1, #008cff) 0%, #000 100%);
    color: #fff;
    font-size: 14px;
    font-weight: 700;
    font-family: inherit;
    cursor: pointer;
    transition: opacity .15s;
    box-shadow: 0 3px 12px rgba(0,140,255,.3);
}
.p9-pin-bio-btn:hover:not(:disabled) { opacity: .88; }
.p9-pin-bio-btn:disabled { opacity: .5; cursor: not-allowed; }

/* ── Account modal Fingerprint section ─────────────────────── */
.p9-acct-bio-section {
    margin-top: 4px;
}
.p9-acct-bio-cred-list {
    display: flex;
    flex-direction: column;
    gap: 8px;
    margin: 12px 0;
    max-height: 200px;
    overflow-y: auto;
}
.p9-acct-bio-cred-row {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px 12px;
    background: var(--p9-bg, #f8fafc);
    border-radius: 10px;
    border: 1px solid var(--p9-border, rgba(0,0,0,.07));
}
.p9-acct-bio-cred-info { flex: 1; min-width: 0; }
.p9-acct-bio-cred-name { font-size: 13px; font-weight: 600; color: var(--p9-text, #0f172a); }
.p9-acct-bio-cred-date { font-size: 11px; color: var(--p9-muted, #64748b); margin-top: 1px; }
.p9-acct-bio-cred-del {
    background: #fee2e2;
    border: none;
    border-radius: 8px;
    width: 28px;
    height: 28px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    color: #b91c1c;
    flex-shrink: 0;
    transition: background .15s;
}
.p9-acct-bio-cred-del:hover { background: #fecaca; }
.p9-acct-bio-empty {
    text-align: center;
    padding: 16px 0;
    color: var(--p9-muted, #64748b);
    font-size: 13px;
}

/* Staff fingerprint management (shop manager only) */
.p9-acct-bio-staff-section { margin-top: 16px; }
.p9-acct-bio-staff-row {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 9px 12px;
    background: var(--p9-bg, #f8fafc);
    border-radius: 10px;
    border: 1px solid var(--p9-border, rgba(0,0,0,.07));
    margin-bottom: 7px;
}
.p9-acct-bio-staff-avatar {
    width: 30px; height: 30px; border-radius: 50%;
    background: linear-gradient(135deg, var(--p9-accent-1,#008cff) 0%, #000 100%);
    display: flex; align-items: center; justify-content: center;
    color: #fff; font-size: 11px; font-weight: 700; flex-shrink: 0;
}
.p9-acct-bio-staff-info { flex: 1; min-width: 0; }
.p9-acct-bio-staff-name { font-size: 12px; font-weight: 600; color: var(--p9-text, #0f172a); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.p9-acct-bio-staff-role { font-size: 10px; color: var(--p9-muted, #64748b); }
.p9-acct-bio-staff-btn {
    padding: 4px 10px; border-radius: 8px;
    border: 1px solid var(--p9-border,rgba(0,0,0,.1));
    background: var(--p9-card,#fff); font-size: 11px; font-weight: 600;
    color: var(--p9-accent-1,#008cff); cursor: pointer; font-family: inherit;
    transition: background .15s; white-space: nowrap; flex-shrink: 0;
}
.p9-acct-bio-staff-btn:hover { background: rgba(0,140,255,.06); }

/* ── Spinner for loading states ─────────────────────── */
@keyframes p9BioSpin {
    to { transform: rotate(360deg); }
}
