// Enterprise-Grade Color Palette
$primary-blue: #0066cc;
$primary-blue-dark: #0052a3;
$primary-blue-light: #e6f2ff;
$primary-blue-lighter: #f0f7ff;
$accent-teal: #0099a1;
$accent-teal-light: #00c4ce;
$text-dark: #0f172a;
$text-medium: #475569;
$text-light: #64748b;
$text-lighter: #94a3b8;
$border-color: #e2e8f0;
$border-color-light: #f1f5f9;
$border-focus: #0066cc;
$error-red: #dc2626;
$error-red-dark: #b91c1c;
$error-bg: #fef2f2;
$error-border: #fecaca;
$success-green: #10b981;
$success-green-dark: #059669;
$success-bg: #d1fae5;
$warning-orange: #f59e0b;
$info-blue: #3b82f6;
$white: #ffffff;
$background-light: #f8fafc;
$background-elevated: #ffffff;
$gradient-primary: linear-gradient(135deg, #0066cc 0%, #0099a1 100%);
$gradient-primary-hover: linear-gradient(135deg, #0052a3 0%, #007a82 100%);
$gradient-bg: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
$gradient-bg-alt: linear-gradient(135deg, #f093fb 0%, #f5576c 100%);

// Enterprise Shadow System
$shadow-xs: 0 1px 2px 0 rgba(0, 0, 0, 0.05);
$shadow-sm: 0 1px 3px 0 rgba(0, 0, 0, 0.1), 0 1px 2px -1px rgba(0, 0, 0, 0.1);
$shadow-md: 0 4px 6px -1px rgba(0, 0, 0, 0.1), 0 2px 4px -2px rgba(0, 0, 0, 0.1);
$shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.1), 0 4px 6px -4px rgba(0, 0, 0, 0.1);
$shadow-xl: 0 20px 25px -5px rgba(0, 0, 0, 0.1), 0 8px 10px -6px rgba(0, 0, 0, 0.1);
$shadow-2xl: 0 25px 50px -12px rgba(0, 0, 0, 0.25);
$shadow-inner: inset 0 2px 4px 0 rgba(0, 0, 0, 0.05);
$shadow-blue: 0 10px 25px -5px rgba(0, 102, 204, 0.25);
$shadow-blue-lg: 0 20px 40px -10px rgba(0, 102, 204, 0.3);

// Typography
$font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;

.register-wrapper {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  background: $gradient-bg;
  background-attachment: fixed;
  padding: 2rem;
  position: relative;
  overflow-y: auto;

  &::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: 
      radial-gradient(circle at 20% 50%, rgba(255, 255, 255, 0.15) 0%, transparent 50%),
      radial-gradient(circle at 80% 80%, rgba(255, 255, 255, 0.12) 0%, transparent 50%),
      radial-gradient(circle at 50% 20%, rgba(102, 126, 234, 0.3) 0%, transparent 60%);
    pointer-events: none;
    animation: backgroundShift 20s ease-in-out infinite alternate;
  }

  &::after {
    content: '';
    position: absolute;
    top: -50%;
    right: -50%;
    width: 200%;
    height: 200%;
    background: radial-gradient(circle, rgba(255, 255, 255, 0.05) 0%, transparent 70%);
    animation: rotateBackground 30s linear infinite;
    pointer-events: none;
  }

  @keyframes backgroundShift {
    0% {
      opacity: 1;
      transform: translateY(0);
    }
    100% {
      opacity: 0.8;
      transform: translateY(-20px);
    }
  }

  @keyframes rotateBackground {
    from {
      transform: rotate(0deg);
    }
    to {
      transform: rotate(360deg);
    }
  }

  @media (max-width: 768px) {
    padding: 1rem;
  }
}

.register-container {
  background: rgba($white, 0.98);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  border: 1px solid rgba(255, 255, 255, 0.3);
  border-radius: 24px;
  box-shadow: $shadow-2xl, 0 0 0 1px rgba(255, 255, 255, 0.2) inset;
  width: 100%;
  max-width: 850px;
  padding: 3.5rem;
  position: relative;
  z-index: 1;
  animation: fadeInUp 0.6s cubic-bezier(0.16, 1, 0.3, 1);
  margin: 2rem 0;
  overflow: hidden;

  &::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 4px;
    background: $gradient-primary;
    z-index: 2;
  }

  @media (max-width: 768px) {
    padding: 2.5rem 2rem;
    border-radius: 20px;
    margin: 1rem 0;
    max-width: 100%;
  }

  @media (max-width: 480px) {
    padding: 2rem 1.5rem;
    border-radius: 16px;
  }

  @keyframes fadeInUp {
    from {
      opacity: 0;
      transform: translateY(30px) scale(0.95);
    }
    to {
      opacity: 1;
      transform: translateY(0) scale(1);
    }
  }
}

