:root {
    --profile-bg: #0d0d1a;
    --profile-card-bg: rgba(22, 33, 62, 0.7);
    --profile-border: rgba(255, 255, 255, 0.1);
    --profile-accent-1: #a78bfa;
    --profile-accent-2: #f472b6;
    --profile-text: #cbd5e1;
    --profile-text-muted: #94a3b8;
}

.profile-page-wrapper {
    background-color: var(--profile-bg);
    color: var(--profile-text);
    padding-bottom: 50px;
    min-height: 100vh;
}

.profile-banner {
    height: 350px;
    position: relative;
    background-color: #1c2938;
}

.profile-banner-image {
    width: 100%;
    height: 100%;
    object-fit: cover;
    object-position: center;
}

.profile-banner-overlay {
    position: absolute;
    inset: 0;
    background: linear-gradient(to top, var(--profile-bg) 5%, rgba(13, 13, 26, 0.5) 100%);
}

.profile-header-container {
    max-width: 1100px;
    margin: -80px auto 0 auto;
    padding: 0 24px;
    position: relative;
    z-index: 10;
    display: flex;
    align-items: flex-end;
    gap: 24px;
}

.profile-avatar-wrapper {
    position: relative;
    flex-shrink: 0;
}

.profile-header-avatar {
    width: 180px;
    height: 180px;
    border-radius: 50%;
    object-fit: cover;
    border: 4px solid var(--profile-bg);
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.5);
}

.profile-info {
    flex-grow: 1;
}

.profile-actions {
    align-self: flex-end;
    padding-bottom: 20px;
}

.profile-name {
    font-size: 2.25rem;
    font-weight: 700;
    color: #fff;
    margin: 0;
    display: flex;
    align-items: center;
}

.badge-image,
.badge-placeholder {
    width: 64px;
    height: 64px;
    margin-left: 0;
    flex-shrink: 0;
    position: relative;
    top: 4px;
}

.badge-image {
    vertical-align: middle;
    object-fit: contain;
    cursor: help;
    filter: drop-shadow(0 1px 3px rgba(0, 0, 0, 0.7));
}

.profile-full-name {
    font-size: 1.1rem;
    font-weight: 500;
    color: var(--profile-text-muted);
    margin: 0.25rem 0 0.5rem 0;
}

.profile-joined-date {
    font-size: 0.9rem;
    color: var(--profile-text-muted);
}

.btn-edit-profile {
    background: linear-gradient(135deg, var(--profile-accent-1) 0%, var(--profile-accent-2) 100%);
    color: white;
    border: none;
    padding: 0.6rem 1.5rem;
    font-size: 0.9rem;
    font-weight: 600;
    border-radius: 8px;
    text-decoration: none;
    transition: all 0.3s ease;
    box-shadow: 0 4px 15px rgba(236, 72, 153, 0.3);
}

.btn-edit-profile:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(139, 92, 246, 0.4);
}

.btn-send-message {
    background: #3db4f2;
    color: white;
    border: none;
    padding: 0.6rem 1.5rem;
    font-size: 0.9rem;
    font-weight: 600;
    border-radius: 8px;
    text-decoration: none;
    transition: all 0.3s ease;
    cursor: pointer;
}

.btn-send-message:hover {
    background: #31a9e6;
    transform: translateY(-2px);
}

.profile-action-buttons {
    display: flex;
    gap: 0.75rem;
}

.btn-action {
    border: none;
    padding: 0.6rem 1.2rem;
    font-size: 0.9rem;
    font-weight: 600;
    border-radius: 8px;
    text-decoration: none;
    transition: all 0.3s ease;
    cursor: pointer;
    text-align: center;
}

.btn-follow {
    background: #3db4f2;
    color: white;
}
.btn-unfollow, .btn-requested {
    background: #374151;
    color: #e5e7eb;
}
.btn-message {
    background: #6b7280;
    color: white;
}
.btn-action:hover {
    transform: translateY(-2px);
    filter: brightness(1.1);
}

.profile-content-container {
    max-width: 1100px;
    margin: 30px auto 0 auto;
    padding: 0 24px;
}

.profile-tabs {
    display: flex;
    gap: 24px;
    border-bottom: 1px solid var(--profile-border);
    margin-bottom: 24px;
}

