/**
 * Modern Login Flow
 * Beautiful, minimal login experience with international phone input
 */

/* Login Container */
.login-page {
  min-height: 100vh;
  min-width: 100vw;
  display: flex;
  align-items: center;
  justify-content: center;
  background: linear-gradient(135deg, var(--ctp-base) 0%, var(--ctp-mantle) 100%);
  padding: var(--space-4);
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  overflow: auto;
}

/* Decorative background elements */
.login-page::before {
  content: '';
  position: absolute;
  top: -10%;
  right: -5%;
  width: 500px;
  height: 500px;
  background: radial-gradient(circle, rgba(30, 102, 245, 0.08) 0%, transparent 70%);
  border-radius: 50%;
  animation: float 20s ease-in-out infinite;
}

.login-page::after {
  content: '';
  position: absolute;
  bottom: -15%;
  left: -5%;
  width: 600px;
  height: 600px;
  background: radial-gradient(circle, rgba(136, 57, 239, 0.06) 0%, transparent 70%);
  border-radius: 50%;
  animation: float 25s ease-in-out infinite reverse;
}

@keyframes float {
  0%, 100% { transform: translate(0, 0) scale(1); }
  50% { transform: translate(30px, -30px) scale(1.1); }
}

/* Login Card */
.login-card {
  background: var(--color-bg-base);
  border-radius: var(--radius-xl);
  box-shadow: var(--shadow-lg);
  padding: var(--space-12);
  width: 100%;
  max-width: 440px;
  position: relative;
  z-index: 1;
  animation: slideUp 0.4s cubic-bezier(0.16, 1, 0.3, 1);
}

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

/* Header */
.login-header {
  text-align: center;
  margin-bottom: var(--space-10);
  position: relative;
}

.login-logo {
  width: 80px;
  height: 80px;
  margin: 0 auto var(--space-4);
  display: flex;
  align-items: center;
  justify-content: center;
  animation: logoAppear 0.6s cubic-bezier(0.16, 1, 0.3, 1) 0.1s backwards;
}

.login-logo img {
  width: 100%;
  height: 100%;
  object-fit: contain;
}

@keyframes logoAppear {
  from {
    opacity: 0;
    transform: scale(0.8) rotate(-10deg);
  }
  to {
    opacity: 1;
    transform: scale(1) rotate(0deg);
  }
}

.login-title {
  font-size: var(--font-size-2xl);
  font-weight: var(--font-weight-bold);
  color: var(--color-text-base);
  margin: 0 0 var(--space-2);
  animation: slideUp 0.5s cubic-bezier(0.16, 1, 0.3, 1) 0.2s backwards;
}

.login-subtitle {
  font-size: var(--font-size-base);
  color: var(--color-text-muted);
  margin: 0;
  animation: slideUp 0.5s cubic-bezier(0.16, 1, 0.3, 1) 0.3s backwards;
}

/* Form */
.login-form {
  animation: slideUp 0.5s cubic-bezier(0.16, 1, 0.3, 1) 0.4s backwards;
}

.form-group {
  margin-bottom: var(--space-6);
}

.form-label {
  display: block;
  font-size: var(--font-size-sm);
  font-weight: var(--font-weight-medium);
  color: var(--color-text-base);
  margin-bottom: var(--space-2);
}

/* International Phone Input Container */
.phone-input-container {
  position: relative;
}

/* Country Selector - Now outside phone input */
.country-selector {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  padding: var(--space-3) var(--space-4);
  background: var(--color-bg-subtle);
  border: 2px solid var(--color-border-base);
  border-radius: var(--radius-lg);
  margin-bottom: var(--space-2);
  cursor: pointer;
  transition: all var(--transition-base);
}

.country-selector:hover {
  background: var(--color-bg-muted);
  border-color: var(--color-border-strong);
}

.country-flag {
  font-size: var(--font-size-xl);
  line-height: 1;
  flex-shrink: 0;
}

.country-name {
  flex: 1;
  font-size: var(--font-size-base);
  font-weight: var(--font-weight-medium);
  color: var(--color-text-base);
}

.country-dropdown-icon {
  color: var(--color-text-muted);
  font-size: var(--font-size-sm);
  transition: transform var(--transition-base);
  flex-shrink: 0;
}

.country-selector.is-open .country-dropdown-icon {
  transform: rotate(180deg);
}

/* Phone Input Wrapper */
.phone-input-wrapper {
  position: relative;
  display: flex;
  align-items: stretch;
  background: var(--color-bg-base);
  border: 2px solid var(--color-border-base);
  border-radius: var(--radius-lg);
  transition: all var(--transition-base);
}

.phone-input-wrapper:hover {
  border-color: var(--color-border-strong);
}

.phone-input-wrapper:focus-within {
  border-color: var(--color-primary);
  box-shadow: 0 0 0 4px var(--color-focus-ring);
}

/* Phone Input Field */
.phone-input {
  flex: 1;
  padding: var(--space-4);
  border: none;
  font-size: var(--font-size-base);
  color: var(--color-text-base);
  background: transparent;
  outline: none;
  font-variant-numeric: tabular-nums;
}

