html, body {
    touch-action: none;
}

body {
    margin: 0;
    padding: 0;
    display: flex;
    justify-content: center;
    align-items: center;
    min-height: 100vh;
    font-family: 'Segoe UI', Roboto, Arial, sans-serif;
    background: linear-gradient(135deg, #0f2027 0%, #203a43 50%, #2c5364 100%);
    overflow: hidden;
    position: relative;
}

#particles-js {
    position: absolute;
    width: 100%;
    height: 100%;
    top: 0;
    left: 0;
    z-index: 1;
}

.content {
    position: relative;
    max-width: 500px;
    padding: 40px;
    background: rgba(255, 255, 255, 0.1);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    border-radius: 24px;
    box-shadow: 0 25px 45px rgba(0, 0, 0, 0.2);
    border: 1px solid rgba(255, 255, 255, 0.1);
    display: flex;
    justify-content: center;
    align-items: center;
    animation: fadeInScale 0.8s cubic-bezier(0.165, 0.84, 0.44, 1);
    z-index: 2;
}

.login-container {
    background: rgba(255, 255, 255, 0.9);
    padding: 40px;
    border-radius: 16px;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.1);
    width: 100%;
    min-width: 400px;
    transform: translateY(-20px);
    backface-visibility: hidden;
    perspective: 1000px;
    opacity: 0;
    animation: fadeIn 0.6s ease-out 0.3s forwards;
}

.logo {
    width: 80px;
    height: 80px;
    margin: 0 auto 20px;
    display: block;
    animation: pulse 2s infinite ease-in-out;
}

@keyframes pulse {
    0% {
        transform: scale(1);
    }
    50% {
        transform: scale(1.05);
    }
    100% {
        transform: scale(1);
    }
}

@keyframes scaleIn {
    from {
        transform: scale(0.95) translateZ(0);
    }
    to {
        transform: scale(1) translateZ(0);
    }
}

