#password-protection-overlay {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  /* Use viewport height that accounts for mobile browsers */
  height: 100vh;
  height: 100dvh;
  /* Dynamic viewport height for better mobile support */
  background: rgb(255, 255, 255);
  z-index: 9999;
  display: flex;
  align-items: center;
  justify-content: center;
  backdrop-filter: blur(5px);
  overflow: hidden;
}

/* Prevent body scroll when overlay is active */
body.password-protection-active {
  overflow: hidden;
  position: fixed;
  width: 100%;
  height: 100%;
}

#password-protection-modal {
  background: white;
  border-radius: 12px;
  padding: 0;
  max-width: 400px;
  width: 90%;
  max-height: 90vh;
  overflow: hidden;
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.3);
  animation: passwordModalFadeIn 0.3s ease-out;
  display: flex;
  flex-direction: column;
}

/* Loading overlay for password form setup */
#password-protection-fetch-loading {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(255, 255, 255);
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 12px;
  z-index: 10;
  transition: all 0.3s ease;
}

.spinner {
  width: 30px;
  height: 30px;
  border: 4px solid #696969;
  border-top-color: rgb(255, 255, 255);
  border-radius: 50%;
  animation: spin 1s linear infinite;
}

@keyframes passwordModalFadeIn {
  from {
    opacity: 0;
    transform: scale(0.9) translateY(-20px);
  }

  to {
    opacity: 1;
    transform: scale(1) translateY(0);
  }
}

#password-protection-content {
  padding: 32px;
  position: relative;
  display: flex;
  flex-direction: column;
  height: 100%;
}

#password-protection-header {
  text-align: center;
  margin-bottom: 24px;
  flex-shrink: 0;
}

#password-protection-inner-container {
  display: flex;
  flex-direction: column;
  flex: 1;
  min-height: 0;
}

#password-protection-header-row {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  margin-bottom: 8px;
}

#password-protection-heading {
  font-size: 24px;
  font-weight: 600;
  color: #333;
  line-height: 1.3;
  margin: 0;
  padding: 0;
}

#password-protection-subheading {
  font-size: 16px;
  color: #666;
  margin: 0;
  padding: 0;
  line-height: 1.4;
}

/* all the p tag in the password-protection-helper-div should have margin: 0; padding: 0; */
#password-protection-helper-div p {
  margin: 0;
  padding: 0;
}

#password-protection-input-container input {
  margin: 0;
  box-shadow: none;
}

#password-protection-back-btn {
  position: absolute;
  left: 0;
  background: none;
  border: none;
  color: #666;
  cursor: pointer;
  padding: 8px;
  border-radius: 6px;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background-color 0.2s ease, color 0.2s ease;
  width: 36px;
  height: 36px;
}

#password-protection-back-btn:hover {
  background-color: #f5f5f5;
  color: #333;
}

#password-protection-form {
  margin: 0;
  display: flex;
  flex-direction: column;
  flex: 1;
  justify-content: center;
}

#password-protection-input-wrapper {
  display: flex;
  gap: 8px;
}

#password-protection-input-container {
  flex: 1;
  position: relative;
  display: flex;
  align-items: center;
}

#password-protection-input {
  width: 100%;
  padding: 12px 48px 12px 16px;
  border: 2px solid #e1e5e9;
  border-radius: 8px;
  font-size: 16px;
  transition: border-color 0.2s ease;
  outline: none;
  color: #000000;
}

#password-protection-input:focus {
  border-color: var(--pp-primary-color, #000000);
}

#password-protection-toggle {
  position: absolute;
  right: 12px;
  background: none;
  border: none;
  cursor: pointer;
  padding: 4px;
  color: #8e8e8e;
  transition: color 0.2s ease;
  display: flex;
  align-items: center;
  justify-content: center;
}

#password-protection-toggle:hover {
  color: #000000;
}

#password-protection-toggle:focus {
  outline-offset: 2px;
  border-radius: 4px;
}

#password-protection-submit {
  padding: 12px 24px;
  background: #0066cc;
  color: white;
  border: none;
  border-radius: 8px;
  font-size: 16px;
  font-weight: 500;
  cursor: pointer;
  transition: background-color 0.2s ease;
  min-width: 80px;
  position: relative;
}

#password-protection-submit:hover {
  background: #0052a3;
}

#password-protection-submit:disabled {
  background: #ccc;
  cursor: not-allowed;
}

#password-protection-submit-text {
  color: white !important;
  transition: opacity 0.2s ease;
}

/* Submit button spinner */
.submit-spinner {
  position: absolute;
  top: 50%;
  left: 50%;
  width: 18px;
  height: 18px;
  border: 2px solid rgba(255, 255, 255, 0.3);
  border-top-color: white;
  border-radius: 50%;
  animation: submitSpin 1s linear infinite;
}

#password-protection-error {
  background: #fee;
  border: 1px solid #fcc;
  color: #c33;
  padding: 8px;
  border-radius: 8px;
  font-size: 14px;
  text-align: center;
  margin-top: 20px;
  margin-bottom: -12px;
}

@keyframes spin {
  to {
    transform: rotate(360deg);
  }
}

@keyframes submitSpin {
  from {
    transform: translate(-50%, -50%) rotate(0deg);
  }

  to {
    transform: translate(-50%, -50%) rotate(360deg);
  }
}

/* Mobile responsive */
@media (max-width: 480px) {
  #password-protection-overlay {
    /* Adjust for mobile keyboards - position modal higher */
    align-items: flex-start;
    padding-top: 10vh;
    /* Support safe areas on mobile devices */
    padding-top: max(10vh, env(safe-area-inset-top, 0px));
    padding-bottom: env(safe-area-inset-bottom, 0px);
    padding-left: env(safe-area-inset-left, 0px);
    padding-right: env(safe-area-inset-right, 0px);
  }

  #password-protection-modal {
    margin: 20px;
    width: calc(100% - 40px);
    /* Ensure modal doesn't get too tall on mobile */
    max-height: 80vh;
    /* Add bottom margin for keyboard spacing */
    margin-bottom: 20vh;
  }

  #password-protection-content {
    padding: 24px;
  }

  #password-protection-heading {
    font-size: 20px;
  }

  #password-protection-input-wrapper {
    flex-direction: column;
  }

  #password-protection-submit {
    width: 100%;
  }
}

/* Additional mobile keyboard handling */
@media (max-width: 480px) and (max-height: 600px) {
  #password-protection-overlay {
    /* For short screens (landscape or keyboard active), position modal at top */
    align-items: flex-start;
    padding-top: 5vh;
  }

  #password-protection-modal {
    margin: 10px;
    max-height: 70vh;
  }

  #password-protection-content {
    padding: 16px;
    padding-top: 24px;
    padding-bottom: 24px;
  }
}

/* Helper Div Styling */
#password-protection-helper-div {
  margin-top: 14px;
  font-size: 14px;
  color: #666;
  text-align: center;
  line-height: 1.4;
}

#password-protection-helper-div .pp-helper-link {
  text-decoration: underline;
  transition: all 0.2s ease;
  cursor: pointer;
}

#password-protection-helper-div .pp-helper-link:hover {
  text-decoration: underline !important;
}

/* Message container styling for access denied messages */
#password-protection-message {
  text-align: center;
  padding-bottom: 20px;
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  flex: 1;
}