/**
 * Responsive Styles for NatureConnect
 * 
 * This file contains responsive design implementations including:
 * - Media queries for different device sizes
 * - Responsive layout adjustments
 * - Mobile navigation
 * - Flex and grid responsive behaviors
 * - Content adaptation for different screen sizes
 */

/* Base responsive elements that apply to all screen sizes */
.post-image img {
    max-width: 100%;
    height: auto;
}

.comment-input-wrapper {
    flex-grow: 1;
    margin-right: 10px;
}

/* Action text can be hidden on smaller screens */
@media (max-width: 480px) {
    .post-actions .action-text {
        display: none;
    }
    
    /* Hide the comment text but keep the count and icon */
    .post-actions .comment-label .comment-text {
        display: none;
    }
    
    /* Make the comment label more compact */
    .post-actions .comment-label {
        padding-right: 0;
    }
}

/* Small devices (landscape phones, less than 768px) */
@media (max-width: 767.98px) {
    /* General container adjustments */
    .container {
        width: 95%;
        padding: 0 10px;
    }
    
    /* Header adjustments */
    .header-content {
        flex-direction: column;
        align-items: center;
        gap: 10px;
    }
    
    nav ul {
        justify-content: center;
        flex-wrap: wrap;
        gap: 5px;
    }
    
    /* News Feed adjustment - force single column */
    .news-feed {
        grid-template-columns: 1fr !important;
        gap: 15px;
    }
    
    /* Post card adjustments */
    .post-card {
        margin-bottom: 15px;
    }
    
    .post-user {
        padding: 10px;
    }
    
    .user-info {
        max-width: 100%; /* Override the fixed calculation */
    }
    
    .user-actions {
        position: absolute;
        right: 10px;
        top: 10px;
    }
    
    /* Post actions become more compact */
    .post-actions {
        padding: 5px;
        flex-wrap: wrap;
        justify-content: space-between;
    }
    
    .post-actions .btn-action {
        padding: 5px 10px;
        font-size: 0.9rem;
    }
    
    /* Comment form made more mobile-friendly */
    .comment-form {
        flex-wrap: wrap;
    }
    
    .comment-form input {
        width: 100%;
        margin-bottom: 10px;
    }
    
    .comment-form .btn {
        width: 100%;
        margin-left: 0;
    }
    
    /* Reduce image sizes on mobile */
    .post-image {
        max-height: 300px;
    }
      .post-image img {
        max-height: 300px;
    }
    
    /* Improved tab handling to avoid scrollbars */
    .profile-tabs {
        border-bottom: 1px solid #eee;
        margin-bottom: 15px;
    }
    
    .tab-btn {
        overflow: hidden;
        text-overflow: ellipsis;
        transition: all 0.3s ease;
    }
    
    /* Use shorthand terms for some tabs on very small screens */
    @media (max-width: 400px) {
        .tab-btn[data-tab="activities"] {
            text-indent: -9999px;
            line-height: 0;
        }
        .tab-btn[data-tab="activities"]:after {
            content: "Activity";
            text-indent: 0;
            display: block;
            line-height: initial;
        }
        
        .tab-btn[data-tab="comments"] {
            text-indent: -9999px;
            line-height: 0;
        }
        .tab-btn[data-tab="comments"]:after {
            content: "Comments";
            text-indent: 0;
            display: block;
            line-height: initial;
        }
        
        .tab-btn[data-tab="followers"], 
        .tab-btn[data-tab="following"] {
            letter-spacing: -0.5px;
        }
    }
    
    /* Fix for post comments container */
    .post-comments {
        padding: 10px;
        width: 100%;
        box-sizing: border-box;
        overflow-x: hidden;
    }
    
    .comments-list {
        width: 100%;
        overflow-wrap: break-word;
        word-wrap: break-word;
        word-break: break-word;
    }
    
    .comment {
        padding: 8px 5px;
        margin-bottom: 8px;
        max-width: 100%;
    }
    
    .comment-content {
        max-width: calc(100% - 40px);
        overflow-wrap: break-word;
        word-wrap: break-word;
        word-break: break-word;
    }
}