@keyframes fadeIn {
    from {
        opacity: 0;
        transform: translateY(-20px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

@keyframes down {
    from {
        opacity: 0;
        transform: translateY(-10px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

@keyframes fadeInScale {
    from {
        opacity: 0;
        transform: scale(0.92);
    }
    to {
        opacity: 1;
        transform: scale(1);
    }
}

/* Form styles */
.login-box {
    text-align: center;
    position: relative;
    padding-top: 10px;
}

.login-box h2 {
    color: #2c5364;
    margin: 0 0 30px 0;
    font-size: 28px;
    font-weight: 600;
    letter-spacing: 0.5px;
}

.input-group {
    position: relative;
    margin-bottom: 28px;
    width: 100%;
}

.input-group input {
    width: 100%;
    padding: 18px 15px 10px;
    border: none;
    border-bottom: 2px solid #ddd;
    border-radius: 8px 8px 0 0;
    font-size: 16px;
    transition: all 0.3s ease;
    box-sizing: border-box;
    background-color: #f8f9fa;
}

.input-group label {
    position: absolute;
    left: 15px;
    top: 50%;
    transform: translateY(-50%);
    color: #666;
    pointer-events: none;
    transition: all 0.3s ease;
}

.input-group input:focus,
.input-group input:valid {
    border-color: #2c5364;
    background-color: #fff;
    box-shadow: 0 5px 15px rgba(44, 83, 100, 0.1);
}

.input-group input:focus + label,
.input-group input:valid + label {
    transform: translateY(-130%);
    font-size: 12px;
    color: #2c5364;
    font-weight: 600;
}

button[type="submit"] {
    width: 100%;
    padding: 18px;
    background: linear-gradient(135deg, #2c5364 0%, #203a43 100%);
    color: white;
    border: none;
    border-radius: 12px;
    font-size: 16px;
    font-weight: 600;
    letter-spacing: 0.5px;
    cursor: pointer;
    transition: all 0.3s ease;
    margin-top: 20px;
    box-shadow: 0 10px 20px rgba(44, 83, 100, 0.2);
}

button[type="submit"]:hover {
    background: linear-gradient(135deg, #203a43 0%, #0f2027 100%);
    transform: translateY(-3px);
    box-shadow: 0 15px 25px rgba(44, 83, 100, 0.3);
}

button[type="submit"]:active {
    transform: translateY(0);
    box-shadow: 0 5px 15px rgba(44, 83, 100, 0.2);
}

/* Password visibility toggle */
.input-group {
    position: relative;
}

.toggle-password {
    position: absolute;
    right: 15px;
    top: 50%;
    transform: translateY(-50%);
    cursor: pointer;
    color: #666;
    padding: 5px;
    z-index: 10;
    transition: all 0.3s ease;
}

.toggle-password:hover {
    color: #2c5364;
}

/* Error animation */
.shake {
    animation: shake 0.6s 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(-3px, 0, 0);
    }
    40%, 60% {
        transform: translate3d(3px, 0, 0);
    }
}

/* 2FA-specific styling */
.input-group.otp-group {
    display: flex;
    justify-content: space-between;
    margin: 30px 0;
}

.input-group.otp-group input {
    width: 50px;
    height: 60px;
    padding: 0;
    text-align: center;
    font-size: 24px;
    font-weight: 600;
    margin: 0 4px;
    border-radius: 12px;
    border: 2px solid #ddd;
    background: white;
}

.input-group.otp-group input::-webkit-outer-spin-button,
.input-group.otp-group input::-webkit-inner-spin-button {
    -webkit-appearance: none;
    margin: 0;
}

.input-group.otp-group input[type=number] {
    appearance: textfield;
    -moz-appearance: textfield;
}

.verification-section {
    display: none;
    animation: fadeIn 0.5s ease-out;
}

.verification-section.show {
    display: block;
}

.credentials-section.hide {
    display: none;
}

.verification-title {
    color: #2c5364;
    margin-bottom: 15px;
    font-size: 22px;
    font-weight: 600;
}

.verification-description {
    color: #555;
    margin-bottom: 25px;
    font-size: 15px;
    line-height: 1.6;
}

.resend-code {
    margin-top: 20px;
    color: #2c5364;
    text-decoration: none;
    cursor: pointer;
    font-size: 14px;
    border: none;
    background: none;
    padding: 5px 15px;
    width: auto;
    font-weight: 600;
    transition: all 0.3s ease;
    border-bottom: 1px dashed #2c5364;
}

.resend-code:hover {
    color: #0f2027;
    transform: translateY(-2px);
}

.resend-code:disabled {
    color: #999;
    cursor: not-allowed;
    text-decoration: none;
    border-bottom-color: transparent;
}

.countdown {
    color: #555;
    font-size: 14px;
    margin-top: 15px;
    font-weight: 500;
}

/* Error messages */
.error-message {
    color: #e74c3c;
    margin: 15px 0;
    font-size: 14px;
    display: none;
    animation: fadeIn 0.3s ease-out;
    padding: 10px;
    background-color: rgba(231, 76, 60, 0.1);
    border-radius: 8px;
    font-weight: 500;
}

.error-message.show {
    display: block;
}

/* Back-button for 2FA */
.back-button {
    position: absolute;
    left: 15px;
    top: 15px;
    background: none;
    border: none;
    color: #2c5364;
    cursor: pointer;
    padding: 8px;
    font-size: 20px;
    transition: all 0.3s ease;
    width: auto;
    margin: 0;
    border-radius: 50%;
}

.back-button:hover {
    transform: translateX(-3px);
    background: rgba(44, 83, 100, 0.1);
}

/* Active OTP-input styling */
.input-group.otp-group input:focus {
    border-color: #2c5364;
    box-shadow: 0 0 0 3px rgba(44, 83, 100, 0.2);
}

/* Setup 2FA styling */
#setup-2fa {
    padding: 20px;
    border-radius: 12px;
    background-color: #f8f9fa;
    margin-bottom: 25px;
}

#qr-code {
    padding: 15px;
    background: white;
    border-radius: 8px;
    display: inline-block;
}

#secret-key {
    letter-spacing: 1px;
    color: #2c5364;
    font-weight: 600;
    background: white !important;
    padding: 12px !important;
}

/* Success Animation */
.success-overlay {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(255, 255, 255, 0.95);
    z-index: 100;
    display: flex;
    justify-content: center;
    align-items: center;
    border-radius: 16px;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.3s ease;
}

.success-overlay.show {
    opacity: 1;
    animation: successFade 1.5s ease forwards;
}

.checkmark-circle {
    width: 80px;
    height: 80px;
    position: relative;
    background: #4CAF50;
    border-radius: 50%;
    transform: scale(0);
    box-shadow: 0 0 0 0 rgba(76, 175, 80, 0.5);
}

.success-overlay.show .checkmark-circle {
    animation: checkmarkAppear 0.5s cubic-bezier(0.22, 0.61, 0.36, 1) forwards,
               pulse-success 1.5s cubic-bezier(0.22, 0.61, 0.36, 1) forwards;
}

.checkmark {
    width: 40px;
    height: 20px;
    position: absolute;
    border-bottom: 5px solid white;
    border-left: 5px solid white;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -75%) rotate(-45deg) scale(0);
}

.success-overlay.show .checkmark {
    animation: checkmarkDraw 0.3s 0.5s forwards;
}

@keyframes successFade {
    0% { opacity: 0; }
    10% { opacity: 1; }
    100% { opacity: 1; } 
}

@keyframes checkmarkAppear {
    0% { transform: scale(0); }
    50% { transform: scale(1.1); }
    70% { transform: scale(0.8); }
    100% { transform: scale(1); }
}

@keyframes checkmarkDraw {
    0% { transform: translate(-50%, -75%) rotate(-45deg) scale(0); }
    100% { transform: translate(-50%, -75%) rotate(-45deg) scale(1); }
}

@keyframes pulse-success {
    0% { box-shadow: 0 0 0 0 rgba(76, 175, 80, 0.5); }
    70% { box-shadow: 0 0 0 20px rgba(76, 175, 80, 0); }
    100% { box-shadow: 0 0 0 0 rgba(76, 175, 80, 0); }
}

/* Responsive adjustments */
@media (max-width: 500px) {
    .content {
        padding: 20px;
        width: 90%;
    }
    
    .login-container {
        min-width: unset;
        width: 100%;
        padding: 30px 20px;
    }
    
    .input-group.otp-group input {
        width: 40px;
        height: 50px;
        font-size: 20px;
    }
}
