/* Variables */
:root {
  --transition-fast: 0.2s ease;
  --text-secondary: #6c757d;
}

/* Layout */
#loginMessage,
#restoreMessage {
  --message-height: 90px !important;
}

#loginMessage.message,
#restoreMessage.message {
  border-radius: 8px !important;
}

.message-text {
  font-size: 1rem;
}

/* Auth Card */
.auth-card {
  background: rgba(255, 255, 255, 0.95);
  backdrop-filter: blur(10px);
  border: 1px solid rgba(255, 255, 255, 0.2);
  border-radius: 8px;
  box-shadow:
    0 20px 40px rgba(0, 0, 0, 0.2),
    var(--shadow-md);
  max-width: 500px;
  width: 100%;
  overflow: hidden;
  margin-bottom: 30px;
  opacity: 1;
  visibility: visible;
  max-height: 600px;
  transform: translateY(0) scale(1);
  transform-origin: center;
  will-change: transform, opacity;
  transition:
    opacity 0.6s cubic-bezier(0.4, 0, 0.2, 1),
    transform 0.8s cubic-bezier(0.4, 0, 0.2, 1),
    max-height 0.6s cubic-bezier(0.4, 0, 0.2, 1),
    border-radius 0.8s cubic-bezier(0.4, 0, 0.2, 1),
    visibility 0s linear;
}

.auth-card.collapsed {
  opacity: 0;
  visibility: hidden;
  max-height: 2px;
  pointer-events: none;
  margin: 0;
  padding: 0;
  border-radius: 100px;
  transform: translateY(-15px) scaleX(0.3) scaleY(0.02);
  transition:
    opacity 0.4s cubic-bezier(0.4, 0, 0.2, 1) 0.2s,
    transform 0.8s cubic-bezier(0.4, 0, 0.2, 1),
    max-height 0.6s cubic-bezier(0.4, 0, 0.2, 1) 0.1s,
    border-radius 0.8s cubic-bezier(0.4, 0, 0.2, 1),
    visibility 0s linear 0.8s;
}

/* Toggle Button */
.auth-toggle-container {
  text-align: center;
  opacity: 0;
  transform: translateY(20px);
  transition: all 0.8s ease;
  margin: 30px 0;
}

.auth-toggle-container.show {
  opacity: 1;
  transform: translateY(0);
}

.auth-toggle-btn {
  position: relative;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 320px;
  padding: 1.2rem 3.5rem 1.2rem 2.5rem;
  background: rgba(255, 255, 255, 0.15);
  border: 1.5px solid rgba(255, 255, 255, 0.4);
  border-radius: 12px;
  color: white;
  font-weight: 600;
  font-size: 1.1rem;
  letter-spacing: 1px;
  box-shadow: 0 8px 25px rgba(0, 0, 0, 0.2);
  transition: all 0.3s ease;
  overflow: hidden;
  cursor: pointer;
}

.auth-toggle-btn:hover {
  transform: translateY(-2px);
  background: rgba(255, 255, 255, 0.25);
  box-shadow: 0 12px 35px rgba(0, 0, 0, 0.3);
}

.auth-toggle-btn:active {
  transform: translateY(0);
}

.auth-toggle-btn::before {
  content: "";
  position: absolute;
  top: 0;
  left: -100%;
  width: 100%;
  height: 100%;
  background: linear-gradient(
    90deg,
    transparent,
    rgba(255, 255, 255, 0.2),
    transparent
  );
  transition: left 0.8s;
}

.auth-toggle-btn:hover::before {
  left: 100%;
}

.auth-toggle-btn i {
  position: absolute;
  right: 1.5rem;
  transition: transform 0.3s ease;
}

.auth-toggle-btn.show-auth i {
  transform: rotate(180deg);
}

.auth-toggle-btn.pulse {
  animation: pulse-auth 2s infinite;
}

/* Status Indicator */
.auth-status-indicator {
  position: absolute;
  top: 20px;
  right: 40px;
  z-index: 10;
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 6px 16px;
  border-radius: 25px;
  font-size: 0.9em;
  font-weight: 500;
  transition: all 0.3s ease;
  cursor: pointer;
}

.auth-status-indicator:hover {
  transform: translateY(-2px);
  box-shadow: var(--shadow-float);
}

