/**
 * Post Component Styles
 * Centralized styles for posts, shares, and interactions
 * Used across feed.php, profile.php, and other pages
 */

/* ===== POST CARD STYLING ===== */
.post-card {
    background-color: var(--card-bg);
    border: 1px solid var(--border-color);
    margin-bottom: 1.5rem;
    border-radius: 12px;
    transition: all 0.3s ease;
}

.post-card:hover {
    box-shadow: 0 4px 12px var(--shadow);
}

/* ===== POST CONTENT ===== */
.post-content {
    color: var(--text-primary) !important;  /* Use theme variable for proper contrast */
    line-height: 1.6;
    word-wrap: break-word;
    overflow-wrap: break-word;
}

/* Force proper text colors in light theme */
.theme-light .post-content,
[data-theme="light"] .post-content {
    color: #212529 !important;  /* Dark text on light background */
}

/* Force proper text colors in dark theme */
.theme-dark .post-content,
[data-theme="dark"] .post-content {
    color: #ffffff !important;  /* Light text on dark background */
}

/* ===== SHARED POST STYLING ===== */
.shared-post-header {
    background: var(--bg-tertiary);
    border-radius: 8px;
    padding: 8px 12px;
    border-left: 3px solid var(--btn-success);
}

.shared-post-content {
    border-left: 3px solid var(--btn-success);
    padding-left: 15px;
    margin: 10px 0;
}

.shared-original-content {
    font-style: italic;
    color: var(--text-primary) !important;
    line-height: 1.6;
}

/* Force proper contrast for shared posts */
.theme-light .shared-original-content,
[data-theme="light"] .shared-original-content {
    color: #212529 !important;
}

.theme-dark .shared-original-content,
[data-theme="dark"] .shared-original-content {
    color: #ffffff !important;
}

.original-post-attribution {
    background: rgba(25, 135, 84, 0.1);
    border-radius: 6px;
    padding: 4px 8px;
    border-left: 2px solid var(--btn-success);
}

.original-post-attribution a {
    color: var(--btn-success) !important;
    text-decoration: none;
}

.original-post-attribution a:hover {
    color: var(--btn-success) !important;
    text-decoration: underline !important;
    opacity: 0.8;
}

/* Dark theme overrides */
[data-theme="dark"] .shared-post-header {
    background: rgba(25, 135, 84, 0.15);
    color: var(--text-primary);
}

[data-theme="dark"] .shared-post-content {
    border-left-color: #38a169;
}

[data-theme="dark"] .original-post-attribution {
    background: rgba(25, 135, 84, 0.2);
    color: var(--text-primary);
}

/* ===== POST INTERACTIONS ===== */
.like-btn.liked {
    background-color: var(--btn-danger);
    color: white;
    border-color: var(--btn-danger);
}

.like-btn.liked {
    animation: heartBeat 0.6s ease-in-out;
}

@keyframes heartBeat {
    0% { transform: scale(1); }
    25% { transform: scale(1.1); }
    50% { transform: scale(1.2); }
    75% { transform: scale(1.1); }
    100% { transform: scale(1); }
}

.share-btn:hover, 
.comment-btn:hover, 
.like-btn:hover {
    transform: translateY(-1px);
    transition: all 0.2s ease;
}

/* ===== CLICKABLE LINKS IN POSTS ===== */
.text-link {
    color: var(--btn-primary);
    text-decoration: underline;
    word-break: break-all;
}

.text-link:hover {
    opacity: 0.8;
    text-decoration: underline;
}

.username-link {
    color: var(--btn-success);
    text-decoration: none;
    font-weight: 500;
}

.username-link:hover {
    opacity: 0.8;
    text-decoration: underline;
}

.hashtag-link {
    color: #667eea;
    text-decoration: none;
    font-weight: 500;
}

.hashtag-link:hover {
    opacity: 0.8;
    text-decoration: underline;
}

/* ===== LINK PREVIEW CARDS ===== */
.link-preview {
    border: 1px solid var(--border-light);
    border-radius: 12px;
    overflow: hidden;
    transition: transform 0.2s ease, box-shadow 0.2s ease;
    max-width: 100%;
    position: relative;
    z-index: 10;
}

.link-preview + p,
.link-preview + div,
.link-preview + .post-content,
.link-preview + .shared-post-content {
    margin-top: 0.5rem;
}

.link-preview:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 18px var(--shadow);
}

.link-preview-anchor {
    display: flex;
    flex-direction: row;
    text-decoration: none;
    color: inherit;
    align-items: stretch;
}

.link-preview-thumb {
    position: relative;
    flex: 0 0 clamp(260px, 32vw, 380px);
    width: clamp(260px, 32vw, 380px);
    background: #000;
    border-right: 1px solid var(--border-light);
    overflow: hidden;
}

