@import url('https://fonts.googleapis.com/css2?family=Cairo:wght@400;500;600;700;800&family=Inter:wght@400;500;600;700&display=swap');

:root {
    /* Color Palette */
    --primary: #0f5132;
    --primary-light: #198754;
    --primary-dark: #0a3622;
    --accent: #0d6efd;
    --bg-body: #f8f9fa;
    --bg-card: #ffffff;
    --text-main: #212529;
    --text-muted: #6c757d;
    --border-color: #e9ecef;
    --shadow-sm: 0 2px 4px rgba(0, 0, 0, 0.04);
    --shadow-md: 0 4px 12px rgba(0, 0, 0, 0.08);
    --shadow-lg: 0 8px 24px rgba(0, 0, 0, 0.12);
    --radius-sm: 8px;
    --radius-md: 12px;
    --radius-lg: 18px;
    --transition: all 0.25s cubic-bezier(0.4, 0, 0.2, 1);
}

[data-theme="dark"] {
    --bg-body: #18191a;
    --bg-card: #242526;
    --text-main: #e4e6eb;
    --text-muted: #b0b3b8;
    --border-color: #393a3b;
    --shadow-sm: 0 2px 4px rgba(0, 0, 0, 0.4);
    --shadow-md: 0 4px 12px rgba(0, 0, 0, 0.5);
}

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

html,
body {
    width: 100%;
}

body {
    font-family: 'Cairo', 'Inter', system-ui, -apple-system, sans-serif;
    background-color: var(--bg-body);
    color: var(--text-main);
    line-height: 1.6;
    padding-top: 85px;
    transition: background-color 0.3s ease, color 0.3s ease;
}

/* Toast Notifications Container */
#toast-container {
    position: fixed;
    top: 20px;
    left: 20px;
    z-index: 100000;
    /* Always above modal backdrop blur */
    display: flex;
    flex-direction: column;
    gap: 10px;
    max-width: 380px;
    width: 90%;
}

[dir="rtl"] #toast-container {
    left: auto;
    right: 20px;
}

.toast {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px 18px;
    border-radius: var(--radius-md);
    background: var(--bg-card);
    color: var(--text-main);
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.15);
    border-inline-start: 4px solid var(--primary);
    font-size: 0.9rem;
    font-weight: 600;
    animation: toastIn 0.35s cubic-bezier(0.175, 0.885, 0.32, 1.275) forwards;
}

.toast.toast-error {
    border-inline-start-color: #dc3545;
}

.toast.toast-info {
    border-inline-start-color: #0d6efd;
}

.toast.toast-warning {
    border-inline-start-color: #ffc107;
}

.toast-icon {
    font-size: 1.2rem;
}

.toast.toast-success .toast-icon {
    color: var(--primary);
}

.toast.toast-error .toast-icon {
    color: #dc3545;
}

.toast.toast-info .toast-icon {
    color: #0d6efd;
}

.toast.toast-warning .toast-icon {
    color: #ffc107;
}

@keyframes toastIn {
    from {
        opacity: 0;
        transform: translateY(-20px) scale(0.9);
    }

    to {
        opacity: 1;
        transform: translateY(0) scale(1);
    }
}

@keyframes toastOut {
    to {
        opacity: 0;
        transform: translateY(-20px) scale(0.9);
    }
}

/* Header & Premium Brand Badge */
.navbar {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    z-index: 1000;
    background: rgba(255, 255, 255, 0.92);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    border-bottom: 1px solid var(--border-color);
    padding: 0.75rem 1.5rem;
    width: 100%;
}

[data-theme="dark"] .navbar {
    background: rgba(36, 37, 38, 0.95);
}

.nav-container {
    max-width: 1200px;
    margin: 0 auto;
    display: flex;
    flex-direction: row;
    align-items: center;
    gap: 1rem;
    width: 100%;
}

/* On desktop: nav-top-row holds logo+actions side by side
   but we want: logo | search | actions order.
   So we keep them as direct flex children of nav-container. */
.nav-top-row {
    display: contents; /* renders children as direct flex items of nav-container */
}

.brand {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    text-decoration: none;
    color: var(--primary);
    font-weight: 800;
    font-size: 1.5rem;
    flex-shrink: 0;
    /* Desktop order: brand stays at the start side (right in RTL, left in LTR) */
    order: 0;
}

[data-theme="dark"] .brand {
    color: #4ade80;
}