.profile-tab-trigger {
    padding-bottom: 12px;
    font-size: 1rem;
    font-weight: 500;
    color: var(--profile-text-muted);
    border-bottom: 2px solid transparent;
    transition: color 0.2s, border-color 0.2s;
    background: none;
    border-top: none;
    border-left: none;
    border-right: none;
}

.profile-tab-trigger:hover {
    color: white;
}

.profile-tab-trigger.active {
    color: white;
    border-bottom-color: var(--profile-accent-1);
}

.profile-tab-panel {
    display: none;
}

.profile-tab-panel.active {
    display: block;
    animation: fadeInUp 0.5s ease-out;
}

.tab-loader {
    display: flex;
    justify-content: center;
    align-items: center;
    min-height: 300px;
    padding: 2rem 0;
    transition: opacity 0.3s ease;
}

.about-section {
    background-color: var(--profile-card-bg);
    border: 1px solid var(--profile-border);
    border-radius: 12px;
    padding: 2rem;
    line-height: 1.7;
}
.about-section p {
    overflow-wrap: break-word;
    word-wrap: break-word;
    margin: 0;
}

.profile-comments-section {
    margin-top: 3rem;
    background-color: var(--profile-card-bg);
    border: 1px solid var(--profile-border);
    border-radius: 12px;
    padding: 2rem;
}

.comments-section-title {
    color: white;
    font-weight: 600;
    margin-bottom: 1.5rem;
}

.profile-comment-form-wrapper {
    display: flex;
    gap: 1rem;
    margin-bottom: 2rem;
}

.profile-comment-avatar {
    flex-shrink: 0;
}

img.profile-comment-avatar,
.profile-comment-avatar img {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    object-fit: cover;
}

.profile-comment-form {
    flex-grow: 1;
}

.profile-comment-form textarea {
    background-color: #1c2938;
    border: 1px solid #343f51;
    color: #d1d5db;
    border-radius: 6px;
    padding: 12px;
    width: 100%;
    transition: border-color 0.2s, box-shadow 0.2s;
    resize: none;
}

.profile-comment-form textarea:focus {
    outline: none;
    border-color: #3db4f2;
    box-shadow: 0 0 0 3px rgba(61, 180, 242, 0.2);
    background-color: #1c2938;
}

.profile-comment-list {
    display: flex;
    flex-direction: column;
    gap: 1.5rem;
}

.profile-comment {
    display: flex;
    gap: 1rem;
}

.profile-comment-body {
    flex-grow: 1;
    min-width: 0;
}

.profile-comment-header {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    margin-bottom: 0.25rem;
}

.profile-comment-author {
    font-weight: 600;
    color: white;
    text-decoration: none;
}
.profile-comment-author:hover {
    text-decoration: underline;
}

.profile-comment-author-container {
    display: flex;
    align-items: center;
}

.profile-comment-author-badge {
    width: 20px;
    height: 20px;
    object-fit: contain;
    vertical-align: middle;
    position: relative;
    top: 2px;
    margin-left: 0;
    cursor: help;
}

.profile-comment-date {
    font-size: 0.8rem;
    color: var(--profile-text-muted);
}

.profile-comment-content p {
    margin: 0;
    line-height: 1.6;
    word-break: break-word;
}

.profile-comment-actions {
    display: flex;
    gap: 1rem;
    margin-top: 0.75rem;
}

.profile-comment-actions .action-btn {
    background: none;
    border: none;
    color: var(--profile-text-muted);
    display: flex;
    align-items: center;
    gap: 0.3rem;
    font-size: 0.8rem;
    font-weight: 500;
    cursor: pointer;
    transition: color 0.2s;
    padding: 0;
}
.profile-comment-actions .action-btn:hover:not(:disabled) {
    color: white;
}
.profile-comment-actions .action-btn.like-btn.liked {
    color: #f87171;
}
.profile-comment-actions .action-btn.delete-btn:hover {
    color: #ef4444;
}

.empty-state-text {
    color: var(--profile-text-muted);
    text-align: center;
    padding: 2rem 0;
}

.friends-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(120px, 1fr));
    gap: 1.5rem;
}

