html, body {
    height: 100%;
    margin: 0;
    padding: 0;
}

body.login-page {
    min-height: 100vh;
    min-height: calc(var(--vh, 1vh) * 100);
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    background-size: cover;
    background-position: center;
    background-repeat: no-repeat;
    overflow-x: hidden;
    overflow-y: auto;
    padding: 1rem;
}

.login-container {
    width: 100%;
    max-width: 500px;
    min-height: 100vh;
    min-height: calc(var(--vh, 1vh) * 100);
    display: flex;
    flex-direction: column;
    justify-content: center;
    padding: 1rem;
    margin: 0 auto;
}

@media (max-width: 768px) {
    .login-container {
        overflow-y: auto;
        -webkit-overflow-scrolling: touch; 
        padding: 1.5rem 0rem;
        width: 100%;
    }

    .login-section {
        width: 100%;
        padding: 0 10px;
    }
}

.login-section {
    width: 100%;
    max-width: 1200px;
    margin: 0 auto;
}

.login-section {
    opacity: 0;
    transform: translateY(20px);
    visibility: hidden;
    transition: opacity 0.6s ease, transform 0.6s ease, visibility 0.6s ease;
}

.login-section.show {
    opacity: 1;
    transform: translateY(0);
    visibility: visible;
}

.login-section .card {
    transition: transform 0.5s ease 0.1s, opacity 0.5s ease 0.1s, box-shadow 0.3s ease;
}

.login-header {
    padding: 15px 0;
    margin-top: 10px;
    position: relative;
}

.login-header h2 {
    font-weight: 700;
    color: #ffffff;
    text-shadow: 0 2px 4px rgba(0, 0, 0, 0.3);
    margin-bottom: 5px;
    letter-spacing: 1px;
}

.login-header h4 {
    font-weight: 500;
    color: rgba(255, 255, 255, 0.9);
    text-shadow: 0 1px 2px rgba(0, 0, 0, 0.2);
    font-size: 1.1rem;
}

