/* ============================================================
   PROFILE.CSS — профиль и достижения (profile-ui)
   Стеклянные карточки, тёмная космическая тема.
   Префиксы: .pf- (профиль), .ach- (страница достижений).
   Брейкпоинты: 900px и 640px.
   ============================================================ */

.profile-page.pf-page,
.ach-page {
    width: 100%;
    max-width: 1180px;
    margin: 0 auto;
    position: relative;
    z-index: 1;
    min-width: 0;
}

.pf-page {
    display: flex;
    flex-direction: column;
    gap: 16px;
}

/* Локальные переменные */
.pf-page,
.ach-page {
    --pf-glass: rgba(12, 12, 32, 0.72);
    --pf-glass-soft: rgba(255, 255, 255, 0.035);
    --pf-border: rgba(108, 60, 225, 0.22);
    --pf-border-soft: rgba(255, 255, 255, 0.07);
    --pf-muted: #9a9ac0;
    --pf-dim: #6d6d92;
    --pf-accent: #A855F7;
    --pf-gold: #FFD700;
    --pf-radius: 20px;
    --pf-radius-sm: 14px;
    --pf-shadow: 0 18px 50px rgba(0, 0, 0, 0.45);
}

/* Цвета редкостей (общие) */
.rarity-common    { --rarity-color: #9aa0b4; }
.rarity-rare      { --rarity-color: #4A90D9; }
.rarity-epic      { --rarity-color: #A855F7; }
.rarity-legendary { --rarity-color: #FFD700; }

.pf-strong { color: #fff; }


/* ============================================================
   ШАПКА ПРОФИЛЯ
   ============================================================ */
.pf-hero {
    position: relative;
    overflow: hidden;
    border-radius: var(--pf-radius);
    border: 1px solid var(--pf-border);
    background: var(--pf-glass);
    backdrop-filter: blur(14px);
    -webkit-backdrop-filter: blur(14px);
    box-shadow: var(--pf-shadow);
}

.pf-banner {
    position: relative;
    height: 230px;
    width: 100%;
    background:
        radial-gradient(circle at 18% 25%, rgba(168, 85, 247, 0.55), transparent 55%),
        radial-gradient(circle at 82% 70%, rgba(74, 144, 217, 0.45), transparent 55%),
        linear-gradient(135deg, #14142e, #0c0c20 70%);
    background-size: cover;
    background-position: center;
    background-repeat: no-repeat;
}

.pf-banner-fade {
    position: absolute;
    inset: 0;
    background: linear-gradient(180deg, rgba(5, 5, 15, 0) 30%, rgba(5, 5, 15, 0.55) 100%);
    pointer-events: none;
}

.pf-icon-btn {
    width: 40px;
    height: 40px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
    border: 1px solid rgba(255, 255, 255, 0.18);
    background: rgba(10, 10, 28, 0.72);
    color: #fff;
    font-size: 17px;
    cursor: pointer;
    backdrop-filter: blur(8px);
    transition: transform 0.18s ease, background 0.18s ease, border-color 0.18s ease;
}

.pf-icon-btn:hover {
    background: rgba(108, 60, 225, 0.85);
    border-color: rgba(168, 85, 247, 0.7);
    transform: scale(1.06);
}

.pf-banner-edit {
    position: absolute;
    right: 16px;
    bottom: 16px;
    z-index: 3;
}

/* Тело шапки */
.pf-hero-body {
    position: relative;
    display: flex;
    align-items: flex-end;
    gap: 20px;
    padding: 0 24px 22px;
    margin-top: -66px;
    min-width: 0;
}

/* Аватар — переопределяем геометрию из main.css */
.pf-avatar-wrap {
    position: relative;
    flex: 0 0 auto;
    margin-top: 0;
    z-index: 2;
}

.profile-avatar.pf-avatar {
    width: 132px;
    height: 132px;
    border-radius: 50%;
    overflow: hidden;
    display: flex;
    align-items: center;
    justify-content: center;
    border: 4px solid #0a0a1e;
    background: linear-gradient(135deg, rgba(108, 60, 225, 0.55), rgba(74, 144, 217, 0.55));
    box-shadow: 0 14px 40px rgba(0, 0, 0, 0.55);
    font-size: 48px;
}

.pf-avatar img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.pf-avatar-empty {
    font-size: 48px;
    line-height: 1;
    color: #6d6d92;
}

.pf-avatar-edit {
    position: absolute;
    right: 2px;
    bottom: 6px;
    z-index: 4;
    width: 38px;
    height: 38px;
    padding: 0;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
    border: 2px solid #0a0a1e;
    background: linear-gradient(135deg, #6C3CE1, #A855F7);
    color: #fff;
    font-size: 15px;
    cursor: pointer;
    transition: transform 0.18s ease, box-shadow 0.18s ease;
}

.pf-avatar-edit:hover:not(.disabled) {
    transform: scale(1.08);
    box-shadow: 0 6px 20px rgba(168, 85, 247, 0.5);
}

.pf-avatar-edit.disabled {
    background: rgba(100, 100, 120, 0.65);
    cursor: not-allowed;
}

/* Информация */
.pf-identity {
    flex: 1 1 auto;
    min-width: 0;
    padding-bottom: 4px;
}

.pf-name.profile-name {
    margin: 0;
    font-size: clamp(22px, 3.4vw, 32px);
    font-weight: 800;
    letter-spacing: -0.4px;
    line-height: 1.15;
    color: #fff;
    overflow-wrap: anywhere;
}

.pf-badges {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 6px;
    margin-top: 10px;
    min-width: 0;
    max-width: 100%;
}

/* Длинные названия должностей переносятся внутри плашки, а не вылезают из карточки */
.pf-badges .badge {
    max-width: 100%;
    min-width: 0;
    font-size: 10.5px;
    padding: 5px 10px;
    line-height: 1.25;
    overflow-wrap: anywhere;
    word-break: break-word;
    text-align: center;
}

.pf-badges .badge-tag {
    font-size: 8.5px;
    padding: 4px 8px;
}

.pf-quote {
    margin: 12px 0 0;
    padding-left: 12px;
    border-left: 3px solid rgba(168, 85, 247, 0.55);
    color: #c9c9e6;
    font-size: 13.5px;
    font-style: italic;
    overflow-wrap: anywhere;
}

.pf-meta-line {
    display: flex;
    flex-wrap: wrap;
    gap: 6px 16px;
    margin-top: 10px;
    color: var(--pf-dim);
    font-size: 12.5px;
}

/* Действия */
.pf-actions {
    display: flex;
    flex-direction: column;
    gap: 8px;
    flex: 0 0 auto;
    align-items: stretch;
}

.pf-actions .ui-btn {
    white-space: nowrap;
}

/* ============================================================
   СТАТ-ПЛИТКИ
   ============================================================ */
.pf-stats {
    display: grid;
    grid-template-columns: repeat(5, minmax(0, 1fr));
    gap: 12px;
}

.pf-stat {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 2px;
    padding: 14px 10px;
    min-width: 0;
    border-radius: var(--pf-radius-sm);
    border: 1px solid var(--pf-border-soft);
    background: var(--pf-glass);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    color: #fff;
    font: inherit;
    text-align: center;
    transition: transform 0.18s ease, border-color 0.18s ease, background 0.18s ease;
}

.pf-stat:hover {
    transform: translateY(-2px);
    border-color: rgba(168, 85, 247, 0.45);
    background: rgba(20, 20, 46, 0.8);
}

.pf-stat--click {
    cursor: pointer;
    appearance: none;
}

.pf-stat-icon {
    font-size: 20px;
    line-height: 1;
    margin-bottom: 4px;
}

.pf-stat-value {
    font-size: clamp(18px, 2.2vw, 24px);
    font-weight: 800;
    line-height: 1.15;
    overflow-wrap: anywhere;
}

.pf-stat-value b {
    font-weight: 800;
}

.pf-stat-value--date {
    font-size: 15px;
    font-weight: 700;
    letter-spacing: 0.2px;
}

.pf-stat-label {
    max-width: 100%;
    font-size: 10.5px;
    font-weight: 600;
    line-height: 1.4;
    letter-spacing: 0.4px;
    text-transform: uppercase;
    color: var(--pf-muted);
    overflow-wrap: anywhere;
}

/* ============================================================
   РАСКЛАДКА: СТЕНА + БОКОВАЯ КОЛОНКА
   ============================================================ */
.pf-layout {
    display: grid;
    grid-template-columns: minmax(0, 1fr) 340px;
    gap: 16px;
    align-items: start;
    min-width: 0;
}

.pf-main {
    display: flex;
    flex-direction: column;
    gap: 16px;
    min-width: 0;
}

.pf-side {
    display: flex;
    flex-direction: column;
    gap: 16px;
    min-width: 0;
    position: sticky;
    top: 84px;
}

.pf-card {
    padding: 18px;
    min-width: 0;
    overflow: hidden;
}

.pf-card-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
    margin-bottom: 14px;
    flex-wrap: wrap;
}

.pf-card-title {
    margin: 0;
    font-size: 16px;
    font-weight: 800;
    letter-spacing: -0.2px;
    display: flex;
    align-items: center;
    gap: 8px;
}

.pf-link {
    color: var(--pf-accent);
    font-size: 13px;
    font-weight: 700;
    white-space: nowrap;
}

.pf-link:hover { color: #c9a6ff; }

.pf-notice {
    padding: 14px 16px;
    margin-bottom: 14px;
    border-radius: 12px;
    border: 1px dashed rgba(108, 60, 225, 0.3);
    background: rgba(255, 255, 255, 0.025);
    color: var(--pf-muted);
    font-size: 13.5px;
}

.pf-notice a {
    color: var(--pf-accent);
    font-weight: 700;
}

/* Наказания */
.pf-bans {
    padding: 16px 18px;
    border-color: rgba(239, 68, 68, 0.32);
    background: rgba(40, 10, 18, 0.55);
}

.pf-bans .profile-bans-title {
    font-size: 14px;
    font-weight: 800;
    color: #ff9a9a;
    margin-bottom: 10px;
}

/* Стена */
.pf-wall {
    padding: 18px;
}

.pf-wall .wall-form {
    margin: 0 0 4px;
}

.pf-wall .wall-input {
    width: 100%;
    max-width: 100%;
    box-sizing: border-box;
}

.pf-wall .wall-comments {
    margin-top: 16px;
}

/* Пустое состояние «профиль скрыт» */
.pf-hidden {
    padding: 64px 24px;
    text-align: center;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 8px;
}

.pf-hidden-icon { font-size: 48px; }
.pf-hidden-title { font-size: 22px; font-weight: 800; }

/* ============================================================
   БЛОК ДОСТИЖЕНИЙ В ПРОФИЛЕ
   ============================================================ */
.pf-ach-top {
    display: flex;
    align-items: flex-end;
    justify-content: space-between;
    gap: 10px;
}

.pf-ach-count {
    display: flex;
    align-items: baseline;
    gap: 4px;
}

.pf-ach-count b {
    font-size: 28px;
    font-weight: 800;
    line-height: 1;
}

.pf-ach-count span {
    font-size: 14px;
    color: var(--pf-muted);
}

.pf-ach-percent {
    font-size: 14px;
    font-weight: 800;
    color: var(--pf-gold);
}

.pf-progress {
    height: 10px;
    margin-top: 10px;
    border-radius: 999px;
    background: rgba(255, 255, 255, 0.06);
    border: 1px solid rgba(255, 255, 255, 0.06);
    overflow: hidden;
}

.pf-progress-fill {
    height: 100%;
    border-radius: inherit;
    background: var(--accent-gradient, linear-gradient(135deg, #6C3CE1, #4A90D9));
    box-shadow: 0 0 16px rgba(108, 60, 225, 0.45);
    transition: width 0.45s ease;
}

.pf-progress--sm {
    height: 7px;
    margin-top: 0;
}

.pf-ach-grid {
    display: grid;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: 10px;
    margin-top: 14px;
}

.pf-ach-icon {
    display: flex;
    align-items: center;
    justify-content: center;
    aspect-ratio: 1 / 1;
    font-size: 21px;
    border-radius: 14px;
    border: 1px solid color-mix(in srgb, var(--ach-color, #888) 45%, transparent);
    background: color-mix(in srgb, var(--ach-color, #888) 12%, rgba(10, 10, 26, 0.6));
    box-shadow: 0 0 16px color-mix(in srgb, var(--ach-color, #888) 18%, transparent);
}

.pf-ach-icon:hover {
    transform: translateY(-1px);
}

.pf-ach-empty {
    margin-top: 12px;
    padding: 14px 12px;
    border-radius: 12px;
    border: 1px dashed rgba(108, 60, 225, 0.28);
    background: rgba(255, 255, 255, 0.02);
    color: var(--pf-muted);
    font-size: 12.5px;
    text-align: center;
    line-height: 1.45;
}

.pf-ach-link {
    margin-top: 14px;
}

/* ============================================================
   БЛОК «О ПОЛЬЗОВАТЕЛЕ»
   ============================================================ */
.pf-info-list {
    display: flex;
    flex-direction: column;
    gap: 9px;
}

.pf-info-row {
    display: flex;
    align-items: baseline;
    justify-content: space-between;
    gap: 12px;
    font-size: 13.5px;
    padding-bottom: 8px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.05);
}

.pf-info-row:last-child {
    border-bottom: none;
    padding-bottom: 0;
}

.pf-info-label {
    color: var(--pf-muted);
    flex: 0 0 auto;
}

.pf-info-value {
    font-weight: 600;
    text-align: right;
    min-width: 0;
    overflow-wrap: anywhere;
}

.pf-info-link {
    color: var(--pf-accent);
}

.pf-info-link:hover { color: #c9a6ff; }


/* ============================================================
   СТРАНИЦА ДОСТИЖЕНИЙ
   ============================================================ */
.ach-page {
    display: flex;
    flex-direction: column;
    gap: 16px;
}

.ach-summary {
    padding: 20px;
}

.ach-summary-top {
    display: flex;
    align-items: flex-end;
    justify-content: space-between;
    gap: 12px;
}

.ach-summary-number b {
    font-size: 34px;
    font-weight: 800;
    line-height: 1;
}

.ach-summary-number span {
    font-size: 16px;
    color: var(--pf-muted);
    margin-left: 4px;
}

.ach-summary-percent {
    font-size: 22px;
    font-weight: 800;
    color: var(--pf-gold);
}

.ach-summary-progress {
    margin-top: 14px;
    height: 12px;
}

.ach-rarity-legend {
    display: flex;
    flex-wrap: wrap;
    gap: 8px 18px;
    margin-top: 16px;
    font-size: 12px;
    color: var(--pf-muted);
}

.ach-legend-item {
    display: inline-flex;
    align-items: center;
    gap: 7px;
    white-space: nowrap;
}

.ach-legend-dot {
    width: 9px;
    height: 9px;
    border-radius: 50%;
    background: var(--rarity-color, #888);
    box-shadow: 0 0 8px color-mix(in srgb, var(--rarity-color, #888) 60%, transparent);
}

.ach-tabs {
    margin: 0;
}

.ach-tab-count {
    display: inline-block;
    min-width: 20px;
    padding: 1px 6px;
    margin-left: 6px;
    border-radius: 999px;
    font-size: 11px;
    font-weight: 700;
    background: rgba(255, 255, 255, 0.07);
    color: inherit;
}

.ach-grid {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 14px;
    min-width: 0;
}

.pf-ach-card {
    position: relative;
    display: flex;
    flex-direction: column;
    gap: 10px;
    padding: 16px;
    min-width: 0;
    overflow: hidden;
    border-radius: 18px;
    border: 1px solid color-mix(in srgb, var(--ach-color, #888) 24%, rgba(255, 255, 255, 0.06));
    background: var(--pf-glass);
    backdrop-filter: blur(14px);
    -webkit-backdrop-filter: blur(14px);
    box-shadow: 0 14px 36px rgba(0, 0, 0, 0.32);
    transition: transform 0.18s ease, border-color 0.18s ease, box-shadow 0.18s ease;
}

.pf-ach-card::before {
    content: '';
    position: absolute;
    inset: 0 0 auto 0;
    height: 2px;
    background: linear-gradient(90deg, transparent, var(--ach-color, #888), transparent);
    opacity: 0.55;
}

.pf-ach-card:hover {
    transform: translateY(-3px);
    border-color: color-mix(in srgb, var(--ach-color, #888) 48%, transparent);
    box-shadow: 0 18px 44px rgba(0, 0, 0, 0.4);
}

.pf-ach-card.is-unlocked {
    border-color: color-mix(in srgb, var(--ach-color, #888) 52%, transparent);
    box-shadow: 0 14px 40px color-mix(in srgb, var(--ach-color, #888) 16%, rgba(0, 0, 0, 0.4));
}

.pf-ach-card.is-locked {
    opacity: 0.82;
}

.pf-ach-card.is-locked:hover {
    opacity: 1;
}

.pf-ach-card-head {
    display: flex;
    align-items: center;
    gap: 12px;
    min-width: 0;
}

.pf-ach-card-icon {
    flex: 0 0 auto;
    width: 46px;
    height: 46px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 23px;
    border-radius: 14px;
    border: 1px solid color-mix(in srgb, var(--ach-color, #888) 40%, transparent);
    background: color-mix(in srgb, var(--ach-color, #888) 13%, rgba(10, 10, 26, 0.6));
}

.pf-ach-card-titles {
    min-width: 0;
    flex: 1 1 auto;
}

.pf-ach-card-name {
    margin: 0;
    font-size: 14.5px;
    font-weight: 700;
    line-height: 1.25;
    overflow-wrap: anywhere;
}

.pf-ach-card-rarity {
    display: inline-block;
    margin-top: 3px;
    font-size: 10.5px;
    font-weight: 800;
    letter-spacing: 0.5px;
    text-transform: uppercase;
    color: var(--ach-color, #888);
}

.pf-ach-check {
    flex: 0 0 auto;
    width: 26px;
    height: 26px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
    background: rgba(34, 197, 94, 0.16);
    border: 1px solid rgba(34, 197, 94, 0.45);
    color: #7ef0a5;
    font-size: 13px;
    font-weight: 800;
}

.pf-ach-card-desc {
    margin: 0;
    flex: 1 1 auto;
    font-size: 12.5px;
    line-height: 1.45;
    color: var(--pf-muted);
    overflow-wrap: anywhere;
}

.pf-ach-card-foot {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
    flex-wrap: wrap;
    font-size: 12px;
}

.pf-ach-card-foot--progress {
    flex-direction: column;
    align-items: stretch;
    gap: 6px;
}

.pf-ach-progress-text {
    font-size: 11.5px;
    font-weight: 600;
    color: var(--pf-dim);
    text-align: right;
}

.pf-ach-date {
    font-size: 11px;
    color: var(--pf-dim);
}

.pf-ach-rewards {
    display: flex;
    flex-wrap: wrap;
    gap: 12px;
    padding-top: 9px;
    border-top: 1px dashed rgba(255, 255, 255, 0.07);
    font-size: 11.5px;
    font-weight: 600;
    color: #ffe27a;
}

/* Плашка «новые достижения» */
.pf-new-ach {
    display: flex;
    align-items: center;
    gap: 14px;
    padding: 14px 18px;
    border-color: rgba(255, 215, 0, 0.35) !important;
    background: rgba(255, 215, 0, 0.06);
}

.pf-new-ach-icon {
    font-size: 28px;
    line-height: 1;
}

.pf-new-ach-body { min-width: 0; }

.pf-new-ach-title {
    font-size: 14.5px;
    font-weight: 800;
    color: #ffe27a;
    margin-bottom: 3px;
}

.ach-empty-filter {
    margin-top: 4px;
}


/* ============================================================
   АДАПТИВ
   ============================================================ */
@media (max-width: 900px) {
    .pf-banner { height: 180px; }

    .pf-hero-body {
        flex-wrap: wrap;
        gap: 14px;
        padding: 0 18px 18px;
        margin-top: -56px;
    }

    .profile-avatar.pf-avatar {
        width: 106px;
        height: 106px;
        font-size: 40px;
        border-width: 3px;
    }

    .pf-identity { flex: 1 1 220px; }

    .pf-actions {
        flex-basis: 100%;
        flex-direction: row;
        flex-wrap: wrap;
    }

    .pf-actions .ui-btn {
        flex: 1 1 auto;
        justify-content: center;
    }

    .pf-stats {
        grid-template-columns: repeat(3, minmax(0, 1fr));
    }

    .pf-layout {
        grid-template-columns: minmax(0, 1fr);
    }

    .pf-side {
        position: static;
        flex-direction: column;
    }

    .ach-grid {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }
}

@media (max-width: 640px) {
    .pf-banner { height: 150px; }

    .pf-hero-body {
        flex-direction: column;
        align-items: center;
        text-align: center;
        padding: 0 14px 16px;
        margin-top: -48px;
    }

    .profile-avatar.pf-avatar {
        width: 94px;
        height: 94px;
        font-size: 34px;
    }

    .pf-avatar-edit {
        width: 34px;
        height: 34px;
        font-size: 13px;
    }

    .pf-identity {
        flex-basis: auto;
        width: 100%;
        padding-bottom: 0;
    }

    .pf-badges {
        justify-content: center;
    }

    .pf-badges .badge {
        font-size: 9.5px;
        padding: 4px 8px;
        border-radius: 7px;
        line-height: 1.25;
    }

    .pf-badges .badge-tag {
        font-size: 8px;
        padding: 3px 7px;
    }

    .pf-meta-line {
        justify-content: center;
    }

    .pf-name.profile-name {
        font-size: 23px;
    }

    .pf-actions {
        width: 100%;
        flex-direction: column;
    }

    .pf-actions .ui-btn {
        width: 100%;
    }

    .pf-stats {
        grid-template-columns: repeat(2, minmax(0, 1fr));
        gap: 10px;
    }

    .pf-stat {
        padding: 12px 8px;
        gap: 1px;
    }

    .pf-stat-icon {
        font-size: 18px;
        margin-bottom: 2px;
    }

    .pf-stat-value {
        font-size: 20px;
    }

    .pf-stat-label {
        font-size: 9.5px;
        letter-spacing: 0.3px;
    }

    .pf-stat--date {
        grid-column: 1 / -1;
    }

    .pf-stat-value--date {
        font-size: 14px;
    }

    .pf-card {
        padding: 14px;
    }

    .pf-wall {
        padding: 14px;
    }

    .pf-ach-grid {
        grid-template-columns: repeat(2, minmax(0, 1fr));
        gap: 12px;
    }

    .pf-ach-icon {
        font-size: 24px;
    }

    .ach-grid {
        grid-template-columns: minmax(0, 1fr);
    }

    .ach-summary {
        padding: 16px;
    }

    .ach-summary-number b {
        font-size: 28px;
    }

    .ach-rarity-legend {
        gap: 6px 14px;
        font-size: 11.5px;
    }

    .ach-tabs {
        gap: 6px;
    }

    .ach-tab-count {
        display: none;
    }

    .pf-new-ach {
        padding: 12px 14px;
        align-items: flex-start;
    }
}