.register-header {
  text-align: center;
  margin-bottom: 2.5rem;
}

.logo-container {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 72px;
  height: 72px;
  background: $gradient-primary;
  border-radius: 18px;
  margin-bottom: 1.75rem;
  box-shadow: $shadow-lg, 0 0 0 4px rgba(0, 102, 204, 0.1);
  position: relative;
  transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);

  &::after {
    content: '';
    position: absolute;
    inset: -2px;
    border-radius: 20px;
    background: $gradient-primary;
    opacity: 0;
    filter: blur(12px);
    transition: opacity 0.3s ease;
    z-index: -1;
  }

  &:hover {
    transform: translateY(-2px) scale(1.05);
    box-shadow: $shadow-xl, 0 0 0 4px rgba(0, 102, 204, 0.15);

    &::after {
      opacity: 0.4;
    }
  }

  .medical-icon {
    width: 40px;
    height: 40px;
    color: $white;
    filter: drop-shadow(0 2px 4px rgba(0, 0, 0, 0.2));
    transition: transform 0.3s ease;
  }

  &:hover .medical-icon {
    transform: scale(1.1);
  }
}

.register-title {
  font-size: 2rem;
  font-weight: 800;
  background: $gradient-primary;
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
  margin: 0 0 0.75rem 0;
  letter-spacing: -0.75px;
  font-family: $font-family;
  line-height: 1.2;

  @media (max-width: 768px) {
    font-size: 1.75rem;
  }
}

.register-subtitle {
  font-size: 1rem;
  color: $text-medium;
  margin: 0;
  font-weight: 500;
  line-height: 1.5;
}

.register-form {
  display: flex;
  flex-direction: column;
  gap: 2rem;
}

.form-section {
  display: flex;
  flex-direction: column;
  gap: 1.75rem;
  padding: 2rem 0;
  border-bottom: 2px solid $border-color-light;
  position: relative;

  &:first-of-type {
    padding-top: 0;
  }

  &:last-of-type {
    border-bottom: none;
    padding-bottom: 0;
  }

  &::before {
    content: '';
    position: absolute;
    left: 0;
    bottom: -2px;
    width: 0;
    height: 2px;
    background: $gradient-primary;
    transition: width 0.3s ease;
  }

  &:focus-within::before,
  &:hover::before {
    width: 100px;
  }
}

.section-title {
  font-size: 1.25rem;
  font-weight: 700;
  background: $gradient-primary;
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
  margin: 0 0 0.5rem 0;
  font-family: $font-family;
  display: flex;
  align-items: center;
  gap: 0.75rem;
  letter-spacing: -0.3px;

  &::before {
    content: '';
    width: 4px;
    height: 1.5rem;
    background: $gradient-primary;
    border-radius: 2px;
    display: block;
  }
}

.form-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1rem;

  @media (max-width: 768px) {
    grid-template-columns: 1fr;
  }
}