.login-header::after {
    content: "";
    position: absolute;
    bottom: 0;
    left: 50%;
    transform: translateX(-50%);
    width: 80px;
    height: 3px;
    background: linear-gradient(to right, transparent, #007bff, transparent);
    border-radius: 3px;
}

/* Mobile optimizations for login form */
.login-wrap {
    padding: 1.5rem;
    background-color: rgba(255, 255, 255, 0.1);
    border-radius: 1rem;
    box-shadow: 0 0 20px rgba(0, 0, 0, 0.1);
}

.login-img {
    margin-bottom: 1.25rem;
    padding: 0.75rem 0.65rem;
    background: linear-gradient(to right, rgba(0, 0, 0, 0.1), rgba(0, 123, 255, 0.1), rgba(0, 0, 0, 0.1));
    border-radius: 0.625rem;
    box-shadow: 0 0.25rem 0.9375rem rgba(0, 0, 0, 0.1);
}

.login-img .row {
    /* background: rgba(255, 255, 255, 0.1); */
    border-radius: 0.5rem;
    box-shadow: inset 0 0 0.625rem rgba(0, 0, 0, 0.05);
}

.login-img .col-4 {
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 0.3125rem;
}

.login-img .col-4 img {
    filter: drop-shadow(0 0.25rem 0.375rem rgba(0, 0, 0, 0.2));
    transition: transform 0.3s ease, filter 0.3s ease;
    height: 4.375rem; /* 70px */
    width: auto;
    object-fit: contain;
}

/* Logo positions and styling */
.login-img .col-4:nth-child(1) img {
    height: 4.0625rem; /* 65px */
    padding: 2rem;
}

.login-img .col-4:nth-child(2) img {
    height: 3.4375rem; /* 55px */
}

.login-img .col-4:nth-child(3) img {
    height: 5.3125rem; /* 85px */
}

/* Hover effects for logos */
.login-img .col-4:hover img {
    filter: drop-shadow(0 0.375rem 0.625rem rgba(0, 0, 0, 0.3)) brightness(1.05);
}

.login-img .col-4:nth-child(1):hover img {
    transform: translateY(-0.125rem);
}

.login-img .col-4:nth-child(2):hover img {
    transform: translateY(-0.125rem);
}

.login-img .col-4:nth-child(3):hover img {
    transform: translateY(0.125rem);
}

/* Media query untuk tablet (layar medium) */
@media (min-width: 577px) and (max-width: 768px) {
    .login-img .col-4 img {
        height: 3.75rem; /* 60px */
        width: auto;
    }
    
    .login-img .col-4:nth-child(1) img {
        height: 3.4375rem; /* 55px */
    }
    
    .login-img .col-4:nth-child(2) img {
        height: 3.75rem; /* 60px */
    }
    
    .login-img .col-4:nth-child(3) img {
        height: 3.4375rem; /* 55px */
    }
    
    .login-header h2 {
        font-size: 2rem;
    }
}

@media (max-width: 576px) {
    .login-img {
        padding: 0.625rem 0.3125rem;
    }
    
    .login-img .col-4 img {
        height: 3.125rem; /* 50px */
        width: auto;
    }
    
    .login-img .col-4:nth-child(1) img {
        height: 2.8125rem; /* 45px */
    }
    
    .login-img .col-4:nth-child(2) img {
        height: 3.125rem; /* 50px */
    }
    
    .login-img .col-4:nth-child(3) img {
        height: 2.8125rem; /* 45px */
    }
    
    .login-header h2 {
        font-size: 1.8rem;
    }
    
    .login-header h4 {
        font-size: 1rem;
    }
    
    .login-wrap {
        padding: 0.9375rem;
    }
    
    .captcha {
        display: flex;
        flex-wrap: wrap;
        justify-content: center;
    }
    
    .img-captcha {
        margin-bottom: 0.625rem;
    }
}

@media (max-width: 767px) {
    .login-section {
        padding: 10px;
    }
    
    .forms-control {
        font-size: 0.8rem;
    }
    
    .btn-login {
        font-size: 16px;
    }
    
    .captcha {
        width: 100%;
        margin-bottom: 10px;
    }
    
    .input-captcha {
        width: 100%;
    }
    
    .login-wrap .mb-3.d-flex {
        flex-direction: column;
    }
    
    .login-wrap .mb-3.d-flex .col-7, 
    .login-wrap .mb-3.d-flex .col-5 {
        width: 100%;
        margin-bottom: 10px;
    }
}

#form-login {
    transition: opacity 0.4s ease;
}

.form-container {
    transition: height 0.4s ease, opacity 0.4s ease;
}

.otp-input {
    width: 3rem;
    height: 3rem;
    font-size: 1.5rem;
    font-weight: bold;
    border-radius: 8px;
    transition: all 0.3s ease;
}

.otp-input:focus {
    border-color: #007bff;
    box-shadow: 0 0 0 0.2rem rgba(0, 123, 255, 0.25);
}

#resendSection {
    padding: 1rem 0;
    border-top: 1px solid rgba(0, 0, 0, 0.1);
    margin-top: 1rem;
}

#countdownContainer {
    padding: 0.75rem;
    background-color: rgba(0, 123, 255, 0.1);
    border-radius: 8px;
    border: 1px solid rgba(0, 123, 255, 0.2);
    transition: all 0.3s ease;
}

#countdownContainer.countdown-finished {
    background-color: rgba(40, 167, 69, 0.1);
    border-color: rgba(40, 167, 69, 0.2);
}

#countdown {
    font-family: "Courier New", monospace;
    font-size: 1.1rem;
    color: #007bff;
    transition: color 0.3s ease;
}

/* Enhanced resend button with smooth show/hide */
#resendOtpBtn {
    transition: all 0.4s cubic-bezier(0.4, 0, 0.2, 1);
    min-width: 150px;
    opacity: 0;
    transform: translateY(10px) scale(0.95);
}

