/* Profile Posts - scoped layout rules (Bootstrap 5 friendly) */

/* Grid layout rules moved to profile-grid-layout.css (shared across all tabs) */
/* This file now only contains post-specific card styling, not grid layout */

/* Post cards - scoped to cards NOT in .cards-grid */
/* CRITICAL: Cards in .cards-grid use 1/1.8 to match 533px height (set in profile-grid-layout.css) */
/* CRITICAL: This rule only applies to post cards NOT in .cards-grid */
.post-card:not(.cards-grid .post-card):not(.cards-grid .unified-card.post-card) {
    /* CRITICAL: Use aspect-ratio, remove fixed heights */
    aspect-ratio: 4 / 5 !important; /* Same ratio everywhere - only for cards NOT in grid */
    height: auto !important; /* Height from aspect-ratio */
    min-height: 0 !important;
    max-height: none !important;
    display: grid !important; /* Internal grid layout */
    grid-template-rows: auto 1fr auto !important; /* image | body | footer */
    grid-template-columns: 1fr !important;
    overflow: hidden !important;
    width: 100% !important;
    max-width: 100% !important;
    box-sizing: border-box !important;
    margin: 0 !important;
}

.post-card:not(.cards-grid .post-card):not(.cards-grid .unified-card.post-card) .card-img-top {
    grid-row: 1 !important; /* First row in grid */
    height: auto !important; /* Height from grid row */
    min-height: 0 !important;
    max-height: none !important;
    width: 100% !important; /* Full width of card container */
    object-fit: cover !important; /* CRITICAL: Same as other cards - cover */
    object-position: center !important;
}

/* Post card body - PROPORTIONAL, NO FIXED HEIGHT */
/* CRITICAL: Body takes remaining space, scales with card */
.post-card:not(.cards-grid .post-card):not(.cards-grid .unified-card.post-card) .card-body {
    grid-row: 2 !important; /* Second row in grid - takes remaining space */
    min-height: 0 !important; /* Remove fixed min-height */
    max-height: none !important; /* Remove fixed max-height */
    padding: 1em !important; /* CRITICAL: Use em, not px - scales with card */
    display: flex !important;
    flex-direction: column !important;
    flex: 1 1 0 !important; /* Take remaining space */
    overflow: hidden !important; /* CRITICAL: Hide overflow, use line-clamp for text truncation */
    box-sizing: border-box !important;
}

/* Post card body text elements - Responsive font sizes and text truncation */
.post-card:not(.cards-grid .post-card):not(.cards-grid .unified-card.post-card) .card-body .card-title {
    font-size: clamp(0.875rem, 2.5vw, 1rem) !important; /* Responsive: 14px on mobile, 16px on desktop */
    line-height: 1.3 !important;
    margin-bottom: 0.5em !important;
    font-weight: 600 !important;
    color: #868e96 !important; /* Lighter gray color for better readability */
    /* Text truncation for long titles */
    display: -webkit-box !important;
    -webkit-line-clamp: 2 !important;
    -webkit-box-orient: vertical !important;
    overflow: hidden !important;
    text-overflow: ellipsis !important;
}

.post-card:not(.cards-grid .post-card):not(.cards-grid .unified-card.post-card) .card-body .card-subtitle {
    font-size: clamp(0.7rem, 2vw, 0.85rem) !important; /* Responsive: 11.2px on mobile, 13.6px on desktop */
    line-height: 1.4 !important;
    margin-bottom: 0.5em !important;
    color: #6c757d !important;
    /* Single line truncation */
    white-space: nowrap !important;
    overflow: hidden !important;
    text-overflow: ellipsis !important;
}

.post-card:not(.cards-grid .post-card):not(.cards-grid .unified-card.post-card) .card-body .card-text {
    font-size: clamp(0.75rem, 2vw, 0.9rem) !important; /* Responsive: 12px on mobile, 14.4px on desktop */
    line-height: 1.5 !important;
    margin-bottom: 0.5em !important;
    color: #495057 !important;
    flex: 1 1 0 !important; /* Take remaining space */
    min-height: 0 !important; /* Allow flex shrinking */
    /* Multi-line truncation with ellipsis */
    display: -webkit-box !important;
    -webkit-line-clamp: 3 !important; /* Show max 3 lines */
    -webkit-box-orient: vertical !important;
    overflow: hidden !important;
    text-overflow: ellipsis !important;
}

.post-card:not(.cards-grid .post-card):not(.cards-grid .unified-card.post-card) .card-body .read-more-link {
    font-size: clamp(0.7rem, 2vw, 0.85rem) !important; /* Responsive font size */
    margin-top: 0.25em !important;
    flex-shrink: 0 !important; /* Don't shrink */
}