/* Medium devices (tablets, less than 992px) */
@media (max-width: 991.98px) {
    /* Profile layout becomes single column */
    .profile-container {
        grid-template-columns: 1fr;
    }
    
    .profile-sidebar {
        order: 1;
    }
      /* Profile specific adjustments */
    .profile-tabs {
        display: flex;
        flex-wrap: wrap;
        overflow-x: visible;
        width: 100%;
        justify-content: flex-start;
        gap: 2px;
    }
    
    .tab-btn {
        flex: 0 0 auto;
        font-size: 0.85rem;
        padding: 8px 10px;
        white-space: nowrap;
    }
    
    /* Enhanced profile card responsiveness */
    .profile-card {
        display: flex;
        flex-direction: column;
    }
    
    .profile-stats {
        justify-content: space-around;
    }
    
    .profile-action-buttons {
        flex-wrap: wrap;
        justify-content: center;
        gap: 10px;
    }
    
    .profile-action-btn {
        min-width: 120px;
    }
    
    /* Adjust forms for better mobile experience */
    .form-container {
        padding: 20px 15px;
    }
    
    /* News feed - single column on tablets */
    .news-feed {
        grid-template-columns: 1fr;
    }
    
    /* Post create form adjustments */
    .post-create-actions {
        flex-direction: column;
        gap: 15px;
        align-items: flex-start;
    }
    
    .media-icons {
        width: 100%;
        justify-content: space-between;
    }
    
    .post-create-actions .btn {
        width: 100%;
    }
}

/* Mobile Navigation Menu */
.mobile-menu-toggle {
    display: none;
    flex-direction: column;
    justify-content: space-around;
    width: 30px;
    height: 25px;
    background: transparent;
    border: none;
    cursor: pointer;
    padding: 0;
    z-index: 10;
}

.mobile-menu-toggle span {
    width: 30px;
    height: 3px;
    background: #3a7d44;
    border-radius: 10px;
    transition: all 0.3s linear;
    position: relative;
    transform-origin: 1px;
}

/* Mobile menu state */
.mobile-menu-open nav ul {
    display: flex !important;
    flex-direction: column;
    position: absolute;
    top: 70px;
    left: 0;
    width: 100%;
    background: white;
    box-shadow: 0 10px 10px rgba(0,0,0,0.1);
    z-index: 999;
    padding: 20px 0;
    text-align: center;
}

.mobile-menu-open nav ul li {
    margin: 10px 0;
    width: 100%;
    justify-content: center;
}

@media (max-width: 767.98px) {
    .mobile-menu-toggle {
        display: flex;
    }
    
    nav ul {
        display: none;
    }
    
    .header-content {
        justify-content: space-between;
    }
}

