/**
 * Industry Standard OTP Modal CSS
 * Gentle, Professional & Fully Responsive
 *
 * @format
 */

/* Modal Container */
.modal {
  display: none;
  position: fixed;
  z-index: 9999;
  left: 0;
  top: 0;
  width: 100%;
  height: 100%;
  background-color: rgba(0, 0, 0, 0.4);
  backdrop-filter: blur(4px);
  -webkit-backdrop-filter: blur(4px);
}

.modal.show {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
}

/* Modal Dialog */
.modal-dialog {
  max-width: 400px;
  width: 100%;
  margin: 0 auto;
  position: relative;
}

/* Modal Content */
.modal-content {
  background: #ffffff;
  border-radius: 16px;
  box-shadow: 0 10px 40px rgba(0, 0, 0, 0.12);
  border: 1px solid rgba(0, 0, 0, 0.08);
  overflow: hidden;
  animation: modalFadeIn 0.3s ease-out;
}

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

/* Modal Header */
.modal-header { 
  border-bottom: 1px solid #e2e8f0;
  padding: 10px 10px 10px;
  text-align: center;
  width: 90%;
  margin: 0 auto;
}

.modal-title {
  font-size: 1rem;
  font-weight: 600;
  color: #1e293b;
  margin: 0 auto;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  letter-spacing: -0.025em;
}

/* Modal Body */
.modal-body {
  padding: 20px;
  width: 90%;
  margin: 0 auto;
  background: #ffffff;
}

/* Phone Number Form */
#phoneNumberForm {
  text-align: center;
  margin-bottom: 0;
}

#phoneNumberForm h3 {
  color: #334155;
  font-size: 1rem;
  margin-bottom: 20px;
  font-weight: 500;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
}

/* Input Box */
.input-box {
  position: relative;
  margin-bottom: 24px;
}

.input-box input {
  width: 100%;
  padding: 16px 20px;
  border: 1.5px solid #cbd5e1;
  border-radius: 12px;
  font-size: 1rem;
  transition: all 0.2s ease;
  background: #ffffff;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  color: #334155;
  box-sizing: border-box;
}

.input-box input:focus {
  outline: none;
  border-color: #ff5252;
  background: #ffffff;
  box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.1);
}

.input-box input::placeholder {
  color: #94a3b8;
  font-weight: 400;
}

/* Buttons */
#phoneNumberNextBtn,
#otpForm button {
  width: 100%;
  padding: 16px 24px;
  background: #ff5252;
  color: white;
  border: none;
  border-radius: 12px;
  font-size: 1rem;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.2s ease;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  position: relative;
  overflow: hidden;
}

#phoneNumberNextBtn:hover,
#otpForm button:hover {
  background: #ff5252;
  transform: translateY(-1px);
  box-shadow: 0 4px 12px rgba(59, 130, 246, 0.3);
}

#phoneNumberNextBtn:active,
#otpForm button:active {
  transform: translateY(0);
}

/* Button Loading State */
#phoneNumberNextBtn.loading,
#otpForm button.loading {
  color: transparent;
  pointer-events: none;
  background: #ff5252;
}

#phoneNumberNextBtn.loading::after,
#otpForm button.loading::after {
  content: "";
  position: absolute;
  top: 50%;
  left: 50%;
  width: 18px;
  height: 18px;
  margin: -9px 0 0 -9px;
  border: 2px solid rgba(255, 255, 255, 0.3);
  border-top: 2px solid #ffffff;
  border-radius: 50%;
  animation: buttonSpin 0.8s linear infinite;
}

/* Button Success State */
#phoneNumberNextBtn.success,
#otpForm button.success {
  color: transparent;
  pointer-events: none;
  background: #10b981;
  transform: scale(1.02);
  box-shadow: 0 4px 20px rgba(16, 185, 129, 0.4);
}

