/* public/css/main.css */

:root {
    /* --- COLOR PALETTE (Civic-Tech, Not Social Media) --- */
    --bg-body: #F0F2F5;       /* Matches your screenshot: Pale Trust Blue */
    --bg-surface: #FFFFFF;    /* Pure white for cards/nav */

    --text-primary: #111827;  /* Soft Black */
    --text-secondary: #6B7280;/* Medium Grey */
    --text-muted: #9CA3AF;    /* Light Grey */

    --brand-blue: #2563EB;    /* Trustworthy Blue (Primary Action) */
    --brand-dark: #1E3A8A;    /* Header/Footer background */

    --danger: #EF4444;        /* Reporting */
    --success: #10B981;       /* Verification */

    /* --- SPACING & LAYOUT --- */
    --nav-height-mobile: 60px;
    --header-height: 64px;
    --max-width: 1250px; 

    /* --- SHADOWS (Premium Feel) --- */
    --shadow-sm: 0 1px 2px 0 rgba(0, 0, 0, 0.05);
    --shadow-md: 0 4px 6px -1px rgba(0, 0, 0, 0.1);
}

/* RESET */
* { box-sizing: border-box; margin: 0; padding: 0; }

body {
    background-color: var(--bg-body);
    color: var(--text-primary);
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
    font-size: 16px;
    padding-top: 70px; /* Space for fixed header (Updated for desktop header) */
    padding-bottom: calc(var(--nav-height-mobile) + 20px); /* Space for mobile nav */
    overflow-y: scroll; /* Stable scrollbar */
}

/* --- UTILITIES --- */
.container {
    width: 100%;
    max-width: var(--max-width);
    margin: 0 auto;
    padding: 0 16px;
}

.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 8px 16px;
    border-radius: 8px;
    font-weight: 600;
    cursor: pointer;
    border: none;
    transition: opacity 0.2s;
}

.btn-primary { background: var(--brand-blue); color: white; }
.btn-ghost { background: transparent; color: var(--text-secondary); }

/* --- RESPONSIVE HELPERS --- */
.mobile-only { display: block; }
.desktop-only { display: none !important; }



/* =====================================================
   DESKTOP / TABLET GRID (Changed to 768px)
   ===================================================== */
@media (min-width: 768px) {
    /* 1. Global Visibility Switches */
    .mobile-only { display: none !important; }
    .desktop-only { display: block !important; }

    /* 2. Body Adjustments */
    body { padding-bottom: 40px; } 

    /* 3. APP LAYOUT: Flexible 2-Column */
    .app-layout {
        display: grid;
        /* Feed gets rest of space, Sidebar stays fixed at 300px */
        grid-template-columns: 1fr 300px; 
        gap: 20px;
        max-width: var(--max-width);
        margin: 0 auto;
    }

    /* 4. POST CARD GRID */
    #feed-container {
        display: grid;
        /* Auto-fit: Fits 2 cards on tablet, 3-4 on wide screens */
        grid-template-columns: repeat(auto-fill, minmax(240px, 1fr)); 
        gap: 20px;
    }

    .post-card { 
        height: auto;       /* Let content dictate height */
        /* min-height: 100%;  <-- DELETE THIS LINE */
        display: flex; 
        flex-direction: column; 
        align-self: start;  /* Stops it from stretching to match tall neighbors */
    }
    .post-image { height: 180px; object-fit: cover; }
    .card-footer { margin-top: auto; }

    /* 5. Hide Bottom Nav */
    .bottom-nav { display: none !important; }
}

/* =====================================================
   COMPONENTS (Badges, Loaders, Etc)
   ===================================================== */

/* NOTIFICATION BADGE */
.nav-item { position: relative; }

.nav-badge {
    position: absolute;
    top: -2px; right: -5px; /* Tighter positioning */
    background-color: var(--danger);
    color: white;
    font-size: 0.7rem;
    font-weight: 700;
    height: 18px; min-width: 18px;
    padding: 0 4px;
    border-radius: 9px;
    display: flex; align-items: center; justify-content: center;
    border: 2px solid white;
    z-index: 10;
}
.nav-badge.hidden { display: none; }

/* CARD FOOTER INFO */
.card-footer {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-top: 12px;
    padding-top: 12px;
    border-top: 1px solid #F3F4F6;
}