.brand-icon {
    width: 44px;
    height: 44px;
    background: linear-gradient(135deg, #0f5132 0%, #198754 55%, #052c1e 100%);
    color: #ffffff;
    border-radius: 12px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.25rem;
    box-shadow: 0 4px 16px rgba(15, 81, 50, 0.4), inset 0 1px 1px rgba(255, 255, 255, 0.3);
    border: 1.5px solid rgba(74, 222, 128, 0.4);
    position: relative;
    transition: var(--transition);
}

.brand-icon i {
    filter: drop-shadow(0 2px 4px rgba(0, 0, 0, 0.3));
    transform: rotate(-10deg);
    transition: var(--transition);
}

.brand:hover .brand-icon {
    transform: translateY(-2px) scale(1.06);
    box-shadow: 0 6px 20px rgba(15, 81, 50, 0.5), 0 0 12px rgba(74, 222, 128, 0.4);
    border-color: rgba(74, 222, 128, 0.8);
}

.brand:hover .brand-icon i {
    transform: rotate(0deg) scale(1.1);
}

.nav-search {
    flex: 1;
    max-width: 480px;
    position: relative;
    margin: 0;
}

.nav-search input {
    width: 100%;
    padding: 0.6rem 1rem 0.6rem 2.6rem;
    border-radius: 20px;
    border: 1px solid var(--border-color);
    background: var(--bg-body);
    color: var(--text-main);
    font-family: inherit;
    font-size: 0.9rem;
    outline: none;
    transition: var(--transition);
}

[dir="rtl"] .nav-search input {
    padding: 0.6rem 2.6rem 0.6rem 1rem;
}

.nav-search i.search-icon {
    position: absolute;
    top: 50%;
    transform: translateY(-50%);
    color: var(--text-muted);
    font-size: 0.9rem;
}

[dir="rtl"] .nav-search i.search-icon {
    right: 1rem;
    left: auto;
}

[dir="ltr"] .nav-search i.search-icon {
    left: 1rem;
    right: auto;
}

.nav-search input:focus {
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(15, 81, 50, 0.15);
}

/* =========================================================
   Search + Filter Row
   ========================================================= */
.search-filter-row {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    flex: 1;
    /* DO NOT set width:100% here — breaks desktop flex layout */
    /* DO NOT set direction — inherited from document dir (rtl/ltr) */
    order: 1; /* always between brand(0) and nav-actions(2) */
}

/* On desktop: search-filter-row stretches with nav-container flex */
.search-filter-row .nav-search {
    flex: 1;
    max-width: none;
}

/* Filter trigger button — hidden on desktop, shown on mobile */
.filter-trigger-btn {
    display: none;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    width: 44px;
    height: 44px;
    border-radius: 12px;
    background: var(--bg-card);
    border: 1.5px solid var(--border-color);
    color: var(--text-main);
    cursor: pointer;
    position: relative;
    transition: var(--transition);
    font-size: 1rem;
}

.filter-trigger-btn:hover {
    border-color: var(--primary);
    color: var(--primary);
    background: rgba(15,81,50,0.07);
}

.filter-trigger-btn.has-filter {
    border-color: var(--primary);
    color: var(--primary);
    background: rgba(15,81,50,0.1);
}

/* Red dot badge when filter is active */
.filter-badge {
    display: none;
    position: absolute;
    top: 6px;
    inset-inline-start: 6px;
    width: 9px;
    height: 9px;
    background: #ef4444;
    border-radius: 50%;
    border: 1.5px solid var(--bg-card);
}

.filter-badge.visible { display: block; }

/* =========================================================
   Filter Panel Bottom Sheet (Flutter-style)
   ========================================================= */
.filter-panel-overlay {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.5);
    z-index: 10000;
    backdrop-filter: blur(2px);
    animation: fp-fade-in 0.25s ease;
}

.filter-panel-overlay.active { display: block; }

/* Filter panel background — must be explicitly solid, never inherit/transparent */
.filter-panel {
    display: flex;
    flex-direction: column;
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    background-color: var(--bg-body) !important;
    background: var(--bg-body) !important;
    border-radius: 20px 20px 0 0;
    z-index: 10001;
    max-height: 85vh;
    transform: translateY(100%);
    transition: transform 0.35s cubic-bezier(0.4, 0, 0.2, 1);
    box-shadow: 0 -8px 40px rgba(0,0,0,0.2);
    overflow: hidden;
}

.filter-panel.active {
    transform: translateY(0);
}

.filter-panel-handle {
    width: 40px;
    height: 4px;
    background: var(--border-color);
    border-radius: 2px;
    margin: 12px auto 0;
    flex-shrink: 0;
}

.filter-panel-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 1rem 1.25rem;
    border-bottom: 1px solid var(--border-color);
    flex-shrink: 0;
}

.filter-panel-title {
    font-size: 1rem;
    font-weight: 700;
    color: var(--text-main);
    display: flex;
    align-items: center;
    gap: 0.5rem;
    margin: 0;
}

.filter-panel-title i {
    color: var(--primary);
}

.filter-close-btn {
    width: 36px;
    height: 36px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    color: var(--text-muted);
    cursor: pointer;
    font-size: 1rem;
    transition: var(--transition);
}

.filter-close-btn:hover {
    background: rgba(239,68,68,0.1);
    color: #ef4444;
    border-color: rgba(239,68,68,0.3);
}

.filter-panel-body {
    flex: 1;
    overflow-y: auto;
    padding: 1rem 1.25rem;
    -webkit-overflow-scrolling: touch;
    background: var(--bg-body);
}

.fp-section {
    margin-bottom: 1.5rem;
}

.fp-section-title {
    font-size: 0.88rem;
    font-weight: 700;
    color: var(--text-muted);
    margin: 0 0 0.75rem;
    text-transform: uppercase;
    letter-spacing: 0.04em;
}

.fp-pills {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
}

