@import "/./src/assets/scss/mixins.scss";
@import "/./src/assets/scss/variables.scss";
@import "/./src/assets/scss/icons.scss";
@import "/./src/assets/scss/fonts.scss";
@import "/./src/assets/scss/input.scss";
@import "/./src/assets/scss/buttons.scss";

// Couleurs Estair
$estair-blue: #4AA8DC;
$estair-blue-alt: #3ea8da;
$estair-green: #8DA969;
$estair-blue-light: #E8F4FD;
$estair-blue-dark: #2A7BA7;
$estair-green-light: #F0F7EA;
$estair-gray-50: #f8fafc;
$estair-gray-100: #f1f5f9;
$estair-gray-200: #e2e8f0;
$estair-gray-300: #cbd5e1;
$estair-gray-400: #94a3b8;
$estair-gray-500: #64748b;
$estair-gray-600: #475569;
$estair-gray-700: #334155;
$estair-gray-800: #1e293b;
$estair-gray-900: #0f172a;

// Main wrapper - Split layout like TailAdmin
.signin-wrapper {
  display: flex;
  min-height: 100vh;
  
  @media (max-width: 1023px) {
    flex-direction: column;
  }
}

// Left side - Form
.signin-left {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 2rem 1.5rem;
  background: white;
  
  @media (min-width: 1024px) {
    flex: 0 0 50%;
    max-width: 50%;
  }
  
  @media (max-width: 1023px) {
    order: 2;
    min-height: 60vh;
  }
}

.signin-form-container {
  width: 100%;
  max-width: 480px;
  
  @media (max-width: 640px) {
    max-width: 100%;
  }
}

// Right side - Branding
.signin-right {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 2rem;
  background: linear-gradient(135deg, $estair-blue-light 0%, $estair-green-light 100%);
  position: relative;
  overflow: hidden;
  
  @media (min-width: 1024px) {
    flex: 0 0 50%;
    max-width: 50%;
  }
  
  @media (max-width: 1023px) {
    order: 1;
    min-height: 40vh;
    padding: 1.5rem;
  }
}

.branding-container {
  text-align: center;
  position: relative;
  z-index: 10;
}

.logo-section {
  .auth-logo {
    height: 120px;
    width: auto;
    margin-bottom: 1.5rem;
    filter: drop-shadow(0 8px 16px rgba(74, 168, 220, 0.2));
    
    @media (max-width: 1023px) {
      height: 80px;
      margin-bottom: 1rem;
    }
  }
}

.branding-title {
  font-size: 2.5rem;
  font-weight: 700;
  color: $estair-blue-dark;
  margin-bottom: 0.75rem;
  letter-spacing: -0.025em;
  
  @media (max-width: 1023px) {
    font-size: 2rem;
  }
  
  @media (max-width: 640px) {
    font-size: 1.75rem;
  }
}

.branding-tagline {
  font-size: 1.125rem;
  color: $estair-gray-600;
  margin: 0;
  font-weight: 400;
  line-height: 1.6;
  
  @media (max-width: 1023px) {
    font-size: 1rem;
  }
  
  @media (max-width: 640px) {
    font-size: 0.875rem;
  }
}

// Decorative grid pattern like TailAdmin
.decorative-grid {
  position: absolute;
  inset: 0;
  opacity: 0.3;
}

.grid-pattern {
  position: absolute;
  inset: 0;
  background-image: 
    radial-gradient(circle at 30px 30px, rgba(74, 168, 220, 0.15) 2px, transparent 2px),
    radial-gradient(circle at 90px 90px, rgba(141, 169, 105, 0.15) 2px, transparent 2px);
  background-size: 120px 120px;
  background-position: 0 0, 60px 60px;
  animation: gridFloat 25s ease-in-out infinite;
}

@keyframes gridFloat {
  0%, 100% { transform: translate(0, 0) rotate(0deg); }
  25% { transform: translate(-10px, -10px) rotate(1deg); }
  50% { transform: translate(10px, -5px) rotate(-1deg); }
  75% { transform: translate(-5px, 10px) rotate(0.5deg); }
}

// Form styling
.signin-header {
  margin-bottom: 2rem;
  
  @media (max-width: 640px) {
    margin-bottom: 1.5rem;
  }
}

.signin-title {
  font-size: 2rem;
  font-weight: 700;
  color: $estair-gray-900;
  margin-bottom: 0.5rem;
  line-height: 1.2;
  
  @media (max-width: 640px) {
    font-size: 1.75rem;
  }
}