.post-card:not(.cards-grid .post-card):not(.cards-grid .unified-card.post-card) .card-footer {
    grid-row: 3 !important; /* Third row in grid - always at bottom */
    min-height: 0 !important; /* Remove fixed min-height */
    max-height: none !important; /* Remove fixed max-height */
    height: auto !important; /* Height from content */
    padding: 0.75em 1em !important; /* CRITICAL: Use em, not px - scales with card */
    flex-shrink: 0 !important;
    flex-grow: 0 !important;
    background-color: #f8f9fa !important;
    display: flex !important;
    align-items: center !important;
    justify-content: center !important;
    border-top: 1px solid #dee2e6 !important;
    display: flex !important;
    align-items: center !important;
    justify-content: flex-start !important;
    overflow: visible !important;
    position: relative !important;
    box-sizing: border-box !important;
    width: 100% !important;
    margin-top: auto !important; /* Push footer to bottom of card */
    transition: background-color 0.3s ease, border-color 0.3s ease, color 0.3s ease !important; /* CRITICAL: Smooth transition for dark mode */
}

/* NOTE: Dark mode styles moved to dark-mode-cards.css for centralized management */

/* Post card footer button improvements */
.post-card .card-footer .interaction-buttons,
.post-card .interaction-buttons {
    width: 100% !important;
    max-width: 100% !important;
    display: flex !important;
    flex-direction: row !important;
    justify-content: flex-start !important;
    align-items: center !important;
    gap: 8px !important;
    flex-wrap: nowrap !important;
    padding: 0 !important;
    box-sizing: border-box !important;
    position: relative !important;
    z-index: 2 !important;
}

.post-card .card-footer .interaction-buttons.d-flex,
.post-card .interaction-buttons.d-flex {
    display: flex !important;
    flex-direction: row !important;
    gap: 8px !important;
    flex-wrap: nowrap !important;
    flex: 0 1 auto !important;
    max-width: 100% !important;
    box-sizing: border-box !important;
    align-items: center !important;
    justify-content: flex-start !important;
}

/* Ensure buttons inside interaction-buttons display side by side */
.post-card .card-footer .interaction-buttons > .btn,
.post-card .card-footer .interaction-buttons > span.btn,
.post-card .interaction-buttons > .btn,
.post-card .interaction-buttons > span.btn,
.post-card .interaction-buttons .d-flex > .btn,
.post-card .interaction-buttons .d-flex > span.btn {
    flex: 0 0 auto !important;
    flex-grow: 0 !important;
    flex-shrink: 0 !important;
    flex-basis: auto !important;
    width: auto !important;
    max-width: none !important;
    min-width: auto !important;
    display: inline-flex !important;
    align-items: center !important;
    justify-content: center !important;
    white-space: nowrap !important;
    margin: 0 !important;
    flex-direction: row !important;
}

/* CRITICAL: Remove border from interaction count displays (not buttons, just displays) */
.post-card .card-footer .interaction-buttons .btn-outline-secondary,
.post-card .card-footer .interaction-buttons span.btn-outline-secondary,
.post-card .interaction-buttons .btn-outline-secondary,
.post-card .interaction-buttons span.btn-outline-secondary {
    border: none !important; /* Remove border - these are display elements, not buttons */
    background-color: transparent !important; /* Transparent background */
    color: #6c757d !important; /* Muted text color */
    padding: clamp(6px, 1.5vw, 8px) clamp(8px, 2vw, 12px) !important;
    font-size: clamp(0.7rem, 1.5vw, 0.8rem) !important;
    box-shadow: none !important; /* Remove any shadow */
    cursor: default !important; /* Not clickable */
}

.post-card .card-footer .interaction-buttons .btn-outline-secondary:hover,
.post-card .card-footer .interaction-buttons span.btn-outline-secondary:hover,
.post-card .interaction-buttons .btn-outline-secondary:hover,
.post-card .interaction-buttons span.btn-outline-secondary:hover {
    border: none !important; /* No border on hover */
    background-color: transparent !important; /* Keep transparent */
    color: #6c757d !important; /* Keep same color on hover */
    box-shadow: none !important; /* No shadow on hover */
}

/* Ensure icons are visible */
.post-card .card-footer .interaction-buttons .btn i,
.post-card .card-footer .interaction-buttons span.btn i,
.post-card .interaction-buttons .btn i,
.post-card .interaction-buttons span.btn i {
    display: inline-block !important;
    visibility: visible !important;
    opacity: 1 !important;
    margin-right: 4px !important;
    font-size: inherit !important;
    width: auto !important;
    height: auto !important;
}