.fp-pill {
    display: inline-flex;
    align-items: center;
    gap: 0.35rem;
    padding: 0.45rem 0.9rem;
    border-radius: 20px;
    background: var(--bg-card);
    border: 1.5px solid var(--border-color);
    color: var(--text-main);
    font-family: inherit;
    font-size: 0.85rem;
    font-weight: 600;
    cursor: pointer;
    transition: var(--transition);
    white-space: nowrap;
}

.fp-pill:hover {
    border-color: var(--primary);
    color: var(--primary);
    transform: translateY(-1px);
}

.fp-pill.active {
    background: var(--primary);
    border-color: var(--primary);
    color: #fff;
    box-shadow: 0 3px 10px rgba(15,81,50,0.35);
}

.fp-pill.active i {
    font-size: 0.7rem;
}

.filter-panel-footer {
    display: flex;
    gap: 0.75rem;
    padding: 1rem 1.25rem;
    border-top: 1px solid var(--border-color);
    flex-shrink: 0;
    padding-bottom: max(1rem, env(safe-area-inset-bottom));
}

.filter-reset-btn {
    flex: 1;
    padding: 0.8rem 1rem;
    border-radius: 25px;
    background: transparent;
    border: 1.5px solid var(--border-color);
    color: var(--text-main);
    font-family: inherit;
    font-size: 0.92rem;
    font-weight: 600;
    cursor: pointer;
    transition: var(--transition);
}

.filter-reset-btn:hover {
    border-color: var(--text-muted);
    background: var(--bg-card);
}

.filter-apply-btn {
    flex: 2;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    padding: 0.8rem 1.5rem;
    border-radius: 25px;
    background: linear-gradient(135deg, var(--primary), var(--primary-light));
    border: none;
    color: #fff;
    font-family: inherit;
    font-size: 0.92rem;
    font-weight: 700;
    cursor: pointer;
    box-shadow: 0 4px 16px rgba(15,81,50,0.4);
    transition: var(--transition);
}

.filter-apply-btn:hover {
    transform: translateY(-1px);
    box-shadow: 0 6px 20px rgba(15,81,50,0.5);
}

@keyframes fp-fade-in {
    from { opacity: 0; }
    to { opacity: 1; }
}

.nav-actions {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    order: 2; /* always at logical end: left in RTL, right in LTR */
}

.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    padding: 0.55rem 1.1rem;
    border-radius: var(--radius-md);
    font-family: inherit;
    font-size: 0.9rem;
    font-weight: 600;
    cursor: pointer;
    border: none;
    transition: var(--transition);
    text-decoration: none;
    white-space: nowrap;
}

.btn-primary {
    background: linear-gradient(135deg, var(--primary), var(--primary-light));
    color: white;
    box-shadow: 0 4px 12px rgba(15, 81, 50, 0.25);
}

.btn-primary:hover {
    transform: translateY(-1px);
    box-shadow: 0 6px 16px rgba(15, 81, 50, 0.35);
}

.btn-outline {
    background: transparent;
    border: 1px solid var(--border-color);
    color: var(--text-main);
}

.btn-outline:hover {
    background: var(--border-color);
}

.btn-sm {
    padding: 0.35rem 0.75rem;
    font-size: 0.8rem;
    border-radius: var(--radius-sm);
}

.btn-danger {
    background: #dc3545;
    color: white;
}

.btn-danger:hover {
    background: #bb2d3b;
}

.btn-icon {
    width: 38px;
    height: 38px;
    padding: 0;
    border-radius: 50%;
}

/* Layout Container */
.main-layout {
    max-width: 1200px;
    width: 100%;
    margin: 1.5rem auto;
    padding: 0 1rem;
    display: grid;
    grid-template-columns: 280px minmax(0, 1fr) 300px;
    gap: 1.5rem;
    align-items: start; /* Essential for sticky sidebars inside CSS Grid */
}

/* Sticky Sidebars on Desktop */
.sidebar-left,
.sidebar-right {
    position: sticky;
    top: 95px; /* Pinned right below the fixed header navbar */
    max-height: calc(100vh - 110px);
    overflow-y: auto;
    /* Clean custom scrollbar for sidebars */
    scrollbar-width: thin;
    scrollbar-color: var(--border-color) transparent;
}

.sidebar-left::-webkit-scrollbar,
.sidebar-right::-webkit-scrollbar {
    width: 5px;
}

.sidebar-left::-webkit-scrollbar-thumb,
.sidebar-right::-webkit-scrollbar-thumb {
    background-color: var(--border-color);
    border-radius: 10px;
}

@media (max-width: 992px) {
    .main-layout {
        grid-template-columns: 1fr;
    }

    .sidebar-left,
    .sidebar-right {
        display: none;
        position: static;
        max-height: none;
    }
}

/* Sidebar Widgets */
.widget {
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    padding: 1.25rem;
    margin-bottom: 1.25rem;
    box-shadow: var(--shadow-sm);
    word-break: break-word;
}