#resendOtpBtn.show {
    opacity: 1;
    transform: translateY(0) scale(1);
}

#resendOtpBtn:disabled {
    opacity: 0.6;
    cursor: not-allowed;
}

#resendOtpBtn .spinner-border-sm {
    width: 1rem;
    height: 1rem;
}

/* Responsive design for OTP inputs */
@media (max-width: 576px) {
    .otp-input-container {
        gap: 5px !important;
    }
    
    .otp-input {
        width: 2.5rem;
        height: 2.5rem;
        font-size: 1rem;
    }
    
    #countdownContainer {
        padding: 0.5rem;
        font-size: 0.9rem;
    }
    
    #countdown {
        font-size: 1rem;
    }
    
    .modal-dialog {
        margin: 0.5rem;
    }
    
    #otpAlertContainer .alert {
        font-size: 0.9rem;
        padding: 0.4rem 0.75rem;
    }
}

/* Form input responsive enhancements */
.forms-control {
    padding: 1rem 3rem 1rem 1rem;
    border-radius: 10rem;
    border: 1px solid rgba(0, 0, 0, 0.1);
    transition: all 0.3s ease;
    width: 100%;
}

.forms-control:focus {
    box-shadow: 0 0 0 3px rgba(0, 123, 255, 0.25);
    border-color: #007bff;
}

.password-container {
    position: relative;
}

.toggle-password {
    position: absolute;
    top: 0.58rem;
    bottom: 0;
    right: 1rem;
    display: flex;
    align-items: center;
    cursor: pointer;
    color: #ffffff;
    transition: color 0.3s ease;
}

.toggle-password:hover {
    color: #007bff;
}

.forgot-password {
    display: block;
    font-size: 0.85rem;
    margin-top: 0.5rem;
    text-align: right;
    color: rgba(255, 255, 255, 0.8);
    text-decoration: none;
}

.btn-login {
    padding: 12px 20px;
    border-radius: 10rem;
    font-weight: 600;
    transition: all 0.3s ease;
    background-color: #0022B2;
    border: none;
    color: white;
}

.btn-confidential {
    padding: 0.5rem 1rem;
    margin: 1.5rem 0 0 0;
    border-radius: 10rem;
    font-size: 0.875rem;
    font-weight: 500;
    transition: all 0.3s ease;
    background-color: transparent;
    border: 1px solid #ff9d35;
    color: #ff9d35;
}

.btn-confidential:hover {
    background-color: rgba(255, 130, 53, 0.1);
    border: 1px solid #ff8200;
    color: #ff8200;
}

.icon-lock {
    display: inline-block;
    margin-right: 0.25rem;
    align-items: center;
}

/* Countdown states */
.countdown-warning {
    color: #ff6b35 !important;
    animation: pulse 1s infinite;
}

.countdown-critical {
    color: #dc3545 !important;
    animation: pulse 0.5s infinite;
}

.countdown-finished {
    color: #28a745 !important;
}

/* Success message for countdown finished */
.countdown-finished-message {
    color: #28a745;
    font-weight: 500;
    animation: fadeInUp 0.5s ease-out;
}