/* Ensure spans inside buttons display properly */
.post-card .card-footer .interaction-buttons .btn span,
.post-card .card-footer .interaction-buttons span.btn span,
.post-card .interaction-buttons .btn span,
.post-card .interaction-buttons span.btn span {
    display: inline !important;
    visibility: visible !important;
    opacity: 1 !important;
    margin: 0 !important;
    font-size: inherit !important;
}

/* CRITICAL: Override any column layout that might be applied */
.post-card .card-footer .interaction-buttons[class*="flex-column"],
.post-card .interaction-buttons[class*="flex-column"] {
    flex-direction: row !important;
}

/* CRITICAL: Ensure buttons are always in a row, never stacked */
.post-card .card-footer .interaction-buttons > *,
.post-card .interaction-buttons > * {
    display: inline-flex !important;
    flex-direction: row !important;
}

/* Responsive adjustments for smaller screens - Match other card types */
/* CRITICAL: Remove fixed heights - use Proportional Layout Contract */
/* CRITICAL: Cards in .cards-grid are handled by profile-grid-layout.css */
@media (max-width: 768px) {
    /* CRITICAL: Only apply to cards NOT in .cards-grid */
    .post-card:not(.cards-grid .post-card):not(.cards-grid .unified-card.post-card) {
        aspect-ratio: 1 / 1.8 !important; /* Use same ratio as grid cards */
        height: auto !important; /* Height from aspect-ratio */
        min-height: 0 !important;
        max-height: none !important;
    }
    
    /* CRITICAL: Remove fixed heights - use Proportional Layout Contract */
    .post-card:not(.cards-grid .post-card):not(.cards-grid .unified-card.post-card) .card-img-top {
        height: auto !important; /* Use aspect-ratio, not fixed height */
        min-height: 0 !important;
        max-height: none !important;
    }
    
    /* CRITICAL: Remove fixed heights - use Proportional Layout Contract */
    .post-card:not(.cards-grid .post-card):not(.cards-grid .unified-card.post-card) .card-body {
        min-height: 0 !important; /* Remove fixed min-height */
        max-height: none !important; /* Remove fixed max-height */
        flex-grow: 1 !important;
        padding: 0.75em !important; /* Reduced padding on mobile */
        overflow: hidden !important; /* No scrolling - use line-clamp */
    }
    
    /* Mobile-specific text sizing for cards NOT in grid */
    .post-card:not(.cards-grid .post-card):not(.cards-grid .unified-card.post-card) .card-body .card-title {
        font-size: clamp(0.8rem, 3vw, 0.95rem) !important; /* Smaller on mobile */
        -webkit-line-clamp: 2 !important; /* Max 2 lines on mobile */
    }
    
    .post-card:not(.cards-grid .post-card):not(.cards-grid .unified-card.post-card) .card-body .card-subtitle {
        font-size: clamp(0.65rem, 2.5vw, 0.8rem) !important; /* Smaller on mobile */
    }
    
    .post-card:not(.cards-grid .post-card):not(.cards-grid .unified-card.post-card) .card-body .card-text {
        font-size: clamp(0.7rem, 2.5vw, 0.85rem) !important; /* Smaller on mobile */
        -webkit-line-clamp: 2 !important; /* Max 2 lines on mobile */
    }
    
    /* CRITICAL: Remove fixed heights - use Proportional Layout Contract */
    .post-card:not(.cards-grid .post-card):not(.cards-grid .unified-card.post-card) .card-footer {
        min-height: 0 !important; /* Remove fixed min-height */
        max-height: none !important; /* Remove fixed max-height */
        height: auto !important; /* Height from content */
        padding: 0.75em 1em !important; /* Use em, not px */
        flex-shrink: 0 !important;
    }
    
    .post-card .card-footer .interaction-buttons,
    .post-card .interaction-buttons {
        flex-direction: row !important;
        gap: 8px !important;
        width: 100% !important;
        max-width: 100% !important;
        overflow: visible !important;
        height: auto !important;
        min-height: auto !important;
        justify-content: flex-start !important;
        flex-wrap: nowrap !important;
        align-items: center !important;
    }
    
    .post-card .card-footer .interaction-buttons.d-flex,
    .post-card .interaction-buttons .d-flex {
        display: flex !important;
        flex-direction: row !important;
        gap: 8px !important;
        width: auto !important;
        justify-content: flex-start !important;
        flex-wrap: nowrap !important;
        align-items: center !important;
    }
    
    .post-card .interaction-buttons > .btn,
    .post-card .interaction-buttons > span.btn,
    .post-card .interaction-buttons .d-flex > .btn,
    .post-card .interaction-buttons .d-flex > span.btn {
        flex: 0 0 auto !important;
        width: auto !important;
        max-width: none !important;
        min-width: auto !important;
        margin: 0 !important;
    }
    
    .post-card .btn-sm {
        flex: 0 0 auto !important;
        width: auto !important;
        max-width: none !important;
        min-width: auto !important;
        margin: 0 !important;
    }
}