.widget-title {
    font-size: 1rem;
    font-weight: 700;
    margin-bottom: 1rem;
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.filter-group {
    display: flex;
    flex-direction: column;
    gap: 0.4rem;
}

.filter-item {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0.6rem 0.75rem;
    border-radius: var(--radius-sm);
    color: var(--text-main);
    text-decoration: none;
    font-size: 0.9rem;
    font-weight: 500;
    cursor: pointer;
    transition: var(--transition);
}

.filter-item:hover,
.filter-item.active {
    background: rgba(15, 81, 50, 0.08);
    color: var(--primary);
}

[data-theme="dark"] .filter-item:hover,
[data-theme="dark"] .filter-item.active {
    background: rgba(74, 222, 128, 0.15);
    color: #4ade80;
}

/* =========================================================
   Mobile Emergency Bar & FAB — hidden on desktop by default
   ========================================================= */
.mobile-emergency-wrapper {
    display: none; /* shown via @media ≤992px */
    position: relative;
    align-items: center;
    gap: 0.5rem;
    margin-bottom: 0.75rem;
    width: 100%;
    direction: ltr !important;
}

.mobile-emergency-bar {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    overflow-x: auto;
    scroll-behavior: smooth;
    padding: 0.25rem 0;
    scrollbar-width: none;
    flex: 1;
}

.mobile-emergency-bar::-webkit-scrollbar {
    display: none;
}

[dir="rtl"] .mobile-emergency-bar {
    direction: rtl;
}

.mobile-emergency-chip {
    display: inline-flex;
    align-items: center;
    gap: 0.4rem;
    padding: 0.45rem 0.85rem;
    border-radius: 20px;
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    font-size: 0.82rem;
    font-weight: 700;
    white-space: nowrap;
    text-decoration: none;
    color: var(--text-main);
    box-shadow: var(--shadow-sm);
    transition: var(--transition);
}

.mobile-emergency-chip:hover {
    transform: translateY(-1px);
    box-shadow: var(--shadow-md);
}

/* FAB — Floating Action Button (matches Flutter app) */
.mobile-fab-btn {
    display: none; /* shown via @media ≤768px */
    position: fixed;
    bottom: 28px;
    inset-inline-end: 20px;
    z-index: 9999;
    align-items: center;
    gap: 0.5rem;
    padding: 0.75rem 1.4rem;
    background: linear-gradient(135deg, var(--primary), var(--primary-light));
    color: #fff;
    border: none;
    border-radius: 30px;
    font-size: 0.92rem;
    font-weight: 700;
    font-family: inherit;
    cursor: pointer;
    box-shadow: 0 6px 20px rgba(15, 81, 50, 0.45), 0 2px 8px rgba(0,0,0,0.15);
    transition: transform 0.2s ease, box-shadow 0.2s ease;
    white-space: nowrap;
}

.mobile-fab-btn:hover,
.mobile-fab-btn:active {
    transform: translateY(-2px) scale(1.04);
    box-shadow: 0 10px 28px rgba(15, 81, 50, 0.55);
}

/* Category Filter Bar with Scroll Navigation Arrows */
.category-pills-wrapper {
    position: relative;
    display: flex;
    align-items: center;
    direction: ltr !important;
    gap: 0.5rem;
    margin-bottom: 1.25rem;
    width: 100%;
}

.category-bar {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    overflow-x: auto;
    scroll-behavior: smooth;
    padding: 0.25rem 0;
    scrollbar-width: none;
    flex: 1;
}

[dir="rtl"] .category-bar {
    direction: rtl;
}

[dir="ltr"] .category-bar {
    direction: ltr;
}

.category-bar::-webkit-scrollbar {
    display: none;
}

.scroll-arrow {
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    color: var(--text-main);
    width: 32px;
    height: 32px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    flex-shrink: 0;
    box-shadow: var(--shadow-sm);
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.25s ease, background 0.2s ease, transform 0.2s ease;
    z-index: 5;
    font-size: 0.85rem;
}

.scroll-arrow:hover {
    background: var(--primary);
    color: white;
    border-color: var(--primary);
}

.cat-pill {
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.5rem 1rem;
    border-radius: 20px;
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    color: var(--text-main);
    font-size: 0.85rem;
    font-weight: 600;
    white-space: nowrap;
    cursor: pointer;
    transition: var(--transition);
}

.cat-pill:hover,
.cat-pill.active {
    background: var(--primary);
    color: white;
    border-color: var(--primary);
}

/* Post Cards */
.feed-container {
    display: flex;
    flex-direction: column;
    gap: 1.25rem;
    width: 100%;
}

.post-card {
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    padding: 1.25rem;
    box-shadow: var(--shadow-sm);
    transition: var(--transition);
    width: 100%;
    overflow: visible; /* Allow 3-dot dropdown to escape card bounds */
    position: relative;
}

/* 3-dot post menu dropdown — must escape card bounds */
.dropdown {
    position: relative;
    z-index: 200;
}

.post-dropdown-menu {
    z-index: 9999 !important;
}

.post-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 0.9rem;
}

.user-info {
    display: flex;
    align-items: center;
    gap: 0.75rem;
}

