/* Pattern Lock Overlay - Full Screen Authentication */

.pattern-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.92);
    backdrop-filter: blur(10px);
    z-index: 9999;
    display: flex;
    justify-content: center;
    align-items: center;
    opacity: 1;
    transition: opacity 0.3s ease;
}

.pattern-overlay.hidden {
    display: none;
    opacity: 0;
}

.pattern-box {
    background: linear-gradient(135deg, rgba(255, 255, 255, 0.98), rgba(250, 250, 255, 0.98));
    padding: 3rem 2rem;
    border-radius: 28px;
    width: 90%;
    max-width: 420px;
    text-align: center;
    box-shadow: 0 25px 80px rgba(102, 126, 234, 0.4);
    position: relative;
    user-select: none;
    -webkit-user-select: none;
    border: 2px solid rgba(102, 126, 234, 0.3);
    
    /* PERFECT CENTERING */
    display: flex;
    flex-direction: column;
    align-items: center;
}

.pattern-box h2 {
    color: #667eea;
    margin-bottom: 2rem;
    font-size: 1.8rem;
    font-weight: 700;
    user-select: none;
    text-shadow: 0 2px 10px rgba(102, 126, 234, 0.2);
}

/* Pattern Grid Container - PERFECTLY CENTERED */
.pattern-container {
    position: relative;
    width: 300px; /* Fixed width for perfect control */
    height: 300px;
    
    /* FORCE CENTER */
    display: flex;
    justify-content: center;
    align-items: center;
}

#patternCanvas {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
    z-index: 1;
}

#patternGrid {
    position: relative;
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    grid-template-rows: repeat(3, 1fr);
    gap: 30px;
    width: 100%;
    height: 100%;
    z-index: 2;
    
    /* ENSURE PERFECT CENTERING */
    place-items: center;
}

/* Pattern Dots - More Colorful */
.dot {
    width: 70px;
    height: 70px;
    border-radius: 50%;
    border: 4px solid #667eea;
    background: linear-gradient(135deg, rgba(255, 255, 255, 0.95), rgba(240, 240, 255, 0.95));
    cursor: pointer;
    transition: all 0.25s cubic-bezier(0.4, 0, 0.2, 1);
    position: relative;
    box-shadow: 0 2px 8px rgba(102, 126, 234, 0.15);
}

.dot::before {
    content: '';
    position: absolute;
    width: 18px;
    height: 18px;
    background: linear-gradient(135deg, #667eea, #764ba2);
    border-radius: 50%;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    opacity: 0.5;
}

.dot:hover {
    transform: scale(1.05);
    border-color: #764ba2;
}

.dot.active {
    background: linear-gradient(135deg, #667eea, #764ba2);
    border-color: #764ba2;
    transform: scale(1.2);
    box-shadow: 0 6px 20px rgba(102, 126, 234, 0.6),
                0 0 30px rgba(118, 75, 162, 0.4);
    animation: pulse 0.3s ease-out;
}

@keyframes pulse {
    0% { transform: scale(1); }
    50% { transform: scale(1.25); }
    100% { transform: scale(1.2); }
}

.dot.active::before {
    background: white;
    opacity: 1;
    width: 24px;
    height: 24px;
    box-shadow: 0 0 10px rgba(255, 255, 255, 0.8);
}

/* Error Message - HIDDEN (backend handles it) */
#patternError {
    display: none; /* Completely hidden */
}

/* Responsive Design */
@media (max-width: 480px) {
    .pattern-box {
        padding: 2.5rem 1.5rem;
        max-width: 95%;
    }

    .pattern-box h2 {
        font-size: 1.5rem;
        margin-bottom: 1.5rem;
    }

    .pattern-container {
        width: 260px;
        height: 260px;
    }

    #patternGrid {
        gap: 25px;
    }

    .dot {
        width: 60px;
        height: 60px;
        border-width: 3px;
    }

    .dot::before {
        width: 16px;
        height: 16px;
    }

    .dot.active::before {
        width: 20px;
        height: 20px;
    }
}

@media (max-width: 360px) {
    .pattern-container {
        width: 240px;
        height: 240px;
    }

    #patternGrid {
        gap: 20px;
    }

    .dot {
        width: 55px;
        height: 55px;
    }
}

/* Error state for wrong pattern */
.dot.error {
    background: linear-gradient(135deg, #e74c3c, #c0392b) !important;
    border-color: #c0392b !important;
    box-shadow: 0 6px 20px rgba(231, 76, 60, 0.6),
                0 0 30px rgba(192, 57, 43, 0.4) !important;
}

.dot.error::before {
    background: white !important;
}

/* Error Message */
#patternError {
    color: #e74c3c;
    margin-top: 1.8rem;
    font-size: 1rem;
    font-weight: 600;
    min-height: 24px;
    text-shadow: 0 1px 3px rgba(231, 76, 60, 0.3);
}

#patternError.hidden {
    display: none;
}