/* Profile page main container */
#profile {
    display: flex;
    flex-direction: column;
    width: 60%; /* This will be adjusted for mobile */
    margin: 10px 24px 0 0; /* This will be adjusted for mobile */
    background: var(--background, #fff);
    border-radius: 10px; /* This will be adjusted for mobile */
    box-shadow: 0 2px 8px rgba(0,0,0,0.07);
    min-height: 80vh;
    font-family: 'Rajdhani', sans-serif;
}

#profile .profile-cover {
    position: relative;
    width: 100%;
    height: 180px; /* Adjust height for smaller screens if needed */
    background: var(--sidebar, #eee);
    border-radius: 10px 10px 0 0; /* This will be adjusted for mobile */
    overflow: hidden;
    z-index: 1;
}

#profile .profile-cover-img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
}

#profile .profile-avatar-group {
    display: flex;
    align-items: center;
    gap: 1.2em;
    position: relative;
    margin-left: 2em;
    margin-top: -48px;
    margin-bottom: 1.5em;
    z-index: 2;
    background: none;
}

#profile .profile-avatar {
    width: 96px;
    height: 96px;
    border-radius: 50%;
    object-fit: cover;
    box-shadow: 0 2px 8px rgba(0,0,0,0.12);
}

#profile .profile-names {
    display: flex;
    flex-direction: column;
    gap: 0.2em;
}

#profile .profile-display-name {
    font-family: 'Orbitron', sans-serif;
    font-size: 2em;
    font-weight: bold;
    color: var(--text);
}

#profile .profile-username {
    font-size: 1.1em;
    color: var(--sidebarText);
}

#profile .balance-info, .balance-info {
    display: flex;
    align-items: center;
    gap: 6px;
}

#profile .profile-tabs {
	display: flex;
	flex-wrap: wrap;
	gap: 1em;
	margin-left: 2em;
	padding-bottom: 0;
}

#profile .profile-tab {
    background: none;
    border: none;
    font-size: 1.1em;
    font-weight: 500;
    color: var(--text, #444);
    padding: 0.5em 1.2em;
    border-radius: 6px 6px 0 0;
    cursor: pointer;
    transition: background 0.15s;
    flex-shrink: 0;
}

#profile .profile-tab.chosen {
    background: var(--sidebar) !important;
    color: var(--text);
}

#profile .profile-tab-content {
	background: var(--sidebar);
    margin: 0 1em 0;
	border-radius: 10px 10px 0 0;
	padding: 2em;
	min-height: 300px;
	flex: 1 1 auto;
}

#profile .profile-tab-panel {
    display: block;
    max-height: 60vh;
    overflow-y: auto;
    overflow-x: hidden;
    scroll-behavior: smooth;
}

/* --- Summary --- */
#profile .profile-summary-textarea {
    color: var(--text);
    background: none;
    border: none;
    width: 95%;
    height: 2in;
    resize: none;
}

#profile .profile-summary-textarea:focus {
    outline: none;
}

/* --- Posts --- */
#profile .profile-content-grid {
    display: flex;
    flex-wrap: wrap;
    gap: 1em;
    justify-content: center;
}

#profile .profile-content-card {
    background: var(--background);
    border-radius: 8px;
    box-shadow: 0 2px 4px rgba(0,0,0,0.08);
    width: calc(50% - 0.5em);
    height: 2.3in;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    cursor: pointer;
    transition: transform 0.2s;
}

#profile .profile-content-card:hover {
    transform: translateY(-5px);
}

#profile .profile-content-img {
    width: 100%;
    height: 60%;
    object-fit: cover;
    border-bottom: 1px solid var(--accent);
}

#profile .profile-content-title {
    font-weight: bold;
    font-size: 1.1em;
    margin: 0.5em 0 0.2em 0.7em;
    color: var(--text, #222);
}

#profile .profile-content-desc {
    font-size: 0.98em;
    color: var(--text, #555);
    margin: 0 0.7em 0.7em 0.7em;
    flex: 1 1 auto;
    overflow: hidden;
    text-overflow: ellipsis;
}

/* --- Comments --- */
#profile .profile-comments-list {
	display: flex;
    flex-wrap: wrap;
    justify-content: center;
	gap: 1.2em;
}

#profile .profile-comment {
	width: 45%;
	background: var(--background);
	box-shadow: 0 2px 4px rgba(0,0,0,0.08);
	border-radius: 10px;
	padding: 15px;
	box-shadow: 0 2px 5px rgba(0,0,0,0.05);
	margin-bottom: 1.2em;
}

#profile .post-header {
    display: flex;
    align-items: center;
    gap: 0.7em;
    margin-bottom: 0.5em;
}

#profile .post-header .profile-picture {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    overflow: hidden;
    flex-shrink: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    border: none;
}

#profile .post-header .profile-picture img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    border-radius: 50%;
}

#profile .post-header .display-name {
    font-weight: bold;
    font-size: 1.1em;
    color: var(--text, #222);
}

#profile .post-header .date-posted {
	font-size: 0.95em;
	color: var(--link);
	font-style: italic;
}

#profile .profile-comment-postinfo {
    margin-bottom: 10px;
}

#profile .profile-comment-post-text {
    font-size: 1em;
    color: var(--text);
    margin-top: 0.2em;
}

#profile .profile-comment-post-image {
	max-width: 100%;
	height: auto;
	border-radius: 5px;
	margin-top: 10px;
}

#profile .profile-comment-post-video {
    width: 120px;
    height: 80px;
    border-radius: 5px;
    margin-top: 10px;
}

#profile .profile-comment-card {
	background: var(--background);
	padding: 12px 15px;
	border-radius: 8px;
	border-top: 1px solid var(--accent);
	box-shadow: 0 4px 8px rgba(0, 0, 0, 0.08);
}