.auth-status-indicator i {
  font-size: 1.2rem;
  animation: statusPulse 2s ease-in-out infinite;
}

.auth-status-indicator.authenticated {
  background: rgba(76, 217, 100, 0.2);
  color: #4cd964;
  border: 1px solid rgba(76, 217, 100, 0.3);
}

.auth-status-indicator.unauthenticated {
  background: rgba(255, 193, 7, 0.1);
  color: #ffc107;
  border: 1px solid rgba(255, 193, 7, 0.2);
}

/* Buttons */
.btn-auth {
  position: relative;
  display: inline-block;
  padding: 15px 30px;
  font-size: 1.1rem;
  font-weight: 600;
  color: white;
  background: var(--btn-bg, transparent);
  border: none;
  border-radius: 8px;
  box-shadow: 0 6px 20px var(--btn-shadow, transparent);
  overflow: hidden;
  cursor: pointer;
  transition:
    transform 0.2s ease,
    box-shadow 0.2s ease;
}

.btn-auth:hover {
  transform: translateY(-3px);
  box-shadow: 0 12px 35px var(--btn-shadow, transparent);
}

.btn-auth:active {
  transform: translateY(2px);
  box-shadow: 0 2px 8px var(--btn-shadow, transparent);
}

.btn-auth:focus,
.btn-auth:focus-visible {
  outline: none;
  box-shadow: 0 6px 20px var(--btn-shadow, transparent);
}

.btn-auth::before {
  content: "";
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 4px;
  background: linear-gradient(180deg, rgba(255, 255, 255, 0.2), transparent);
  border-radius: 8px 8px 0 0;
}

.btn-auth::after {
  content: "";
  position: absolute;
  top: 50%;
  left: 50%;
  width: 0;
  height: 0;
  background: rgba(255, 255, 255, 0.3);
  border-radius: 50%;
  transform: translate(-50%, -50%);
  transition:
    width 0.6s,
    height 0.6s;
}

.btn-auth:active::after {
  width: 300px;
  height: 300px;
}

.btn-auth-primary {
  --btn-bg: var(--gradient-primary);
  --btn-shadow: var(--color-primary-shadow);
}

.btn-auth-success {
  --btn-bg: linear-gradient(
    135deg,
    var(--color-accent),
    var(--color-accent-dark)
  );
  --btn-shadow: var(--color-accent-shadow);
}

.btn-auth-logout {
  --btn-bg: linear-gradient(
    135deg,
    var(--color-danger-dark),
    var(--color-danger)
  );
  --btn-shadow: var(--color-danger-shadow);
  width: 100%;
}

/* Forms */
.auth-body {
  padding: 20px 30px 25px;
}

.auth-forms-wrapper {
  display: grid;
  min-height: 350px;
}

.form-section {
  grid-area: 1 / 1;
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
  transition:
    opacity 0.3s ease-in-out,
    visibility 0.3s;
  z-index: 0;
}

.form-section.active {
  opacity: 1;
  visibility: visible;
  pointer-events: auto;
  z-index: 1;
}

.form-label {
  display: block;
  margin-bottom: 8px;
  font-weight: 600;
  color: var(--color-text);
}

.input-locked {
  opacity: 0.6;
  cursor: not-allowed;
  pointer-events: none;
}

.input-group-text {
  background: linear-gradient(135deg, #f8f9fa, #e9ecef);
  border: 2px solid #e9ecef;
  border-right: none;
  color: var(--text-secondary);
}

.form-control {
  padding: 15px 20px;
  font-size: 1rem;
  background: white;
  border: 2px solid #e9ecef;
  transition: var(--transition-fast);
}

#userCode,
#maskedCodeDisplay,
#emailAddress {
  border-radius: 0 8px 8px 0;
}

.input-group {
  border-radius: 8px;
}

.input-group:focus-within {
  box-shadow: 0 0 0 0.1rem rgba(41, 128, 185, 0.25);
}

.input-group:focus-within .input-group-text {
  border-color: rgba(13, 110, 253, 0.4);
  transition: var(--transition-fast);
}

.input-group:focus-within .form-control {
  border-color: rgba(13, 110, 253, 0.4);
  border-left-color: transparent;
  background: white;
  box-shadow: none;
  outline: none;
  transition: var(--transition-fast);
}

