/* --- DESIGN VARIABLES --- */
:root {
    /* DARK THEME (Default) */
    --bg-color: #0f172a;

    /* Neon Orbs for Dark Mode */
    --orb-1: #7c3aed;
    --orb-2: #2563eb;
    --orb-3: #ec4899;

    /* Dark Glass Logic */
    --glass-bg: rgba(17, 25, 40, 0.75);
    --glass-border: rgba(255, 255, 255, 0.125);
    --glass-highlight: rgba(255, 255, 255, 0.1);
    --card-shadow: 0 8px 32px 0 rgba(0, 0, 0, 0.37);

    /* Text & Keys */
    --text-main: #f8fafc;
    --text-muted: #94a3b8;
    --key-bg: rgba(255, 255, 255, 0.05);
    --key-hover: rgba(255, 255, 255, 0.1);
    --key-shadow: 0 4px 6px rgba(0, 0, 0, 0.1);

    --accent: #38bdf8;
    --success: #34d399;
    --error: #f43f5e;
    --icon-bg: rgba(255, 255, 255, 0.05);
}

/* LIGHT THEME OVERRIDES */
body.light-theme {
    --bg-color: #eef2f6;

    /* Pastel Orbs for Light Mode */
    --orb-1: #c4b5fd;
    /* Soft Violet */
    --orb-2: #93c5fd;
    /* Soft Blue */
    --orb-3: #f9a8d4;
    /* Soft Pink */

    /* Light Glass Logic - CRITICAL FIXES */
    --glass-bg: rgba(255, 255, 255, 0.65);
    /* More opaque */
    --glass-border: rgba(255, 255, 255, 0.5);
    /* Inner white glow */
    /* We add a specific border color for light mode on the element itself later */

    --card-shadow:
        0 4px 6px -1px rgba(0, 0, 0, 0.1),
        0 2px 4px -1px rgba(0, 0, 0, 0.06),
        inset 0 0 0 1px rgba(255, 255, 255, 0.7);
    /* Imitate reflection */

    /* High Contrast Text */
    --text-main: #0f172a;
    /* Near Black */
    --text-muted: #475569;
    /* Dark Slate */

    /* Visible Keys */
    --key-bg: rgba(255, 255, 255, 0.7);
    --key-hover: #ffffff;
    --key-shadow: 0 2px 5px rgba(100, 116, 139, 0.15);
    /* Gray shadow */

    --accent: #0ea5e9;
    --success: #10b981;
    --error: #ef4444;
    --icon-bg: rgba(0, 0, 0, 0.05);
}

* {
    box-sizing: border-box;
}

body {
    margin: 0;
    height: 100vh;
    display: flex;
    justify-content: center;
    align-items: center;
    background-color: var(--bg-color);
    font-family: 'Outfit', sans-serif;
    overflow: hidden;
    transition: background-color 0.5s ease;
}

/* --- BACKGROUND ORBS --- */
.background-fx {
    position: absolute;
    width: 100%;
    height: 100%;
    overflow: hidden;
    z-index: 0;
}

.orb {
    position: absolute;
    border-radius: 50%;
    filter: blur(80px);
    opacity: 0.6;
    animation: float 20s infinite ease-in-out;
    transition: background 0.5s ease;
}

.orb-1 {
    width: 400px;
    height: 400px;
    background: var(--orb-1);
    top: -10%;
    left: -10%;
    animation-delay: 0s;
}

.orb-2 {
    width: 300px;
    height: 300px;
    background: var(--orb-2);
    bottom: 10%;
    right: -5%;
    animation-delay: -5s;
}

.orb-3 {
    width: 250px;
    height: 250px;
    background: var(--orb-3);
    bottom: 40%;
    left: 20%;
    animation-delay: -10s;
}

@keyframes float {

    0%,
    100% {
        transform: translate(0, 0) scale(1);
    }

    33% {
        transform: translate(30px, -50px) scale(1.1);
    }

    66% {
        transform: translate(-20px, 20px) scale(0.9);
    }
}

/* --- THEME TOGGLE --- */
.theme-toggle {
    position: absolute;
    top: 30px;
    right: 30px;
    z-index: 100;
    background: var(--glass-bg);
    border: 1px solid var(--glass-border);
    border-radius: 50%;
    width: 50px;
    height: 50px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    color: var(--text-main);
    backdrop-filter: blur(12px);
    box-shadow: var(--card-shadow);
    transition: all 0.3s ease;
}

.theme-toggle:hover {
    transform: scale(1.1) rotate(15deg);
}