#phoneNumberNextBtn.success::after,
#otpForm button.success::after {
  content: "✓";
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  font-size: 24px;
  font-weight: bold;
  color: #ffffff;
  animation: successIconPop 0.4s ease-out;
}

@keyframes successIconPop {
  0% {
    opacity: 0;
    transform: translate(-50%, -50%) scale(0.5);
  }
  50% {
    transform: translate(-50%, -50%) scale(1.2);
  }
  100% {
    opacity: 1;
    transform: translate(-50%, -50%) scale(1);
  }
}

@keyframes buttonSpin {
  0% {
    transform: rotate(0deg);
  }
  100% {
    transform: rotate(360deg);
  }
}

/* OTP Inputs */
.otp-inputs {
  display: none;
  text-align: center;
}

.otp-inputs h3 {
  color: #334155;
  font-size: 1.125rem;
  margin-bottom: 20px;
  font-weight: 500;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
}

.otp-inputs .input-box {
  display: flex;
  gap: 12px;
  justify-content: center;
  margin-bottom: 24px;
  flex-wrap: wrap;
}

.otp-inputs input {
  width: 56px;
  height: 56px;
  text-align: center;
  font-size: 1.25rem;
  font-weight: 600;
  border: 1.5px solid #cbd5e1;
  border-radius: 12px;
  background: #ffffff;
  transition: all 0.2s ease;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  color: #334155;
  padding: 0;
}

/* Remove number input spinners */
.otp-inputs input::-webkit-outer-spin-button,
.otp-inputs input::-webkit-inner-spin-button {
  -webkit-appearance: none;
  margin: 0;
}

.otp-inputs input[type="number"] {
  -moz-appearance: textfield;
}

.otp-inputs input:focus {
  outline: none;
  border-color: #ff5252;
  background: #ffffff;
  box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.1);
  transform: scale(1.02);
}

.otp-inputs input:disabled {
  background: #f8fafc;
  color: #94a3b8;
  cursor: not-allowed;
  border-color: #e2e8f0;
}

/* Resend Section */
#resendOTPSection {
  margin-top: 20px;
  text-align: center;
}

#resendOTP {
  background: #64748b;
  color: white;
  border: none;
  padding: 12px 20px;
  border-radius: 8px;
  font-size: 0.875rem;
  cursor: pointer;
  transition: all 0.2s ease;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  font-weight: 500;
}

#resendOTP:hover {
  background: #475569;
  transform: translateY(-1px);
}

#resendOTP:disabled {
  opacity: 0.5;
  cursor: not-allowed;
  transform: none;
}

#resendTimer {
  color: #64748b;
  font-size: 0.875rem;
  font-weight: 400;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  display: block;
  margin-top: 8px;
}

/* Error Messages */
.error-message {
  color: #dc2626;
  background: #fef2f2;
  border: 1px solid #fecaca;
  border-radius: 8px;
  padding: 12px 16px;
  margin: 16px 0;
  font-size: 0.875rem;
  text-align: center;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  font-weight: 400;
  animation: messageSlideIn 0.2s ease-out;
}

/* Success Messages */
.success-message {
  color: #059669;
  background: #f0fdf4;
  border: 1px solid #bbf7d0;
  border-radius: 8px;
  padding: 12px 16px;
  margin: 16px 0;
  font-size: 0.875rem;
  text-align: center;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  font-weight: 400;
  animation: messageSlideIn 0.2s ease-out;
}