.friend-card {
    text-decoration: none;
    color: var(--profile-text);
    text-align: center;
    transition: transform 0.2s ease;
}

.friend-card:hover {
    transform: translateY(-5px);
}

.friend-card img {
    width: 100px;
    height: 100px;
    border-radius: 50%;
    object-fit: cover;
    margin-bottom: 0.75rem;
    border: 2px solid var(--profile-border);
}

.friend-card span {
    font-weight: 500;
    display: block;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.empty-state {
    text-align: center;
    padding: 3rem;
    background-color: var(--profile-card-bg);
    border: 1px solid var(--profile-border);
    border-radius: 12px;
    color: var(--profile-text-muted);
}

.lists-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
  gap: 1.5rem;
}

.list-card {
  position: relative;
  border-radius: 12px;
  overflow: hidden;
  background-color: var(--profile-card-bg);
  transition: all 0.3s ease;
  border: 1px solid var(--profile-border);
}

.list-card:hover {
  transform: translateY(-5px);
  box-shadow: 0 8px 25px rgba(0, 0, 0, 0.3);
}

.list-card-link {
  text-decoration: none;
  display: block;
}

.list-card-image-wrapper {
  position: relative;
  aspect-ratio: 1 / 1;
  transition: transform 0.3s ease;
  overflow: hidden;
  border-radius: 12px;
}