#profile .profile-comment-content {
    font-size: 1.1em;
    margin-bottom: 5px;
}

#profile .profile-comment-date {
    font-size: 0.85em;
    color: #777;
}

/* Spaces */
#profile .profile-spaces-list {
    display: flex;
    flex-wrap: wrap;
    gap: 1.2em;
    margin-top: 0.5em;
}
#profile .profile-space-card {
    background: var(--background);
    border-radius: 10px;
    box-shadow: 0 2px 5px rgba(0,0,0,0.07);
    border: 1px solid var(--accent, #e0e0e0);
    padding: 1.2em 1.5em;
    min-width: 220px;
    max-width: 340px;
    flex: 1 1 220px;
    display: flex;
    flex-direction: column;
    gap: 0.5em;
    transition: box-shadow 0.15s, border 0.15s;
}
#profile .profile-space-card:hover {
    box-shadow: 0 4px 16px rgba(0,0,0,0.13);
    border: 1.5px solid var(--link, #1a73e8);
}
#profile .profile-space-name {
    font-size: 1.25em;
    font-weight: bold;
    color: var(--text, #222);
    margin-bottom: 0.2em;
}
#profile .profile-space-desc {
    font-size: 1em;
    color: var(--text, #555);
    margin-bottom: 0.3em;
    word-break: break-word;
}
#profile .profile-space-meta {
    font-size: 0.95em;
    color: var(--link);
    margin-bottom: 0.2em;
}
#profile .profile-space-visibility {
    font-size: 0.9em;
    color: var(--link, #1a73e8);
    background: var(--sidebar, #f0f4fa);
    border-radius: 5px;
    padding: 0.2em 0.7em;
    align-self: flex-start;
    margin-top: 0.2em;
}

#profile .profile-no-posts, #profile .profile-no-comments { text-align: center; margin: 1em }

/* === Mobile === */
@media screen and (max-width: 1199px) and (orientation: portrait) {
    #profile {
        width: 100vw;
        min-width: 0;
        padding: 0;
        border-radius: 0;
    }

    #profile .profile-cover {
        border-radius: 0;
    }
}

@media screen and (max-width: 768px) {
    #profile {
        margin: 0;
        width: 100%;
        border-radius: 0;
    }

    #profile .profile-cover {
        height: 150px;
        border-radius: 0;
    }

    #profile .profile-avatar-group {
        margin-left: 1em;
        margin-top: -36px;
        gap: 0.8em;
    }

    #profile .profile-avatar {
        width: 72px;
        height: 72px;
        border-width: 3px;
    }

    #profile .profile-display-name {
        font-size: 1.6em;
    }
    
    #profile .profile-username {
        font-size: 0.9em;
    }

    #profile .profile-tabs {
      display: flex;
      flex-wrap: wrap;
      gap: 10px;
      margin: 0;
      padding-bottom: 0;
      justify-content: center;
    }

    #profile .profile-tab {
        font-size: 0.95em;
        padding: 0.4em 1em;
        /* Tabs will now wrap */
        flex-basis: auto; /* Allow items to determine their own width */
    }

    #profile .profile-tab-content {
        padding: 1.5em;
        border-radius: 0;
    }

    #profile .profile-content-grid {
        justify-content: space-between; /* Distribute items with space between */
    }

    #profile .profile-content-card {
        width: calc(50% - 0.5em); /* Two cards per row, accounting for gap */
        max-width: unset; /* Remove max-width constraint for two columns */
        height: auto;
    }

    #profile .profile-comment {
        padding: 0.5em 0.8em;
        font-size: 0.95em;
        flex-direction: column; /* Stack date below comment on mobile */
    }

    #profile .profile-comment-date {
        font-size: 0.85em;
        margin-top: 0.5em; /* Add space above date */
    }

    #profile .profile-space {
        padding: 0.6em 1em;
        font-size: 1em;
    }

    #profile .profile-space-card {
        padding: 0.7em 1em;
        gap: 0.8em;
    }

    #profile .profile-space-icon {
        width: 40px;
        height: 40px;
    }

    #profile .profile-space-name {
        font-size: 1.1em;
    }

    #profile .profile-space-members {
        font-size: 0.9em;
    }
}

@media screen and (max-width: 499px) and (orientation: portrait) {
    #profile .profile-cover {
        height: 120px;
    }

    #profile .profile-avatar-group {
        margin-top: -30px;
    }

    #profile .profile-avatar {
        width: 64px;
        height: 64px;
    }

    #profile .profile-display-name {
        font-size: 1.4em;
    }

    #profile .profile-username {
        font-size: 0.85em;
    }

    #profile .profile-tab {
        font-size: 0.9em;
        padding: 0.3em 0.8em;
    }

    #profile .profile-tab-content {
        padding: 1em;
    }

    #profile .profile-content-card {
        width: calc(50% - 0.5em); /* Keep two cards per line even on smaller phones */
    }

    #profile .discover-preview, #profile .profile-comment {
        width: 100%;
    }

    #profile .profile-comment-parent {
        flex-direction: column;
        padding: 0.7em 0.5em;
    }

    #profile .profile-comment-postinfo {
        flex-direction: column;
        align-items: flex-start;
        gap: 0.5em;
        padding: 0.5em 0.7em;
    }

    #profile .profile-comment-post-authorpic {
        width: 36px;
        height: 36px;
    }

    #profile .profile-comment-post-authorname {
        font-size: 1em;
    }

    #profile .profile-comment-post-image {
        width: 60px;
        height: 60px;
    }

    #profile .profile-comment-post-video {
        width: 90px;
        height: 60px;
    }
}