/* ════════════════════════════════════════════════════════════
   PROFILE — личный кабинет
   Переиспользует .au-panel из admin_users.css
   ════════════════════════════════════════════════════════════ */

/* ─────────────────────────────────────────────
   1. ПОЛЯ ФОРМЫ (read-only + hints)
   ───────────────────────────────────────────── */
#profilePanel .au-input[readonly],
#profilePanel .au-input:disabled {
    background-color: rgba(255, 255, 255, 0.02);
    color: #8b949e;
    cursor: default;
    opacity: 0.85;
}

#profilePanel .au-fieldset .au-hint {
    margin-top: 8px;
    font-size: 11px;
    color: #6e7681;
    font-style: italic;
}

/* ─────────────────────────────────────────────
   2. ВАЛИДАЦИЯ
   ───────────────────────────────────────────── */
#profilePanel .au-input.is-invalid {
    border-color: #f85149 !important;
    box-shadow: 0 0 0 2px rgba(248, 81, 73, 0.15);
}
#profilePanel .au-input.is-valid {
    border-color: #3fb950 !important;
}

#profilePanel .au-field-error {
    display: block;
    margin-top: 4px;
    min-height: 14px;
    font-size: 11px;
    color: #f85149;
}

/* ─────────────────────────────────────────────
   3. ИНДИКАЦИЯ ИЗМЕНЕНИЙ
   (кнопка «Сохранить» + бейдж «изменено»)
   ───────────────────────────────────────────── */
#profilePanel #btnProfileSave {
    opacity: 0.45;
    cursor: not-allowed;
    box-shadow: none;
    transition: opacity 0.25s ease,
                box-shadow 0.25s ease,
                transform 0.15s ease;
}

#profilePanel.has-changes #btnProfileSave {
    opacity: 1;
    cursor: pointer;
    box-shadow: 0 0 0 1px rgba(63, 185, 110, 0.35),
                0 0 14px rgba(63, 185, 110, 0.25);
}
#profilePanel.has-changes #btnProfileSave:hover {
    transform: translateY(-1px);
    box-shadow: 0 0 0 1px rgba(63, 185, 110, 0.55),
                0 0 18px rgba(63, 185, 110, 0.4);
}
#profilePanel.has-changes #btnProfileSave:active {
    transform: translateY(0);
}

#profilePanel .changes-badge {
    display: none;
    margin-left: 8px;
    padding: 2px 8px;
    background: rgba(139, 92, 246, 0.18);
    color: #c4b5fd;
    border: 1px solid rgba(139, 92, 246, 0.35);
    border-radius: 10px;
    font-size: 10px;
    font-weight: 600;
    letter-spacing: 0.3px;
    vertical-align: middle;
}
#profilePanel.has-changes .changes-badge {
    display: inline-block;
}

/* ─────────────────────────────────────────────
   4. PASSWORD TOGGLE (глазик)
   ───────────────────────────────────────────── */
.pwd-input-wrap {
    position: relative;
}
.pwd-input-wrap input.au-input {
    padding-right: 36px;
}

.pwd-toggle-btn {
    position: absolute;
    top: 50%;
    right: 6px;
    transform: translateY(-50%);
    display: flex;
    align-items: center;
    justify-content: center;
    width: 28px;
    height: 28px;
    padding: 0;
    background: none;
    border: none;
    border-radius: 6px;
    color: #8b949e;
    cursor: pointer;
    transition: 0.15s;
}
.pwd-toggle-btn:hover {
    background: rgba(255, 255, 255, 0.06);
    color: #e6edf3;
}
.pwd-toggle-btn svg {
    width: 16px;
    height: 16px;
    stroke-width: 1.8;
}

/* ─────────────────────────────────────────────
   5. ИНДИКАТОР СИЛЫ ПАРОЛЯ
   ───────────────────────────────────────────── */
.pwd-strength-wrap {
    margin-top: 6px;
}

