/* =========================================================
   Profile module
   Load after landing.css
   File: styles/profile.css
   ========================================================= */

/* ---------- Top user chip avatar ---------- */
.user-chip-avatar {
    width: 30px;
    height: 30px;
    min-width: 30px;
    border-radius: 50%;
    overflow: hidden;
    display: grid;
    place-items: center;
    background: linear-gradient(135deg, var(--brand), #93a2ff);
    color: #fff;
    font-weight: 800;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.12);
}

.user-chip-avatar img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    border-radius: 50%;
}

/* ---------- Profile page layout ---------- */
.profile-layout {
    display: grid;
    grid-template-columns: 260px minmax(0, 1fr);
    gap: 20px;
    margin-bottom: 18px;
}

.profile-side,
.profile-main {
    background: rgba(255, 255, 255, 0.92);
    border: 1px solid var(--line);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow);
}

/* ---------- Left profile strip ---------- */
.profile-side {
    padding: 22px;
    text-align: center;
    align-self: start;
}

.profile-side-avatar {
    width: 118px;
    height: 118px;
    margin: 0 auto 14px;
    border-radius: 18px;
    overflow: hidden;
    background: linear-gradient(135deg, var(--brand), #93a2ff);
    display: grid;
    place-items: center;
}

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

.avatar-placeholder {
    width: 100%;
    height: 100%;
    display: grid;
    place-items: center;
    font-size: 3rem;
    font-weight: 800;
    color: #fff;
}

.profile-side-name {
    font-size: 1.25rem;
    margin-bottom: 4px;
    letter-spacing: -0.03em;
}

.profile-side-location {
    color: var(--muted);
    font-size: 0.92rem;
    margin-bottom: 12px;
}

.profile-side-badges {
    display: flex;
    justify-content: center;
    flex-wrap: wrap;
    gap: 6px;
    margin: 12px 0;
}

.badge {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    font-size: 0.75rem;
    padding: 5px 9px;
    border-radius: 999px;
    font-weight: 700;
}

.badge.verified {
    background: rgba(90, 103, 216, 0.1);
    color: var(--brand-dark);
}

.badge.premium {
    background: rgba(245, 180, 0, 0.2);
    color: #9a6a00;
}

.profile-side-stats {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 8px;
    padding: 14px 0;
    border-top: 1px solid var(--line);
    border-bottom: 1px solid var(--line);
    margin: 14px 0;
}

.profile-side-stats strong {
    display: block;
    font-size: 1rem;
}

.profile-side-stats span {
    font-size: 0.75rem;
    color: var(--muted);
}

/* ---------- Right bio/form area ---------- */
.profile-main {
    padding: 22px;
    display: flex;
    flex-direction: column;
    gap: 16px;
}

.profile-preview {
    padding: 18px;
    border-radius: 18px;
    background: #f5f8ff;
    border: 1px solid var(--line);
}

.profile-preview-head {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    gap: 16px;
    margin-bottom: 12px;
}

.profile-preview h3 {
    font-size: 1.4rem;
    letter-spacing: -0.03em;
}

.profile-preview p {
    color: var(--muted);
    line-height: 1.7;
}

.profile-age-chip {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 64px;
    padding: 8px 10px;
    border-radius: 999px;
    background: rgba(90, 103, 216, 0.1);
    color: var(--brand-dark);
    font-weight: 800;
}

/* ---------- Profile form ---------- */
.profile-form {
    display: grid;
    gap: 16px;
}

.profile-form .field textarea,
.field textarea {
    border-radius: 14px;
    border: 1px solid var(--line);
    background: #f9fbff;
    padding: 14px 15px;
    outline: none;
    color: var(--text);
    resize: vertical;
    font: inherit;
}

.profile-form .field textarea:focus,
.field textarea:focus {
    border-color: var(--brand);
    box-shadow: 0 0 0 4px rgba(90, 103, 216, 0.12);
}

.avatar-upload-btn {
    justify-content: center;
    width: 100%;
    margin-top: 4px;
}

/* ---------- Old profile editor fallback ---------- */
/* Keeps older HTML render from breaking if it still exists somewhere. */
.profile-editor-card {
    background: rgba(255, 255, 255, 0.92);
    border: 1px solid var(--line);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow);
    padding: 24px;
    display: grid;
    grid-template-columns: 220px 1fr;
    gap: 24px;
    align-items: start;
}