.list-card-image {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.list-card:hover .list-card-image-wrapper {
  transform: scale(1.05);
}

.list-card-overlay {
  position: absolute;
  inset: 0;
  background: linear-gradient(to top, rgba(22, 33, 62, 1) 10%, rgba(22, 33, 62, 0.5) 60%, transparent 100%);
}

.list-card-content {
  padding: 1rem 1.5rem;
  position: absolute;
  bottom: 0;
  left: 0;
  right: 0;
}

.list-card-name {
  font-size: 1.1rem;
  font-weight: 600;
  color: white;
  margin-bottom: 0.5rem;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.list-card-creator {
  position: absolute;
  top: 0.75rem;
  left: 0.75rem;
  background-color: rgba(13, 13, 26, 0.6);
  color: var(--profile-text-muted);
  padding: 0.25rem 0.6rem;
  border-radius: 6px;
  font-size: 0.8rem;
  font-weight: 500;
  z-index: 2;
  backdrop-filter: blur(5px);
  max-width: 120px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.list-card-creator-mobile {
    display: none;
}

.list-card-meta {
  font-size: 0.85rem;
  color: var(--profile-text-muted);
  display: flex;
  gap: 1rem;
}

.list-card-meta span {
  display: flex;
  align-items: center;
  gap: 0.3rem;
}

.list-card-actions {
  position: absolute;
  top: 0.75rem;
  right: 0.75rem;
  display: flex;
  gap: 0.5rem;
  background-color: rgba(13, 13, 26, 0.6);
  padding: 0.3rem 0.5rem;
  border-radius: 99px;
  backdrop-filter: blur(5px);
}

.list-card-actions .action-btn {
    background: rgba(255, 255, 255, 0.1);
    border: none;
    color: var(--profile-text);
    width: 36px;
    height: 36px;
    border-radius: 50%;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s ease;
}
.list-card-actions .action-btn:hover { background: rgba(255, 255, 255, 0.15); color: white; }
.list-card-actions .action-btn.delete:hover { background: rgba(239, 68, 68, 0.2); color: #f87171; }
.list-card-actions .action-btn.like-btn.liked { color: #f87171; }
.list-card-actions .action-btn.like-btn .like-count { font-size: 0.8rem; margin-left: 0.2rem; }

#image-preview-container {
    max-width: 100%;
    border-radius: 8px;
    overflow: hidden;
}
#image-preview { width: 100%; object-fit: cover; }

@media (max-width: 768px) {
    .lists-grid {
        display: grid;
        grid-template-columns: repeat(2, 1fr);
        gap: 1rem;
    }

    .list-card-creator {
        display: none;
    }

    .list-card-content {
        bottom: 0.5rem;
    }

    .list-card-name {
        text-align: center;
        margin-bottom: 0;
    }

    .list-card-creator-mobile {
        display: block;
        text-align: center;
        font-size: 0.75rem;
        color: var(--profile-text-muted);
    }

    .list-card-meta {
        display: none;
    }

    .list-card-actions {
        left: 50%;
        right: auto;
        transform: translateX(-50%);
    }

    .profile-header-container {
        flex-direction: column;
        align-items: center;
        text-align: center;
        margin-top: -100px;
        gap: 0.5rem;
    }
    .profile-header-avatar {
        width: 150px;
        height: 150px;
    }
    .profile-info {
        padding-bottom: 0;
        width: 100%;
    }
    .profile-name {
        font-size: 1.75rem;
        justify-content: center;
        align-items: center;
    }
    .badge-image,
    .badge-image {
        width: 60px;
        height: 60px;
        margin-left: 0;
        position: relative;
        top: 2px;
    }
    .badge-placeholder {
        display: none;
    }
    .profile-actions {
        width: 100%;
        margin-top: 1rem;
        padding-bottom: 0;
        display: flex;
        justify-content: center;
    }
    .btn-edit-profile, .btn-send-message {
        width: 100%;
        max-width: 300px;
    }
    .profile-full-name {
        font-size: 1rem;
    }
    .profile-content-container, .profile-header-container {
        padding: 0 16px;
    }
    .profile-tabs {
        overflow-x: auto;
        white-space: nowrap;
        -webkit-overflow-scrolling: touch;
        scrollbar-width: none;
        padding-bottom: 0;
    }
    .profile-tabs::-webkit-scrollbar {
        display: none;
    }
    .follow-request-username {
        max-width: 120px;
        white-space: nowrap;
        overflow: hidden;
        text-overflow: ellipsis;
    }
    .follow-request-actions {
        flex-direction: column;
        gap: 0.4rem;
    }
    .follow-grid {
        grid-template-columns: repeat(4, 1fr) !important;
        gap: 0.5rem;
    }
    .follow-card img {
        width: 50px !important;
        height: 50px !important;
        margin-bottom: 0.4rem;
        border-width: 1px !important;
    }
    .follow-card span {
        font-size: 0.7rem;
    }

    .explore-posts-list {
        grid-template-columns: 1fr;
    }
}

@keyframes fadeInUp {
    from { opacity: 0; transform: translateY(20px); }
    to { opacity: 1; transform: translateY(0); }
}

.profile-comment.highlight {
    background-color: rgba(167, 139, 250, 0.1) !important;
    border-color: rgba(167, 139, 250, 0.4) !important;
    box-shadow: 0 0 0 2px rgba(167, 139, 250, 0.3);
    transition: background-color 0.5s ease-out, box-shadow 0.5s ease-out, border-color 0.5s ease-out;
}

.custom-popover {
    --bs-popover-bg: #151f2e;
    --bs-popover-border-color: rgba(255, 255, 255, 0.1);
    --bs-popover-header-bg: #1c2938;
    --bs-popover-header-color: white;
    --bs-popover-body-color: #a0b1c5;
    max-width: 300px;
    border-radius: 8px;
    box-shadow: 0 5px 15px rgba(0,0,0,0.3);
}

.follow-requests-list {
    display: flex;
    flex-direction: column;
    gap: 1rem;
}

.follow-request-card {
    display: flex;
    justify-content: space-between;
    align-items: center;
    background-color: var(--profile-card-bg);
    padding: 1rem 1.5rem;
    border-radius: 12px;
    border: 1px solid var(--profile-border);
    transition: background-color 0.2s ease;
}

.follow-request-avatar {
    width: 50px;
    height: 50px;
    border-radius: 50%;
    object-fit: cover;
}

.follow-request-username {
    font-weight: 600;
    color: var(--profile-text);
}

.follow-request-actions {
    display: flex;
    gap: 0.5rem;
}

.btn-request-action {
    border: none;
    padding: 0.4rem 0.8rem;
    font-size: 0.85rem;
    font-weight: 600;
    border-radius: 6px;
    text-decoration: none;
    transition: all 0.3s ease;
    cursor: pointer;
    text-align: center;
}

.follow-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(120px, 1fr));
    gap: 1.5rem;
}

.follow-card {
    text-decoration: none;
    color: var(--profile-text);
    text-align: center;
    transition: transform 0.2s ease;
}

.follow-card:hover {
    transform: translateY(-5px);
}

.follow-card img {
    width: 100px;
    height: 100px;
    border-radius: 50%;
    object-fit: cover;
    margin-bottom: 0.75rem;
    border: 2px solid var(--profile-border);
    background-color: var(--profile-card-bg);
}

.follow-card span {
    font-weight: 500;
    display: block;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.btn-accept-follow {
    background: linear-gradient(135deg, var(--profile-accent-1) 0%, var(--profile-accent-2) 100%);
    color: white;
    box-shadow: 0 2px 10px rgba(236, 72, 153, 0.2);
}

.btn-decline-follow {
    background: #374151;
    color: #e5e7eb;
}

.btn-request-action:hover {
    transform: translateY(-2px);
    filter: brightness(1.1);
}

.explore-posts-list {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(320px, 1fr));
    gap: 1.5rem;
}

.post-card-link {
    text-decoration: none;
    color: inherit;
}

.explore-post-card {
    background-color: var(--profile-card-bg);
    border: 1px solid var(--profile-border);
    border-radius: 12px;
    padding: 1.5rem;
    transition: background-color 0.2s, border-color 0.2s;
    display: flex;
    flex-direction: column;
    height: 100%;
}

.explore-post-card:hover {
    background-color: rgba(30, 41, 59, 0.7);
    border-color: var(--profile-accent-1);
}

.post-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 0.75rem;
}

.post-author-info {
    display: flex;
    align-items: center;
    gap: 0.75rem;
}

.author-avatar {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    object-fit: cover;
}

.author-name {
    font-weight: 600;
    color: white;
}

.post-date {
    font-size: 0.8rem;
    color: var(--profile-text-muted);
    flex-shrink: 0;
}

.post-body {
    display: flex;
    gap: 1rem;
    margin: 1rem 0;
    min-height: 80px;
}

.post-text {
    color: var(--profile-text);
    word-break: break-word;
    line-height: 1.6;
    margin: 0;
    flex-grow: 1;
    display: -webkit-box;
    -webkit-line-clamp: 5;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

.post-image {
    width: 80px;
    height: 80px;
    flex-shrink: 0;
    object-fit: cover;
    border-radius: 8px;
    margin-top: 0;
}

.post-footer {
    display: flex;
    gap: 1rem;
    margin-top: auto;
    font-size: 0.85rem;
    color: var(--profile-text-muted);
}

.community-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
    gap: 1.5rem;
}

.community-card {
    background-color: var(--profile-card-bg);
    border: 1px solid var(--profile-border);
    border-radius: 16px;
    overflow: hidden;
    text-decoration: none;
    color: var(--profile-text);
    transition: all 0.3s ease;
    display: flex;
    flex-direction: column;
    height: 100%;
}

.community-card {
    transform: translateY(-5px);
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.3);
    border-color: var(--profile-accent-1);
}

