// 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;

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

  &::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;
  }
}

.login-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: 460px;
  padding: 3.5rem;
  position: relative;
  z-index: 1;
  animation: fadeInUp 0.6s cubic-bezier(0.16, 1, 0.3, 1);
  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;
    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);
    }
  }
}

.login-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);
  }
}

.login-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;
  }
}

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

.login-form {
  display: flex;
  flex-direction: column;
  gap: 1.5rem;
}

.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: 1.125rem;
  width: 20px;
  height: 20px;
  color: $text-light;
  pointer-events: none;
  transition: all 0.25s cubic-bezier(0.4, 0, 0.2, 1);
  z-index: 1;
}

.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;

  &::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;
  }

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

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

  &.code-input {
    text-align: center;
    font-size: 1.75rem;
    font-weight: 700;
    letter-spacing: 0.75rem;
    padding-right: 0.75rem;
    padding-left: 0.75rem;
    font-variant-numeric: tabular-nums;
    background: $primary-blue-lighter;
    border-color: $primary-blue-light;
  }
}

.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;
  }
}

.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);
    }
  }
}

.form-hint {
  display: flex;
  align-items: flex-start;
  gap: 0.5rem;
  font-size: 0.8125rem;
  color: $text-medium;
  margin: 0.5rem 0 0 0;
  line-height: 1.5;

  svg {
    width: 16px;
    height: 16px;
    flex-shrink: 0;
    margin-top: 0.125rem;
    color: $text-light;
  }
}

.label-icon {
  width: 18px;
  height: 18px;
  margin-right: 0.5rem;
  vertical-align: middle;
  color: $primary-blue;
}

.form-options {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-top: 0.5rem;
  margin-bottom: 1rem;
}

.remember-me {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  font-size: 0.875rem;
  color: $text-medium;
  cursor: pointer;
  user-select: none;

  input[type="checkbox"] {
    width: 18px;
    height: 18px;
    cursor: pointer;
    accent-color: $primary-blue;
  }

  span {
    font-weight: 500;
  }

  &:hover {
    color: $text-dark;
  }
}

.forgot-password-link {
  font-size: 0.875rem;
  color: $primary-blue;
  text-decoration: none;
  font-weight: 600;
  transition: color 0.2s ease;

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

  &:focus-visible {
    outline: 2px solid $border-focus;
    outline-offset: 2px;
    border-radius: 4px;
  }
}

.link-button {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  background: none;
  border: none;
  color: $primary-blue;
  font-size: 0.875rem;
  font-weight: 600;
  cursor: pointer;
  padding: 0.5rem 0;
  margin-top: 0.5rem;
  transition: color 0.2s ease;
  font-family: $font-family;

  svg {
    width: 16px;
    height: 16px;
  }

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

  &:focus-visible {
    outline: 2px solid $border-focus;
    outline-offset: 2px;
    border-radius: 4px;
  }
}

.info-message {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 1rem 1.25rem;
  background: linear-gradient(135deg, $primary-blue-lighter 0%, lighten($primary-blue-lighter, 2%) 100%);
  border: 2px solid $primary-blue-light;
  border-left: 4px solid $primary-blue;
  border-radius: 12px;
  color: $primary-blue-dark;
  font-size: 0.875rem;
  font-weight: 600;
  animation: slideInInfo 0.4s cubic-bezier(0.16, 1, 0.3, 1);
  box-shadow: $shadow-sm;
  margin-bottom: 1rem;

  svg {
    width: 20px;
    height: 20px;
    flex-shrink: 0;
    color: $primary-blue;
  }

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

.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); }
  }
}

.submit-button {
  width: 100%;
  padding: 1.125rem 2rem;
  font-size: 1rem;
  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: 0.75rem;
  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);
    }
  }
}

.login-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 0 1.5rem 0;
  font-family: $font-family;
}

.registration-links {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
  margin-top: 1.5rem;
}

.register-link {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.625rem;
  padding: 0.875rem 1.25rem;
  font-size: 0.875rem;
  font-weight: 600;
  font-family: $font-family;
  color: $primary-blue;
  text-decoration: none;
  border: 2px solid $primary-blue;
  border-radius: 10px;
  transition: all 0.25s cubic-bezier(0.4, 0, 0.2, 1);
  background: transparent;
  position: relative;
  overflow: hidden;

  &::before {
    content: '';
    position: absolute;
    inset: 0;
    background: $primary-blue-light;
    opacity: 0;
    transition: opacity 0.25s ease;
    z-index: -1;
  }

  svg {
    width: 18px;
    height: 18px;
    transition: transform 0.25s ease;
  }

  &:hover {
    background: $primary-blue-light;
    border-color: $primary-blue-dark;
    color: $primary-blue-dark;
    transform: translateY(-2px);
    box-shadow: $shadow-md;

    &::before {
      opacity: 1;
    }

    svg {
      transform: translateX(2px);
    }
  }

  &:active {
    transform: translateY(0);
    box-shadow: $shadow-sm;
  }

  &:focus-visible {
    outline: 2px solid $border-focus;
    outline-offset: 2px;
  }
}

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

// Dark mode support (optional, if needed)
@media (prefers-color-scheme: dark) {
  .login-container {
    background: #1e1e1e;
  }

  .login-title {
    color: $white;
  }

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

  .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);
  }
}

.success-message {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 1rem 1.25rem;
  background: linear-gradient(135deg, #d1fae5 0%, #a7f3d0 100%);
  border: 1px solid #10b981;
  border-radius: 12px;
  margin-bottom: 1.5rem;
  color: #059669;
  font-size: 0.875rem;
  line-height: 1.5;

  .success-icon {
    width: 20px;
    height: 20px;
    flex-shrink: 0;
    color: #10b981;
  }
}

.back-to-login-link {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  color: $primary-blue;
  text-decoration: none;
  font-size: 0.875rem;
  font-weight: 600;
  margin-top: 1rem;
  transition: color 0.2s ease;

  svg {
    width: 16px;
    height: 16px;
  }

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

