// 🔐 Password Input Component Styles
// Componente reutilizável para inputs de senha com toggle de visibilidade

// ===================================================
// VARIÁVEIS E MIXINS
// ===================================================

:host {
  display: block;
  width: 100%;
}

// ===================================================
// CONTAINER PRINCIPAL
// ===================================================

.password-input-container {
  position: relative;
  width: 100%;
  margin-bottom: 0;

  // Estados do container
  &.focused {
    .input-wrapper {
      border-color: var(--primary-color);
      box-shadow: 0 0 0 2px rgba(var(--primary-rgb), 0.1);
    }
  }

  &.disabled {
    opacity: 0.6;
    pointer-events: none;
  }

  &.has-value {
    .password-label {
      color: var(--text-primary);
      font-weight: 500;
    }
  }
}

// ===================================================
// LABEL
// ===================================================

.password-label {
  display: block;
  font-size: 0.875rem;
  font-weight: 400;
  color: var(--text-secondary);
  margin-bottom: 6px;
  transition: all 0.2s ease;

  &.required {
    font-weight: 500;
  }

  .required-asterisk {
    color: var(--danger-color);
    margin-left: 2px;
    font-weight: 600;
  }
}

// ===================================================
// INPUT WRAPPER E INPUT
// ===================================================

.input-wrapper {
  position: relative;
  display: flex;
  align-items: center;
  background: var(--background-secondary);
  border: 1px solid var(--border-color);
  border-radius: 8px;
  transition: all 0.2s ease;
  overflow: hidden;

  &:hover:not(.disabled) {
    border-color: var(--border-hover-color);
  }
}

.password-input {
  flex: 1;
  width: 100%;
  padding: 12px 16px;
  font-size: 0.875rem;
  color: var(--text-primary);
  background: transparent;
  border: none;
  outline: none;
  font-family: inherit;
  transition: all 0.2s ease;

  &.with-toggle {
    padding-right: 48px; // Espaço para o botão de toggle
  }

  &::placeholder {
    color: var(--text-placeholder);
    opacity: 1;
  }

  &:disabled {
    cursor: not-allowed;
    color: var(--text-disabled);
  }

  // Remove autofill styling
  &:-webkit-autofill,
  &:-webkit-autofill:hover,
  &:-webkit-autofill:focus {
    -webkit-box-shadow: 0 0 0 1000px var(--background-secondary) inset;
    -webkit-text-fill-color: var(--text-primary);
    transition: background-color 5000s ease-in-out 0s;
  }
}

// ===================================================
// BOTÕES DE AÇÃO
// ===================================================

.toggle-visibility-btn {
  position: absolute;
  right: 12px;
  top: 50%;
  transform: translateY(-50%);
  width: 24px;
  height: 24px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: none;
  border: none;
  cursor: pointer;
  color: var(--text-secondary);
  border-radius: 4px;
  transition: all 0.2s ease;
  z-index: 2;

  &:hover:not(:disabled) {
    color: var(--primary-color);
    background: var(--primary-color-10);
  }

  &:focus {
    outline: 2px solid var(--primary-color);
    outline-offset: 2px;
  }

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

  i {
    font-size: 0.875rem;
    transition: all 0.2s ease;
  }
}

.lock-icon {
  position: absolute;
  right: 12px;
  top: 50%;
  transform: translateY(-50%);
  color: var(--text-tertiary);
  pointer-events: none;

  i {
    font-size: 0.75rem;
  }
}

// ===================================================
// INDICADOR DE FORÇA DA SENHA
// ===================================================

.strength-indicator {
  margin-top: 12px;
  animation: fadeIn 0.3s ease;
}

.strength-bar {
  width: 100%;
  height: 4px;
  background: var(--border-color);
  border-radius: 2px;
  overflow: hidden;
  margin-bottom: 8px;

  .strength-fill {
    height: 100%;
    border-radius: 2px;
    transition: all 0.4s cubic-bezier(0.4, 0, 0.2, 1);
    transform-origin: left;

    // Cores baseadas na força
    &.empty {
      width: 0 !important;
      background: transparent;
    }

    &.very-weak {
      background: #ef4444; // red-500
    }

    &.weak {
      background: #f97316; // orange-500
    }

    &.medium {
      background: #eab308; // yellow-500
    }

    &.strong {
      background: #22c55e; // green-500
    }

    &.very-strong {
      background: #16a34a; // green-600
      box-shadow: 0 0 8px rgba(34, 197, 94, 0.3);
    }
  }
}

