/* friends.css - Fully Responsive Grid Layout */

body {
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
    background-color: #f0f2f5;
    margin: 0;
    padding: 0;
    color: #050505;
}

/* --- Layout Containers --- */
.app-container {
    max-width: 1200px;
    margin: 0 auto;
    /* Sufficient padding to clear fixed header */
    padding-top: 80px; 
    padding-bottom: 60px;
    box-sizing: border-box;
}

.main-content-area {
    width: 100%;
    padding: 0 20px;
    box-sizing: border-box;
}

.page-title {
    font-size: 1.8rem;
    font-weight: 700;
    color: #1c1e21;
    margin-bottom: 20px;
}

/* --- Responsive Tabs (Scrollable on Mobile) --- */
.tabs {
    display: flex;
    gap: 10px;
    margin-bottom: 20px;
    overflow-x: auto; /* Allow scrolling on very small screens */
    white-space: nowrap;
    padding-bottom: 5px; /* Space for scrollbar if visible */
    scrollbar-width: none; /* Hide scrollbar Firefox */
}
.tabs::-webkit-scrollbar { display: none; } /* Hide scrollbar Chrome */

.tab {
    padding: 8px 16px;
    border-radius: 20px;
    font-weight: 600;
    font-size: 0.95rem;
    color: #65676b;
    background: #e4e6eb;
    cursor: pointer;
    border: none;
    transition: 0.2s;
    flex-shrink: 0; /* Prevent tabs from squishing */
}

.tab.active {
    background: #e91e63; /* Lovculator Pink */
    color: #fff;
}

.tab:hover:not(.active) {
    background-color: #d8dadf;
}

/* --- THE GRID SYSTEM --- */
.user-list {
    display: grid;
    /* Desktop Default: Auto-fit columns, roughly 200px wide */
    grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
    gap: 12px;
}

/* --- User Card Styles --- */
.user-card {
    background: #fff;
    border-radius: 8px;
    overflow: hidden;
    box-shadow: 0 1px 2px rgba(0,0,0,0.1);
    border: 1px solid #ddd;
    display: flex;
    flex-direction: column;
    height: 100%; /* Match height of neighbors */
    position: relative;
}

.user-card:hover {
    box-shadow: 0 4px 8px rgba(0,0,0,0.15);
    border-color: #ccc;
}

/* Image Aspect Ratio Wrapper */
.card-image-wrapper {
    width: 100%;
    aspect-ratio: 1 / 1; /* Perfect Square */
    background-color: #f0f2f5;
    position: relative;
}

.user-avatar {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
}

/* Info Section */
.user-info {
    padding: 12px;
    display: flex;
    flex-direction: column;
    flex-grow: 1; /* Pushes content to fill space */
    justify-content: space-between;
    min-height: 0; /* Critical for proper flex behavior */
}

.user-details {
    margin-bottom: 12px;
    min-height: 0; /* Allows truncation to work properly */
}

.user-name {
    font-size: 1.05rem;
    font-weight: 600;
    color: #050505;
    margin-bottom: 2px;
    line-height: 1.3;
    
    /* FIXED: Multi-line truncation */
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
    text-overflow: ellipsis;
    
    /* Fix for Firefox and other browsers */
    display: -moz-box;
    max-height: 2.6em; /* 2 lines * 1.3 line-height */
    min-height: 0; /* Critical for flex container */
    word-break: break-word;
}

.user-username {
    font-size: 0.85rem;
    color: #65676b;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    min-width: 0; /* Allows text-overflow to work in flex context */
}

/* Button Styling */
.follow-btn, .unfollow-btn {
    width: 100%;
    padding: 8px 0;
    border-radius: 6px;
    font-size: 0.9rem;
    font-weight: 600;
    cursor: pointer;
    border: none;
    transition: background 0.1s;
    margin-top: auto; /* Pushes button to bottom */
}

.follow-btn {
    background-color: #e91e63; /* Pink */
    color: white;
}
.follow-btn:hover { background-color: #d81b60; }

.unfollow-btn {
    background-color: #e4e6eb; /* Light Gray */
    color: #050505;
}
.unfollow-btn:hover { background-color: #d8dadf; }

/* States */
.loading-spinner, .empty-state {
    grid-column: 1 / -1; /* Span full width */
    text-align: center;
    padding: 40px;
    color: #65676b;
}

.empty-state {
    background: #fff;
    border-radius: 8px;
    border: 1px solid #eee;
    padding: 60px 20px;
}

/* --- TABLET STYLES (Optional) --- */
@media (max-width: 1024px) and (min-width: 769px) {
    .user-list {
        grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
        gap: 10px;
    }
    
    .user-name {
        font-size: 1rem;
        line-height: 1.25;
        max-height: 2.5em; /* Adjust for smaller font */
    }
}

/* --- MOBILE SPECIFIC STYLES --- */
@media (max-width: 768px) {
    .app-container {
        /* Reduce top padding slightly for mobile header */
        padding-top: 70px; 
    }

    .main-content-area {
        padding: 0 10px; /* Smaller side margins on mobile */
    }

    .page-title {
        font-size: 1.5rem; /* Smaller title */
        margin-bottom: 15px;
    }

    /* GRID FIX: Force 2 Columns on Mobile */
    .user-list {
        grid-template-columns: 1fr 1fr; /* Two equal columns */
        gap: 8px; /* Tighter gap */
    }

    /* Smaller adjustments for tight spaces */
    .user-info {
        padding: 8px; /* Less padding inside card */
    }

    .user-name {
        font-size: 0.95rem;
        line-height: 1.25;
        max-height: 2.5em; /* Adjust for smaller font */
    }

    .user-username {
        font-size: 0.8rem;
    }

    .follow-btn, .unfollow-btn {
        padding: 6px 0; /* Smaller button */
        font-size: 0.85rem;
    }
}

/* --- EXTRA SMALL MOBILE STYLES --- */
@media (max-width: 480px) {
    .user-list {
        grid-template-columns: 1fr 1fr;
        gap: 6px;
    }
    
    .user-info {
        padding: 6px;
    }
    
    .user-name {
        font-size: 0.9rem;
        max-height: 2.25em; /* Adjust for smaller font */
    }
    
    .follow-btn, .unfollow-btn {
        padding: 5px 0;
        font-size: 0.8rem;
    }
}

/* --- ANIMATION FOR LOADING CARDS (Optional) --- */
@keyframes pulse {
    0% { opacity: 0.6; }
    50% { opacity: 1; }
    100% { opacity: 0.6; }
}

.user-card.loading {
    animation: pulse 1.5s infinite ease-in-out;
}

.user-card.loading .user-name,
.user-card.loading .user-username,
.user-card.loading .follow-btn {
    background-color: #e4e6eb;
    color: transparent;
    border-radius: 4px;
}