/* ==========================================================================
   kd-screen-guard: Lock Screen Interface, WebAuthn & Intruder Snapshot Modal
   Theme: Dark Mode (Google Material Standards)
   Mobile Viewport: 100dvh support & Windows Layout Shift Prevention (width: 100%)
   Accessibility: Focus-visible outline indicators
   ========================================================================== */

@import url('https://fonts.googleapis.com/css2?family=Google+Sans:wght@400;500;700&display=swap');

html.kd-body-locked,
body.kd-body-locked {
    overflow: hidden !important;
    height: 100% !important;
    touch-action: none !important;
}

body.kd-body-locked > *:not(#kd-lock-screen):not(#kd-intruder-modal):not(script):not(style) {
    user-select: none !important;
    -webkit-user-select: none !important;
    pointer-events: none !important;
}

.kd-lock-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    width: 100%;
    height: 100vh;
    height: 100dvh;
    min-height: 100%;
    background-color: rgba(0, 0, 0, 0.55);
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
    z-index: 9999999 !important;
    display: flex;
    align-items: center;
    justify-content: center;
    font-family: 'Google Sans', Roboto, Arial, sans-serif;
    box-sizing: border-box;
    pointer-events: auto !important;
    overflow-y: auto;
    padding: 20px;
    -webkit-overflow-scrolling: touch;
}

/* --- Main Panel Component --- */

.kd-lock-panel {
    width: 90%;
    max-width: 420px;
    padding: 32px;
    border-radius: 24px;
    background-color: #1e1f20;
    color: #e3e3e3;
    border: 1px solid #444746;
    text-align: center;
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.4);
    transform: scale(0.95);
    opacity: 0;
    animation: kd-lock-fadein 0.3s cubic-bezier(0.05, 0.7, 0.1, 1.0) forwards;
    overflow: visible;
    margin: auto;
}

.kd-lock-panel:focus {
    outline: none;
}

@keyframes kd-lock-fadein {
    to {
        transform: scale(1);
        opacity: 1;
    }
}

.kd-lock-panel h2 {
    font-size: 22px;
    font-weight: 700;
    margin-top: 0;
    margin-bottom: 8px;
    color: #e3e3e3;
}

.kd-lock-panel p {
    font-size: 14px;
    color: #c4c7c5;
    margin-bottom: 28px;
    line-height: 1.5;
}

/* --- Form Elements --- */

.kd-lock-input-container {
    margin-bottom: 4px;
    text-align: left;
    position: relative;
}

.kd-lock-input {
    width: 100%;
    height: 56px;
    padding: 16px;
    font-size: 16px;
    border: 1px solid #8e918f;
    border-radius: 12px;
    background-color: #2a2b2e;
    box-sizing: border-box;
    transition: border-color 0.2s ease, box-shadow 0.2s ease;
    color: #e3e3e3;
}

.kd-lock-input:focus {
    outline: none;
    border: 2px solid #a8c7fa;
    padding: 15px;
}

.kd-lock-button {
    width: 80%;
    height: 48px;
    padding: 10px 24px;
    font-size: 15px;
    font-weight: 500;
    letter-spacing: .5px;
    border-radius: 24px;
    border: none;
    cursor: pointer;
    background-color: #a8c7fa;
    color: #202124;
    transition: all 0.2s ease;
}

.kd-lock-button:hover {
    box-shadow: 0 1px 3px 1px rgba(0, 0, 0, .15), 0 1px 2px rgba(0, 0, 0, .3);
    background-color: #c3d8fc;
}

.kd-lock-button:focus-visible {
    outline: 2px solid #a8c7fa;
    outline-offset: 2px;
}

.kd-btn-webauthn {
    width: 80%;
    height: 44px;
    padding: 8px 20px;
    font-size: 14px;
    font-weight: 500;
    border-radius: 22px;
    border: 1px solid #8e918f;
    background: transparent;
    color: #a8c7fa;
    cursor: pointer;
    margin-top: 10px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    transition: background-color 0.2s ease, border-color 0.2s ease;
}

.kd-btn-webauthn:hover {
    background-color: rgba(168, 199, 250, 0.12);
    border-color: #a8c7fa;
}

.kd-btn-webauthn:focus-visible {
    outline: 2px solid #a8c7fa;
    outline-offset: 2px;
}

.kd-lock-error {
    color: #d93025;
    font-size: 14px;
    min-height: 18px;
    text-align: left;
    padding: 2px 4px;
    margin-bottom: 12px;
}

.kd-lock-forgot-link {
    font-size: 14px;
    font-weight: 500;
    color: #a8c7fa;
    cursor: pointer;
    margin-top: 12px;
    display: inline-block;
    background: none;
    border: none;
    padding: 10px 16px;
    font-family: inherit;
    border-radius: 20px;
    transition: background-color 0.2s ease;
}