#userCodeForm,
#forgotCodeForm {
  position: relative;
  min-height: 100%;
}

#userCodeForm .form-group {
  margin-top: 35px;
}

#restoreSection .form-group {
  margin-top: 20px;
}

#restoreSection .mt-auto {
  margin-top: 0 !important;
}

#authButtons,
#restoreSubmitBtn-container {
  position: absolute;
  bottom: 0;
  width: 100%;
}

/* Tabs */
.tab-switcher {
  margin-bottom: 30px;
}

.tab-nav {
  position: relative;
  display: flex;
  padding: 5px;
  background: #f8f9fa;
  border-radius: 8px;
}

.tab-nav input[type="radio"] {
  display: none;
}

.tab-label {
  flex: 1;
  position: relative;
  z-index: 1;
  padding: 15px 20px;
  color: var(--text-secondary);
  font-weight: 500;
  text-align: center;
  transition: color 0.3s ease;
  cursor: pointer;
  white-space: nowrap;
}

.tab-label:hover {
  color: var(--color-primary);
}

#tabLogin:checked + .tab-label,
#tabRestore:checked + .tab-label {
  color: white;
}

.tab-slider {
  position: absolute;
  top: 5px;
  left: 0;
  height: calc(100% - 10px);
  width: calc(50% - 8px);
  background: var(--gradient-primary);
  border-radius: 8px;
  box-shadow: 0 4px 10px var(--color-primary-shadow);
  transition:
    transform 0.5s cubic-bezier(0.34, 1.5, 0.64, 1),
    background 0.5s ease;
  transform: translateX(8px);
}

#tabRestore:checked ~ .tab-slider {
  transform: translateX(calc(100% + 8px));
  background: linear-gradient(
    135deg,
    var(--color-accent),
    var(--color-accent-dark)
  );
  box-shadow: 0 4px 10px var(--color-accent-shadow);
}

/* Validation */
.validation-icon {
  position: absolute;
  right: 0.75rem;
  top: 50%;
  transform: translateY(-50%);
  z-index: 10;
  font-size: 1.1rem;
  width: 18px;
  height: 18px;
  display: flex;
  align-items: center;
  justify-content: center;
  opacity: 0;
  transition: opacity 0.3s ease;
}

.validation-icon.visible {
  opacity: 1;
}

.validation-icon.clickable {
  pointer-events: auto;
  cursor: pointer;
  transition: opacity 0.2s ease;
}

.validation-icon.clickable:hover {
  opacity: 0.7;
}

.validation-icon.non-clickable {
  pointer-events: none;
}

/* Animations */
@keyframes pulse-auth {
  0%,
  100% {
    box-shadow: 0 8px 25px rgba(41, 128, 185, 0.3);
  }
  50% {
    box-shadow:
      0 8px 25px rgba(41, 128, 185, 0.6),
      0 0 0 10px rgba(41, 128, 185, 0.1);
  }
}

@keyframes statusPulse {
  0%,
  100% {
    transform: scale(1);
    opacity: 1;
  }
  50% {
    transform: scale(1.1);
    opacity: 0.8;
  }
}

@keyframes spin-centered {
  0% {
    transform: translateY(-50%) rotate(0deg);
  }
  100% {
    transform: translateY(-50%) rotate(360deg);
  }
}

/* Media Queries */
@media (max-width: 576px) {
  .auth-body {
    padding: 20px 10px 50px;
  }

  .form-control {
    padding: 15px 20px;
    font-size: 0.9rem;
  }

  .message-text {
    font-size: 1rem;
  }

  #loginMessage,
  #restoreMessage {
    --message-height: 80px !important;
  }
}

@media (max-width: 768px) {
  #userCode,
  #emailAddress {
    font-size: 16px;
  }

  .auth-toggle-btn {
    min-width: 100%;
  }

  .auth-body {
    padding-bottom: 15px;
  }

  .tab-label {
    padding: 12px 15px;
    font-size: 0.9rem;
  }

  .auth-status-indicator {
    top: 10px;
    right: 16px;
    gap: 6px;
    padding: 0 10px;
    font-size: 0.8em;
  }
}
