/* VillaHandle Social Core UI - Production v1.0 */
@import url('https://fonts.googleapis.com/css2?family=Inter:wght@300;400;500;600;700&display=swap');

:root {
    --bg-color: #f0f2f5;
    --card-bg: #ffffff;
    --primary: #1877F2;
    --text-main: #050505;
    --text-muted: #65676b;
    --border-color: #ced0d4;
    --hover-bg: #e4e6eb;
}

body {
    background-color: var(--bg-color) !important;
    font-family: 'Inter', system-ui, -apple-system, sans-serif;
    color: var(--text-main);
    overflow-x: hidden;
    padding-bottom: 70px; /* Space for PWA Dock */
}

/* -------------------------------------------
   1. HEADER (NAVBAR)
------------------------------------------- */
.social-header {
    background: #fff;
    height: 60px;
    box-shadow: 0 1px 2px rgba(0, 0, 0, 0.1);
    position: sticky;
    top: 0;
    z-index: 1000;
    padding: 0 16px;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.search-input {
    background: #f0f2f5;
    border: none;
    height: 40px;
    border-radius: 20px;
    padding-left: 20px;
    width: 240px;
    margin-left: 10px;
}

.nav-center {
    display: flex;
    height: 100%;
}

.nav-icon-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 100px;
    height: 55px;
    margin: 2px 5px;
    border-radius: 8px;
    color: var(--text-muted);
    font-size: 24px;
    text-decoration: none;
    transition: 0.2s;
}

.nav-icon-btn.active {
    color: var(--primary);
    border-bottom: 3px solid var(--primary);
    border-radius: 0;
}

.nav-icon-btn:hover {
    background-color: #f0f2f5;
}

/* -------------------------------------------
   2. LAYOUT GRID & UTILITIES
------------------------------------------- */
.row {
    margin-right: 0;
    margin-left: 0;
}

::-webkit-scrollbar {
    width: 8px;
}
::-webkit-scrollbar-track {
    background: #f1f1f1; 
}
::-webkit-scrollbar-thumb {
    background: #bcc0c4; 
    border-radius: 4px;
}
::-webkit-scrollbar-thumb:hover {
    background: #888; 
}

/* -------------------------------------------
   3. SIDEBARS (Desktop Default)
------------------------------------------- */
.social-sidebar {
    height: calc(100vh - 60px);
    overflow-y: auto;
    position: sticky;
    top: 60px;
    padding: 20px 10px;
}

.sidebar-link {
    display: flex;
    align-items: center;
    padding: 10px;
    border-radius: 8px;
    color: var(--text-main);
    text-decoration: none;
    font-weight: 500;
    font-size: 15px;
    margin-bottom: 5px;
    transition: background 0.2s;
}

.sidebar-link:hover {
    background-color: var(--hover-bg);
    color: var(--text-main);
}

.sidebar-link img {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    margin-right: 12px;
}

.sidebar-link i {
    width: 36px; /* Center icons */
    text-align: center;
    font-size: 20px;
    margin-right: 12px;
}

/* -------------------------------------------
   4. FEED & POSTS
------------------------------------------- */
.create-post-card {
    background: #fff;
    border-radius: 8px;
    box-shadow: 0 1px 2px rgba(0, 0, 0, 0.1);
    margin-bottom: 20px;
}

.feed-post {
    background: #fff;
    border-radius: 8px;
    box-shadow: 0 1px 2px rgba(0, 0, 0, 0.1);
    margin-bottom: 20px;
    overflow: hidden; /* Contains images */
}

.post-header {
    display: flex;
    align-items: center;
    padding: 12px 16px;
}

.user-avatar-sm {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    margin-right: 10px;
}

.post-content {
    padding: 4px 16px 16px 16px;
    font-size: 15px;
    line-height: 1.4;
}

.post-stats {
    padding: 10px 16px;
    border-bottom: 1px solid var(--border-color);
    display: flex;
    justify-content: space-between;
    color: var(--text-muted);
    font-size: 14px;
}

.post-actions {
    display: flex;
    padding: 4px;
}

.action-btn {
    flex: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 8px;
    border-radius: 4px;
    color: var(--text-muted);
    font-weight: 600;
    font-size: 14px;
    cursor: pointer;
    transition: 0.2s;
}

.action-btn:hover {
    background-color: #f0f2f5;
}

.action-btn i {
    margin-right: 6px;
    font-size: 18px;
}

/* -------------------------------------------
   5. MOBILE SEARCH BAR (Toggleable)
------------------------------------------- */
#mobile-search-bar {
    background-color: #fff;
    padding: 10px;
    box-shadow: 0 2px 5px rgba(0,0,0,0.1);
    position: absolute;
    top: 60px;
    left: 0;
    width: 100%;
    z-index: 999;
    display: none; /* JS will toggle this */
}

#mobile-search-bar.active {
    display: block;
}