.form-group {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.form-label {
  font-size: 0.875rem;
  font-weight: 600;
  color: $text-dark;
  letter-spacing: 0.2px;
  font-family: $font-family;
}

.input-wrapper {
  position: relative;
  display: flex;
  align-items: center;
}

.input-icon {
  position: absolute;
  left: 1rem;
  width: 20px;
  height: 20px;
  color: $text-light;
  pointer-events: none;
  transition: color 0.2s ease;
}

.form-input {
  width: 100%;
  padding: 1rem 3rem 1rem 3rem;
  font-size: 0.9375rem;
  font-family: $font-family;
  color: $text-dark;
  background: $background-elevated;
  border: 2px solid $border-color;
  border-radius: 12px;
  transition: all 0.25s cubic-bezier(0.4, 0, 0.2, 1);
  outline: none;
  box-shadow: $shadow-inner;

  &:not(.form-textarea) {
    padding-left: 3rem;
  }

  &::placeholder {
    color: $text-lighter;
    font-weight: 400;
  }

  &:hover:not(:disabled):not(:focus) {
    border-color: $border-color-light;
    background: $white;
    box-shadow: $shadow-sm;
  }

  &:focus {
    border-color: $border-focus;
    background: $white;
    box-shadow: 0 0 0 4px rgba($border-focus, 0.1), $shadow-md;
    transform: translateY(-1px);
    
    ~ .input-icon {
      color: $border-focus;
      transform: scale(1.1);
    }
  }

  &:disabled {
    background: $background-light;
    cursor: not-allowed;
    opacity: 0.6;
    border-color: $border-color;
  }
}

.form-textarea {
  padding: 1rem 1.25rem;
  resize: vertical;
  min-height: 120px;
  font-family: $font-family;
  line-height: 1.6;
  border-radius: 12px;
  border: 2px solid $border-color;
  background: $background-elevated;
  transition: all 0.25s cubic-bezier(0.4, 0, 0.2, 1);
  box-shadow: $shadow-inner;

  &:hover:not(:focus) {
    border-color: $border-color-light;
    background: $white;
    box-shadow: $shadow-sm;
  }

  &:focus {
    border-color: $border-focus;
    background: $white;
    box-shadow: 0 0 0 4px rgba($border-focus, 0.1), $shadow-md;
    outline: none;
  }
}

select.form-input {
  padding-left: 1rem;
  appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 12 12'%3E%3Cpath fill='%236b6b6b' d='M6 9L1 4h10z'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 1rem center;
  padding-right: 2.5rem;
}

.input-error {
  border-color: $error-red !important;
  background: $error-bg !important;
  
  ~ .input-icon {
    color: $error-red !important;
  }

  &:focus {
    box-shadow: 0 0 0 4px rgba($error-red, 0.1), $shadow-md !important;
    background: $white !important;
  }
}

.field-error {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  font-size: 0.8125rem;
  color: $error-red;
  margin-top: 0.375rem;
  font-weight: 500;
  padding-left: 0.25rem;
  animation: slideDown 0.2s ease-out;

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

.password-toggle {
  position: absolute;
  right: 0.75rem;
  background: transparent;
  border: none;
  cursor: pointer;
  padding: 0.625rem;
  display: flex;
  align-items: center;
  justify-content: center;
  color: $text-light;
  transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
  z-index: 2;
  border-radius: 8px;

  svg {
    width: 20px;
    height: 20px;
    transition: transform 0.2s ease;
  }

  &:hover {
    color: $text-dark;
    background: $background-light;
    transform: scale(1.1);
  }

  &:active {
    transform: scale(0.95);
  }

  &:focus-visible {
    outline: 2px solid $border-focus;
    outline-offset: 2px;
    background: $primary-blue-lighter;
  }
}

.password-strength {
  margin-top: 0.5rem;
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.strength-bar {
  width: 100%;
  height: 4px;
  background: $background-light;
  border-radius: 2px;
  overflow: hidden;
}

.strength-fill {
  height: 100%;
  transition: all 0.4s cubic-bezier(0.4, 0, 0.2, 1);
  border-radius: 2px;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
  
  &.strength-0 { 
    width: 0%; 
    background: transparent; 
  }
  &.strength-1 { 
    background: linear-gradient(90deg, $error-red, lighten($error-red, 10%)); 
    box-shadow: 0 0 8px rgba($error-red, 0.3);
  }
  &.strength-2 { 
    background: linear-gradient(90deg, $warning-orange, lighten($warning-orange, 10%)); 
    box-shadow: 0 0 8px rgba($warning-orange, 0.3);
  }
  &.strength-3 { 
    background: linear-gradient(90deg, $info-blue, lighten($info-blue, 10%)); 
    box-shadow: 0 0 8px rgba($info-blue, 0.3);
  }
  &.strength-4 { 
    background: linear-gradient(90deg, $success-green, lighten($success-green, 10%)); 
    box-shadow: 0 0 8px rgba($success-green, 0.3);
  }
  &.strength-5 { 
    background: linear-gradient(90deg, $success-green, $success-green-dark); 
    box-shadow: 0 0 12px rgba($success-green, 0.4);
    animation: pulse 2s ease-in-out infinite;
  }

  @keyframes pulse {
    0%, 100% {
      opacity: 1;
    }
    50% {
      opacity: 0.8;
    }
  }
}

.strength-text {
  font-size: 0.8125rem;
  font-weight: 600;
  transition: color 0.3s ease;
  
  &.strength-0 { color: $text-lighter; }
  &.strength-1 { color: $error-red-dark; }
  &.strength-2 { color: darken($warning-orange, 10%); }
  &.strength-3 { color: darken($info-blue, 10%); }
  &.strength-4 { color: $success-green-dark; }
  &.strength-5 { color: $success-green-dark; }
}

.error-message {
  display: flex;
  align-items: flex-start;
  gap: 0.875rem;
  padding: 1rem 1.25rem;
  background: linear-gradient(135deg, $error-bg 0%, lighten($error-bg, 2%) 100%);
  border: 2px solid $error-border;
  border-left: 4px solid $error-red;
  border-radius: 12px;
  color: $error-red-dark;
  font-size: 0.875rem;
  font-weight: 600;
  animation: slideInError 0.4s cubic-bezier(0.16, 1, 0.3, 1), shake 0.5s ease-out 0.4s;
  box-shadow: $shadow-sm;
  margin-top: 0.5rem;

  .error-icon {
    width: 20px;
    height: 20px;
    flex-shrink: 0;
    margin-top: 0.125rem;
    filter: drop-shadow(0 1px 2px rgba(220, 38, 38, 0.2));
  }

  @keyframes slideInError {
    from {
      opacity: 0;
      transform: translateY(-10px) scale(0.95);
    }
    to {
      opacity: 1;
      transform: translateY(0) scale(1);
    }
  }

  @keyframes shake {
    0%, 100% { transform: translateX(0); }
    25% { transform: translateX(-6px); }
    75% { transform: translateX(6px); }
  }
}

.success-message {
  display: flex;
  align-items: flex-start;
  gap: 1.25rem;
  padding: 1.75rem 2rem;
  background: linear-gradient(135deg, $success-bg 0%, lighten($success-bg, 2%) 100%);
  border: 2px solid rgba($success-green, 0.3);
  border-left: 4px solid $success-green;
  border-radius: 16px;
  margin-bottom: 2rem;
  animation: slideInSuccess 0.5s cubic-bezier(0.16, 1, 0.3, 1);
  box-shadow: $shadow-lg;

  .success-icon {
    width: 36px;
    height: 36px;
    color: $success-green;
    flex-shrink: 0;
    margin-top: 0.125rem;
    filter: drop-shadow(0 2px 4px rgba(16, 185, 129, 0.2));
    animation: checkmark 0.6s cubic-bezier(0.16, 1, 0.3, 1);
  }

  .success-content {
    flex: 1;

    h3 {
      font-size: 1.25rem;
      font-weight: 700;
      color: $success-green-dark;
      margin: 0 0 0.5rem 0;
      font-family: $font-family;
      letter-spacing: -0.3px;
    }

    p {
      font-size: 0.9375rem;
      color: $text-dark;
      margin: 0;
      font-family: $font-family;
      line-height: 1.6;
    }
  }

  @keyframes slideInSuccess {
    from {
      opacity: 0;
      transform: translateY(-15px) scale(0.95);
    }
    to {
      opacity: 1;
      transform: translateY(0) scale(1);
    }
  }

  @keyframes checkmark {
    0% {
      transform: scale(0);
      opacity: 0;
    }
    50% {
      transform: scale(1.2);
    }
    100% {
      transform: scale(1);
      opacity: 1;
    }
  }
}

.submit-button {
  width: 100%;
  padding: 1.125rem 2rem;
  font-size: 1.0625rem;
  font-weight: 700;
  font-family: $font-family;
  color: $white;
  background: $gradient-primary;
  border: none;
  border-radius: 12px;
  cursor: pointer;
  transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  box-shadow: $shadow-md, 0 0 0 1px rgba(255, 255, 255, 0.1) inset;
  margin-top: 1rem;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.75rem;
  position: relative;
  overflow: hidden;
  text-transform: none;
  letter-spacing: 0.3px;

  &::before {
    content: '';
    position: absolute;
    top: 0;
    left: -100%;
    width: 100%;
    height: 100%;
    background: linear-gradient(90deg, transparent, rgba(255, 255, 255, 0.25), transparent);
    transition: left 0.6s ease;
  }

  &::after {
    content: '';
    position: absolute;
    inset: 0;
    border-radius: 12px;
    padding: 2px;
    background: $gradient-primary;
    -webkit-mask: linear-gradient(#fff 0 0) content-box, linear-gradient(#fff 0 0);
    -webkit-mask-composite: xor;
    mask-composite: exclude;
    opacity: 0;
    transition: opacity 0.3s ease;
  }

  &:hover:not(:disabled) {
    transform: translateY(-3px) scale(1.01);
    box-shadow: $shadow-blue-lg, 0 0 0 1px rgba(255, 255, 255, 0.15) inset;
    background: $gradient-primary-hover;
    
    &::before {
      left: 100%;
    }

    &::after {
      opacity: 0.3;
    }
  }

  &:active:not(:disabled) {
    transform: translateY(-1px) scale(0.99);
    box-shadow: $shadow-md;
  }

  &:disabled {
    opacity: 0.6;
    cursor: not-allowed;
    transform: none;
    background: $text-lighter;
    box-shadow: none;
  }

  &.loading {
    pointer-events: none;
  }

  .loading-content {
    display: flex;
    align-items: center;
    gap: 0.75rem;
  }

  .spinner {
    width: 20px;
    height: 20px;
    animation: spin 0.8s linear infinite;
    filter: drop-shadow(0 1px 2px rgba(0, 0, 0, 0.2));
  }

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

.register-footer {
  margin-top: 2rem;
  padding-top: 1.5rem;
  border-top: 1px solid $border-color;
  text-align: center;
}

.footer-text {
  font-size: 0.8125rem;
  color: $text-light;
  margin: 0;
  font-family: $font-family;
}

.login-link {
  color: $primary-blue;
  text-decoration: none;
  font-weight: 600;
  transition: color 0.2s ease;

  &:hover {
    color: $primary-blue-dark;
    text-decoration: underline;
  }
}

// Focus visible for accessibility
.form-input:focus-visible,
select.form-input:focus-visible,
.submit-button:focus-visible {
  outline: 2px solid $border-focus;
  outline-offset: 2px;
}

// Dark mode support
@media (prefers-color-scheme: dark) {
  .register-container {
    background: #1e1e1e;
  }

  .register-title {
    color: $white;
  }

  .register-subtitle {
    color: rgba($white, 0.7);
  }

  .section-title {
    color: rgba($white, 0.9);
  }

  .form-label {
    color: rgba($white, 0.9);
  }

  .form-input {
    background: #2a2a2a;
    border-color: #404040;
    color: $white;

    &:focus {
      border-color: $border-focus;
    }
  }

  .footer-text {
    color: rgba($white, 0.5);
  }
}