@media (max-width: 576px) {
    /* CRITICAL: Remove fixed heights - use Proportional Layout Contract */
    /* CRITICAL: Cards in .cards-grid are handled by profile-grid-layout.css */
    /* CRITICAL: Only apply to cards NOT in .cards-grid */
    .post-card:not(.cards-grid .post-card):not(.cards-grid .unified-card.post-card) {
        aspect-ratio: 1 / 1.8 !important; /* Use same ratio as grid cards */
        height: auto !important; /* Height from aspect-ratio */
        min-height: 0 !important;
        max-height: none !important;
    }
    
    /* CRITICAL: Remove fixed heights - use Proportional Layout Contract */
    .post-card:not(.cards-grid .post-card):not(.cards-grid .unified-card.post-card) .card-img-top {
        height: auto !important; /* Use aspect-ratio, not fixed height */
        min-height: 0 !important;
        max-height: none !important;
    }
    
    /* CRITICAL: Remove fixed heights - use Proportional Layout Contract */
    .post-card:not(.cards-grid .post-card):not(.cards-grid .unified-card.post-card) .card-body {
        min-height: 0 !important; /* Remove fixed min-height */
        max-height: none !important; /* Remove fixed max-height */
        flex-grow: 1 !important;
        padding: 0.6em !important; /* Further reduced padding on very small screens */
        overflow: hidden !important; /* No scrolling - use line-clamp */
    }
    
    /* Very small screen text sizing */
    .post-card:not(.cards-grid .post-card):not(.cards-grid .unified-card.post-card) .card-body .card-title {
        font-size: clamp(0.75rem, 3.5vw, 0.9rem) !important; /* Even smaller on very small screens */
        -webkit-line-clamp: 2 !important; /* Max 2 lines */
    }
    
    .post-card:not(.cards-grid .post-card):not(.cards-grid .unified-card.post-card) .card-body .card-subtitle {
        font-size: clamp(0.6rem, 3vw, 0.75rem) !important; /* Even smaller on very small screens */
    }
    
    .post-card:not(.cards-grid .post-card):not(.cards-grid .unified-card.post-card) .card-body .card-text {
        font-size: clamp(0.65rem, 3vw, 0.8rem) !important; /* Even smaller on very small screens */
        -webkit-line-clamp: 2 !important; /* Max 2 lines on very small screens */
    }
    
    /* CRITICAL: Remove fixed heights - use Proportional Layout Contract */
    .post-card:not(.cards-grid .post-card):not(.cards-grid .unified-card.post-card) .card-footer {
        min-height: 0 !important; /* Remove fixed min-height */
        max-height: none !important; /* Remove fixed max-height */
        height: auto !important; /* Height from content */
        padding: 0.75em 1em !important; /* Use em, not px */
        flex-shrink: 0 !important;
    }
    
    .post-card .card-footer .interaction-buttons,
    .post-card .interaction-buttons {
        flex-direction: row !important;
        gap: 6px !important;
        width: 100% !important;
        max-width: 100% !important;
        overflow: visible !important;
        height: auto !important;
        min-height: auto !important;
        justify-content: flex-start !important;
        flex-wrap: nowrap !important;
        align-items: center !important;
    }
    
    .post-card .card-footer .interaction-buttons.d-flex,
    .post-card .interaction-buttons .d-flex {
        display: flex !important;
        flex-direction: row !important;
        gap: 6px !important;
        width: auto !important;
        justify-content: flex-start !important;
        flex-wrap: nowrap !important;
        align-items: center !important;
    }
    
    .post-card .card-footer .btn-sm,
    .post-card .interaction-buttons .btn-sm {
        flex: 0 0 auto !important;
        width: auto !important;
        max-width: none !important;
        min-width: auto !important;
        margin: 0 !important;
    }
}