.avatar {
    width: 44px;
    height: 44px;
    border-radius: 50%;
    background: linear-gradient(135deg, #e2e8f0, #cbd5e1);
    color: var(--primary);
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 700;
    font-size: 1.1rem;
    object-fit: cover;
    flex-shrink: 0;
}

.user-details h4 {
    font-size: 0.95rem;
    font-weight: 700;
    margin: 0;
}

.post-meta {
    font-size: 0.8rem;
    color: var(--text-muted);
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.badge {
    padding: 0.25rem 0.65rem;
    border-radius: 12px;
    font-size: 0.75rem;
    font-weight: 700;
    color: white;
    display: inline-flex;
    align-items: center;
    gap: 0.3rem;
}

.badge-emergency {
    background-color: #dc3545;
}

.badge-urgent {
    background-color: #fd7e14;
}

.badge-normal {
    background-color: #198754;
}

.post-title {
    font-size: 1.1rem;
    font-weight: 700;
    margin-bottom: 0.5rem;
    color: var(--text-main);
}

.post-content {
    font-size: 0.95rem;
    color: var(--text-main);
    margin-bottom: 1rem;
    white-space: pre-line;
    word-break: break-word;
}

/* Facebook-Grade Responsive Post Gallery */
.post-single-image {
    width: 100%;
    max-height: 520px;
    border-radius: var(--radius-md);
    overflow: hidden;
    margin-bottom: 1rem;
    background: #0f172a;
    display: flex;
    align-items: center;
    justify-content: center;
    border: 1px solid var(--border-color);
}

.post-single-image img {
    width: 100%;
    max-height: 520px;
    object-fit: contain;
    /* Full picture visibility without cut-off */
    border-radius: var(--radius-md);
    cursor: pointer;
    transition: var(--transition);
}

.post-single-image img:hover {
    transform: scale(1.01);
}

.post-gallery {
    display: grid;
    gap: 0.5rem;
    margin-bottom: 1rem;
    border-radius: var(--radius-md);
    overflow: hidden;
}

.post-gallery-multi-2 {
    grid-template-columns: 1fr 1fr;
}

.post-gallery-multi-3 {
    grid-template-columns: 2fr 1fr;
}

.post-gallery-multi-4 {
    grid-template-columns: 1fr 1fr;
}

.post-gallery img {
    width: 100%;
    height: 320px;
    object-fit: cover;
    border-radius: var(--radius-sm);
    cursor: pointer;
    transition: var(--transition);
}

.post-gallery img:hover {
    transform: scale(1.02);
}

.post-stats {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0.5rem 0;
    border-top: 1px solid var(--border-color);
    border-bottom: 1px solid var(--border-color);
    font-size: 0.85rem;
    color: var(--text-muted);
    margin-bottom: 0.5rem;
}

.post-actions {
    display: flex;
    align-items: center;
    justify-content: space-around;
    padding-top: 0.25rem;
}

.action-btn {
    flex: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    padding: 0.55rem;
    border: none;
    background: transparent;
    color: var(--text-muted);
    font-family: inherit;
    font-size: 0.88rem;
    font-weight: 600;
    border-radius: var(--radius-sm);
    cursor: pointer;
    transition: var(--transition);
}

.action-btn:hover {
    background: var(--bg-body);
    color: var(--primary);
}

.action-btn.liked {
    color: #dc3545;
}

.action-btn.saved {
    color: var(--primary);
    font-weight: 700;
    background: rgba(15, 81, 50, 0.08);
}

/* Facebook-style Inline Collapsible Comment Section */
.inline-comments-section {
    display: none;
    margin-top: 0.8rem;
    padding-top: 0.8rem;
    border-top: 1px solid var(--border-color);
}

.inline-comments-list {
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
    margin-bottom: 0.75rem;
    max-height: 280px;
    overflow-y: auto;
}

.comment-bubble-item {
    display: flex;
    gap: 0.6rem;
    align-items: flex-start;
}

.comment-bubble {
    background: var(--bg-body);
    padding: 0.6rem 0.9rem;
    border-radius: 14px;
    font-size: 0.88rem;
    flex: 1;
}

.comment-bubble-author {
    font-weight: 700;
    margin-bottom: 0.15rem;
    font-size: 0.85rem;
}

.comment-input-box {
    display: flex;
    gap: 0.5rem;
    align-items: center;
}

.comment-input-box input {
    flex: 1;
    padding: 0.55rem 0.9rem;
    border-radius: 20px;
    border: 1px solid var(--border-color);
    background: var(--bg-body);
    color: var(--text-main);
    font-family: inherit;
    font-size: 0.88rem;
    outline: none;
}

/* Image Upload Drag-and-Drop & Preview Grid */
.image-upload-zone {
    border: 2px dashed var(--border-color);
    border-radius: var(--radius-md);
    padding: 1.5rem;
    text-align: center;
    background: var(--bg-body);
    cursor: pointer;
    transition: var(--transition);
}

.image-upload-zone:hover {
    border-color: var(--primary);
    background: rgba(15, 81, 50, 0.04);
}

.image-preview-grid {
    display: flex;
    flex-wrap: wrap;
    gap: 0.6rem;
    margin-top: 0.75rem;
}

.preview-thumb {
    position: relative;
    width: 80px;
    height: 80px;
    border-radius: var(--radius-sm);
    overflow: hidden;
    border: 1px solid var(--border-color);
}

.preview-thumb img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.preview-thumb .remove-btn {
    position: absolute;
    top: 4px;
    right: 4px;
    background: rgba(220, 53, 69, 0.9);
    color: white;
    border: none;
    border-radius: 50%;
    width: 20px;
    height: 20px;
    font-size: 0.7rem;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.3);
}

/* Modals */
.modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.65);
    backdrop-filter: blur(6px);
    -webkit-backdrop-filter: blur(6px);
    display: none;
    /* Changed from visibility hidden to display none for 100% reliable DOM toggle */
    align-items: center;
    justify-content: center;
    z-index: 9999;
    opacity: 0;
    transition: opacity 0.25s ease;
}