.profile-avatar-wrap {
    display: grid;
    gap: 16px;
    justify-items: center;
}

.profile-avatar-preview {
    width: 170px;
    height: 170px;
    border-radius: 32px;
    background: linear-gradient(135deg, var(--brand), #93a2ff);
    color: #fff;
    display: grid;
    place-items: center;
    font-size: 4rem;
    font-weight: 800;
    overflow: hidden;
    box-shadow: 0 18px 35px rgba(90, 103, 216, 0.22);
}

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

/* ---------- Responsive ---------- */
@media (max-width: 860px) {
    .profile-layout {
        grid-template-columns: 1fr;
    }
}

@media (max-width: 760px) {
    .profile-editor-card {
        grid-template-columns: 1fr;
    }

    .profile-preview-head {
        flex-direction: column;
    }
}

/* ---------- Avatar hover upload ---------- */
.avatar-upload-overlay {
    position: relative;
    cursor: pointer;
}

.avatar-overlay {
    position: absolute;
    inset: 0;
    display: grid;
    place-items: center;
    align-content: center;
    gap: 6px;
    background: rgba(15, 23, 42, 0.62);
    color: #fff;
    opacity: 0;
    transition: opacity 0.2s ease;
    font-size: 0.82rem;
    font-weight: 800;
    text-align: center;
}

.avatar-overlay i {
    font-size: 1.3rem;
}

.avatar-upload-overlay:hover .avatar-overlay {
    opacity: 1;
}
/* ===== v2 profiles, directory, public profile ===== */
#profiles-root {
    display: grid;
    gap: 18px;
}

.card-shell,
.directory-card,
.profile-info-card,
.profile-form-card,
.profile-top {
    background: rgba(255,255,255,.94);
    border: 1px solid var(--line);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow);
}

.directory-hero {
    display: flex;
    justify-content: space-between;
    gap: 18px;
    align-items: end;
    padding: 22px;
}

.directory-filters {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    align-items: end;
}

.inline-field {
    min-width: 220px;
}

.only-online { padding-bottom: 12px; }

.directory-hero-copy {
    min-width: 0;
    max-width: 300px;
}

.directory-hero-copy h1 {
    margin: 6px 0 10px;
    line-height: 1.05;
    overflow-wrap: anywhere;
}

.directory-hero-copy .section-intro {
    margin: 0;
    color: var(--ink-muted);
}

.directory-hero {
    display: grid;
    grid-template-columns: minmax(220px, 290px) minmax(0, 1fr);
    align-items: start;
}

.directory-filters {
    display: grid;
    grid-template-columns: repeat(2, minmax(210px, 1fr));
    gap: 14px;
    align-items: end;
}

.directory-filters .field,
.directory-filters .inline-field {
    min-width: 0;
    width: 100%;
}

.directory-filters .ghost-btn {
    justify-self: start;
    align-self: end;
}

.directory-filters .checkbox-line {
    min-height: 44px;
    align-self: end;
}

.directory-grid {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 16px;
}

.directory-card-inner {
    width: 100%;
    display: grid;
    grid-template-columns: 84px 1fr;
    gap: 14px;
    padding: 16px;
    text-align: left;
}

.directory-avatar,
.profile-avatar-large,
.friend-mini-user img,
.friend-mini-user span {
    background: linear-gradient(135deg, var(--brand), #93a2ff);
    color: #fff;
    display: grid;
    place-items: center;
    overflow: hidden;
}

.directory-avatar {
    width: 84px;
    height: 84px;
    border-radius: 20px;
}

.directory-avatar img,
.profile-avatar-large img,
.friend-mini-user img,
.video-placeholder-thumb img,
.profile-album-card img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
}

.directory-body p {
    color: var(--muted);
    line-height: 1.5;
    margin-top: 8px;
}

.directory-name-row {
    display: flex;
    gap: 8px;
    align-items: center;
    flex-wrap: wrap;
}