.signin-subtitle {
  font-size: 1rem;
  color: $estair-gray-500;
  margin: 0;
  font-weight: 400;
  
  @media (max-width: 640px) {
    font-size: 0.875rem;
  }
}

// Modern input styling
.modern-input-group {
  margin-bottom: 1.5rem;
  
  .input-wrapper {
    position: relative;
    display: flex;
    align-items: center;
  }
}

.modern-input {
  width: 100%;
  padding: 1rem 1rem 1rem 3rem;
  border: 2px solid $estair-gray-200;
  border-radius: 0.75rem;
  font-size: 1rem;
  background: $estair-gray-50;
  transition: all 0.2s ease;
  
  &::placeholder {
    color: transparent;
  }
  
  &:focus {
    outline: none;
    border-color: $estair-blue;
    background: white;
    box-shadow: 0 0 0 3px rgba(74, 168, 220, 0.1);
    
    + .floating-label {
      transform: translateY(-1.5rem) scale(0.875);
      color: $estair-blue;
      font-weight: 500;
    }
  }
  
  &:not(:placeholder-shown) + .floating-label,
  &:focus + .floating-label {
    transform: translateY(-1.5rem) scale(0.875);
  }
  
  &.is-valid {
    border-color: $estair-green;
    background: rgba(141, 169, 105, 0.05);
    
    &:focus {
      box-shadow: 0 0 0 3px rgba(141, 169, 105, 0.1);
    }
    
    + .floating-label {
      color: $estair-green;
    }
  }
  
  &.is-invalid {
    border-color: #ef4444;
    background: rgba(239, 68, 68, 0.05);
    
    &:focus {
      box-shadow: 0 0 0 3px rgba(239, 68, 68, 0.1);
    }
    
    + .floating-label {
      color: #ef4444;
    }
  }
}

.floating-label {
  position: absolute;
  left: 3rem;
  top: 50%;
  transform: translateY(-50%);
  color: $estair-gray-400;
  font-size: 1rem;
  transition: all 0.2s ease;
  pointer-events: none;
  background: transparent;
  padding: 0 0.25rem;
  z-index: 1;
}

.input-icon {
  position: absolute;
  left: 1rem;
  top: 50%;
  transform: translateY(-50%);
  color: $estair-gray-400;
  font-size: 1.25rem;
  z-index: 2;
  transition: color 0.2s ease;
}

.modern-input:focus ~ .input-icon {
  color: $estair-blue;
}

.modern-input.is-valid ~ .input-icon {
  color: $estair-green;
}

.modern-input.is-invalid ~ .input-icon {
  color: #ef4444;
}

.password-toggle {
  position: absolute;
  right: 1rem;
  top: 50%;
  transform: translateY(-50%);
  cursor: pointer;
  color: $estair-gray-400;
  font-size: 1.125rem;
  z-index: 2;
  transition: color 0.2s ease;
  
  &:hover:not(.disabled) {
    color: $estair-blue;
  }
  
  &.disabled {
    opacity: 0.5;
    cursor: not-allowed;
  }
}

// Button styling
.modern-btn {
  width: 100%;
  padding: 1rem 1.5rem;
  border-radius: 0.75rem;
  font-size: 1rem;
  font-weight: 600;
  background: linear-gradient(135deg, $estair-blue 0%, $estair-blue-alt 100%);
  border: none;
  color: white;
  cursor: pointer;
  transition: all 0.3s ease;
  position: relative;
  overflow: hidden;
  margin-top: 1rem;
  
  .btn-content {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
  }
  
  &:hover:not(:disabled) {
    background: linear-gradient(135deg, $estair-blue-dark 0%, $estair-blue 100%);
    transform: translateY(-1px);
    box-shadow: 0 10px 20px rgba(74, 168, 220, 0.3);
  }
  
  &:active:not(:disabled) {
    transform: translateY(0);
    box-shadow: 0 5px 10px rgba(74, 168, 220, 0.2);
  }
  
  &:disabled {
    opacity: 0.6;
    cursor: not-allowed;
    transform: none;
    background: $estair-gray-300;
  }
  
  .loading-content {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    
    .spinner {
      width: 16px;
      height: 16px;
      border: 2px solid transparent;
      border-top: 2px solid currentColor;
      border-radius: 50%;
      animation: spin 1s linear infinite;
    }
  }
  
  &.btn-loading {
    background: linear-gradient(135deg, $estair-blue 0%, $estair-blue-alt 100%);
    
    &::before {
      content: '';
      position: absolute;
      top: 0;
      left: -100%;
      width: 100%;
      height: 100%;
      background: linear-gradient(90deg, transparent, rgba(255,255,255,0.2), transparent);
      animation: loading-shimmer 1.5s infinite;
    }
  }
}