.strength-info {
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-size: 0.75rem;
  margin-bottom: 8px;

  .strength-text {
    font-weight: 500;
    transition: color 0.3s ease;

    &.empty {
      color: var(--text-tertiary);
    }

    &.very-weak {
      color: #ef4444;
    }

    &.weak {
      color: #f97316;
    }

    &.medium {
      color: #eab308;
    }

    &.strong {
      color: #22c55e;
    }

    &.very-strong {
      color: #16a34a;
    }
  }

  .strength-percentage {
    color: var(--text-secondary);
    font-size: 0.6875rem;
  }
}

// ===================================================
// REQUISITOS DA SENHA
// ===================================================

.password-requirements {
  background: var(--background-tertiary);
  border: 1px solid var(--border-color);
  border-radius: 6px;
  padding: 12px;
  margin-top: 8px;
  animation: slideDown 0.3s ease;

  .requirements-title {
    display: flex;
    align-items: center;
    font-size: 0.75rem;
    font-weight: 500;
    color: var(--text-secondary);
    margin-bottom: 8px;

    i {
      margin-right: 6px;
      color: var(--primary-color);
    }
  }

  .requirements-list {
    list-style: none;
    padding: 0;
    margin: 0;

    li {
      display: flex;
      align-items: center;
      font-size: 0.6875rem;
      color: var(--text-tertiary);
      margin-bottom: 4px;
      transition: all 0.2s ease;

      &:last-child {
        margin-bottom: 0;
      }

      i {
        width: 12px;
        margin-right: 8px;
        font-size: 0.625rem;
        color: var(--danger-color);
      }

      &.met {
        color: var(--success-color);

        i {
          color: var(--success-color);
        }
      }
    }
  }
}

// ===================================================
// HELP TEXT
// ===================================================

.help-text {
  display: flex;
  align-items: flex-start;
  font-size: 0.75rem;
  color: var(--text-secondary);
  margin-top: 6px;
  line-height: 1.4;

  i {
    margin-right: 6px;
    margin-top: 2px;
    color: var(--primary-color);
    flex-shrink: 0;
  }
}

// ===================================================
// ACESSIBILIDADE
// ===================================================

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

// ===================================================
// ANIMAÇÕES
// ===================================================

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

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

// ===================================================
// RESPONSIVIDADE
// ===================================================

@media (max-width: 768px) {
  .password-input-container {
    .password-input {
      font-size: 16px; // Evita zoom no iOS
      padding: 14px 16px;

      &.with-toggle {
        padding-right: 52px;
      }
    }

    .toggle-visibility-btn {
      width: 28px;
      height: 28px;
      right: 14px;

      i {
        font-size: 1rem;
      }
    }

    .password-requirements {
      .requirements-list li {
        font-size: 0.75rem;
        margin-bottom: 6px;
      }
    }
  }
}

// ===================================================
// DARK MODE
// ===================================================

@media (prefers-color-scheme: dark) {
  .password-input-container {
    .input-wrapper {
      background: var(--dark-background-secondary, #1f2937);
      border-color: var(--dark-border-color, #374151);

      &:hover:not(.disabled) {
        border-color: var(--dark-border-hover-color, #4b5563);
      }
    }

    &.focused .input-wrapper {
      border-color: var(--primary-color);
      box-shadow: 0 0 0 2px rgba(var(--primary-rgb), 0.2);
    }

    .password-input {
      color: var(--dark-text-primary, #f9fafb);

      &::placeholder {
        color: var(--dark-text-placeholder, #9ca3af);
      }

      &:-webkit-autofill,
      &:-webkit-autofill:hover,
      &:-webkit-autofill:focus {
        -webkit-box-shadow: 0 0 0 1000px var(--dark-background-secondary, #1f2937) inset;
        -webkit-text-fill-color: var(--dark-text-primary, #f9fafb);
      }
    }

    .password-requirements {
      background: var(--dark-background-tertiary, #111827);
      border-color: var(--dark-border-color, #374151);
    }
  }
}

// ===================================================
// ESTADOS DE ERRO (Para integração com validação)
// ===================================================

.password-input-container.ng-invalid.ng-touched {
  .input-wrapper {
    border-color: var(--danger-color);
    
    &:focus-within {
      box-shadow: 0 0 0 2px rgba(239, 68, 68, 0.1);
    }
  }
}

// ===================================================
// TEMA CUSTOMIZADO (Opcional)
// ===================================================

.password-input-container.theme-success {
  .strength-bar .strength-fill.very-strong {
    background: linear-gradient(90deg, #22c55e, #16a34a);
  }
}

.password-input-container.theme-minimal {
  .input-wrapper {
    border-radius: 4px;
    border-width: 1px;
  }

  .strength-bar {
    height: 2px;
    border-radius: 1px;
  }
}
