/*
  Ensany v2 — NGOs directory page (website/ngos.blade.php +
  website/partials/ngos_grid.blade.php). Scoped under #v2Ngos.

  FUNCTIONAL SAFETY — the AJAX search/pagination flow (route('ngos'),
  .ngos-filterbar, .ngos-search, .ngos-country-wrap/.ngos-country,
  .nf-btn, #ngos-results, #table_div, select2) is unchanged from the
  original — only new v2n-prefixed classes were added around it for
  layout. ngos_grid.blade.php renders as a bare fragment (no navbar/
  footer) since it's swapped in via $results.html(html) on every
  search/pagination — its card markup is styled here too so both the
  first paint and every AJAX refresh look identical.
*/

#v2Ngos {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
    background: #F7F4EC;
}

#v2Ngos * {
    box-sizing: border-box;
}

#v2Ngos a {
    text-decoration: none;
}

/* ---------- Header band ---------- */
#v2Ngos .v2n-head {
    background: linear-gradient(155deg, #12332A, #1B4636);
    padding: 46px 0 90px;
    position: relative;
    overflow: hidden;
}

#v2Ngos .v2n-head::before {
    content: '';
    position: absolute;
    inset: 0;
    background-image: radial-gradient(rgba(255, 255, 255, .08) 1.5px, transparent 1.5px);
    background-size: 24px 24px;
    -webkit-mask-image: radial-gradient(ellipse 70% 60% at 30% 0%, black, transparent);
    mask-image: radial-gradient(ellipse 70% 60% at 30% 0%, black, transparent);
    pointer-events: none;
}

#v2Ngos .v2n-head-inner {
    max-width: 1180px;
    margin: 0 auto;
    padding: 0 16px;
    position: relative;
    z-index: 1;
    text-align: center;
}

#v2Ngos .v2n-eyebrow {
    display: inline-block;
    color: #D4A94B;
    font-weight: 800;
    font-size: 11.5px;
    text-transform: uppercase;
    letter-spacing: .05em;
    margin-bottom: 8px;
}

#v2Ngos .v2n-title {
    color: #fff;
    font-size: clamp(24px, 3.4vw, 34px);
    font-weight: 800;
    margin: 0 0 26px;
}

/* ---------- Filter bar — floats over the header band, same fields/
   classes as before, restyled as a white card ---------- */
#v2Ngos .ngos-filterbar {
    display: flex;
    align-items: center;
    justify-content: center;
    flex-wrap: wrap;
    gap: 10px;
    max-width: 900px;
    margin: 0 auto;
    background: #fff;
    border-radius: 18px;
    padding: 14px;
    box-shadow: 0 24px 50px -20px rgba(18, 51, 42, .45);
}

#v2Ngos .ngos-filterbar>* {
    min-width: 0;
}

#v2Ngos .ngos-search {
    position: relative;
    flex: 1 1 260px;
}

#v2Ngos .ngos-search .nf-search-icon {
    position: absolute;
    top: 50%;
    inset-inline-start: 14px;
    transform: translateY(-50%);
    display: flex;
    color: #9AA39C;
    pointer-events: none;
}

#v2Ngos .ngos-search input {
    width: 100%;
    height: 46px;
    border: 1.5px solid #E7E1D0;
    border-radius: 12px;
    background: #F7F4EC;
    padding-inline-start: 42px;
    padding-inline-end: 14px;
    font-size: 13.5px;
    font-weight: 500;
    color: #12332A;
    transition: border-color .15s ease, box-shadow .15s ease, background .15s ease;
}

#v2Ngos .ngos-search input::placeholder {
    color: #9AA39C;
}

#v2Ngos .ngos-search input:focus {
    outline: none;
    border-color: #7FB239;
    background: #fff;
    box-shadow: 0 0 0 3px rgba(127, 178, 57, .15);
}

#v2Ngos .ngos-country-wrap {
    flex: 0 1 220px;
}