#edit-modal {
    z-index: 10005;
}

.modal-overlay.active {
    display: flex !important;
    opacity: 1 !important;
}

.modal-card {
    background: var(--bg-card);
    border-radius: var(--radius-lg);
    width: 90%;
    max-width: 580px;
    max-height: 90vh;
    overflow-y: auto;
    padding: 1.75rem;
    box-shadow: var(--shadow-lg);
    transform: translateY(20px);
    transition: var(--transition);
}

.modal-overlay.active .modal-card {
    transform: translateY(0);
}

.modal-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 1.25rem;
    padding-bottom: 0.75rem;
    border-bottom: 1px solid var(--border-color);
}

.modal-header h3 {
    font-size: 1.2rem;
    font-weight: 700;
}

.close-btn {
    background: none;
    border: none;
    font-size: 1.2rem;
    cursor: pointer;
    color: var(--text-muted);
}

.form-group {
    margin-bottom: 1rem;
}

.form-group label {
    display: block;
    font-size: 0.88rem;
    font-weight: 600;
    margin-bottom: 0.4rem;
}

.form-control {
    width: 100%;
    padding: 0.65rem 0.9rem;
    border-radius: var(--radius-sm);
    border: 1px solid var(--border-color);
    background: var(--bg-body);
    color: var(--text-main);
    font-family: inherit;
    font-size: 0.9rem;
    outline: none;
}

.form-control:focus {
    border-color: var(--primary);
}

textarea.form-control {
    resize: vertical;
    min-height: 100px;
}

.tab-header {
    display: flex;
    gap: 0.5rem;
    border-bottom: 1px solid var(--border-color);
    margin-bottom: 1rem;
}

.tab-btn {
    padding: 0.6rem 1rem;
    border: none;
    background: transparent;
    color: var(--text-muted);
    font-family: inherit;
    font-size: 0.9rem;
    font-weight: 700;
    cursor: pointer;
    border-bottom: 2px solid transparent;
    transition: var(--transition);
}

.tab-btn.active {
    color: var(--primary);
    border-bottom-color: var(--primary);
}

/* Admin Dashboard KPI Cards & Flag Queue */
.admin-stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 1rem;
    margin-bottom: 1rem;
}

.admin-kpi-card {
    background: var(--bg-body);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    padding: 1.1rem;
    text-align: center;
    transition: var(--transition);
}

.admin-kpi-card:hover {
    border-color: var(--primary);
    transform: translateY(-2px);
}

.admin-kpi-card i {
    font-size: 1.6rem;
    margin-bottom: 0.5rem;
    color: var(--primary);
}

.admin-kpi-val {
    font-size: 1.6rem;
    font-weight: 800;
    color: var(--text-main);
    line-height: 1.2;
}

.admin-kpi-label {
    font-size: 0.85rem;
    color: var(--text-muted);
    font-weight: 600;
}

.flagged-item-card {
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    padding: 1rem;
    margin-bottom: 1rem;
    background: var(--bg-body);
    transition: var(--transition);
}

.flagged-item-card:hover {
    border-color: #dc3545;
}

/* Floating "New Posts Available" Notification Banner Pill */
.new-posts-pill {
    display: none;
    position: sticky;
    top: 70px;
    z-index: 100;
    margin: 0 auto 1rem auto;
    width: fit-content;
    padding: 0.65rem 1.25rem;
    background: #0F5132;
    color: #ffffff;
    font-weight: 700;
    font-size: 0.88rem;
    border-radius: 30px;
    box-shadow: 0 4px 14px rgba(15, 81, 50, 0.35);
    cursor: pointer;
    transition: transform 0.2s ease, background 0.2s ease;
    text-align: center;
}

.new-posts-pill:hover {
    transform: scale(1.04);
    background: #0b3d26;
}

/* Fixed Floating Toast Notification (Visible Anywhere on Screen) */
.new-posts-toast-fixed {
    display: none;
    position: fixed;
    bottom: 24px;
    left: 50%;
    transform: translateX(-50%);
    z-index: 9999;
    padding: 0.75rem 1.4rem;
    background: #0F5132;
    color: #ffffff;
    font-weight: 700;
    font-size: 0.9rem;
    border-radius: 30px;
    box-shadow: 0 8px 24px rgba(15, 81, 50, 0.45);
    cursor: pointer;
    transition: all 0.25s cubic-bezier(0.175, 0.885, 0.32, 1.275);
    text-align: center;
    border: 1px solid rgba(255, 255, 255, 0.2);
}

.new-posts-toast-fixed:hover {
    transform: translateX(-50%) scale(1.05);
    background: #0b3d26;
}