.kd-lock-forgot-link:hover {
    background-color: rgba(168, 199, 250, 0.12);
}

.kd-lock-forgot-link:focus-visible {
    outline: 2px solid #a8c7fa;
    outline-offset: 2px;
}

.kd-lock-forgot-link:disabled {
    color: #9e9e9e;
    cursor: not-allowed;
    opacity: 0.6;
}

.kd-lock-forgot-link:disabled:hover {
    background-color: transparent !important;
}

/* --- View Management & Animations --- */

.kd-lock-panel .kd-view {
    display: none;
}

.kd-lock-panel .kd-view.active {
    display: block;
    animation: kd-view-fadein 0.3s ease;
}

@keyframes kd-view-fadein {
    from {
        opacity: 0;
        transform: translateY(5px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* --- Interactive Components (Password Toggle) --- */

.kd-password-toggle {
    position: absolute;
    top: 50%;
    right: 12px;
    transform: translateY(-50%);
    background: none;
    border: none;
    cursor: pointer;
    padding: 6px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
    color: #8e918f;
}

.kd-password-toggle:hover {
    background-color: rgba(255, 255, 255, 0.08);
    color: #a8c7fa;
}

.kd-password-toggle:focus-visible {
    outline: 2px solid #a8c7fa;
    outline-offset: 2px;
}

.kd-password-toggle svg {
    width: 24px;
    height: 24px;
}

.kd-password-toggle .kd-eye-icon-slashed,
.kd-password-toggle.show-password .kd-eye-icon {
    display: none;
}

.kd-password-toggle.show-password .kd-eye-icon-slashed {
    display: block;
}

/* --- Header Controls --- */

.kd-header-lock-btn {
    background: none;
    border: none;
    cursor: pointer;
    color: inherit;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 8px;
    border-radius: 50%;
}

.kd-header-lock-btn:focus-visible {
    outline: 2px solid #a8c7fa;
    outline-offset: 2px;
}

.kd-header-lock-btn svg {
    width: 23px;
    height: 23px;
}

#kd-view-reset .kd-lock-input-container:first-of-type {
    margin-bottom: 16px;
}

/* --- Intruder Snapshot Review Modal --- */

.kd-intruder-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    width: 100%;
    height: 100vh;
    height: 100dvh;
    background-color: rgba(0, 0, 0, 0.75);
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
    z-index: 10000000 !important;
    display: flex;
    align-items: center;
    justify-content: center;
    font-family: 'Google Sans', Roboto, Arial, sans-serif;
    padding: 20px;
    box-sizing: border-box;
    animation: kd-lock-fadein 0.3s ease;
}

.kd-intruder-panel {
    width: 90%;
    max-width: 440px;
    padding: 28px;
    border-radius: 24px;
    background-color: #1e1f20;
    color: #e3e3e3;
    border: 1px solid #f2b8b5;
    text-align: center;
    box-shadow: 0 12px 32px rgba(0, 0, 0, 0.6);
}

.kd-intruder-badge {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    background-color: rgba(242, 184, 181, 0.15);
    color: #f2b8b5;
    font-size: 13px;
    font-weight: 500;
    padding: 6px 14px;
    border-radius: 16px;
    margin-bottom: 16px;
}

.kd-intruder-panel h3 {
    font-size: 20px;
    font-weight: 700;
    margin: 0 0 8px 0;
    color: #f2b8b5;
}

.kd-intruder-panel p {
    font-size: 14px;
    color: #c4c7c5;
    margin: 0 0 20px 0;
    line-height: 1.4;
}

.kd-intruder-img-container {
    width: 100%;
    max-height: 260px;
    border-radius: 16px;
    overflow: hidden;
    margin-bottom: 20px;
    border: 2px solid #444746;
    background-color: #000;
}

.kd-intruder-img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
}

.kd-intruder-actions {
    display: flex;
    gap: 12px;
    justify-content: center;
}

.kd-btn-download {
    flex: 1;
    height: 44px;
    border-radius: 22px;
    border: none;
    background-color: #a8c7fa;
    color: #001d35;
    font-weight: 500;
    font-size: 14px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    transition: background-color 0.2s ease;
}

.kd-btn-download:hover {
    background-color: #c3d8fc;
}

.kd-btn-dismiss {
    flex: 1;
    height: 44px;
    border-radius: 22px;
    border: 1px solid #8e918f;
    background: transparent;
    color: #e3e3e3;
    font-weight: 500;
    font-size: 14px;
    cursor: pointer;
    transition: background-color 0.2s ease;
}

.kd-btn-dismiss:hover {
    background-color: rgba(255, 255, 255, 0.08);
}