.community-card-banner {
    height: 70px;
}

.community-card-banner img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.community-card-content {
    padding: 1rem;
    padding-top: 0;
    text-align: center;
    flex-grow: 1;
    display: flex;
    flex-direction: column;
}

.community-card-image {
    width: 60px;
    height: 60px;
    border-radius: 50%;
    overflow: hidden;
    margin: -30px auto 0.5rem auto;
    border: 4px solid var(--profile-card-bg);
    background-color: var(--profile-card-bg);
    flex-shrink: 0;
}

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

.community-card-name {
    font-size: 1rem;
    font-weight: 600;
    color: #fff;
    margin-bottom: 0.4rem;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.community-card-description {
    font-size: 0.8rem;
    color: var(--profile-text-muted);
    line-height: 1.5;
    margin-bottom: 0.75rem;
    flex-grow: 1;
    overflow-wrap: break-word;
    display: -webkit-box;
    -webkit-line-clamp: 3;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

.community-card-meta {
    font-size: 0.75rem;
    font-weight: 500;
    color: var(--profile-text-muted);
    border-top: 1px solid var(--profile-border);
    padding-top: 0.75rem;
    margin-top: auto;
}
    display: block;
    font-weight: 600;
    color: white;
    margin-bottom: 0.25rem;
}

.community-card-members {
    font-size: 0.85rem;
    color: var(--profile-text-muted);
}