@keyframes reportHighlightPulse {
    0% {
        box-shadow: 0 0 0 0 rgba(15, 81, 50, 0.7);
        border-color: #0F5132;
    }

    50% {
        box-shadow: 0 0 0 10px rgba(15, 81, 50, 0.35);
        border-color: #0F5132;
    }

    100% {
        box-shadow: 0 0 0 0 rgba(15, 81, 50, 0);
    }
}

.report-highlight-pulse {
    animation: reportHighlightPulse 2s ease-in-out 2;
    border: 2px solid #0F5132 !important;
}

/* ==========================================================================
   Comprehensive Mobile & Tablet Responsive Media Queries
   ========================================================================== */

@media (max-width: 992px) {
    .main-layout {
        grid-template-columns: 1fr !important;
        margin: 0.75rem auto !important;
        padding: 0 0.75rem !important;
        width: 100% !important;
        max-width: 100% !important;
        box-sizing: border-box !important;
        overflow-x: hidden !important;
    }

    .sidebar-left,
    .sidebar-right {
        display: none !important;
    }

    /* Show the emergency bar wrapper on mobile/tablet */
    .mobile-emergency-wrapper {
        display: flex !important;
    }
}

/* ==========================================================================
   MOBILE RESPONSIVE (≤768px) — Complete Rewrite
   ========================================================================== */