.poster-info {
    display: flex; align-items: center; gap: 8px;
}

.poster-name {
    font-size: 0.75rem; color: var(--text-secondary);
    font-weight: 500;
    white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
    max-width: 100px;
}

.badge {
    font-size: 0.65rem; padding: 3px 8px;
    border-radius: 4px; text-transform: uppercase;
    font-weight: 700; letter-spacing: 0.5px;
}
.badge-individual { background: #F3F4F6; color: #4B5563; }
.badge-business { background: #EEF2FF; color: #4F46E5; }

/* LOADING SCREEN */
#global-loader {
    position: fixed; inset: 0;
    background: var(--bg-body);
    display: flex; justify-content: center; align-items: center;
    z-index: 99999; color: var(--text-primary);
}
.loader-hidden { display: none !important; }
.loader-content { text-align: center; padding: 18px; }

.loader-logo {
    font-size: 44px; font-weight: 900; letter-spacing: 2px;
    font-family: Arial, sans-serif; color: var(--text-primary);
}
.cursor {
    display: inline-block; margin-left: 4px;
    opacity: 1; animation: blink 0.8s infinite; color: var(--brand-blue);
}
@keyframes blink { 0%, 100% { opacity: 1; } 50% { opacity: 0; } }

.loader-progress {
    width: 260px; height: 8px;
    background: rgba(37, 99, 235, 0.18);
    border-radius: 50px; margin: 20px auto 10px;
    overflow: hidden; border: 1px solid rgba(37, 99, 235, 0.25);
}
#loader-bar {
    width: 0%; height: 100%; background: var(--brand-blue); border-radius: 50px;
}

/* =========================================
   HEADER LINKS STYLING (Desktop)
   ========================================= */

/* 1. The Container (Flex Fix) */
.desktop-nav-links { display: none; } /* Hidden on Mobile */

@media (min-width: 768px) {
    .desktop-nav-links {
        display: flex !important; /* Force Horizontal Row */
        align-items: center;
        gap: 24px;
        margin-right: 20px;
    }
}

/* 2. The Link Item */
.nav-link {
    color: #4B5563; /* Default Gray */
    text-decoration: none;
    font-weight: 500;
    font-size: 0.95rem;
    padding: 5px 0;
    position: relative; /* Anchor for the underline */
    transition: color 0.2s;
}

.nav-link:hover {
    color: var(--brand-blue);
}

/* 3. The Active State (Triggered by JS) */
.nav-link.active {
    color: var(--brand-blue);
    font-weight: 700;
}

/* Optional: Active Underline Dot */
.nav-link.active::after {
    content: '';
    position: absolute;
    bottom: -4px; left: 50%;
    transform: translateX(-50%);
    width: 4px; height: 4px;
    background: var(--brand-blue);
    border-radius: 50%;
}

/* =========================================
   LOCATION MODAL STYLES
   ========================================= */

/* The Dark Overlay */
.modal-overlay {
    position: fixed;
    top: 0; left: 0; width: 100%; height: 100%;
    background: rgba(0, 0, 0, 0.6); /* Darkens background */
    backdrop-filter: blur(4px);      /* Blurs background */
    z-index: 9999;
    display: flex;
    justify-content: center;
    align-items: center;
    padding: 20px;
    animation: fadeIn 0.2s ease-out;
}

/* The White Card */
.modal-card {
    background: white;
    width: 100%;
    max-width: 400px;
    border-radius: 16px;
    padding: 24px;
    box-shadow: 0 10px 25px rgba(0,0,0,0.2);
    position: relative;
    transform: translateY(0);
    animation: slideUp 0.3s cubic-bezier(0.16, 1, 0.3, 1);
}

/* Animations */
@keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }
@keyframes slideUp { from { transform: translateY(20px); opacity: 0; } to { transform: translateY(0); opacity: 1; } }

/* Grid for Manual Selection */
#manual-district-grid {
    display: none; /* Hidden by default */
    grid-template-columns: 1fr 1fr;
    gap: 10px;
    margin-top: 15px;
    text-align: left;
}

/* Specific Button Tweaks for Modal */
.modal-card .btn-ghost {
    transition: background 0.2s, border-color 0.2s;
}
.modal-card .btn-ghost:hover {
    background: #F9FAFB;
    border-color: #D1D5DB;
}