/* Extra small devices (portrait phones, less than 576px) */
@media (max-width: 575.98px) {
    /* Even smaller containers */
    .container {
        width: 100%;
        padding: 0 8px;
        box-sizing: border-box;
    }
    
    /* Further reduce post card padding */
    .post-card {
        border-radius: 0;
        margin-left: -8px;
        margin-right: -8px;
    }
    
    .post-body {
        padding: 15px;
    }
    
    /* Avatar sizes */
    .user-avatar {
        width: 40px;
        height: 40px;
        margin-right: 10px;
    }
    
    /* Typography adjustments */
    .user-info h4 {
        font-size: 0.9rem;
    }
    
    .post-body p {
        font-size: 0.95rem;
    }
    
    /* Comment form adjustments */
    .comment-form {
        flex-direction: column;
    }
    
    .comment-form .comment-input-wrapper {
        margin-bottom: 10px;
        margin-right: 0;
        width: 100%;
    }
    
    .comment-form .btn {
        width: 100%;
        margin-left: 0;
    }
    
    /* Profile-specific adjustments for very small screens */
    .profile-header {
        flex-direction: column;
        text-align: center;
    }
    
    .profile-avatar {
        margin: 0 auto 15px;
    }
      .profile-tabs {
        justify-content: center;
        padding: 0;
        margin: 0 -5px 15px;
    }
    
    .tab-btn {
        padding: 6px 5px;
        font-size: 0.75rem;
        flex-basis: calc(33.33% - 4px);
        text-align: center;
        margin: 2px;
        min-width: 0;
    }
    
    .profile-menu {
        margin-top: 20px;
    }
    
    .user-grid {
        grid-template-columns: 1fr 1fr;
        gap: 10px;
    }
    
    .user-card {
        padding: 10px;
    }
    
    .user-name {
        font-size: 0.9rem;
    }
    
    .user-handle {
        font-size: 0.8rem;
    }
    
    .activity-list {
        padding: 10px;
    }
    
    .activity-item {
        padding: 10px;
        margin-bottom: 10px;
    }
    
    .comment-activity-item .comment-text {
        font-size: 0.9rem;
    }
    
    /* Fix post card in mobile view */
    .post-card {
        border-radius: 0;
        margin-left: -8px;
        margin-right: -8px;
    }
    
    /* Hide comment label on small screens */
    .comment-label {
        display: none !important;
    }
    
    /* Make Likes and Shares buttons take 50% width each */
    .post-actions .btn-action {
        flex: 1;
        justify-content: center;
    }
    
    /* Improved post actions for very small screens */
    .post-actions {
        display: flex;
        justify-content: space-between;
        gap: 5px;
    }
    
    .post-actions .btn-action {
        flex: 1;
        justify-content: center;
        padding: 8px 5px;
    }
    
    /* Make like and share buttons prominent */
    .like-btn, .share-btn {
        display: flex;
        justify-content: center;
        align-items: center;
        text-align: center;
    }
    
    /* Override comment label styling for small screens */
    .post-actions .comment-label {
        display: none !important; /* Hide comment label on very small screens */
    }
    
    /* Enhanced comment section handling */
    .post-comments {
        padding: 8px 5px;
    }
    
    .comment-form {
        display: flex;
        flex-direction: column;
        margin-bottom: 10px;
    }
    
    .comment-form .btn {
        width: 100%;
        margin-top: 5px;
        padding: 6px;
    }
    
    .comment-input-wrapper {
        width: 100%;
        margin-right: 0;
    }
    
    .new-comment-input {
        width: 100%;
        padding: 8px 5px;
        box-sizing: border-box;
    }
    
    /* Fix for comment text overflow */
    .comment-text {
        max-width: 100%;
        font-size: 0.9rem;
        overflow-wrap: break-word;
        word-wrap: break-word;
        word-break: break-word;
        hyphens: auto;
    }
    
    .comment-user-avatar {
        width: 30px;
        height: 30px;
        min-width: 30px;
        margin-right: 8px;
    }
    
    /* Handle long usernames in comments */
    .user-handle, .user-name {
        max-width: 100%;
        overflow: hidden;
        text-overflow: ellipsis;
        white-space: nowrap;
    }
    
    /* More compact comment displays */
    .comment-item {
        padding: 6px 0;
        margin-bottom: 6px;
    }
    
    .comment-metadata {
        font-size: 0.75rem;
    }
    
    /* Fix for view more comments link */
    .more-comments-text {
        font-size: 0.85rem;
        white-space: normal;
        text-align: left;
    }
}

/* Clean approach to comment display on small screens */
@media (max-width: 575.98px) {
    /* Better layout for "view more comments" links */
    .view-comments-link {
        font-size: 0.85rem;
        max-width: 100%;
        display: block;
        white-space: normal;
    }
    
    .more-comments {
        padding: 5px 0;
    }
    
    /* Improve comment display */
    .comments-list {
        width: 100%;
        overflow-x: hidden;
    }
}