.link-preview-thumb::before {
    content: '';
    display: block;
    padding-bottom: 56.25%;
}

.link-preview-thumb img {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.link-preview[data-preview-orientation="vertical"] .link-preview-thumb {
    flex: 0 0 clamp(180px, 24vw, 240px);
    width: clamp(180px, 24vw, 240px);
}

.link-preview[data-preview-orientation="vertical"] .link-preview-thumb::before {
    padding-bottom: 150%;
}

@media (max-width: 576px) {
    .link-preview-thumb {
        flex: 0 0 auto;
        width: 100%;
        border-right: none;
    }
    .link-preview-anchor {
        flex-direction: column;
    }
}

.link-preview-play {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: 56px;
    height: 56px;
    border-radius: 50%;
    background: rgba(0, 0, 0, 0.6);
    display: flex;
    align-items: center;
    justify-content: center;
    color: white;
    font-size: 1.25rem;
}

.link-preview-body {
    padding: 14px 18px;
    background: var(--card-bg);
    display: flex;
    flex-direction: column;
    justify-content: center;
    gap: 6px;
}

.link-preview-site {
    font-size: 0.75rem;
    font-weight: 600;
    text-transform: uppercase;
    color: var(--text-muted);
    margin-bottom: 4px;
}

.link-preview-title {
    font-weight: 600;
    color: var(--text-primary);
    margin-bottom: 6px;
    line-height: 1.4;
}

.link-preview-description {
    font-size: 0.9rem;
    color: var(--text-secondary);
    margin: 0;
}

.link-preview-domain {
    font-size: 0.75rem;
    color: var(--text-muted);
}

[data-theme="dark"] .link-preview-body,
.theme-dark .link-preview-body {
    background: var(--bg-secondary);
}

[data-theme="dark"] .link-preview:hover,
.theme-dark .link-preview:hover {
    box-shadow: 0 8px 20px rgba(15, 23, 42, 0.4);
}

/* ===== COMMENT STYLING ===== */
.comment-item {
    background: var(--bg-secondary);
    border: 1px solid var(--border-light);
    padding: 10px;
    border-radius: 8px;
    margin-bottom: 10px;
    color: var(--text-primary);
}

.comment-item strong {
    color: var(--text-primary) !important;
    font-weight: 600;
}

.comment-item a {
    transition: all 0.2s ease;
    color: var(--text-primary) !important;
}

.comment-item a:hover {
    opacity: 0.8;
}

.comment-item a:hover strong {
    text-decoration: underline;
}

/* Ensure comment text is readable */
.comment-item p {
    color: var(--text-primary);
}

/* Comment timestamps and small text */
.comment-item small {
    color: var(--text-secondary) !important;
}

.comment-item .text-muted {
    color: var(--text-muted) !important;
}

.comments-section {
    border-top: 1px solid var(--border-light);
    padding-top: 15px;
    margin-top: 15px;
}

/* ===== LIVE STREAMS ===== */
.hover-lift { 
    transition: transform 0.2s, box-shadow 0.2s; 
    cursor: pointer;
}

.hover-lift:hover { 
    transform: translateY(-4px); 
    box-shadow: 0 8px 20px var(--shadow-lg); 
}

.live-badge {
    background: var(--btn-danger) !important;
    animation: pulse 2s infinite;
}

.live-badge i {
    animation: blink 1.5s infinite;
}

@keyframes pulse {
    0%, 100% {
        box-shadow: 0 0 0 0 rgba(220, 53, 69, 0.7);
    }
    50% {
        box-shadow: 0 0 0 8px rgba(220, 53, 69, 0);
    }
}

@keyframes blink {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.3; }
}

/* ===== MEDIA GALLERY ===== */
.folder-item {
    cursor: pointer;
    transition: transform 0.2s ease;
}

.folder-item:hover {
    transform: translateY(-2px);
}

.folder-card {
    background: var(--bg-secondary);
    border: 1px solid var(--border-light);
    border-radius: 8px;
    padding: 15px;
    height: 100%;
    transition: all 0.2s ease;
}

.folder-card:hover {
    box-shadow: 0 4px 12px var(--shadow);
}

/* ===== PIN POST ===== */
.pin-post-btn.pinned {
    background-color: var(--btn-info);
    color: white;
    border-color: var(--btn-info);
}

/* ===== POST ITEM ANIMATIONS ===== */
.post-item {
    position: relative;
    z-index: 1;
    transition: transform 0.2s ease;
}

.post-item:hover {
    transform: translateY(-2px);
    z-index: 3;
}

#profilePostsContainer.posts-refreshing {
    position: relative;
    pointer-events: none;
}

#profilePostsContainer.posts-refreshing::after {
    content: '';
    position: absolute;
    inset: 0;
    background: rgba(255, 255, 255, 0.65);
    border-radius: 12px;
    z-index: 2;
}