/* Mobile Tweak: Ensure it doesn't get cut off on small screens */
@media (max-height: 600px) {
    .modal-card {
        max-height: 90vh;
        overflow-y: auto;
    }
}

/* --- COMPONENT: Slim Location Bar --- */
.location-bar {
    position: fixed;
    top: 60px; /* Sits directly below your 60px Header */
    left: 0;
    width: 100%;
    height: 36px; /* Very slim */
    background: #EFF6FF; /* Very light blue */
    border-bottom: 1px solid #DBEAFE;
    color: #2563EB;
    z-index: 850; /* Below Header (900), Above Content */
    cursor: pointer;
    transition: transform 0.3s ease-in-out;
    display: flex;
    justify-content: center;
    align-items: center;
}

/* The Hiding Animation */
.location-bar.bar-hidden {
    transform: translateY(-100%); /* Slides UP behind the header */
    opacity: 0;
}

.loc-inner {
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 0.8rem;
}

.loc-arrow {
    width: 16px; height: 16px; fill: currentColor; opacity: 0.7;
}

/* PUSH CONTENT DOWN so the bar doesn't cover the first post */
.feed-column {
    padding-top: 40px; /* 36px bar + 4px breathing room */
}

/* =====================================================
   FIX: MASONRY / PINTEREST LAYOUT
   Solves "Wide Gaps" and "White Space" inside cards
   ===================================================== */

@media (min-width: 768px) {
    /* 1. Turn the Feed into Columns */
    #feed-container {
        display: block !important;    /* Disable Grid */
        column-count: 2;              /* 2 Columns */
        column-gap: 20px;             /* Gap between columns */
    }

    /* 2. Fix the Card behavior */
    .post-card {
        display: inline-block !important; /* Required for columns */
        width: 100%;
        margin-bottom: 20px !important;   /* Bottom spacing */
        break-inside: avoid;              /* Prevent cutting cards in half */
        
        /* CRITICAL: Let height shrink to fit content */
        height: auto !important;          
        min-height: 0 !important;
        align-self: auto !important;
    }

    /* 3. Reset internal flex stretching */
    .post-card .card-content {
        flex: none !important;
        display: block !important;
        height: auto !important;
    }
}

/* Optional: 3 Columns for large screens */
@media (min-width: 1100px) {
    #feed-container { column-count: 3; }
}



/* --- OKFO UNIQUE HERO (Maximum Width) --- */

.okfo-unique-hero-wrapper {
    background: transparent; 
    display: flex;
    justify-content: center;
    align-items: center;
    
    /* PADDING UPDATE: Reduced side padding to almost zero (4px) */
    /* Top: 5px | Right: 4px | Bottom: 15px | Left: 4px */
    padding: 5px 4px 15px 4px; 
    
    /* Margin below */
    margin-bottom: 15px; 
    
    font-family: system-ui, -apple-system, sans-serif;
    width: 100%;
    box-sizing: border-box;
}

.okfo-unique-card {
    background-color: #FFFFFF;
    border-radius: 12px; /* Slightly reduced radius for wider look */
    
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.05);
    border: 1px solid rgba(0,0,0,0.05);
    
    /* FORCE FULL WIDTH */
    width: 100%;
    max-width: 100%; /* Allows it to touch the wrapper edges */
    
    padding: 20px 10px; /* Kept text away from edges */
    text-align: center;
}

.okfo-unique-headline {
    color: #111827;
    font-size: 1.25rem;
    font-weight: 700;
    margin: 0 0 6px 0;
    line-height: 1.3;
}

.okfo-unique-subtext {
    color: #6B7280;
    font-size: 0.9rem;
    line-height: 1.4;
    margin: 0 auto 12px auto;
    max-width: 95%; /* Allow text to use more width */
}

.okfo-unique-btn-wrapper {
    display: flex;
    justify-content: center;
    width: 100%;
}

.okfo-unique-action-btn {
    background-color: #2563EB;
    color: white !important;
    padding: 12px 0;
    
    /* Button Width Logic */
    width: 100%;      
    max-width: 90%;   /* Button stays slightly inside the card */
    
    border-radius: 50px;
    text-decoration: none;
    font-size: 1rem;
    font-weight: 600;
    transition: all 0.2s ease;
    box-shadow: 0 2px 4px rgba(37, 99, 235, 0.2);
    border: none;
    display: block;
    text-align: center;
}