.online-dot-badge {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 5px 10px;
    border-radius: 999px;
    background: rgba(73, 201, 109, 0.12);
    color: #1c8c42;
    font-size: .78rem;
    font-weight: 800;
    text-transform: uppercase;
}

.online-dot-badge::before {
    content: '';
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: #29b653;
}

.profile-page,
.public-profile-page {
    display: grid;
    gap: 18px;
}

.profile-top {
    padding: 24px;
}

.profile-cover-head {
    display: flex;
    justify-content: space-between;
    gap: 18px;
    align-items: center;
    flex-wrap: wrap;
}

.profile-main-ident {
    display: flex;
    gap: 18px;
    align-items: center;
}

.profile-avatar-large {
    width: 112px;
    height: 112px;
    border-radius: 32px;
    font-size: 2.4rem;
    font-weight: 800;
    flex: 0 0 auto;
    position: relative;
}

.avatar-upload-overlay {
    cursor: pointer;
}

.avatar-overlay {
    position: absolute;
    inset: 0;
    display: flex;
    flex-direction: column;
    gap: 6px;
    align-items: center;
    justify-content: center;
    background: rgba(13, 17, 38, 0.58);
    color: #fff;
    opacity: 0;
    transition: opacity .2s ease;
    font-size: .78rem;
    font-weight: 700;
}

.avatar-upload-overlay:hover .avatar-overlay { opacity: 1; }

.profile-name-line {
    display: flex;
    align-items: center;
    gap: 10px;
    flex-wrap: wrap;
}

.profile-name-line h2 { margin: 0; font-size: clamp(2rem, 3vw, 3rem); letter-spacing: -.05em; }
.profile-quick-meta { color: var(--muted); margin-top: 6px; }

.profile-action-stack {
    display: flex;
    gap: 10px;
    flex-wrap: wrap;
}

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

.profile-top-stats div {
    padding: 14px;
    border-radius: 16px;
    background: #f6f8ff;
    border: 1px solid var(--line);
}

.profile-top-stats strong { display: block; font-size: 1.15rem; }
.profile-top-stats span { color: var(--muted); font-size: .88rem; }

.profile-layout-grid {
    display: grid;
    grid-template-columns: minmax(0, 1.4fr) 380px;
    gap: 18px;
}

.profile-form-card,
.profile-info-card { padding: 22px; }
.profile-side-column,
.public-profile-main,
.public-profile-rail { display: grid; gap: 18px; align-self: start; }
.public-profile-layout { display: grid; grid-template-columns: 280px minmax(0, 1fr); gap: 18px; }

.extended-profile-form { gap: 14px; }

.info-list-grid { display: grid; gap: 12px; }
.info-row { display: flex; justify-content: space-between; gap: 12px; padding-bottom: 10px; border-bottom: 1px solid var(--line); }
.info-row span { color: var(--muted); }
.info-row strong { text-align: right; }

.friend-request-list { display: grid; gap: 10px; }
.friend-request-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 10px;
    padding: 12px;
    border-radius: 16px;
    background: #f8faff;
    border: 1px solid var(--line);
}