.pwd-strength-bar {
    position: relative;
    height: 4px;
    background: rgba(255, 255, 255, 0.06);
    border-radius: 2px;
    overflow: hidden;
}
.pwd-strength-fill {
    height: 100%;
    width: 0%;
    background: #f85149;
    border-radius: 2px;
    transition: width 0.25s ease, background-color 0.25s ease;
}
.pwd-strength-fill[data-level="1"] { width: 20%;  background: #f85149; }
.pwd-strength-fill[data-level="2"] { width: 40%;  background: #fb8500; }
.pwd-strength-fill[data-level="3"] { width: 60%;  background: #d29922; }
.pwd-strength-fill[data-level="4"] { width: 80%;  background: #3fb950; }
.pwd-strength-fill[data-level="5"] { width: 100%; background: #2ea043; }

.pwd-strength-label {
    display: block;
    margin-top: 4px;
    min-height: 14px;
    font-size: 11px;
    color: #8b949e;
}
.pwd-strength-label[data-level="1"] { color: #f85149; }
.pwd-strength-label[data-level="2"] { color: #fb8500; }
.pwd-strength-label[data-level="3"] { color: #d29922; }
.pwd-strength-label[data-level="4"] { color: #3fb950; }
.pwd-strength-label[data-level="5"] { color: #2ea043; }

/* ─────────────────────────────────────────────
   6. CONFIRM DIALOG (внутри панели)
   ⚠ Этот же блок дублируется в admin-users.css
   под #userPanel — туда копия для независимости
   от подключения этого файла. Если этот файл
   ВСЕГДА грузится первым — копию из admin-users
   можно удалить и оставить только здесь.
   ───────────────────────────────────────────── */
.profile-confirm-overlay {
    position: absolute;
    inset: 0;
    z-index: 10;
    display: none;
    align-items: center;
    justify-content: center;
    background: rgba(13, 17, 23, 0.75);
    backdrop-filter: blur(4px);
    -webkit-backdrop-filter: blur(4px);
}
.profile-confirm-overlay.is-open {
    display: flex;
}

.profile-confirm-box {
    width: 90%;
    max-width: 360px;
    padding: 20px 22px;
    background: rgba(22, 27, 44, 0.98);
    border: 1px solid rgba(139, 92, 246, 0.25);
    border-radius: 12px;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.6);
}
.profile-confirm-box h4 {
    margin: 0 0 8px;
    font-size: 14px;
    color: #e6edf3;
}
.profile-confirm-box p {
    margin: 0 0 16px;
    font-size: 12px;
    color: #8b949e;
    line-height: 1.5;
}
.profile-confirm-actions {
    display: flex;
    justify-content: flex-end;
    gap: 8px;
}

/* ─────────────────────────────────────────────
   7. АВАТАР В БОКОВОЙ ПАНЕЛИ ПРОФИЛЯ
   Стиль один-в-один как в админке
   (.au-avatar-overlay / .au-avatar-btn)
   ───────────────────────────────────────────── */
.au-panel-avatar-wrap {
    position: relative;
    display: inline-block;
    width: 72px;
    height: 72px;
    border-radius: 50%;
    overflow: hidden;
    flex-shrink: 0;
    cursor: pointer;
}

/* Внутренний контейнер с инициалами на всю обёртку */
.au-panel-avatar-wrap .au-panel-avatar {
    position: absolute;
    inset: 0;
    z-index: 1;
    margin: 0 !important;
    width: 100%;
    height: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
    background: linear-gradient(135deg, #8b5cf6 0%, #6366f1 100%);
    color: #fff;
    font-size: 26px;
    font-weight: 700;
    letter-spacing: 1px;
    user-select: none;
}

.au-panel-avatar-wrap .au-panel-avatar-img {
    position: absolute;
    inset: 0;
    z-index: 2;
    display: none; /* по умолчанию скрыт; показываем при наличии src */
    width: 100%;
    height: 100%;
    object-fit: cover;
    border-radius: 50%;
}
.au-panel-avatar-wrap .au-panel-avatar-img[src]:not([src=""]) {
    display: block;
}

/* Оверлей с кнопками-иконками */
.au-panel-avatar-wrap .au-panel-avatar-overlay {
    position: absolute;
    left: 0;
    right: 0;
    bottom: 0;
    z-index: 10;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    height: 30px;
    padding: 0 4px;
    background: linear-gradient(to top,
                rgba(0, 0, 0, 0.85) 0%,
                rgba(0, 0, 0, 0)    100%);
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.18s ease;
    box-sizing: border-box;
}
.au-panel-avatar-wrap:hover .au-panel-avatar-overlay {
    opacity: 1;
    pointer-events: auto;
}

/* Кнопки-иконки внутри оверлея */
.au-panel-avatar-wrap .au-avatar-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 22px;
    height: 22px;
    padding: 0;
    margin: 0;
    background: rgba(255, 255, 255, 0.25);
    border: none;
    border-radius: 50%;
    color: #fff;
    cursor: pointer;
    line-height: 0;
    box-sizing: border-box;
    flex-shrink: 0;
    transition: background 0.15s, transform 0.15s;
}
.au-panel-avatar-wrap .au-avatar-btn:hover {
    background: rgba(139, 92, 246, 0.95);
    transform: scale(1.1);
}
.au-panel-avatar-wrap .au-avatar-btn-danger:hover {
    background: rgba(248, 81, 73, 0.95);
}
.au-panel-avatar-wrap .au-avatar-btn svg {
    display: block;
    width: 12px;
    height: 12px;
    stroke: #fff;
    fill: none;
    pointer-events: none;
}
.au-panel-avatar-wrap .au-avatar-btn:disabled {
    opacity: 0.5;
    cursor: wait;
}
.au-panel-avatar-wrap .au-avatar-btn.is-loading {
    opacity: 0.6;
    pointer-events: none;
}
.au-panel-avatar-wrap .au-avatar-btn.is-loading svg {
    animation: profileAvatarSpin 0.8s linear infinite;
}

/* Состояние загрузки всей обёртки (спиннер по центру) */
.au-panel-avatar-wrap.is-loading {
    pointer-events: none;
}
.au-panel-avatar-wrap.is-loading .au-panel-avatar-overlay {
    opacity: 1;
}
.au-panel-avatar-wrap.is-loading::after {
    content: '';
    position: absolute;
    top: 50%;
    left: 50%;
    z-index: 20;
    width: 28px;
    height: 28px;
    margin: -14px 0 0 -14px;
    border: 3px solid rgba(255, 255, 255, 0.25);
    border-top-color: #fff;
    border-radius: 50%;
    animation: profileAvatarSpin 0.8s linear infinite;
}

@keyframes profileAvatarSpin {
    to { transform: rotate(360deg); }
}

/* ─────────────────────────────────────────────
   8. ROLE PILL — плашка роли в hero
   ───────────────────────────────────────────── */
#profileHeroRole {
    display: inline-block;
    margin-top: 6px;
    padding: 3px 10px;
    background: rgba(139, 92, 246, 0.15);
    color: #b8a4f5;
    border: 1px solid rgba(139, 92, 246, 0.25);
    border-radius: 999px;
    font-size: 10px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}
#profileHeroRole.role-admin {
    background: rgba(56, 139, 253, 0.08);
    color: #58a6ff;
    border-color: rgba(56, 139, 253, 0.35);
}
#profileHeroRole.role-superadmin {
    background: rgba(139, 92, 246, 0.12);
    color: #a78bfa;
    border-color: rgba(139, 92, 246, 0.4);
    box-shadow: 0 0 8px rgba(139, 92, 246, 0.15);
}

/* ─────────────────────────────────────────────
   9. КРЕСТИК ЗАКРЫТИЯ ПАНЕЛИ ПРОФИЛЯ
   (наследует .au-panel-close из admin_users.css,
    здесь только убираем рамку/outline во всех состояниях)
   ───────────────────────────────────────────── */
#profilePanelClose,
#profilePanelClose:hover,
#profilePanelClose:focus,
#profilePanelClose:focus-visible,
#profilePanelClose:active {
    border: none !important;
    outline: none !important;
    box-shadow: none !important;
}