.okfo-unique-action-btn:hover {
    background-color: #1D4ED8;
    transform: translateY(-1px);
    box-shadow: 0 4px 6px rgba(37, 99, 235, 0.3);
}


/* --- COMPLETED POST STYLES --- */
.post-card-completed {
    opacity: 0.75;
    background: #F9FAFB;
    border: 1px dashed #D1D5DB;
}
.post-card-completed img {
    filter: grayscale(100%); /* Makes images black & white */
}
.badge-done {
    position: absolute; 
    top: 10px; 
    right: 10px; 
    background: #374151; 
    color: white; 
    padding: 4px 10px; 
    font-size: 0.75rem; 
    border-radius: 20px; 
    z-index: 10; 
    font-weight: 800;
    box-shadow: 0 2px 4px rgba(0,0,0,0.2);
}


/* =========================================
   SKELETON LOADER SYSTEM (High Fidelity)
   ========================================= */

/* The Shimmer Animation */
@keyframes shimmer {
    0% { background-position: -200% 0; }
    100% { background-position: 200% 0; }
}

.skeleton-loading {
    background: #f0f2f5;
    background: linear-gradient(90deg, #f0f2f5 25%, #fafafa 37%, #f0f2f5 63%);
    background-size: 200% 100%;
    animation: shimmer 1.5s infinite;
}

/* --- 1. POST CARD SKELETON --- */
.sk-card {
    background: #fff;
    border-radius: 12px;
    padding: 10px;
    border: 1px solid #F3F4F6;
    margin-bottom: 20px;
    box-shadow: 0 1px 3px rgba(0,0,0,0.05);
}

.sk-card-img {
    width: 100%;
    height: 180px; /* Approx height of your images */
    border-radius: 8px;
    margin-bottom: 12px;
}

.sk-title { height: 18px; width: 85%; border-radius: 4px; margin-bottom: 8px; }
.sk-title-short { height: 18px; width: 60%; border-radius: 4px; margin-bottom: 12px; }

.sk-meta { display: flex; gap: 8px; margin-bottom: 15px; }
.sk-meta-item { height: 12px; width: 60px; border-radius: 3px; }

.sk-footer {
    border-top: 1px solid #F3F4F6;
    padding-top: 10px;
    display: flex;
    justify-content: space-between;
    align-items: center;
}
.sk-avatar { width: 20px; height: 20px; border-radius: 50%; }
.sk-name { width: 80px; height: 12px; border-radius: 3px; }
.sk-rating { width: 30px; height: 12px; border-radius: 3px; }

/* --- 2. HEADER SKELETON --- */
.sk-header {
    height: 60px;
    display: flex;
    align-items: center;
    padding: 0 12px;
    background: #fff;
    border-bottom: 1px solid #E5E7EB;
    gap: 15px;
}
.sk-menu { width: 26px; height: 26px; border-radius: 4px; }
.sk-logo { width: 80px; height: 24px; display: none; } /* Hidden on mobile */
.sk-search { 
    flex-grow: 1; 
    height: 36px; 
    border-radius: 20px; 
}
.sk-profile { width: 34px; height: 34px; border-radius: 50%; }

@media (min-width: 768px) {
    .sk-logo { display: block; }
    .sk-search { max-width: 450px; margin: 0 20px; }
}

/* --- 3. CATEGORY PILL SKELETON --- */
.sk-cat-container {
    display: flex;
    gap: 12px;
    padding: 0 0 15px 0;
    overflow: hidden;
}
.sk-pill {
    height: 36px;
    width: 90px;
    border-radius: 8px;
    flex-shrink: 0;
}
.sk-pill:first-child { width: 60px; } /* Mimics "All" button */

/* --- 4. SIDEBAR SKELETON --- */
.sk-sidebar-box {
    background: #fff;
    padding: 16px;
    border-radius: 12px;
    border: 1px solid #E5E7EB;
}
.sk-sidebar-row {
    display: flex;
    flex-direction: column;
    gap: 6px;
    margin-bottom: 15px;
    border-bottom: 1px solid #f3f4f6;
    padding-bottom: 10px;
}