.phone-input::placeholder {
  color: var(--color-text-subtle);
}

/* Validation States */
.phone-input-wrapper.is-valid {
  border-color: var(--color-success);
}

.phone-input-wrapper.is-invalid {
  border-color: var(--color-error);
}

.phone-input-wrapper.is-valid:focus-within {
  box-shadow: 0 0 0 4px rgba(64, 160, 43, 0.1);
}

.phone-input-wrapper.is-invalid:focus-within {
  box-shadow: 0 0 0 4px rgba(210, 15, 57, 0.1);
}

/* Validation Icon */
.validation-icon {
  position: absolute;
  right: var(--space-4);
  top: 50%;
  transform: translateY(-50%);
  font-size: var(--font-size-lg);
  pointer-events: none;
  opacity: 0;
  transition: opacity var(--transition-base);
}

.phone-input-wrapper.is-valid .validation-icon.check {
  opacity: 1;
  color: var(--color-success);
}

.phone-input-wrapper.is-invalid .validation-icon.cross {
  opacity: 1;
  color: var(--color-error);
}

/* Helper Text */
.form-helper {
  margin-top: var(--space-2);
  font-size: var(--font-size-sm);
  color: var(--color-text-muted);
}

.form-error {
  margin-top: var(--space-2);
  font-size: var(--font-size-sm);
  color: var(--color-error);
  display: none;
}

.phone-input-wrapper.is-invalid ~ .form-error {
  display: block;
  animation: shake 0.4s;
}

@keyframes shake {
  0%, 100% { transform: translateX(0); }
  10%, 30%, 50%, 70%, 90% { transform: translateX(-4px); }
  20%, 40%, 60%, 80% { transform: translateX(4px); }
}

/* Submit Button */
.btn-submit {
  width: 100%;
  padding: var(--space-4) var(--space-6);
  background: linear-gradient(135deg, var(--ctp-blue) 0%, var(--ctp-mauve) 100%);
  color: white;
  border: none;
  border-radius: var(--radius-lg);
  font-size: var(--font-size-base);
  font-weight: var(--font-weight-semibold);
  cursor: pointer;
  transition: all var(--transition-base);
  box-shadow: 0 4px 12px rgba(30, 102, 245, 0.3);
  position: relative;
  overflow: hidden;
}

.btn-submit::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.5s;
}

.btn-submit:hover {
  transform: translateY(-2px);
  box-shadow: 0 6px 16px rgba(30, 102, 245, 0.4);
}

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

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

.btn-submit:disabled {
  opacity: 0.6;
  cursor: not-allowed;
  transform: none;
}

/* Loading State */
.btn-submit.is-loading {
  pointer-events: none;
}

.btn-submit .btn-text {
  transition: opacity var(--transition-base);
}

.btn-submit.is-loading .btn-text {
  opacity: 0;
}

.btn-spinner {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  width: 20px;
  height: 20px;
  border: 2px solid rgba(255, 255, 255, 0.3);
  border-top-color: white;
  border-radius: 50%;
  opacity: 0;
  transition: opacity var(--transition-base);
}

.btn-submit.is-loading .btn-spinner {
  opacity: 1;
  animation: spin 0.6s linear infinite;
}

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

/* Success State */
.login-success {
  display: none;
  text-align: center;
  animation: slideUp 0.5s cubic-bezier(0.16, 1, 0.3, 1);
}

.login-success.is-visible {
  display: block;
}

.success-icon {
  width: 100px;
  height: 100px;
  margin: 0 auto var(--space-6);
  display: flex;
  align-items: center;
  justify-content: center;
}

.success-icon svg {
  width: 100%;
  height: 100%;
}

/* Circle animation - scales in with bounce */
.success-circle {
  stroke: var(--color-success);
  stroke-width: 2;
  stroke-miterlimit: 10;
  animation: scaleCircle 0.4s cubic-bezier(0.175, 0.885, 0.32, 1.275) forwards;
}

@keyframes scaleCircle {
  0% {
    opacity: 0;
    transform: scale(0);
    transform-origin: center;
  }
  100% {
    opacity: 1;
    transform: scale(1);
    transform-origin: center;
  }
}

/* Checkmark animation - draws itself */
.success-check {
  stroke: var(--color-success);
  stroke-width: 3;
  stroke-linecap: round;
  stroke-linejoin: round;
  stroke-dasharray: 48;
  stroke-dashoffset: 48;
  animation: drawCheck 0.5s cubic-bezier(0.65, 0, 0.45, 1) 0.2s forwards;
}

@keyframes drawCheck {
  to {
    stroke-dashoffset: 0;
  }
}

.success-title {
  font-size: var(--font-size-xl);
  font-weight: var(--font-weight-bold);
  color: var(--color-text-base);
  margin: 0 0 var(--space-3);
}

.success-message {
  font-size: var(--font-size-base);
  color: var(--color-text-muted);
  margin: 0;
  line-height: var(--line-height-relaxed);
}

/* Dev Mode Link */
.dev-link {
  margin-top: var(--space-6);
  padding-top: var(--space-6);
  border-top: 1px solid var(--color-border-base);
  text-align: center;
}

