/* QR Code Login Tab Styles */
.login-tabs {
    display: flex;
    gap: 0;
    margin-bottom: 8px; /* Reduced from 12px to save space */
    border-bottom: 1px solid #E5E7EB; /* Reduced from 2px */
}

.login-tabs .tab-btn {
    flex: 1;
    padding: 6px 10px; /* Reduced from 8px 12px for smaller tabs */
    border: none;
    border-bottom: 2px solid transparent;
    color: #6B7280;
    font-size: 12px; /* Reduced from 13px */
    font-weight: 500;
    cursor: pointer;
    transition: all 0.3s ease;
    outline: none;
    margin-bottom: -1px; /* Match border width */
}

.login-tabs .tab-btn:hover {
    color: #1E73E8;
    background-color: #F3F4F6;
}

.login-tabs .tab-btn.active {
    color: #1E73E8;
    border-bottom-color: #1E73E8;
    font-weight: 600;
}

.tab-content {
    display: none;
    animation: fadeIn 0.3s ease-in;
}

.tab-content.active {
    display: block;
}

@keyframes fadeIn {
    from {
        opacity: 0;
        transform: translateY(-10px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* QR Code Container */
#qr-login-container {
    display: flex;
    flex-direction: column;
    align-items: center;
    padding: 12px 0; /* Reduced from 20px to save space */
}

#misaid-passwordless-container {
    margin-bottom: 16px; /* Reduced from 24px */
}

/* Control QR code size to prevent form stretching */
#misaid-passwordless-container canvas,
#misaid-passwordless-container img {
    max-width: 260px !important;
    max-height: 260px !important;
    width: 260px !important;
    height: 260px !important;
}

.qr-instructions {
    max-width: 400px;
    text-align: left;
    padding: 16px;
    background: #F9FAFB;
    border-radius: 8px;
    border: 1px solid #E5E7EB;
}

.qr-instructions h4 {
    font-size: 16px;
    font-weight: 600;
    color: #111827;
    margin-bottom: 12px;
    text-align: center;
}

.qr-instructions ol {
    margin: 0;
    padding-left: 20px;
    color: #4B5563;
}

.qr-instructions li {
    font-size: 14px;
    line-height: 1.6;
    margin-bottom: 8px;
}

.qr-instructions li:last-child {
    margin-bottom: 0;
}

/* QR Status Messages */
.qr-status {
    text-align: center;
    padding: 12px;
    border-radius: 6px;
    margin-top: 16px;
    font-size: 14px;
}

.qr-status.scanning {
    background-color: #EFF6FF;
    color: #1E40AF;
    border: 1px solid #DBEAFE;
}

.qr-status.waiting {
    background-color: #FEF3C7;
    color: #92400E;
    border: 1px solid #FDE68A;
}

.qr-status.success {
    background-color: #D1FAE5;
    color: #065F46;
    border: 1px solid #A7F3D0;
}

.qr-status.error {
    background-color: #FEE2E2;
    color: #991B1B;
    border: 1px solid #FECACA;
}

.qr-status.scanned-success {
    background-color: #4CAF50;
    color: white;
    border: 1px solid #45a049;
    font-size: 16px;
    font-weight: 600;
    padding: 16px 20px;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
    box-shadow: 0 2px 8px rgba(76, 175, 80, 0.3);
    animation: slideInSuccess 0.4s ease;
}

.qr-status.scanned-success i {
    font-size: 24px;
}

@keyframes slideInSuccess {
    from {
        opacity: 0;
        transform: translateY(-20px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* Loading Animation for QR Login */
.qr-loading {
    display: inline-block;
    width: 16px;
    height: 16px;
    border: 2px solid #E5E7EB;
    border-top-color: #1E73E8;
    border-radius: 50%;
    animation: qr-spin 0.8s linear infinite;
    margin-left: 8px;
    vertical-align: middle;
}

@keyframes qr-spin {
    to { transform: rotate(360deg); }
}

/* QR tab must not stretch the card — height is locked to password-tab height by JS */
.has-qr-tabs #qrcode-tab {
    overflow: hidden;
}

/* Reduce spacing ONLY when QR tabs are present to prevent form stretching */
.has-qr-tabs .tab-content .form-signin {
    padding-top: 2px !important; /* Ultra compact to compensate for tabs */
    margin-bottom: 2px !important;
}

.has-qr-tabs .tab-content .action {
    margin-top: 8px !important; /* Reduced from original */
}

.has-qr-tabs .tab-content .row:last-of-type {
    margin-bottom: 20px !important; /* Reduced further to balance height */
}

/* External login section when tabs are present */
.has-qr-tabs .profile-login__hr {
    margin-bottom: 4px !important;
}

.has-qr-tabs .profile-login__hr + .row {
    padding-top: 4px !important;
    margin-bottom: 24px !important;
}

/* QR container fills the locked height set by JS */
.has-qr-tabs #qr-login-container {
    padding: 16px 16px !important;
    height: 100%;
    box-sizing: border-box;
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
}

.has-qr-tabs #misaid-passwordless-container {
    margin-bottom: 12px !important;
}