/* Animations */
@keyframes fadeInUp {
    from {
        opacity: 0;
        transform: translateY(20px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

@keyframes pulse {
    0% {
        opacity: 1;
    }
    50% {
        opacity: 0.7;
    }
    100% {
        opacity: 1;
    }
}

@keyframes slideInFromBottom {
    from {
        opacity: 0;
        transform: translateY(20px) scale(0.9);
    }
    to {
        opacity: 1;
        transform: translateY(0) scale(1);
    }
}

/* Modal improvements */
.modal-content {
    border-radius: 15px;
}

.modal-header {
    border-top-left-radius: 15px;
    border-top-right-radius: 15px;
}

.modal-footer {
    border-bottom-left-radius: 15px;
    border-bottom-right-radius: 15px;
}

/* Responsive modal adjustments */
@media (max-width: 576px) {
    .modal-dialog {
        margin: 0.75rem;
    }
    
    .modal-content {
        border-radius: 12px;
    }
    
    .modal-title {
        font-size: 1.25rem;
    }
    
    .modal-body {
        padding: 1rem;
    }
    
    #fallbackOtpCode {
        font-size: 1.5rem;
    }
}

/* Loading Screen Styles */
.loading-screen {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: 9999;
    opacity: 0;
    visibility: hidden;
    transition: all 0.45s cubic-bezier(0.3, 0, 0.2, 1);
    overflow: hidden;
    will-change: opacity, visibility;
}

.loading-screen.show {
    opacity: 1;
    visibility: visible;
}

/* Background Gradient with Animation */
.loading-overlay {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    background-size: 200% 200%;
    background-attachment: fixed;
    display: flex;
    align-items: center;
    justify-content: center;
    backdrop-filter: blur(10px);
    animation: gradientShift 15s ease infinite;
}

/* Moving Particles Background */
.loading-overlay::before {
    content: "";
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-image: radial-gradient(
        circle,
        rgba(255, 255, 255, 0.15) 1px,
        transparent 1px
    );
    background-size: 40px 40px;
    opacity: 0.6;
    animation: particlesMove 20s linear infinite;
}

/* Main Content Container */
.loading-content {
    width: 90%;
    max-width: 400px;
    padding: 2.5rem;
    position: relative;
    z-index: 10;
    animation: pulseScale 1s ease-out;
    transform-origin: center;
    background: rgba(255, 255, 255, 0.1);
    backdrop-filter: blur(10px);
    border-radius: 16px;
    border: 1px solid rgba(255, 255, 255, 0.1);
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.15);
}

/* Enhanced Logo Animation */
.loading-logo-img {
    max-width: 120px;
    height: auto;
    filter: drop-shadow(0 0 15px rgba(255, 255, 255, 0.5));
    animation: logoEnhanced 4s infinite;
    transform-origin: center;
}

/* Enhanced Text Animation with Staggered Entry */
.loading-text {
    animation: fadeInScale 0.8s cubic-bezier(0.22, 1, 0.36, 1) 0.3s both;
    transform-origin: top center;
}

/* Progress Bar Container with Glow Effect */
.loading-progress {
    height: 10px;
    border-radius: 12px;
    background-color: rgba(255, 255, 255, 0.15);
    overflow: hidden;
    box-shadow: inset 0 2px 8px rgba(0, 0, 0, 0.2);
    position: relative;
    margin: 1.5rem 0;
}

/* Animated Progress Bar with Shimmer Effect */
.loading-progress .progress-bar {
    transition: width 0.5s cubic-bezier(0.22, 1, 0.36, 1);
    background: linear-gradient(90deg, #00d2ff, #3a7bd5, #00d2ff);
    background-size: 200% 100%;
    box-shadow: 0 0 20px rgba(0, 123, 255, 0.5);
    animation: shimmerEffect 2s infinite;
    position: relative;
    height: 100%;
}

/* Progress Bar Pulse Glow */
.loading-progress::after {
    content: "";
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: linear-gradient(
        90deg,
        transparent,
        rgba(255, 255, 255, 0.4),
        transparent
    );
    animation: progressPulse 2s ease-out infinite;
    pointer-events: none;
}

/* Loading Step Text Animation */
.loading-steps {
    animation: fadeInUp 0.7s cubic-bezier(0.22, 1, 0.36, 1) 0.5s both;
    margin-top: 1rem;
}

#loadingStep {
    transition: all 0.45s cubic-bezier(0.22, 1, 0.36, 1);
    display: inline-block;
    min-height: 1.2em;
    position: relative;
    padding: 0.25rem 1rem;
    border-radius: 20px;
    background: rgba(255, 255, 255, 0.15);
    text-shadow: 0 1px 2px rgba(0, 0, 0, 0.2);
}

#loadingStep.updating {
    opacity: 0;
    transform: translateY(-10px);
}