/* Simple fix for comment display on small screens */
@media (max-width: 575.98px) {
    /* Hide the comments label entirely on small screens */
    .post-actions .comment-label {
        display: none !important;
    }
    
    /* Make like and share buttons take equal space */
    .post-actions .btn-action {
        flex: 1;
        justify-content: center;
    }
    
    /* Basic comment styling for better display */
    .comment, .styled-comment {
        width: 100%;
        box-sizing: border-box;
        margin-bottom: 10px;
    }
    
    .comment-content {
        width: calc(100% - 40px);
        overflow-wrap: break-word;
        word-wrap: break-word;
        word-break: break-word;
    }
}

/* Comment display responsive adjustments */
@media (max-width: 767.98px) {
    /* Basic responsive styling for comments */
    .comments-list {
        width: 100%;
        overflow-x: hidden; /* Prevent horizontal scrolling */
    }
    
    .comment, .styled-comment {
        display: flex;
        flex-wrap: nowrap;
        margin-bottom: 10px;
    }
    
    .comment-content {
        flex: 1;
        min-width: 0; /* Critical for text wrapping */
        overflow-wrap: break-word;
        word-wrap: break-word;
    }
    
    .comment-content p {
        word-wrap: break-word;
        word-break: break-word;
        hyphens: auto;
    }
}

/* Smaller screens: adjust post actions for 50/50 layout */
@media (max-width: 480px) {
    /* Hide comments label completely */
    .post-actions .comment-label {
        display: none !important;
    }
    
    /* Make like and share buttons take equal space */
    .post-actions .btn-action {
        flex: 1;
        justify-content: center;
        text-align: center;
    }
}

/* Adjustments for desktop and large tablet screens */
@media (min-width: 992px) {
    /* Wider container for profile page */
    .profile-section .container {
        width: 90%;
        max-width: 1400px; /* Increased from the default 1200px */
    }
    
    /* Increase the sidebar width slightly */
    .profile-container {
        grid-template-columns: 320px 1fr;
        gap: 35px;
    }
    
    /* Better layout for wider profile content area */
    .profile-content {
        padding: 30px;
    }
    
    /* Improve news feed layout in profile for wider screens */
    .profile-content .news-feed {
        display: grid;
        grid-template-columns: repeat(auto-fill, minmax(500px, 1fr));
        gap: 25px;
    }
    
    /* Ensure tabs have proper spacing in wider layout */
    .profile-tabs {
        padding-bottom: 10px;
        margin-bottom: 25px;
    }
    
    /* Better layout for user grids in wider container */
    .profile-content .user-grid {
        grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
        gap: 20px;
    }
}

/* Medium-sized tablets */
@media (min-width: 768px) and (max-width: 991.98px) {
    /* Wider container for profile page on tablets */
    .profile-section .container {
        width: 92%;
        max-width: 900px;
    }
    
    /* Adjust profile content spacing on tablets */
    .profile-content {
        padding: 25px 20px;
    }
    
    /* User grid for tablets */
    .profile-content .user-grid {
        grid-template-columns: repeat(3, 1fr);
        gap: 15px;
    }
}

/* Large desktop screens for better use of wide space */
@media (min-width: 1400px) {
    /* Maximize use of space in profile posts */
    .profile-content .news-feed {
        grid-template-columns: repeat(auto-fill, minmax(550px, 1fr));
    }
      /* Improved post card layout for wide screens */
    .post-card {
        transition: box-shadow 0.2s ease;
    }
    
    .post-card:hover {
        box-shadow: 0 10px 30px rgba(0, 0, 0, 0.15);
    }
    
    /* Improved spacing for post content on large screens */
    .post-body {
        padding: 25px;
    }
    
    /* Larger images on big screens */
    .post-image {
        max-height: 450px;
    }
}
