/* =============================================
 *  Universal Avatar Component — avatar.css
 *  Professional initial-letter avatar system
 *  Supports: images, initials, status, badges
 * ============================================= */

/* ── Base Container ── */
.ua-avatar {
    position: relative;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    overflow: hidden;
    vertical-align: middle;
    transition: transform 0.2s ease, box-shadow 0.2s ease;
    user-select: none;
}
.ua-avatar:hover {
    transform: scale(1.04);
}

/* ── Image Layer ── */
.ua-avatar-img {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
    object-fit: cover;
    z-index: 2;
    transition: opacity 0.3s ease;
}

/* ── Initials Layer (always present as fallback) ── */
.ua-avatar-initials {
    position: absolute;
    inset: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    color: #fff;
    font-weight: 700;
    letter-spacing: 0.03em;
    line-height: 1;
    z-index: 1;
    text-shadow: 0 1px 2px rgba(0, 0, 0, 0.15);
}

/* When image fails → show initials */
.ua-avatar.ua-fallback .ua-avatar-img {
    display: none !important;
}
.ua-avatar.ua-fallback .ua-avatar-initials,
.ua-avatar:not(:has(.ua-avatar-img)) .ua-avatar-initials {
    z-index: 2;
}

/* When image loads → hide initials */
.ua-avatar:not(.ua-fallback) .ua-avatar-img ~ .ua-avatar-initials {
    z-index: 0;
}

/* ── Status Indicator ── */
.ua-avatar-status {
    position: absolute;
    bottom: 0;
    right: 0;
    border-radius: 50%;
    border-style: solid;
    border-color: #fff;
    z-index: 5;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.12);
}
.ua-status-online  { background: #22c55e; }
.ua-status-away    { background: #f59e0b; }
.ua-status-offline { background: #94a3b8; }
.ua-status-busy    { background: #ef4444; }

/* Pulse animation for online status */
.ua-status-online {
    animation: ua-pulse 2s ease-in-out infinite;
}
@keyframes ua-pulse {
    0%, 100% { box-shadow: 0 0 0 0 rgba(34, 197, 94, 0.4); }
    50%      { box-shadow: 0 0 0 4px rgba(34, 197, 94, 0); }
}

/* ── Badge Overlay ── */
.ua-avatar-badge {
    position: absolute;
    bottom: -2px;
    right: -2px;
    background: linear-gradient(135deg, #6366f1, #4f46e5);
    color: #fff;
    border-radius: 50%;
    font-size: 0.55rem;
    width: 18px;
    height: 18px;
    display: flex;
    align-items: center;
    justify-content: center;
    border: 2px solid #fff;
    z-index: 5;
    line-height: 1;
}
.ua-avatar-badge i { font-size: 0.55rem; }

/* ── Avatar Group (stacked) ── */
.ua-avatar-group {
    display: flex;
    flex-direction: row-reverse;
    justify-content: flex-end;
}
.ua-avatar-group .ua-avatar {
    margin-left: -8px;
    box-shadow: 0 0 0 2px #fff;
}
.ua-avatar-group .ua-avatar:last-child {
    margin-left: 0;
}
.ua-avatar-group .ua-avatar:hover {
    z-index: 10;
    transform: translateY(-2px) scale(1.08);
}

/* ── Dark Mode ── */
[data-theme="dark"] .ua-avatar-status {
    border-color: #1e293b;
}
[data-theme="dark"] .ua-avatar-badge {
    border-color: #1e293b;
}
[data-theme="dark"] .ua-avatar-group .ua-avatar {
    box-shadow: 0 0 0 2px #1e293b;
}
[data-theme="dark"] .ua-avatar {
    box-shadow: none;
}
[data-theme="dark"] .ua-avatar[style*="box-shadow: 0 0 0"] {
    --ring-color: #1e293b;
}

/* ── Skeleton Loading ── */
.ua-avatar.ua-loading .ua-avatar-initials {
    background: linear-gradient(
        90deg,
        rgba(148, 163, 184, 0.2) 25%,
        rgba(148, 163, 184, 0.35) 50%,
        rgba(148, 163, 184, 0.2) 75%
    ) !important;
    background-size: 200% 100% !important;
    animation: ua-shimmer 1.5s infinite;
    color: transparent !important;
    text-shadow: none !important;
}
@keyframes ua-shimmer {
    0%   { background-position: 200% 0; }
    100% { background-position: -200% 0; }
}
