/* User Profile Page (/u/{username}) */

.user-profile-page {
    max-width: 1100px;
    margin: 0 auto;
    padding: 24px;
    color: #e0e0e0;
}

.user-profile-loading,
.user-profile-error {
    max-width: 600px;
    margin: 80px auto;
    padding: 40px;
    text-align: center;
    color: #999;
}

.user-profile-error .error-icon {
    font-size: 64px;
    color: #555;
    margin-bottom: 16px;
}

.user-profile-error h2 {
    color: #e0e0e0;
    margin-bottom: 8px;
}

.user-profile-error p {
    margin-bottom: 24px;
}

/* Header */
.user-profile-header {
    display: flex;
    align-items: center;
    gap: 24px;
    padding: 28px;
    background: #1a1a1a;
    border: 1px solid #2a2a2a;
    border-radius: 12px;
    margin-bottom: 20px;
}

.user-profile-avatar {
    width: 120px;
    height: 120px;
    border-radius: 50%;
    overflow: hidden;
    background: #2a2a2a;
    flex-shrink: 0;
    display: flex;
    align-items: center;
    justify-content: center;
}

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

.user-profile-avatar-placeholder {
    width: 100%;
    height: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
    background: linear-gradient(135deg, #3a3a3a, #2a2a2a);
    color: #888;
    font-size: 48px;
    font-weight: 600;
    text-transform: uppercase;
}

.user-profile-identity {
    flex: 1;
    min-width: 0;
}

.user-profile-username {
    margin: 0 0 8px 0;
    font-size: 28px;
    color: #fff;
    word-break: break-all;
}

.user-profile-meta {
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: 12px;
    color: #999;
    font-size: 14px;
}

.user-profile-meta i {
    margin-right: 4px;
}

.user-profile-tier {
    padding: 3px 10px;
    border-radius: 12px;
    font-size: 12px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    background: #2a2a2a;
    color: #888;
}

.user-profile-tier.tier-1 { background: #1f3a52; color: #6cb6ff; }
.user-profile-tier.tier-2 { background: #3a2f1a; color: #ffb86c; }
.user-profile-tier.tier-3 { background: #3a1a2f; color: #ff6cb6; }

.user-profile-actions {
    flex-shrink: 0;
}

.user-profile-actions .btn i {
    margin-right: 6px;
}

/* Stats bar */
.user-profile-stats {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 12px;
    margin-bottom: 20px;
}

.user-profile-stat {
    padding: 18px;
    background: #1a1a1a;
    border: 1px solid #2a2a2a;
    border-radius: 12px;
    text-align: center;
}

.user-profile-stat .stat-value {
    display: block;
    font-size: 26px;
    font-weight: 700;
    color: #fff;
    line-height: 1;
    margin-bottom: 6px;
}

.user-profile-stat .stat-label {
    display: block;
    font-size: 12px;
    color: #888;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

/* Sections */
.user-profile-section {
    background: #1a1a1a;
    border: 1px solid #2a2a2a;
    border-radius: 12px;
    padding: 24px;
    margin-bottom: 20px;
}

.user-profile-section .section-title {
    margin: 0 0 16px 0;
    font-size: 18px;
    color: #fff;
    display: flex;
    align-items: center;
    gap: 8px;
}

.user-profile-section .section-title i {
    color: #4a9eff;
}

/* Bio */
.user-profile-bio {
    color: #ccc;
    font-size: 15px;
    line-height: 1.6;
    word-wrap: break-word;
}

.user-profile-bio a {
    color: #4a9eff;
    text-decoration: none;
}

.user-profile-bio a:hover {
    color: #6cb6ff;
}

.user-profile-bio-empty {
    color: #888;
    font-size: 14px;
    display: flex;
    align-items: center;
    gap: 12px;
    flex-wrap: wrap;
}

.user-profile-bio-empty p {
    margin: 0;
}

.user-profile-empty {
    color: #888;
    text-align: center;
    padding: 16px;
    font-size: 14px;
}

/* Image groups */
.user-profile-image-group {
    margin-bottom: 16px;
}

.user-profile-image-group:last-child {
    margin-bottom: 0;
}

.user-profile-image-group .group-header {
    margin-bottom: 12px;
}

.user-profile-image-group .group-name {
    margin: 0 0 4px 0;
    font-size: 16px;
    color: #fff;
}

.user-profile-image-group .group-description {
    margin: 0;
    font-size: 13px;
    color: #999;
}

.group-images-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
    gap: 8px;
}

.group-image-card {
    display: block;
    aspect-ratio: 1;
    border-radius: 8px;
    overflow: hidden;
    background: #2a2a2a;
    text-decoration: none;
}

.group-image-card img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
}

.group-image-card:hover {
    outline: 2px solid #4a9eff;
}

/* Recent posts grid */
.user-posts-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
    gap: 12px;
}

.user-post-card {
    display: block;
    background: #222;
    border: 1px solid #2a2a2a;
    border-radius: 10px;
    overflow: hidden;
    text-decoration: none;
    color: inherit;
}

.user-post-card:hover {
    border-color: #4a9eff;
}

.user-post-card-thumb {
    width: 100%;
    aspect-ratio: 1;
    background: #2a2a2a;
    overflow: hidden;
}

.user-post-card-thumb img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
}

.user-post-card-thumb-placeholder {
    width: 100%;
    height: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
    color: #666;
    font-size: 32px;
}

.user-post-card-meta {
    padding: 10px;
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.user-post-card-title {
    font-size: 13px;
    color: #e0e0e0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.post-card-untitled {
    color: #888;
    font-style: italic;
}

.user-post-card-stats {
    font-size: 12px;
    color: #888;
    display: flex;
    align-items: center;
    gap: 8px;
    flex-wrap: wrap;
}

.user-post-card-stats i {
    color: #f06292;
}

.user-post-card-date {
    margin-left: auto;
}

/* Activity */
.user-activity-list {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.user-activity-item {
    display: flex;
    align-items: flex-start;
    gap: 12px;
    padding: 12px;
    background: #222;
    border-radius: 8px;
}

.user-activity-icon {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    background: #2a2a2a;
    display: flex;
    align-items: center;
    justify-content: center;
    color: #4a9eff;
    flex-shrink: 0;
}

.user-activity-body {
    flex: 1;
    min-width: 0;
}

.user-activity-desc {
    color: #ccc;
    font-size: 14px;
    margin-bottom: 4px;
    word-wrap: break-word;
}

.user-activity-date {
    color: #888;
    font-size: 12px;
}

/* Edit modal */
.user-profile-edit-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.7);
    z-index: 10000;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 20px;
    overscroll-behavior: contain;
}

.user-profile-edit-modal {
    background: #1a1a1a;
    border: 1px solid #2a2a2a;
    border-radius: 12px;
    width: 100%;
    max-width: 560px;
    max-height: 90vh;
    max-height: 90dvh;
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

.edit-modal-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 18px 24px;
    border-bottom: 1px solid #2a2a2a;
}

.edit-modal-header h2 {
    margin: 0;
    font-size: 18px;
    color: #fff;
}

.edit-modal-close {
    background: none;
    border: none;
    color: #999;
    font-size: 18px;
    cursor: pointer;
    width: 32px;
    height: 32px;
    border-radius: 6px;
}

.edit-modal-close:hover {
    background: #2a2a2a;
    color: #fff;
}

.edit-modal-body {
    padding: 20px 24px;
    overflow-y: auto;
    flex: 1;
}

.edit-field {
    margin-bottom: 20px;
}

.edit-field:last-child {
    margin-bottom: 0;
}

.edit-field-label {
    display: block;
    font-size: 13px;
    color: #ccc;
    font-weight: 600;
    margin-bottom: 8px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.edit-avatar-row {
    display: flex;
    align-items: center;
    gap: 16px;
}

.edit-avatar-preview {
    width: 80px;
    height: 80px;
    border-radius: 50%;
    overflow: hidden;
    background: #2a2a2a;
    flex-shrink: 0;
}

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

.edit-avatar-preview .user-profile-avatar-placeholder {
    font-size: 32px;
}

.edit-avatar-controls {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
}

.edit-bio-input {
    width: 100%;
    padding: 12px;
    background: #0f0f0f;
    border: 1px solid #2a2a2a;
    border-radius: 8px;
    color: #e0e0e0;
    font-size: 16px; /* >= 16px to avoid iOS zoom */
    font-family: inherit;
    resize: vertical;
    min-height: 120px;
    box-sizing: border-box;
}

.edit-bio-input:focus {
    outline: none;
    border-color: #4a9eff;
}

.edit-bio-hint {
    margin-top: 6px;
    font-size: 12px;
    color: #888;
}

.edit-modal-footer {
    display: flex;
    align-items: center;
    justify-content: flex-end;
    gap: 10px;
    padding: 16px 24px;
    border-top: 1px solid #2a2a2a;
}

.loading-spinner-inline {
    display: inline-block;
    width: 14px;
    height: 14px;
    border: 2px solid #fff;
    border-top-color: transparent;
    border-radius: 50%;
    vertical-align: middle;
    margin-right: 6px;
}

/* Mobile */
@media (max-width: 768px) {
    .user-profile-page {
        padding: 16px;
    }

    .user-profile-header {
        flex-direction: column;
        align-items: flex-start;
        text-align: left;
        gap: 16px;
        padding: 20px;
    }

    .user-profile-avatar {
        width: 96px;
        height: 96px;
    }

    .user-profile-username {
        font-size: 22px;
    }

    .user-profile-actions {
        width: 100%;
    }

    .user-profile-actions .btn {
        width: 100%;
        justify-content: center;
    }

    .user-profile-stats {
        grid-template-columns: repeat(3, 1fr);
        gap: 8px;
    }

    .user-profile-stat {
        padding: 12px 8px;
    }

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

    .user-posts-grid {
        grid-template-columns: repeat(2, 1fr);
    }

    .edit-avatar-row {
        flex-direction: column;
        align-items: flex-start;
    }

    .edit-modal-footer {
        flex-direction: column-reverse;
    }

    .edit-modal-footer .btn {
        width: 100%;
        justify-content: center;
    }
}