/* Spinner Animation */
.loading-spinner {
    margin: 1.5rem auto;
    position: relative;
    width: 80px;
    height: 80px;
}

.loading-spinner .spinner-circle {
    position: absolute;
    border: 4px solid rgba(255, 255, 255, 0.3);
    border-top-color: #fff;
    border-radius: 50%;
    animation: spinnerRotate 1s linear infinite;
}

.loading-spinner .spinner-circle:nth-child(1) {
    width: 100%;
    height: 100%;
}

.loading-spinner .spinner-circle:nth-child(2) {
    top: 15%;
    left: 15%;
    width: 70%;
    height: 70%;
    animation-duration: 0.8s;
    animation-direction: reverse;
}

.loading-spinner .spinner-circle:nth-child(3) {
    top: 30%;
    left: 30%;
    width: 40%;
    height: 40%;
    animation-duration: 0.6s;
}

/* Loading Title with Highlight */
#loadingTitle {
    margin-bottom: 1rem;
    display: inline-block;
    background: linear-gradient(45deg, #fff, #c9d6ff, #fff);
    background-size: 200% auto;
    background-clip: text;
    -webkit-background-clip: text;
    color: transparent;
    -webkit-text-fill-color: transparent;
    animation: gradientText 3s linear infinite;
}

/* Loading Message */
#loadingMessage {
    opacity: 0.9;
    animation: fadeInUp 0.8s ease 0.4s both;
}

/* ===== ANIMATIONS ===== */

/* Logo Enhanced Animation */
@keyframes logoEnhanced {
    0%,
    100% {
        transform: scale(1) translateY(0);
        filter: brightness(1) drop-shadow(0 0 15px rgba(255, 255, 255, 0.3));
    }
    25% {
        transform: scale(1.08) translateY(-5px) rotate(2deg);
        filter: brightness(1.2) drop-shadow(0 0 20px rgba(255, 255, 255, 0.5));
    }
    50% {
        transform: scale(1.12) translateY(0) rotate(-1deg);
        filter: brightness(1.4) drop-shadow(0 0 25px rgba(255, 255, 255, 0.7));
    }
    75% {
        transform: scale(1.08) translateY(5px) rotate(1deg);
        filter: brightness(1.2) drop-shadow(0 0 20px rgba(255, 255, 255, 0.5));
    }
}

/* Gradient Movement Animation */
@keyframes gradientShift {
    0% {
        background-position: 0% 50%;
    }
    50% {
        background-position: 100% 50%;
    }
    100% {
        background-position: 0% 50%;
    }
}

/* Particles Movement Animation */
@keyframes particlesMove {
    0% {
        background-position: 0 0;
    }
    100% {
        background-position: 100px 100px;
    }
}

/* Progress Bar Shimmer Effect */
@keyframes shimmerEffect {
    0% {
        background-position: 200% 0;
    }
    100% {
        background-position: -200% 0;
    }
}

/* Progress Glow Pulse Animation */
@keyframes progressPulse {
    0% {
        transform: translateX(-100%);
    }
    100% {
        transform: translateX(100%);
    }
}

/* Spinner Animation */
@keyframes spinnerRotate {
    0% {
        transform: rotate(0deg);
    }
    100% {
        transform: rotate(360deg);
    }
}

/* Pulse Scale Animation */
@keyframes pulseScale {
    0% {
        transform: scale(0.95);
        opacity: 0;
    }
    50% {
        transform: scale(1.02);
    }
    100% {
        transform: scale(1);
        opacity: 1;
    }
}

/* Gradient Text Animation */
@keyframes gradientText {
    0% {
        background-position: 0% 50%;
    }
    100% {
        background-position: 200% 50%;
    }
}

/* Fade In with Scale Animation */
@keyframes fadeInScale {
    0% {
        opacity: 0;
        transform: scale(0.95);
    }
    100% {
        opacity: 1;
        transform: scale(1);
    }
}