.post-card .btn-sm {
    padding: clamp(6px, 1.5vw, 8px) clamp(8px, 2vw, 12px) !important;
    font-size: clamp(0.7rem, 1.5vw, 0.8rem) !important;
    min-width: auto !important;
    max-width: none !important;
    white-space: nowrap !important;
    line-height: 1.3 !important;
    height: auto !important;
    min-height: clamp(32px, 4vw, 36px) !important;
    display: inline-flex !important;
    align-items: center !important;
    justify-content: center !important;
    flex: 0 0 auto !important;
    flex-grow: 0 !important;
    flex-shrink: 0 !important;
    gap: 4px !important;
}

/* Ensure button content (icon + text) displays properly */
.post-card .btn-sm i,
.post-card .interaction-buttons .btn-sm i,
.post-card .interaction-buttons span.btn-sm i {
    display: inline-block !important;
    visibility: visible !important;
    opacity: 1 !important;
    margin-right: 4px !important;
    font-size: inherit !important;
    width: auto !important;
    height: auto !important;
}

.post-card .btn-sm span,
.post-card .interaction-buttons .btn-sm span,
.post-card .interaction-buttons span.btn-sm span {
    display: inline !important;
    visibility: visible !important;
    opacity: 1 !important;
    margin: 0 !important;
    font-size: inherit !important;
}

.post-card .btn-outline-info {
    color: #0dcaf0 !important;
    border-color: #0dcaf0 !important;
    font-size: clamp(0.7rem, 1.5vw, 0.8rem) !important;
    padding: clamp(6px, 1.5vw, 8px) clamp(8px, 2vw, 12px) !important;
    height: auto !important;
    min-height: clamp(32px, 4vw, 36px) !important;
    flex: 0 1 auto !important;
}

.post-card .btn-outline-info:hover {
    background-color: #0dcaf0 !important;
    border-color: #0dcaf0 !important;
    color: white !important;
}

.post-card .btn-outline-primary {
    font-size: clamp(0.7rem, 1.5vw, 0.8rem) !important;
    padding: clamp(6px, 1.5vw, 8px) clamp(8px, 2vw, 12px) !important;
    height: auto !important;
    min-height: clamp(32px, 4vw, 36px) !important;
    flex: 0 1 auto !important;
}

.post-card .btn-outline-secondary {
    font-size: clamp(0.7rem, 1.5vw, 0.8rem) !important;
    padding: clamp(6px, 1.5vw, 8px) clamp(8px, 2vw, 12px) !important;
    height: auto !important;
    min-height: clamp(32px, 4vw, 36px) !important;
    flex: 0 1 auto !important;
}

/* Post card actions + legacy class aliases (surface/hover in card-core.css) */
.post-actions,
.post-card .card-actions,
#posts-tab-pane .post-card .card-actions {
    position: absolute;
    top: 10px;
    right: 10px;
    background-color: rgba(255, 255, 255, 0.9);
    border-radius: 8px;
    padding: 5px;
    opacity: 0;
    transition: opacity 0.3s ease;
    pointer-events: none;
    display: flex;
    gap: 5px;
    z-index: 20;
}

.post-card:hover .post-actions,
.post-card:hover .card-actions,
#posts-tab-pane .post-card:hover .card-actions {
    opacity: 1 !important;
    pointer-events: auto !important;
    visibility: visible !important;
}

.post-card .post-content {
    display: -webkit-box;
    -webkit-line-clamp: 3;
    -webkit-box-orient: vertical;
    overflow: hidden;
    line-height: 1.6;
}

/* Post card link & image hover behavior (replaces inline styles) */
.post-card .post-card-link,
.post-card .cards-grid__post-card__image-link {
    display: block;
    width: 100%;
    height: 100%;
    text-decoration: none;
    position: relative;
}

.post-card .post-card-image,
.post-card .cards-grid__post-card__image {
    width: 100%;
    height: 100%;
    object-fit: cover;
    object-position: center;
    cursor: pointer;
    transition: transform 0.3s ease, box-shadow 0.3s ease;
}

.post-card .view-details-overlay,
.post-card .cards-grid__post-card__overlay {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    background: rgba(0, 0, 0, 0.7);
    color: #fff;
    padding: 8px 12px;
    border-radius: 6px;
    font-size: 0.8rem;
    font-weight: 500;
    opacity: 0;
    transition: opacity 0.3s ease;
    pointer-events: none;
    z-index: 10;
}

@media (hover: hover) {
    .post-card:hover .post-card-image,
    .post-card:hover .cards-grid__post-card__image {
        transform: scale(1.02);
        box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
    }

    .post-card:hover .view-details-overlay,
    .post-card:hover .cards-grid__post-card__overlay {
        opacity: 1;
    }
}

/* Expanded post card typography moved to card-behavior.css (shared) */