@keyframes messageSlideIn {
  from {
    opacity: 0;
    transform: translateY(-8px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

/* Responsive Design */
@media (max-width: 480px) {
  .modal.show {
    padding: 16px;
  }

  .modal-dialog {
    max-width: 100%;
  }

  .modal-content {
    border-radius: 12px;
  }

  .modal-header {
    padding: 10px 10px 16px;
  }

  .modal-body {
    padding: 10px !important;
    width: 100%;
  }

  .modal-title {
    font-size: 1.125rem;
  }

  #phoneNumberForm h3,
  .otp-inputs h3 {
    font-size: 1rem;
  }

  .input-box input {
    padding: 14px 18px;
    font-size: 0.875rem;
  }

  #phoneNumberNextBtn,
  #otpForm button {
    padding: 14px 20px;
    font-size: 0.875rem;
  }

  .otp-inputs .input-box {
    gap: 8px;
  }

  .otp-inputs input {
    width: 48px;
    height: 48px;
    padding: 0px;
    font-size: 1.125rem;
  }
}

@media (max-width: 360px) {
  .otp-inputs .input-box {
    gap: 6px;
  }

  .otp-inputs input {
    width: 44px;
    padding: 0px;
    height: 44px;
    font-size: 1rem;
  }
}

/* Focus Management */
button:focus-visible,
input:focus-visible {
  outline: 2px solid #ff5252;
  outline-offset: 2px;
}

/* Disabled States */
button:disabled {
  opacity: 0.6;
  cursor: not-allowed;
  transform: none !important;
  box-shadow: none !important;
}

/* Smooth Transitions */
.modal-content,
.input-box input,
#phoneNumberNextBtn,
#otpForm button,
#resendOTP {
  transition: all 0.2s ease;
}

/* Hover Effects */
.otp-inputs input:hover:not(:disabled) {
  border-color: #94a3b8;
}

/* Loading State */
.loading {
  opacity: 0.7;
  pointer-events: none;
}

/* Success Animation */
.success-checkmark {
  display: none;
  text-align: center;
  margin: 24px 0;
}

.success-checkmark .check-icon {
  width: 64px;
  height: 64px;
  position: relative;
  border-radius: 50%;
  box-sizing: content-box;
  border: 3px solid #10b981;
  margin: 0 auto;
  background: #ecfdf5;
}

.success-checkmark .check-icon::before {
  top: 3px;
  left: -2px;
  width: 30px;
  transform-origin: 100% 50%;
  border-radius: 100px 0 0 100px;
}

.success-checkmark .check-icon::after {
  top: 0;
  left: 30px;
  width: 60px;
  transform-origin: 0 50%;
  border-radius: 0 100px 100px 0;
  animation: rotate-circle 4.25s ease-in;
}

.success-checkmark .check-icon::before,
.success-checkmark .check-icon::after {
  content: "";
  height: 100px;
  position: absolute;
  background: #10b981;
  transform: rotate(-45deg);
}

.success-checkmark .check-icon .icon-line {
  height: 4px;
  background-color: #10b981;
  display: block;
  border-radius: 2px;
  position: absolute;
  z-index: 10;
}

.success-checkmark .check-icon .icon-line.line-tip {
  top: 46px;
  left: 14px;
  width: 25px;
  transform: rotate(45deg);
  animation: icon-line-tip 0.75s;
}

.success-checkmark .check-icon .icon-line.line-long {
  top: 38px;
  right: 8px;
  width: 47px;
  transform: rotate(-45deg);
  animation: icon-line-long 0.75s;
}

/* Crackers Waiting Message */
.crackers-waiting-message {
  display: none;
  text-align: center;
  margin: 24px 0;
  animation: messageFadeIn 0.5s ease-out;
}

.crackers-waiting-message .message-icon {
  font-size: 4rem;
  margin-bottom: 16px;
  animation: iconBounce 1s ease-in-out;
}

.crackers-waiting-message .message-title {
  color: #ff5252;
  font-size: 1.5rem;
  font-weight: 600;
  margin-bottom: 12px;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
}

.crackers-waiting-message .message-subtitle {
  color: #64748b;
  font-size: 1rem;
  font-weight: 400;
  margin-bottom: 0;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
}

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

@keyframes iconBounce {
  0%,
  20%,
  50%,
  80%,
  100% {
    transform: translateY(0);
  }
  40% {
    transform: translateY(-10px);
  }
  60% {
    transform: translateY(-5px);
  }
}