/* -------------------------------------------
   6. MOBILE BOTTOM NAV (PWA DOCK FIX)
------------------------------------------- */
.mobile-bottom-nav {
    position: fixed;
    bottom: 0;
    left: 0;
    width: 100%;
    height: 65px; /* Taller for better touch target */
    background: #ffffff;
    border-top: 1px solid #e4e6eb;
    display: flex;
    justify-content: space-around;
    align-items: center;
    z-index: 9999;
    padding-bottom: env(safe-area-inset-bottom);
    box-shadow: 0 -2px 10px rgba(0,0,0,0.05);
}

.mobile-bottom-nav .nav-item {
    color: #65676b;
    font-size: 24px;
    padding: 10px 15px;
    position: relative;
    display: flex;
    align-items: center;
    justify-content: center;
    text-decoration: none;
}

.mobile-bottom-nav .nav-item.active {
    color: #1877F2;
}

.mobile-bottom-nav .nav-item.active::after {
    content: '';
    position: absolute;
    top: 0;
    width: 40px;
    height: 3px;
    background: #1877F2;
    border-radius: 0 0 4px 4px;
}

.nav-avatar {
    width: 28px;
    height: 28px;
    border-radius: 50%;
    border: 2px solid transparent;
}
.nav-item.active .nav-avatar { border-color: #1877F2; }

/* -------------------------------------------
   7. PWA ELEMENTS (Banners & Toasts)
------------------------------------------- */
.pwa-banner {
    position: fixed;
    bottom: 80px; /* Above nav bar */
    left: 50%;
    transform: translateX(-50%);
    width: 90%;
    max-width: 400px;
    background: #fff;
    border-radius: 12px;
    box-shadow: 0 5px 20px rgba(0,0,0,0.2);
    padding: 15px;
    z-index: 10000;
    display: flex;
    align-items: center;
    justify-content: space-between;
    animation: slideUp 0.5s ease-out;
}

@keyframes slideUp { from { bottom: -100px; } to { bottom: 80px; } }

.network-toast {
    position: fixed;
    top: 70px;
    left: 50%;
    transform: translateX(-50%);
    padding: 8px 16px;
    border-radius: 20px;
    font-size: 14px;
    font-weight: bold;
    z-index: 10001;
    color: white;
    box-shadow: 0 2px 10px rgba(0,0,0,0.2);
    transition: opacity 0.3s;
}
.network-toast.hidden { opacity: 0; pointer-events: none; }
.network-toast.offline { background: #333; }
.network-toast.online { background: #28a745; }
.network-toast.syncing { background: #1877F2; }

/* -------------------------------------------
   8. MEDIA FIXES (Video & Images)
------------------------------------------- */
.post-media {
    background-color: #000; /* Black background for cinematic feel */
    display: flex;
    justify-content: center;
    align-items: center;
    overflow: hidden;
    max-height: 500px; /* Desktop Max Height */
}

.post-media video {
    width: 100%;
    max-height: 500px; 
    object-fit: contain; /* Ensures video isn't cropped */
}

.post-media img {
    width: 100%;
    max-height: 500px;
    object-fit: cover;
}

/* --- RESPONSIVE LOGIC (Mobile) --- */
@media (max-width: 991px) {
    
    /* 1. Mobile Sidebar (Hidden by default, Slides in when active) */
    .social-sidebar {
        display: none; 
        position: fixed;
        left: 0;
        top: 60px;
        width: 280px;
        height: calc(100% - 60px); /* Height below header */
        background: #fff;
        z-index: 2000; /* High z-index to sit on top */
        box-shadow: 2px 0 10px rgba(0,0,0,0.2);
        padding-top: 20px;
        overflow-y: auto;
        transition: transform 0.3s ease;
    }

    /* This class is added by JS when Hamburger is clicked */
    .social-sidebar.active {
        display: block !important;
        animation: slideIn 0.3s forwards;
    }

    @keyframes slideIn {
        from { transform: translateX(-100%); }
        to { transform: translateX(0); }
    }
    
    /* 2. Overlay (Dark background) */
    .sidebar-overlay {
        display: none;
        position: fixed;
        top: 60px;
        left: 0;
        width: 100%;
        height: 100%;
        background: rgba(0,0,0,0.5);
        z-index: 1999;
    }
    
    .sidebar-overlay.active { 
        display: block; 
    }

    /* 3. General Layout Fixes */
    .create-post-card, .feed-post { 
        border-radius: 0; 
        border-top: 1px solid #ced0d4; 
    }
    
    .col-lg-6 { padding: 0; }
    .container-fluid { padding: 0; }

    /* 4. Fix Profile Header Overlap */
    .card-body.position-relative {
        text-align: center;
        padding-top: 60px !important;
    }
    .col-lg-2.col-3 {
        margin-top: -90px !important;
        margin-bottom: 10px;
        width: auto;
    }
    .rounded-circle.border.border-4 {
        width: 120px !important;
        height: 120px !important;
    }
    .col-lg-10 { width: 100%; text-align: center; }
    
    /* 5. Prevent content hiding behind PWA Nav */
    body { padding-bottom: 80px; }
}