.friend-mini-user { display: inline-flex; align-items: center; gap: 10px; }
.friend-mini-user img,
.friend-mini-user span { width: 42px; height: 42px; border-radius: 12px; }
.friend-request-actions { display: flex; gap: 8px; }
.mini-btn { padding: 8px 12px; border-radius: 999px; font-weight: 700; border: 1px solid var(--line); background: #fff; }
.mini-btn.accept { color: #1c8c42; }
.mini-btn.reject { color: var(--danger); }

.public-albums-grid,
.public-video-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 12px; }
.sidebar-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.profile-album-card {
    display: block;
    position: relative;
    border-radius: 18px;
    overflow: hidden;
    background: #ecf1f8;
    border: 1px solid var(--line);
    min-height: 156px;
}
.profile-album-card img { aspect-ratio: 1 / 1.08; }
.profile-album-badge {
    position: absolute; left: 10px; top: 10px; padding: 4px 8px; border-radius: 999px; background: rgba(16,24,40,.7); color:#fff; font-size:.74rem; font-weight:700;
}
.profile-album-title {
    position: absolute; left: 10px; right: 10px; bottom: 10px; color:#fff; font-weight:800; text-shadow: 0 2px 10px rgba(0,0,0,.55);
}
.rejection-note { display: block; position:absolute; left:10px; right:10px; bottom:34px; color:#ffe3e3; font-weight:700; font-size:.78rem; text-shadow:0 2px 10px rgba(0,0,0,.45); }

.video-placeholder-card { padding: 12px; border-radius: 18px; background: #f7faff; border: 1px solid var(--line); }
.video-placeholder-thumb { aspect-ratio: 16 / 10; display: grid; place-items: center; border-radius: 14px; background: linear-gradient(135deg, #e6ecff, #d8e6ff); margin-bottom: 10px; }
.video-placeholder-thumb i { font-size: 1.8rem; color: var(--brand-dark); }

.tag-row { display: flex; gap: 8px; flex-wrap: wrap; }
.soft-tag { padding: 7px 10px; border-radius: 999px; font-weight: 700; font-size: .84rem; }
.soft-tag.warm { background: rgba(214,73,73,.09); color: var(--danger); }
.soft-tag.cool { background: rgba(90,103,216,.1); color: var(--brand-dark); }
.soft-tag.neutral { background: #eef2fb; color: var(--text); }

@media (max-width: 1180px) {
    .directory-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
    .profile-layout-grid, .public-profile-layout { grid-template-columns: 1fr; }
}

@media (max-width: 760px) {
    .directory-hero, .profile-cover-head { grid-template-columns: 1fr; }
    .directory-filters { grid-template-columns: 1fr; }
    .directory-grid, .public-albums-grid, .public-video-grid { grid-template-columns: 1fr; }
    .profile-top-stats { grid-template-columns: repeat(2, minmax(0, 1fr)); }
    .directory-card-inner { grid-template-columns: 1fr; }
}

/* --- v4 profile tidy overrides --- */
.profile-page,
.public-profile-page,
.directory-hero,
.profile-info-card,
.profile-form-card,
.profile-top,
.profile-album-card,
.info-row,
.friend-request-row,
.friend-mini-user,
.directory-card-inner {
    min-width: 0;
}

.tidy-profile-layout {
    grid-template-columns: minmax(0, 1.15fr) minmax(320px, .85fr);
    align-items: start;
    gap: 22px;
}

.profile-main-column,
.tidy-side-column,
.public-profile-main,
.public-profile-rail {
    min-width: 0;
}

.profile-quick-bio {
    margin-top: 8px;
    color: var(--ink-muted);
    max-width: 640px;
    overflow-wrap: anywhere;
}

.profile-top-stats.compact-six {
    grid-template-columns: repeat(6, minmax(0, 1fr));
}

.profile-top-stats.compact-six div {
    min-width: 0;
}

.extended-profile-form .field-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
}

.extended-profile-form input,
.extended-profile-form textarea,
.extended-profile-form select,
.info-row strong,
.info-row span,
.profile-quick-meta,
.profile-name-line h2,
.directory-body p,
.profile-album-title,
.profile-album-meta,
.rejection-note,
.friend-mini-user strong,
.friend-mini-user small {
    overflow-wrap: anywhere;
    word-break: break-word;
}

.info-list-grid {
    display: grid;
    gap: 10px;
}

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

.info-row strong {
    text-align: right;
}

.profile-action-stack {
    flex-wrap: wrap;
    justify-content: flex-end;
}

.profile-side-column .block-head,
.public-profile-main .block-head,
.public-profile-rail .block-head {
    gap: 10px;
}

.friend-request-row {
    align-items: center;
    gap: 12px;
}

.friend-mini-user {
    flex: 1;
    justify-content: flex-start;
    min-width: 0;
}

.friend-mini-user div {
    display: flex;
    flex-direction: column;
    min-width: 0;
}

.friend-mini-user strong,
.friend-mini-user small {
    display: block;
}

.friend-request-actions {
    flex-shrink: 0;
}

.public-albums-grid {
    grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
    gap: 14px;
}

.sidebar-grid {
    grid-template-columns: 1fr;
}

.profile-album-card {
    position: relative;
    min-height: 220px;
    display: flex;
    align-items: flex-end;
    overflow: hidden;
    border-radius: 18px;
    text-decoration: none;
}

.profile-album-card img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    position: absolute;
    inset: 0;
}

.profile-album-overlay {
    position: absolute;
    inset: 0;
    background: linear-gradient(180deg, rgba(8,13,29,0) 28%, rgba(8,13,29,.82) 100%);
}

.profile-album-body {
    position: relative;
    z-index: 1;
    width: 100%;
    padding: 14px;
    color: #fff;
    display: grid;
    gap: 4px;
}

.profile-album-title {
    font-weight: 800;
    color: #fff;
}

.profile-album-meta {
    font-size: .84rem;
    color: rgba(255,255,255,.85);
}

.profile-album-badge {
    display: none !important;
}

.rejection-note {
    display: block;
    margin-top: 6px;
    padding: 6px 9px;
    border-radius: 10px;
    background: rgba(214, 76, 92, .18);
    color: #ffe2e6;
}

.profile-info-card p,
.public-profile-main p {
    overflow-wrap: anywhere;
}

.online-dot-badge,
.profile-top-stats span,
.profile-top-stats strong {
    white-space: normal;
}

@media (max-width: 1100px) {
    .profile-top-stats.compact-six {
        grid-template-columns: repeat(3, minmax(0, 1fr));
    }

    .tidy-profile-layout,
    .public-profile-layout {
        grid-template-columns: 1fr;
    }
}

@media (max-width: 720px) {
    .extended-profile-form .field-grid,
    .info-row,
    .profile-top-stats.compact-six {
        grid-template-columns: 1fr;
    }

    .info-row strong {
        text-align: left;
    }
}

/* ---------- DARK MODE AVATAR FIX v14.2 ---------- */
body.dark-mode .user-chip-avatar,
body.dark-mode .profile-avatar-large,
body.dark-mode .profile-side-avatar,
body.dark-mode .directory-avatar {
    background: linear-gradient(135deg, var(--brand), #93a2ff) !important;
    overflow: hidden !important;
}

body.dark-mode .user-chip-avatar img,
body.dark-mode .profile-avatar-large img,
body.dark-mode .profile-side-avatar img,
body.dark-mode .directory-avatar img {
    display: block !important;
    opacity: 1 !important;
    filter: none !important;
    mix-blend-mode: normal !important;
    object-fit: cover !important;
}

/* --- v14.5 profile form containment fix --- */
.profile-form-card,
.profile-info-card,
.profile-main-column,
.profile-side-column,
.profile-layout-grid,
.tidy-profile-layout,
.extended-profile-form,
.extended-profile-form .field-grid,
.extended-profile-form .field {
    min-width: 0 !important;
    max-width: 100% !important;
}

.profile-form-card {
    overflow: hidden !important;
}

.extended-profile-form .field-grid {
    width: 100% !important;
    display: grid !important;
    grid-template-columns: repeat(2, minmax(0, 1fr)) !important;
    gap: 14px !important;
}

.extended-profile-form .field {
    width: 100% !important;
    overflow: hidden !important;
}

.extended-profile-form .field input,
.extended-profile-form .field textarea,
.extended-profile-form .field select,
.profile-form-card input,
.profile-form-card textarea,
.profile-form-card select {
    width: 100% !important;
    min-width: 0 !important;
    max-width: 100% !important;
    box-sizing: border-box !important;
}

.profile-layout-grid.tidy-profile-layout {
    grid-template-columns: minmax(0, 1fr) minmax(280px, 0.74fr) !important;
}

.profile-top-stats.compact-six div {
    overflow: hidden !important;
}

.profile-top-stats.compact-six strong,
.profile-top-stats.compact-six span {
    overflow: hidden !important;
    text-overflow: ellipsis !important;
}

@media (max-width: 1180px) {
    .profile-layout-grid.tidy-profile-layout {
        grid-template-columns: 1fr !important;
    }
}

@media (max-width: 760px) {
    .extended-profile-form .field-grid {
        grid-template-columns: 1fr !important;
    }
}