[data-theme="dark"] #profilePostsContainer.posts-refreshing::after,
.theme-dark #profilePostsContainer.posts-refreshing::after {
    background: rgba(15, 23, 42, 0.7);
}

#profilePostsContainer.posts-refreshing::before {
    content: '';
    position: absolute;
    top: 50%;
    left: 50%;
    width: 36px;
    height: 36px;
    margin-top: -18px;
    margin-left: -18px;
    border-radius: 50%;
    border: 3px solid rgba(13, 202, 240, 0.35);
    border-top-color: var(--btn-info, #0dcaf0);
    animation: profile-posts-spin 0.8s linear infinite;
    z-index: 3;
}

@keyframes profile-posts-spin {
    from {
        transform: rotate(0deg);
    }
    to {
        transform: rotate(360deg);
    }
}

.post-privacy-dropdown {
    position: relative;
    z-index: 30;
}

.post-privacy-dropdown .dropdown-menu {
    z-index: 40;
}

.suggestion-item {
    transition: background-color 0.2s ease;
}

.suggestion-item:hover {
    background-color: var(--bg-secondary);
    border-radius: 8px;
    padding: 8px;
    margin: -8px;
}

/* ===== STREAMING STYLES ===== */
.stream-gradient-bg {
    background: linear-gradient(135deg, var(--btn-danger) 0%, #fd7e14 100%) !important;
    color: white !important;
    border: none !important;
}

.stream-thumbnail {
    position: relative;
    padding-top: 56.25%;
    overflow: hidden;
    background: #000;
    border-radius: 8px 8px 0 0;
}

.stream-thumbnail img {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.viewer-count {
    background: rgba(0, 0, 0, 0.7);
    color: white;
    padding: 4px 10px;
    border-radius: 4px;
    font-size: 0.8rem;
    font-weight: 600;
}

/* ===== PROFILE-SPECIFIC STYLES ===== */
.modern-profile-card {
    box-shadow: 0 10px 30px var(--shadow-lg);
    border: 1px solid var(--border-color);
    border-radius: 16px;
    overflow: hidden;
    transition: all 0.3s ease;
    background: var(--card-bg);
}

.modern-profile-card:hover {
    box-shadow: 0 15px 40px var(--shadow-lg);
    transform: translateY(-2px);
}

.profile-banner-container {
    position: relative;
    height: 250px;
    overflow: hidden;
    border-radius: 16px 16px 0 0;
    margin: 0;
    width: 100%;
    background: var(--sidebar-bg);
}

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

.profile-picture-container {
    position: relative;
    width: 120px;
    height: 120px;
    border-radius: 50%;
    box-shadow: 0 8px 25px var(--shadow-lg);
    overflow: hidden;
    transition: all 0.3s ease;
}

.profile-picture-container:hover {
    transform: scale(1.02);
    box-shadow: 0 10px 30px var(--shadow-lg);
}

.profile-picture {
    width: 100%;
    height: 100%;
    border-radius: 50%;
    object-fit: cover;
    transition: all 0.3s ease;
}

.profile-picture-container:not([style*="border"]) .profile-picture {
    border: 3px solid rgba(255, 255, 255, 0.9);
    box-shadow: 0 0 0 1px rgba(0, 0, 0, 0.1);
}

.profile-info-section {
    position: relative;
    z-index: 1;
}

.profile-header-info .profile-name {
    font-size: 2.5rem;
    font-weight: 700;
    color: var(--text-primary);
    margin-bottom: 0.5rem;
    text-shadow: 0 1px 2px var(--shadow);
}

.profile-meta {
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: 1rem;
}

.profile-username {
    font-size: 1.2rem;
    font-weight: 500;
    color: var(--text-secondary);
}

/* Pin button active state */
.pin-post-btn.pinned {
    background-color: var(--btn-info);
    color: white;
    border-color: var(--btn-info);
}

.pin-post-btn.pinned:hover {
    opacity: 0.9;
}

/* Bookmark button active state */
.bookmark-btn.bookmarked {
    background-color: var(--btn-info);
    color: white;
    border-color: var(--btn-info);
}

.bookmark-btn.bookmarked:hover {
    opacity: 0.9;
}

/* Highlight post when accessed via anchor link */
.card:target {
    animation: highlightPost 2s ease;
    border-color: var(--btn-primary) !important;
    box-shadow: 0 0 20px rgba(102, 126, 234, 0.3);
}

@keyframes highlightPost {
    0%, 100% { 
        background-color: transparent; 
    }
    50% { 
        background-color: rgba(102, 126, 234, 0.1); 
    }
}

/* ===== RESPONSIVE ADJUSTMENTS ===== */
@media (max-width: 768px) {
    .post-card {
        border-radius: 8px;
        margin-bottom: 1rem;
    }
    
    .shared-post-content {
        padding-left: 10px;
    }
}