.dev-link a {
  color: var(--color-link);
  text-decoration: none;
  font-size: var(--font-size-sm);
  font-weight: var(--font-weight-medium);
  transition: color var(--transition-base);
}

.dev-link a:hover {
  color: var(--color-link-hover);
  text-decoration: underline;
}

/* Country Dropdown (simplified - you'd use a library in production) */
.country-dropdown {
  position: absolute;
  top: calc(100% + var(--space-2));
  left: 0;
  right: 0;
  background: var(--color-bg-base);
  border: 1px solid var(--color-border-base);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-lg);
  max-height: 300px;
  overflow-y: auto;
  z-index: var(--z-dropdown);
  display: none;
}

.country-dropdown.is-open {
  display: block;
  animation: slideDown 0.2s cubic-bezier(0.16, 1, 0.3, 1);
}

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

.country-option {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  padding: var(--space-3) var(--space-4);
  cursor: pointer;
  transition: background-color var(--transition-fast);
}

.country-option:hover {
  background: var(--color-bg-subtle);
}

.country-option-flag {
  font-size: var(--font-size-lg);
}

.country-option-name {
  flex: 1;
  font-size: var(--font-size-sm);
  color: var(--color-text-base);
}

.country-option-code {
  font-size: var(--font-size-sm);
  color: var(--color-text-muted);
  font-variant-numeric: tabular-nums;
}

/* Country Dropdown Separator */
.country-dropdown-separator {
  height: 1px;
  background: var(--color-border-base);
  margin: var(--space-2) 0;
}

/* Language Selector - Dropdown with harmonious palette */
.language-selector {
  position: absolute;
  top: -12px;
  right: -12px;
  animation: slideUp 0.5s cubic-bezier(0.16, 1, 0.3, 1) 0.15s backwards;
  z-index: 10;
}

.language-current {
  display: inline-flex;
  align-items: center;
  gap: var(--space-1);
  min-width: 56px;
  height: 28px;
  padding: 0 var(--space-2);
  background: hsla(270, 20%, 95%, 0.6);
  color: hsl(270, 8%, 45%);
  border: 1px solid hsla(270, 15%, 85%, 0.8);
  border-radius: 999px;
  font-size: 11px;
  font-weight: var(--font-weight-medium);
  cursor: pointer;
  transition: all 0.3s cubic-bezier(0.16, 1, 0.3, 1);
  backdrop-filter: blur(8px);
}

.language-current:hover {
  background: hsla(270, 25%, 92%, 0.8);
  border-color: hsla(270, 30%, 75%, 0.9);
  color: hsl(270, 10%, 35%);
}

.language-current:active {
  transform: scale(0.98);
}

.language-label {
  flex: 1;
  text-align: center;
  letter-spacing: 0.5px;
}

.language-arrow {
  font-size: 8px;
  opacity: 0.5;
  transition: transform 0.3s cubic-bezier(0.16, 1, 0.3, 1);
}

.language-selector.is-open .language-arrow {
  transform: rotate(180deg);
}

.language-dropdown {
  position: absolute;
  top: calc(100% + var(--space-2));
  right: 0;
  min-width: 64px;
  background: hsl(270, 8%, 98%);
  border: 1px solid hsl(270, 6%, 90%);
  border-radius: var(--radius-lg);
  box-shadow: 0 4px 12px hsla(270, 10%, 20%, 0.12), 0 2px 6px hsla(270, 10%, 20%, 0.08);
  opacity: 0;
  visibility: hidden;
  transform: translateY(-8px);
  transition: all 0.3s cubic-bezier(0.16, 1, 0.3, 1);
  overflow: hidden;
}

.language-selector.is-open .language-dropdown {
  opacity: 1;
  visibility: visible;
  transform: translateY(0);
}

.language-option {
  display: block;
  padding: var(--space-3);
  text-align: center;
  font-size: var(--font-size-sm);
  font-weight: var(--font-weight-medium);
  color: hsl(270, 6%, 32%);
  text-decoration: none;
  transition: all 0.2s cubic-bezier(0.16, 1, 0.3, 1);
  letter-spacing: 0.5px;
}

.language-option:hover {
  background: linear-gradient(135deg, hsl(270, 70%, 62%) 0%, hsl(260, 65%, 58%) 100%);
  color: white;
  text-shadow: 0 1px 2px hsla(270, 50%, 20%, 0.2);
}

.language-option:not(:last-child) {
  border-bottom: 1px solid hsl(270, 6%, 92%);
}

/* Responsive */
@media (max-width: 640px) {
  .login-card {
    padding: var(--space-8);
  }

  .login-title {
    font-size: var(--font-size-xl);
  }

  .login-subtitle {
    font-size: var(--font-size-sm);
  }
}

/* Accessibility */
@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
}

/* Focus visible for keyboard navigation */
.country-selector:focus-visible,
.phone-input:focus-visible,
.btn-submit:focus-visible {
  outline: 2px solid var(--color-primary);
  outline-offset: 2px;
}