/* Force QR canvas/img to be square */
.has-qr-tabs #misaid-passwordless-container canvas,
.has-qr-tabs #misaid-passwordless-container img {
    width: 260px !important;
    height: 260px !important;
    max-width: 260px !important;
    max-height: 260px !important;
    display: block;
    object-fit: contain;
}

/* Ảnh after_scan sau khi scan — override rule trên */
.has-qr-tabs #misaid-passwordless-container #qr-scanned-overlay img {
    width: 160px !important;
    height: 200px !important;
    max-width: 160px !important;
    max-height: 200px !important;
}

/* Hint text below QR code */
.qr-scan-hint {
    font-size: 13px;
    color: #6B7280;
    text-align: center;
    margin: 8px 0 0 0;
    padding: 0 16px;
    line-height: 1.4;
}
@media (max-width: 576px) {
    .login-tabs {
        margin-bottom: 6px;
    }
    
    .login-tabs .tab-btn {
        font-size: 11px; /* Smaller on mobile */
        padding: 5px 8px; /* More compact on mobile */
    }
    
    .qr-instructions {
        padding: 12px;
    }
    
    .qr-instructions h4 {
        font-size: 14px;
    }
    
    .qr-instructions li {
        font-size: 13px;
    }
    
    /* Smaller QR code on mobile */
    #misaid-passwordless-container canvas,
    #misaid-passwordless-container img {
        max-width: 200px !important;
        max-height: 200px !important;
        width: 200px !important;
        height: 200px !important;
    }
}

/* QR Expired Overlay - Hiển thị khi QR hết hạn */
#misaid-passwordless-container {
    position: relative;
}

.qr-expired-overlay {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background-color: rgba(255, 255, 255, 0.95);
    backdrop-filter: blur(3px);
    display: flex;
    justify-content: center;
    align-items: center;
    border-radius: 8px;
    z-index: 10;
    animation: fadeInOverlay 0.4s ease;
}

@keyframes fadeInOverlay {
    from {
        opacity: 0;
    }
    to {
        opacity: 1;
    }
}

.qr-expired-content {
    text-align: center;
    padding: 20px;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 16px;
}

.qr-expired-icon {
    width: 64px;
    height: 64px;
    background-color: #FEE2E2;
    border-radius: 50%;
    display: flex;
    justify-content: center;
    align-items: center;
    animation: scaleIn 0.5s ease;
}

.qr-expired-icon i {
    font-size: 32px;
    color: #DC2626;
}

@keyframes scaleIn {
    from {
        opacity: 0;
        transform: scale(0.5);
    }
    to {
        opacity: 1;
        transform: scale(1);
    }
}

.qr-expired-message {
    margin: 0;
    font-size: 16px;
    font-weight: 600;
    color: #DC2626;
    line-height: 1.5;
}

.btn-reload-qr {
    padding: 10px 24px;
    font-size: 14px;
    font-weight: 600;
    border-radius: 6px;
    background-color: #1E73E8;
    color: white;
    border: none;
    cursor: pointer;
    transition: all 0.3s ease;
    display: inline-flex;
    align-items: center;
    gap: 8px;
    box-shadow: 0 2px 4px rgba(30, 115, 232, 0.2);
}

.btn-reload-qr:hover {
    background-color: #1765CC;
    transform: translateY(-2px);
    box-shadow: 0 4px 8px rgba(30, 115, 232, 0.3);
}

.btn-reload-qr:active {
    transform: translateY(0);
    box-shadow: 0 2px 4px rgba(30, 115, 232, 0.2);
}

.btn-reload-qr i {
    font-size: 14px;
}

/* QR Timer Display */
.qr-timer {
    text-align: center;
    margin-top: 16px;
    font-size: 14px;
    font-weight: 500;
    color: #6B7280;
    padding: 8px 16px;
    background-color: #F9FAFB;
    border-radius: 20px;
    display: inline-block;
    transition: all 0.3s ease;
}

.qr-timer.warning {
    color: #DC2626;
    background-color: #FEE2E2;
    font-weight: 600;
    animation: pulseWarning 1s infinite;
}

@keyframes pulseWarning {
    0%, 100% {
        opacity: 1;
    }
    50% {
        opacity: 0.7;
    }
}

/* Override misaid-qr library styles if needed */
.misaid-qr-container {
    position: relative;
    display: flex;
    justify-content: center;
    align-items: center;
}

.misaid-qr-reload-button {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif !important;
}

.misaid-qr-expire-text,
.misaid-qr-error-text {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif !important;
}