/* --- GLASS CARD --- */
.glass-card {
    position: relative;
    z-index: 10;
    width: 360px;
    padding: 40px 30px;

    background: var(--glass-bg);
    border-radius: 28px;
    box-shadow: var(--card-shadow);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);

    /* Border Logic: Dark mode needs light border, Light mode needs dark boundary */
    border: 1px solid var(--glass-border);

    display: flex;
    flex-direction: column;
    align-items: center;
    transition: all 0.3s ease;
}

/* Specific border adjustment for light theme to separate card from white background */
body.light-theme .glass-card {
    border: 1px solid rgba(255, 255, 255, 0.6);
    box-shadow:
        0 10px 40px -10px rgba(0, 0, 0, 0.1),
        inset 0 0 0 1px rgba(255, 255, 255, 0.8);
}

/* --- ICON AREA --- */
.icon-area {
    width: 80px;
    height: 80px;
    border-radius: 50%;
    background: var(--icon-bg);
    border: 1px solid var(--glass-border);
    display: flex;
    justify-content: center;
    align-items: center;
    margin-bottom: 20px;
    color: var(--text-main);
    transition: all 0.4s ease;
    box-shadow: inset 0 0 10px rgba(0, 0, 0, 0.05);
}

.icon-area svg {
    width: 32px;
    height: 32px;
    opacity: 0.9;
}

h2 {
    margin: 0 0 30px 0;
    font-weight: 600;
    font-size: 1rem;
    letter-spacing: 2px;
    text-transform: uppercase;
    color: var(--text-muted);
}

/* --- PIN DOTS --- */
.pin-display {
    display: flex;
    gap: 15px;
    margin-bottom: 35px;
    height: 20px;
    align-items: center;
}

.dot {
    width: 14px;
    height: 14px;
    border-radius: 50%;
    border: 2px solid var(--text-muted);
    background: transparent;
    transition: all 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275);
    opacity: 0.5;
}

.dot.filled {
    background: var(--accent);
    border-color: var(--accent);
    opacity: 1;
    transform: scale(1.1);
    box-shadow: 0 0 15px var(--accent);
}

/* Remove glow in light mode to keep it clean */
body.light-theme .dot.filled {
    box-shadow: none;
}

.dot.error {
    background: var(--error);
    border-color: var(--error);
    opacity: 1;
}

.dot.success {
    background: var(--success);
    border-color: var(--success);
    opacity: 1;
    transform: scale(1.2);
}

/* --- KEYPAD --- */
.keypad {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 16px;
    width: 100%;
}

.key {
    height: 60px;
    border: 1px solid var(--glass-border);
    background: var(--key-bg);
    border-radius: 14px;
    color: var(--text-main);
    font-size: 1.25rem;
    font-weight: 500;
    cursor: pointer;
    outline: none;
    transition: all 0.2s ease;
    display: flex;
    justify-content: center;
    align-items: center;
    user-select: none;
    box-shadow: var(--key-shadow);
}

/* Specific borders for light mode keys */
body.light-theme .key {
    border: 1px solid rgba(255, 255, 255, 1);
}

.key:hover {
    background: var(--key-hover);
    transform: translateY(-2px);
}

.key:active {
    transform: translateY(1px) scale(0.98);
}

.key-submit {
    color: var(--accent);
    font-weight: 700;
}

/* --- STATUS MESSAGE --- */
.status-msg {
    margin-top: 25px;
    min-height: 24px;
    font-size: 0.9rem;
    color: var(--text-muted);
    text-align: center;
    font-weight: 500;
    letter-spacing: 0.5px;
}

/* --- ANIMATIONS --- */
.shake {
    animation: shake 0.4s cubic-bezier(.36, .07, .19, .97) both;
}

@keyframes shake {

    10%,
    90% {
        transform: translate3d(-1px, 0, 0);
    }

    20%,
    80% {
        transform: translate3d(2px, 0, 0);
    }

    30%,
    50%,
    70% {
        transform: translate3d(-4px, 0, 0);
    }

    40%,
    60% {
        transform: translate3d(4px, 0, 0);
    }
}

/* Loading Spinner */
.spinner {
    width: 16px;
    height: 16px;
    border: 2px solid var(--text-muted);
    border-top: 2px solid transparent;
    border-radius: 50%;
    display: inline-block;
    animation: spin 1s linear infinite;
    margin-right: 8px;
    vertical-align: middle;
}

@keyframes spin {
    100% {
        transform: rotate(360deg);
    }
}

.locked-out {
    opacity: 0.6;
    pointer-events: none;
    filter: grayscale(0.8);
}