@layer components {
  /* ============================================================================
   * AVATAR COMPONENT
   * User avatar with image or initials fallback
   * ========================================================================= */

  .avatar {
    position: relative;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    overflow: hidden;
    background-color: var(--brand);
    color: white;
    font-weight: var(--weight-semi);
    flex-shrink: 0;
  }

  /* Avatar image */
  .avatar__image {
    width: 100%;
    height: 100%;
    object-fit: cover;
  }

  /* Avatar initials */
  .avatar__initials {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 100%;
    height: 100%;
    user-select: none;
  }

  /* Status indicator - small circle in corner */
  .avatar__status {
    position: absolute;
    bottom: -4%;
    right: -4%;
    width: 30%;
    height: 30%;
    border: 2px solid var(--surface);
    border-radius: var(--radius-full);
  }

  /* ============================================================================
   * SIZE VARIANTS
   * ========================================================================= */

  .avatar--xs {
    width: 1.5rem;
    height: 1.5rem;
    font-size: var(--text-2xs);
  }

  .avatar--sm {
    width: 2rem;
    height: 2rem;
    font-size: var(--text-xs);
  }

  .avatar--md {
    width: 2.5rem;
    height: 2.5rem;
    font-size: var(--text-md);
  }

  .avatar--lg {
    width: 3.5rem;
    height: 3.5rem;
    font-size: var(--text-lg);
  }

  .avatar--xl {
    width: 5rem;
    height: 5rem;
    font-size: var(--text-xl);
  }

  /* ============================================================================
   * SHAPE VARIANTS
   * ========================================================================= */

  .avatar--circle {
    border-radius: var(--radius-full);
  }

  .avatar--rounded {
    border-radius: var(--radius-2);
  }

  /* ============================================================================
   * STATUS VARIANTS
   * ========================================================================= */

  .avatar__status--online {
    background-color: var(--brand);
  }

  .avatar__status--offline {
    background-color: var(--neutral-400);
  }

  .avatar__status--away {
    background-color: var(--caution);
  }

  .avatar__status--busy {
    background-color: var(--danger);
  }

  /* ============================================================================
   * DARK MODE ADJUSTMENTS
   * ========================================================================= */

  @media (prefers-color-scheme: dark) {
    .avatar__status {
      border-color: var(--surface-sunken);
    }
  }
}