/* Enhanced Fade In Up Animation */
@keyframes fadeInUp {
    0% {
        opacity: 0;
        transform: translateY(20px);
    }
    100% {
        opacity: 1;
        transform: translateY(0);
    }
}

/* ===== RESPONSIVE ADJUSTMENTS ===== */

/* Large desktop screens */
@media (min-width: 1200px) {
    .login-img .col-4 img {
        height: 5rem; /* 80px */
    }
    
    .login-img .col-4:nth-child(1) img {
        height: 4.6875rem; /* 75px */
    }
    
    .login-img .col-4:nth-child(3) img {
        height: 4.6875rem; /* 75px */
    }
    
    .login-img {
        padding: 1.25rem 0.9375rem;
    }
}

/* Enhanced responsive styles for various devices */
@media (max-width: 768px) {
    .login-content {
        max-width: 320px;
        padding: 1.75rem;
    }

    .login-logo-img {
        max-width: 90px;
    }

    .loading-spinner {
        width: 60px;
        height: 60px;
        margin: 1rem auto;
    }

    .loading-progress {
        height: 8px;
        margin: 1rem 0;
    }
    
    /* Fix captcha layout */
    .captcha {
        flex-direction: column;
        align-items: center;
    }
    
    .img-captcha {
        margin-bottom: 10px;
    }
    
    .reload {
        margin-top: 10px;
    }
    
    /* Adjust form layout */
    .mb-3.d-flex {
        flex-direction: column;
    }
    
    .mb-3.d-flex .col-7,
    .mb-3.d-flex .col-5 {
        width: 100%;
    }
}

/* Extra small devices */
@media (max-width: 576px) {
    .login-section {
        padding: 0;
    }
    
    .login-wrap {
        padding: 15px;
        margin: 0;
    }
    
    .login-img .row {
        flex-wrap: wrap;
    }
    
    .login-img .col-4 {
        width: 33.333%;
        padding: 5px;
    }
    
    .login-img .col-4 img {
        max-width: 100%;
        height: auto;
    }
    
    .login-header h2 {
        font-size: 1.5rem;
        margin-bottom: 5px;
    }
    
    .login-header h4 {
        font-size: 0.9rem;
    }
    
    .login-wrap h5 {
        font-size: 1.1rem;
    }
    
    .forms-control {
        padding: 1rem 3rem 1rem 1rem;
        font-size: 0.8rem; 
    }
    
    .toggle-password {
        right: 1rem;
    }
    
    /* Adjustments for OTP modal */
    .otp-input {
        width: 2.5rem;
        height: 2.5rem;
        font-size: 1.2rem;
    }
    
    #loadingTitle {
        font-size: 1.3rem;
    }
    
    #loadingMessage {
        font-size: 0.9rem;
    }
    
    #loadingStep {
        font-size: 0.8rem;
        padding: 0.2rem 0.75rem;
    }
}

/* Dark Mode Enhancements */
@media (prefers-color-scheme: dark) {
    .loading-overlay {
        background: linear-gradient(
            135deg,
            #1a2a6c 0%,
            #2d3a4f 50%,
            #1a2a6c 100%
        );
    }

    .loading-content {
        box-shadow: 0 8px 32px rgba(0, 0, 0, 0.3);
    }
}

/* Performance Optimization for Low-End Devices */
@media (prefers-reduced-motion: reduce) {
    .loading-overlay,
    .loading-overlay::before,
    .loading-logo-img,
    .loading-progress::after,
    .loading-progress .progress-bar,
    .loading-spinner .spinner-circle,
    #loadingTitle {
        animation: none !important;
    }

    .loading-screen,
    .loading-content,
    .loading-text,
    .loading-steps,
    #loadingStep {
        animation: fadeIn 0.5s ease-out !important;
        transition: opacity 0.3s ease !important;
    }

    @keyframes fadeIn {
        from {
            opacity: 0;
        }
        to {
            opacity: 1;
        }
    }
}