@media (max-width: 768px) {

    /* --- Base --- */
    html, body {
        overflow-x: hidden !important;
        width: 100% !important;
        max-width: 100vw !important;
    }

    /* --- Navbar: row 1 = logo + actions, row 2 = search --- */
    .navbar {
        padding: 0.5rem 0.75rem !important;
        width: 100% !important;
        max-width: 100vw !important;
        box-sizing: border-box !important;
        overflow: hidden !important;
    }

    .nav-container {
        display: flex !important;
        flex-direction: column !important;
        gap: 0.5rem !important;
        width: 100% !important;
        max-width: 100% !important;
        box-sizing: border-box !important;
        overflow: hidden !important;
    }

    /* On mobile, nav-top-row is a real flex row: logo left, actions right */
    .nav-top-row {
        display: flex !important;
        align-items: center !important;
        justify-content: space-between !important;
        width: 100% !important;
        max-width: 100% !important;
        box-sizing: border-box !important;
        overflow: hidden !important;
        gap: 0.5rem !important;
    }

    .brand img {
        height: 44px !important;
        max-width: 140px !important;
        object-fit: contain !important;
    }

    /* Hide the big green 'بلاغ جديد' button – FAB replaces it */
    #create-report-btn {
        display: none !important;
    }

    .nav-actions {
        display: flex !important;
        flex-wrap: nowrap !important;
        align-items: center !important;
        justify-content: flex-end !important;
        gap: 0.3rem !important;
        flex-shrink: 0 !important;
    }

    /* Fix: auth buttons can shrink so icon buttons (theme/lang) never get pushed off */
    #auth-buttons {
        flex: 1 1 auto !important;
        min-width: 0 !important;
        overflow: hidden !important;
        display: flex !important;
        align-items: center !important;
        gap: 0.3rem !important;
    }

    #auth-buttons .btn {
        max-width: 130px !important;
        overflow: hidden !important;
        text-overflow: ellipsis !important;
        white-space: nowrap !important;
    }

    #auth-buttons .btn span {
        overflow: hidden !important;
        text-overflow: ellipsis !important;
        max-width: 80px !important;
        display: inline-block !important;
    }

    /* Icon buttons never shrink */
    #theme-toggle,
    #lang-toggle {
        flex-shrink: 0 !important;
    }

    /* Show filter button, hide category pills on mobile */
    .filter-trigger-btn {
        display: flex !important;
    }

    .category-pills-wrapper {
        display: none !important;
    }

    /* search-filter-row on mobile: full width row */
    .search-filter-row {
        width: 100% !important;
        box-sizing: border-box !important;
    }

    .btn-icon {
        width: 34px !important;
        height: 34px !important;
    }

    /* Row 2: full-width search */
    .nav-search {
        width: 100% !important;
        max-width: 100% !important;
        margin: 0 !important;
        box-sizing: border-box !important;
    }

    .nav-search input {
        width: 100% !important;
        box-sizing: border-box !important;
        font-size: 0.85rem !important;
    }

    /* --- Floating Action Button (matches Flutter app: bottom inline-start corner) --- */
    .mobile-fab-btn {
        display: flex !important;
        position: fixed !important;
        bottom: 28px !important;
        inset-inline-end: 20px !important; /* LEFT in RTL Arabic (matches Flutter), RIGHT in LTR */
        right: auto !important;
        left: auto !important;
        z-index: 9999 !important;
        background: linear-gradient(135deg, var(--primary), var(--primary-light)) !important;
        color: #fff !important;
        border: none !important;
        border-radius: 30px !important;
        padding: 0.75rem 1.4rem !important;
        font-size: 0.92rem !important;
        font-weight: 700 !important;
        font-family: inherit !important;
        gap: 0.5rem !important;
        align-items: center !important;
        box-shadow: 0 6px 20px rgba(15, 81, 50, 0.45), 0 2px 8px rgba(0,0,0,0.15) !important;
        cursor: pointer !important;
        white-space: nowrap !important;
    }

    /* --- Main layout: single column, no side padding overflow --- */
    .main-layout {
        width: 100% !important;
        max-width: 100% !important;
        box-sizing: border-box !important;
        padding: 0 0.75rem !important;
        margin: 0.75rem 0 !important;
    }

    .feed-section {
        width: 100% !important;
        max-width: 100% !important;
        box-sizing: border-box !important;
        min-width: 0 !important;
    }

    /* --- Post / Report Cards --- */
    .post-card,
    .report-card {
        width: 100% !important;
        max-width: 100% !important;
        box-sizing: border-box !important;
        overflow: visible !important; /* MUST be visible — overflow:hidden clips the 3-dot dropdown */
        padding: 0.9rem !important;
        margin-bottom: 0.85rem !important;
        position: relative !important;
    }

    /* Dropdown menu wrapper — allow z-index stacking above other cards */
    .post-card .dropdown,
    .report-card .dropdown {
        position: relative !important;
        z-index: 300 !important;
        overflow: visible !important;
    }

    /* Dropdown menu itself: high z-index, escapes card bounds */
    .post-dropdown-menu {
        z-index: 9999 !important;
        position: absolute !important;
    }

    /* Post header: avatar + details on left, badge + menu on right */
    .post-header {
        display: flex !important;
        align-items: flex-start !important;
        justify-content: space-between !important;
        gap: 0.5rem !important;
        width: 100% !important;
        overflow: visible !important; /* must be visible so dropdown can escape */
    }

    .user-info {
        display: flex !important;
        align-items: center !important;
        gap: 0.5rem !important;
        min-width: 0 !important;
        flex: 1 !important;
        overflow: hidden !important;
    }

    .user-details {
        min-width: 0 !important;
        flex: 1 !important;
        overflow: hidden !important;
    }

    .user-details h4 {
        font-size: 0.88rem !important;
        white-space: nowrap !important;
        overflow: hidden !important;
        text-overflow: ellipsis !important;
        margin: 0 !important;
    }

    .post-meta {
        flex-direction: column !important;
        align-items: flex-start !important;
        gap: 0.1rem !important;
        font-size: 0.75rem !important;
        overflow: hidden !important;
    }

    .post-meta span {
        white-space: nowrap !important;
        overflow: hidden !important;
        text-overflow: ellipsis !important;
        max-width: 100% !important;
        display: block !important;
    }

    /* Title & body text */
    .post-title,
    .report-title {
        font-size: 0.97rem !important;
        font-weight: 700 !important;
        line-height: 1.5 !important;
        word-break: break-word !important;
        overflow-wrap: break-word !important;
        margin-bottom: 0.4rem !important;
    }

    .post-content,
    .report-description {
        font-size: 0.87rem !important;
        line-height: 1.6 !important;
        word-break: break-word !important;
        overflow-wrap: break-word !important;
        white-space: pre-line !important;
        margin-bottom: 0.75rem !important;
    }

    /* Contact buttons: side by side pills */
    .contact-buttons-row {
        display: flex !important;
        flex-direction: row !important;
        gap: 0.4rem !important;
        width: 100% !important;
        box-sizing: border-box !important;
        margin: 0.6rem 0 !important;
    }

    .contact-btn {
        flex: 1 !important;
        min-width: 0 !important;
        display: inline-flex !important;
        align-items: center !important;
        justify-content: center !important;
        gap: 0.3rem !important;
        padding: 0.45rem 0.25rem !important;
        border-radius: 20px !important;
        font-size: 0.75rem !important;
        font-weight: 700 !important;
        text-decoration: none !important;
        box-sizing: border-box !important;
        overflow: hidden !important;
        text-overflow: ellipsis !important;
        white-space: nowrap !important;
    }

    /* Post stats row */
    .post-stats {
        font-size: 0.78rem !important;
        flex-wrap: wrap !important;
        gap: 0.3rem !important;
    }

    /* Post action buttons row */
    .post-actions {
        gap: 0 !important;
    }

    .action-btn {
        font-size: 0.78rem !important;
        padding: 0.45rem 0.2rem !important;
        gap: 0.3rem !important;
    }

    /* Gallery images: shorter on mobile */
    .post-gallery img {
        height: 180px !important;
    }

    /* Modals */
    .modal-card {
        width: 96% !important;
        padding: 1rem !important;
        max-height: 90vh !important;
        border-radius: 14px !important;
    }

    .modal-card form div[style*="grid-template-columns"] {
        grid-template-columns: 1fr !important;
    }

    /* Tabs */
    .tab-header {
        overflow-x: auto !important;
        white-space: nowrap !important;
    }

    .tab-btn {
        padding: 0.45rem 0.7rem !important;
        font-size: 0.8rem !important;
    }
}

@media (min-width: 769px) {
    .mobile-fab-btn {
        display: none !important;
    }
}

@media (max-width: 480px) {
    .brand img {
        height: 38px !important;
        max-width: 120px !important;
    }

    .navbar {
        padding: 0.4rem 0.5rem !important;
    }
}