@keyframes loading-shimmer {
  0% { left: -100%; }
  100% { left: 100%; }
}

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

// Sign up link
.signup-link {
  text-align: center;
  margin-top: 1.5rem;
  
  p {
    font-size: 0.875rem;
    color: $estair-gray-500;
    margin: 0;
  }
  
  .link-primary {
    color: $estair-blue;
    text-decoration: none;
    font-weight: 500;
    transition: color 0.2s ease;
    
    &:hover {
      color: $estair-blue-dark;
      text-decoration: underline;
    }
  }
}

// Loading progress
.loading-progress {
  margin-bottom: 1.5rem;
  text-align: center;
  
  .progress-bar {
    width: 100%;
    height: 6px;
    background-color: $estair-gray-200;
    border-radius: 3px;
    overflow: hidden;
    margin-bottom: 0.75rem;
    
    .progress-fill {
      height: 100%;
      background: linear-gradient(90deg, $estair-blue, $estair-blue-alt);
      transition: width 0.4s cubic-bezier(0.4, 0, 0.2, 1);
      border-radius: 3px;
    }
  }
  
  .loading-message {
    font-size: 0.875rem;
    color: $estair-blue;
    margin: 0.5rem 0;
    font-weight: 500;
  }
  
  .loading-spinner {
    width: 20px;
    height: 20px;
    border: 2px solid $estair-gray-200;
    border-top: 2px solid $estair-blue;
    border-radius: 50%;
    animation: spin 1s linear infinite;
    margin: 0.75rem auto;
  }
}