#v2Ngos .nf-btn {
    flex: 0 0 auto;
    height: 46px;
    padding: 0 26px;
    border: none;
    border-radius: 12px;
    background: linear-gradient(135deg, #7FB239, #578021);
    color: #fff;
    font-weight: 800;
    font-size: 13.5px;
    white-space: nowrap;
    cursor: pointer;
    box-shadow: 0 12px 26px -12px rgba(87, 128, 33, .55);
    transition: transform .15s ease;
}

#v2Ngos .nf-btn:hover {
    transform: translateY(-1px);
}

#v2Ngos .nf-btn:active {
    transform: translateY(0);
}

#v2Ngos .ngos-filterbar[dir="ltr"] .nf-btn {
    order: 3;
}

#v2Ngos .ngos-filterbar[dir="ltr"] .ngos-search {
    order: 1;
}

#v2Ngos .ngos-filterbar[dir="ltr"] .ngos-country-wrap {
    order: 2;
}

#v2Ngos .ngos-filterbar[dir="rtl"] .ngos-country-wrap {
    order: 2;
}

#v2Ngos .ngos-filterbar[dir="rtl"] .ngos-search {
    order: 1;
}

#v2Ngos .ngos-filterbar[dir="rtl"] .nf-btn {
    order: 3;
}

@media (max-width: 575.98px) {
    #v2Ngos .ngos-filterbar {
        justify-content: stretch;
    }

    #v2Ngos .ngos-filterbar[dir] .ngos-search {
        flex: 1 1 100%;
        order: 1;
    }

    #v2Ngos .ngos-filterbar[dir] .ngos-country-wrap {
        flex: 1 1 100%;
        order: 2;
    }

    #v2Ngos .ngos-filterbar[dir] .nf-btn {
        flex: 1 1 100%;
        order: 3;
    }
}

/* select2, restyled to match the v2 inputs */
#v2Ngos .ngos-filterbar .select2-container {
    width: 100% !important;
}

#v2Ngos .ngos-filterbar .select2-container--default .select2-selection--single {
    height: 46px !important;
    border: 1.5px solid #E7E1D0 !important;
    border-radius: 12px !important;
    background: #F7F4EC !important;
}

#v2Ngos .ngos-filterbar .select2-container--default .select2-selection--single .select2-selection__rendered {
    line-height: 46px !important;
    padding-inline-start: 14px !important;
    padding-inline-end: 30px !important;
    color: #12332A !important;
    font-size: 13.5px !important;
    font-weight: 500 !important;
}

#v2Ngos .ngos-filterbar .select2-container--default .select2-selection--single .select2-selection__arrow {
    height: 44px !important;
}

#v2Ngos .ngos-filterbar .select2-container--default.select2-container--focus .select2-selection--single,
#v2Ngos .ngos-filterbar .select2-container--default.select2-container--open .select2-selection--single {
    border-color: #7FB239 !important;
    box-shadow: 0 0 0 3px rgba(127, 178, 57, .15) !important;
}

.select2-container--default .select2-results__option--highlighted[aria-selected] {
    background: #578021 !important;
}

.select2-dropdown {
    border-color: #E7E1D0 !important;
    border-radius: 12px !important;
    overflow: hidden;
}

/* ---------- Results grid ---------- */
#v2Ngos .v2n-grid-section {
    max-width: 1180px;
    margin: -50px auto 0;
    padding: 0 16px 70px;
    position: relative;
    z-index: 2;
}

#v2Ngos #ngos-results {
    transition: opacity .2s ease;
}

#v2Ngos #table_div {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(230px, 1fr));
    gap: 20px;
    margin: 0 0 30px;
}

#v2Ngos .v2n-card {
    background: #fff;
    border: 1px solid #EFE9D8;
    border-radius: 18px;
    overflow: hidden;
    box-shadow: 0 14px 32px -24px rgba(18, 51, 42, .25);
    transition: transform .18s ease, box-shadow .18s ease, border-color .18s ease;
    display: block;
}