// Error and status messages
.error-login {
  text-align: center;
  color: #ef4444;
  margin-top: 1rem;
  padding: 0.75rem 1rem;
  background: linear-gradient(135deg, #fef2f2 0%, #fee2e2 100%);
  border: 1px solid #fecaca;
  border-radius: 0.5rem;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.875rem;
  animation: shake 0.4s ease-in-out;
  
  .icon-warning {
    margin-right: 0.5rem;
    font-size: 1rem;
    color: #ef4444;
  }
}

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

.blocked-message {
  background: linear-gradient(135deg, #ef4444, #dc2626);
  color: white;
  padding: 1rem;
  border-radius: 0.75rem;
  text-align: center;
  margin-bottom: 1.5rem;
  box-shadow: 0 10px 25px rgba(239, 68, 68, 0.25);
  animation: pulse 2s infinite;
  
  .icon-warning {
    font-size: 1.25rem;
    margin-bottom: 0.5rem;
    display: block;
  }
  
  p {
    margin: 0.25rem 0;
    font-size: 0.875rem;
    
    strong {
      font-weight: 600;
      font-size: 1rem;
    }
  }
}

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

.attempts-warning {
  background: linear-gradient(135deg, #f59e0b, #d97706);
  color: white;
  padding: 0.5rem 0.75rem;
  border-radius: 0.5rem;
  font-size: 0.75rem;
  margin-bottom: 1rem;
  display: flex;
  align-items: center;
  box-shadow: 0 4px 12px rgba(245, 158, 11, 0.25);
  
  .icon-warning {
    margin-right: 0.375rem;
    font-size: 0.875rem;
  }
}

// Form disabled state
.form-disabled {
  pointer-events: none;
  opacity: 0.6;
  
  .modern-input {
    background-color: $estair-gray-100;
    color: $estair-gray-400;
    border-color: $estair-gray-200;
  }
  
  .input-icon,
  .floating-label {
    color: $estair-gray-300;
  }
}

// Icons
.icon-user::before { content: "👤"; }
.icon-lock::before { content: "🔒"; }
.icon-login::before { content: "🚀"; }
.icon-clock::before { content: "⏰"; }
.icon-eye::before { content: "👁️"; }
.icon-eye-close::before { content: "🙈"; }
.icon-warning::before { content: "⚠️"; }

// Preview element styling
.selected-element-preview {
  margin-top: 1rem;
  padding: 0.75rem;
  background: linear-gradient(135deg, $estair-blue-light 0%, rgba(255, 255, 255, 0.9) 100%);
  border: 1px solid rgba(74, 168, 220, 0.2);
  border-radius: 0.5rem;
  font-size: 0.75rem;
  backdrop-filter: blur(5px);
  animation: slideInUp 0.4s ease-out;
  
  .preview-header {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    margin-bottom: 0.5rem;
    font-weight: 600;
    color: $estair-blue;
    
    .icon-preview::before {
      content: "👁️";
      font-size: 0.875rem;
    }
  }
  
  .preview-content {
    .preview-item {
      margin-bottom: 0.375rem;
      
      strong {
        display: block;
        color: $estair-blue-dark;
        font-weight: 600;
        margin-bottom: 0.125rem;
        font-size: 0.8125rem;
      }
      
      .preview-path {
        color: $estair-gray-500;
        font-size: 0.6875rem;
      }
    }
    
    .preview-stats {
      display: flex;
      gap: 0.75rem;
      margin: 0.5rem 0;
      
      .stat-item {
        display: flex;
        align-items: center;
        gap: 0.25rem;
        color: $estair-gray-600;
        font-size: 0.6875rem;
        padding: 0.125rem 0.375rem;
        background: rgba(255, 255, 255, 0.7);
        border-radius: 0.25rem;
        
        .icon-list::before {
          content: "📋";
          font-size: 0.625rem;
        }
        
        .icon-action::before {
          content: "⚡";
          font-size: 0.625rem;
        }
      }
    }
    
    .preview-actions {
      margin-top: 0.5rem;
      
      .actions-label {
        display: block;
        font-size: 0.625rem;
        color: $estair-gray-500;
        margin-bottom: 0.25rem;
        font-weight: 500;
      }
      
      .action-chip {
        display: inline-block;
        background: rgba(141, 169, 105, 0.15);
        color: $estair-green;
        padding: 0.125rem 0.375rem;
        border-radius: 0.25rem;
        font-size: 0.625rem;
        margin-right: 0.25rem;
        margin-bottom: 0.125rem;
        font-weight: 500;
        border: 1px solid rgba(141, 169, 105, 0.2);
      }
    }
  }
}

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

// Form hints and validation
.form-hint {
  text-align: center;
  margin-top: 0.5rem;
  
  small {
    color: $estair-gray-400;
    font-size: 0.75rem;
    font-weight: 400;
  }
}

.invalid-feedback {
  color: #ef4444;
  font-size: 0.75rem;
  margin-top: 0.25rem;
  display: flex;
  align-items: center;
  
  &::before {
    content: "⚠️";
    margin-right: 0.25rem;
    font-size: 0.75rem;
  }
}

// Emergency unblock button
.emergency-unblock {
  margin-top: 1rem;
  text-align: center;

  .btn {
    font-size: 0.75rem;
    padding: 0.5rem 0.75rem;
    border-radius: 0.375rem;
    background: rgba(245, 158, 11, 0.1);
    border: 1px solid rgba(245, 158, 11, 0.3);
    color: #d97706;

    &:hover {
      background: rgba(245, 158, 11, 0.2);
      border-color: rgba(245, 158, 11, 0.5);
    }
  }
}

// Section mot de passe oublié
.forgot-password-section {
  text-align: center;
  margin: 1rem 0;
}

.forgot-password-link {
  background: none;
  border: none;
  color: $estair-blue;
  font-size: 0.875rem;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.2s ease;
  padding: 0.5rem;
  border-radius: 0.375rem;
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;

  .forgot-icon {
    font-size: 1rem;
    filter: grayscale(0.3);
    transition: filter 0.2s ease;
  }

  &:hover:not(:disabled) {
    color: $estair-blue-dark;
    background: rgba(74, 168, 220, 0.05);
    transform: translateY(-1px);

    .forgot-icon {
      filter: grayscale(0);
    }
  }

  &:active:not(:disabled) {
    transform: translateY(0);
  }

  &:disabled {
    opacity: 0.5;
    cursor: not-allowed;
  }
}

// Modal mot de passe oublié
.forgot-password-overlay {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(0, 0, 0, 0.5);
  backdrop-filter: blur(4px);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 9999;
  animation: fadeIn 0.3s ease-out;
  padding: 1rem;
}

.forgot-password-modal {
  background: white;
  border-radius: 1rem;
  box-shadow: 0 25px 50px rgba(0, 0, 0, 0.25);
  max-width: 480px;
  width: 100%;
  max-height: 90vh;
  overflow-y: auto;
  animation: slideUp 0.3s ease-out;

  @media (max-width: 640px) {
    margin: 1rem;
    border-radius: 0.75rem;
  }
}

.forgot-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  padding: 2rem 2rem 0 2rem;

  @media (max-width: 640px) {
    padding: 1.5rem 1.5rem 0 1.5rem;
  }
}

.forgot-title-section {
  flex: 1;
  text-align: center;
}

.forgot-icon-large {
  font-size: 3rem;
  margin-bottom: 1rem;
  filter: drop-shadow(0 4px 8px rgba(74, 168, 220, 0.3));
  animation: iconFloat 2s ease-in-out infinite;
}

@keyframes iconFloat {
  0%, 100% { transform: translateY(0); }
  50% { transform: translateY(-4px); }
}

.forgot-title {
  font-size: 1.5rem;
  font-weight: 700;
  color: $estair-gray-900;
  margin-bottom: 0.5rem;

  @media (max-width: 640px) {
    font-size: 1.25rem;
  }
}

.forgot-subtitle {
  font-size: 0.875rem;
  color: $estair-gray-500;
  margin: 0;
  line-height: 1.5;
}

.close-btn {
  background: none;
  border: none;
  width: 32px;
  height: 32px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: all 0.2s ease;
  color: $estair-gray-400;
  flex-shrink: 0;

  .close-icon {
    font-size: 1.125rem;
    font-weight: 500;
  }

  &:hover {
    background: $estair-gray-100;
    color: $estair-gray-600;
    transform: rotate(90deg);
  }
}

.forgot-form {
  padding: 1.5rem 2rem 2rem 2rem;

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

.forgot-actions {
  display: flex;
  gap: 1rem;
  margin-top: 1.5rem;

  @media (max-width: 640px) {
    flex-direction: column;
    gap: 0.75rem;
  }
}

.forgot-cancel-btn {
  flex: 1;
  padding: 0.875rem 1.5rem;
  border-radius: 0.75rem;
  font-size: 0.875rem;
  font-weight: 500;
  background: $estair-gray-100;
  border: 1px solid $estair-gray-200;
  color: $estair-gray-600;
  cursor: pointer;
  transition: all 0.2s ease;

  .btn-content {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
  }

  &:hover:not(:disabled) {
    background: $estair-gray-200;
    border-color: $estair-gray-300;
    color: $estair-gray-700;
  }

  &:disabled {
    opacity: 0.5;
    cursor: not-allowed;
  }
}

.forgot-submit-btn {
  flex: 1;
  padding: 0.875rem 1.5rem;
  border-radius: 0.75rem;
  font-size: 0.875rem;
  font-weight: 600;
  background: linear-gradient(135deg, $estair-blue 0%, $estair-blue-alt 100%);
  border: none;
  color: white;
  cursor: pointer;
  transition: all 0.2s ease;

  .btn-content {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
  }

  .loading-content {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;

    .spinner {
      width: 14px;
      height: 14px;
      border: 2px solid rgba(255, 255, 255, 0.3);
      border-top: 2px solid white;
      border-radius: 50%;
      animation: spin 1s linear infinite;
    }
  }

  &:hover:not(:disabled) {
    background: linear-gradient(135deg, $estair-blue-dark 0%, $estair-blue 100%);
    transform: translateY(-1px);
    box-shadow: 0 6px 20px rgba(74, 168, 220, 0.3);
  }

  &:active:not(:disabled) {
    transform: translateY(0);
  }

  &:disabled {
    opacity: 0.6;
    cursor: not-allowed;
    transform: none;
  }
}

// Messages d'erreur et de succès pour le mot de passe oublié
.error-message {
  text-align: center;
  color: #ef4444;
  margin-top: 1rem;
  padding: 0.75rem 1rem;
  background: linear-gradient(135deg, #fef2f2 0%, #fee2e2 100%);
  border: 1px solid #fecaca;
  border-radius: 0.5rem;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.875rem;

  .icon-warning {
    margin-right: 0.5rem;
    font-size: 1rem;
  }
}

.success-message {
  text-align: center;
  color: $estair-green;
  margin-top: 1rem;
  padding: 0.75rem 1rem;
  background: linear-gradient(135deg, $estair-green-light 0%, rgba(240, 247, 234, 0.8) 100%);
  border: 1px solid rgba(141, 169, 105, 0.3);
  border-radius: 0.5rem;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.875rem;
  animation: successPulse 0.5s ease-out;

  .icon-success {
    margin-right: 0.5rem;
    font-size: 1rem;
  }
}

@keyframes successPulse {
  0% {
    transform: scale(0.95);
    opacity: 0;
  }
  50% {
    transform: scale(1.02);
  }
  100% {
    transform: scale(1);
    opacity: 1;
  }
}

// Animations pour la modal
@keyframes fadeIn {
  from {
    opacity: 0;
  }
  to {
    opacity: 1;
  }
}

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

// Icônes supplémentaires
.icon-mail::before { content: "📧"; }
.icon-send::before { content: "📤"; }
.icon-cancel::before { content: "❌"; }
.icon-success::before { content: "✅"; }