#v2Ngos .v2n-card:hover {
    transform: translateY(-3px);
    box-shadow: 0 20px 40px -20px rgba(18, 51, 42, .35);
    border-color: #7FB239;
}

#v2Ngos .v2n-card-img-wrap {
    position: relative;
    aspect-ratio: 4/3;
    background: #F7F4EC;
    overflow: hidden;
    display: flex;
    align-items: center;
    justify-content: center;
}

#v2Ngos .v2n-card-img-wrap img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
    opacity: 1;
    transition: opacity .35s ease;
}

/* Shown while the image is still loading — hides the (possibly broken/
   empty) <img> and shimmers in its place, then fades to the real photo
   once onload fires (see ngos_grid.blade.php). */
#v2Ngos .v2n-card-img-wrap.v2n-img-loading img {
    opacity: 0;
}

#v2Ngos .v2n-card-img-wrap.v2n-img-loading::before {
    content: '';
    position: absolute;
    inset: 0;
    background: linear-gradient(90deg, #EFE9D8 25%, #F7F4EC 37%, #EFE9D8 63%);
    background-size: 400px 100%;
    animation: v2nShimmer 1.4s ease infinite;
}

@keyframes v2nShimmer {
    0% {
        background-position: -400px 0;
    }

    100% {
        background-position: 400px 0;
    }
}

#v2Ngos .v2n-card-name {
    padding: 14px;
    text-align: center;
    font-size: 13.5px;
    font-weight: 800;
    color: #12332A;
    line-height: 1.5;
    min-height: 52px;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

#v2Ngos .v2n-empty {
    grid-column: 1 / -1;
    text-align: center;
    padding: 60px 20px;
    color: #5B6660;
    font-size: 14px;
    font-weight: 600;
}

/* ---------- Full-grid skeleton (search/filter/pagination in flight) ----------
   Rendered client-side the instant a search fires — see the load()
   function in ngos.blade.php — and swapped out for the real
   #table_div once the AJAX response comes back. Reuses .v2n-card's own
   box shape so there's no layout jump between skeleton and real cards. */
#v2Ngos .v2n-skel-card {
    pointer-events: none;
}

#v2Ngos .v2n-skel-card .v2n-card-img-wrap {
    animation: v2nShimmer 1.4s ease infinite;
    background: linear-gradient(90deg, #EFE9D8 25%, #F7F4EC 37%, #EFE9D8 63%);
    background-size: 400px 100%;
}

#v2Ngos .v2n-card-name-skel {
    height: 34px;
    margin: 14px;
    border-radius: 8px;
    background: linear-gradient(90deg, #EFE9D8 25%, #F7F4EC 37%, #EFE9D8 63%);
    background-size: 400px 100%;
    animation: v2nShimmer 1.4s ease infinite;
}

/* ---------- Pagination (Laravel default Bootstrap markup) ---------- */
#v2Ngos .pagination {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    list-style: none;
    margin: 0;
    padding: 0;
    flex-wrap: wrap;
}

#v2Ngos .pagination .page-item .page-link {
    display: flex;
    align-items: center;
    justify-content: center;
    min-width: 38px;
    height: 38px;
    padding: 0 10px;
    border: 1.5px solid #E7E1D0;
    border-radius: 10px;
    background: #fff;
    color: #12332A;
    font-weight: 700;
    font-size: 13px;
    text-decoration: none;
    transition: border-color .15s ease, background .15s ease, color .15s ease;
}

#v2Ngos .pagination .page-item .page-link:hover {
    border-color: #7FB239;
    background: #F7F4EC;
}

#v2Ngos .pagination .page-item.active .page-link {
    background: linear-gradient(135deg, #7FB239, #578021);
    border-color: transparent;
    color: #fff;
}

#v2Ngos .pagination .page-item.disabled .page-link {
    opacity: .4;
    cursor: default;
}