/**
 * Vimiss CMS - Post Grid / List Block Stylesheet
 * Responsive 4/2/1 grid layout with standard Vimiss typography & spacing
 */

.vm-post-list-wrapper {
    position: relative;
    width: 100%;
    box-sizing: border-box;
    margin: 0 auto 32px auto;
    font-family: var(--wp--preset--font-family--noto-sans, "Noto Sans", sans-serif);
}

/* Heading section */
.vm-post-list-heading {
    margin-bottom: 24px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    text-align: left;
    gap: 16px;
}

.vm-post-list-heading h2 {
    display: inline-flex;
    align-items: center;
    gap: 12px;
    font-size: clamp(22px, 2.4vw, 32px);
    font-weight: 600;
    line-height: 1.25;
    color: #0D509C;
    margin: 0;
    padding: 0;
    letter-spacing: 0.2px;
}

.vm-post-list-heading-icon {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    line-height: 1;
}

.vm-post-list-heading-icon img {
    width: 0.88em;
    height: 0.88em;
    max-width: none;
    display: block;
    object-fit: contain;
    transform: translateY(-0.04em);
}

.vm-post-list-heading-text {
    white-space: normal;
    word-break: break-word;
}

/* 4/2/1 Responsive Grid */
.vm-post-grid {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 24px;
    width: 100%;
    box-sizing: border-box;
}

.vm-post-grid-item {
    display: flex;
    flex-direction: column;
    min-width: 0; /* Prevents overflow in grid cells */
    height: 100%;
}

.vm-post-grid-item .vm-post-card {
    height: 100%;
    flex: 1;
}

.vm-post-grid-item .vm-post-card__thumb {
    position: relative;
    width: 100%;
    aspect-ratio: 16 / 9;
    overflow: hidden;
    background-color: #f3f4f6;
    flex-shrink: 0;
    box-sizing: border-box;
}

.vm-post-grid-item .vm-post-card__img,
.vm-post-grid-item .vm-post-card__thumb img {
    position: absolute !important;
    inset: 0 !important;
    top: 0 !important;
    left: 0 !important;
    width: 100% !important;
    height: 100% !important;
    min-width: 100% !important;
    min-height: 100% !important;
    max-width: none !important;
    max-height: none !important;
    object-fit: cover !important;
    object-position: center !important;
    display: block !important;
    margin: 0 !important;
    padding: 0 !important;
}

/* Tablet: 2 columns (<= 1024px) */
@media (max-width: 1024px) {
    .vm-post-grid {
        grid-template-columns: repeat(2, 1fr);
        gap: 20px;
    }
}

/* Mobile: 1 column (<= 640px) */
@media (max-width: 640px) {
    .vm-post-grid {
        grid-template-columns: 1fr;
        gap: 16px;
    }
}

/* Pagination */
.vm-pagination {
    margin-top: 36px;
    margin-bottom: 24px;
    display: flex;
    justify-content: center;
    align-items: center;
    flex-wrap: wrap;
    gap: 8px;
}

.vm-pagination .page-numbers {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 40px;
    height: 40px;
    padding: 0 14px;
    border-radius: 8px;
    border: 1px solid #C8DFEF;
    background: #FFFFFF;
    color: #0D509C;
    font-weight: 500;
    font-size: 14px;
    font-family: inherit;
    text-decoration: none;
    box-sizing: border-box;
    transition: all 0.2s ease;
}

.vm-pagination .page-numbers.current {
    background: #0D509C;
    border-color: #0D509C;
    color: #FFFFFF;
    font-weight: 600;
    cursor: default;
}

.vm-pagination .page-numbers:hover:not(.current):not(.dots) {
    background: #EBF4FC;
    border-color: #97C4E7;
    color: #083870;
}

.vm-pagination .page-numbers.dots {
    border: none;
    background: transparent;
    color: #888888;
    min-width: 20px;
    padding: 0 4px;
    cursor: default;
}

/* ═══════════════════════════════════════════════════════════════
   Post Filter Bar (Thanh lọc thuộc tính dạng pill bo tròn)
   ═══════════════════════════════════════════════════════════════ */
.vm-post-filter-bar {
    margin-bottom: 28px;
    width: 100%;
    box-sizing: border-box;
}

.vm-post-filter-form {
    width: 100%;
    margin: 0;
    padding: 0;
}

.vm-filter-fields {
    display: flex;
    align-items: center;
    justify-content: flex-start;
    flex-wrap: wrap;
    gap: 12px;
    width: 100%;
}

.vm-filter-item {
    flex: 1 1 180px;
    min-width: 140px;
    max-width: 100%;
    position: relative;
}

.vm-filter-item:has(.is-open) {
    z-index: 102;
}

.vm-filter-item.vm-filter-action {
    flex: 0 0 auto;
    min-width: auto;
}

/* Pill-shaped select wrapper */
.vm-filter-select-wrap {
    position: relative;
    width: 100%;
    background: #ffffff;
    border: 1px solid var(--Colors-Border-border-primary, #D4D4D4);
    border-radius: 9999px;
    transition: border-color 0.2s ease;
    box-shadow: 0px 1px 2px 0px var(--ColorsEffectsShadowsshadow-xs, rgba(0, 0, 0, 0.05));
    box-sizing: border-box;
}

.vm-filter-select-wrap:hover {
    border-color: #a3a3a3;
    box-shadow: 0px 1px 2px 0px var(--ColorsEffectsShadowsshadow-xs, rgba(0, 0, 0, 0.05));
}

.vm-filter-select-wrap.is-open {
    border-color: #225074 !important;
    z-index: 101;
}

/* Custom Select Trigger Button */
.vm-custom-select-trigger {
    display: flex;
    align-items: center;
    justify-content: space-between;
    width: 100%;
    height: 42px;
    padding: 0 16px 0 18px;
    background: transparent;
    border: none;
    outline: none;
    cursor: pointer;
    font-size: 13.5px;
    color: #737373;
    font-weight: 400;
    font-family: inherit;
    text-align: left;
    box-sizing: border-box;
    border-radius: 9999px;
    user-select: none;
}

.vm-custom-select-label {
    flex: 1;
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    padding-right: 8px;
}

.vm-filter-select-wrap.has-value .vm-custom-select-label {
    color: #171717;
    font-weight: 500;
}

/* Chevron arrow */
.vm-filter-select-arrow {
    display: flex;
    align-items: center;
    justify-content: center;
    color: #737373;
    flex-shrink: 0;
    transition: transform 0.25s cubic-bezier(0.4, 0, 0.2, 1), color 0.2s ease;
}

.vm-filter-select-wrap.is-open .vm-filter-select-arrow {
    transform: rotate(180deg);
    color: #225074;
}

/* Custom Dropdown Floating Menu */
.vm-custom-select-dropdown {
    position: absolute;
    top: calc(100% + 6px);
    left: 0;
    width: 100%;
    min-width: 190px;
    background: #ffffff;
    border: 1px solid #e2e8f0;
    border-radius: 12px;
    box-shadow: 0 10px 25px -5px rgba(15, 23, 42, 0.12), 0 8px 10px -6px rgba(15, 23, 42, 0.06);
    padding: 6px;
    z-index: 105;
    opacity: 0;
    visibility: hidden;
    transform: translateY(-6px);
    pointer-events: none;
    transition: opacity 0.18s cubic-bezier(0.16, 1, 0.3, 1),
                transform 0.18s cubic-bezier(0.16, 1, 0.3, 1),
                visibility 0.18s ease;
    box-sizing: border-box;
}

.vm-filter-select-wrap.is-open .vm-custom-select-dropdown {
    opacity: 1;
    visibility: visible;
    transform: translateY(0);
    pointer-events: auto;
}

.vm-custom-select-options {
    max-height: 240px;
    overflow-y: auto;
    overscroll-behavior: contain;
    padding-right: 2px;
}

/* Scrollbar styling */
.vm-custom-select-options::-webkit-scrollbar {
    width: 5px;
}
.vm-custom-select-options::-webkit-scrollbar-track {
    background: transparent;
}
.vm-custom-select-options::-webkit-scrollbar-thumb {
    background: #e2e8f0;
    border-radius: 4px;
}
.vm-custom-select-options::-webkit-scrollbar-thumb:hover {
    background: #cbd5e1;
}

/* Dropdown Option Items */
.vm-custom-select-option {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 9px 12px;
    border-radius: 8px;
    font-size: 13.5px;
    color: #737373;
    cursor: pointer;
    line-height: 1.4;
    font-weight: 400;
    transition: background-color 0.15s ease, color 0.15s ease;
    user-select: none;
}

.vm-custom-select-option:hover {
    background-color: rgba(34, 80, 116, 0.06);
    color: #225074;
}

/* Item được chọn: giữ nguyên màu xanh #225074 và nền #ebf4fc */
.vm-custom-select-option.is-selected {
    background-color: #ebf4fc;
    color: #225074;
    font-weight: 600;
}

.vm-option-check {
    color: #225074;
    flex-shrink: 0;
    margin-left: 8px;
}

/* Pill Submit Button */
.vm-filter-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    height: 42px;
    padding: 0 24px;
    background: linear-gradient(180deg, #225074 0%, #3075AA 100%);
    color: #ffffff;
    border: none;
    border-radius: 9999px;
    font-family: var(--wp--preset--font-family--noto-sans, "Noto Sans", sans-serif);
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    transition: opacity 0.2s ease, filter 0.2s ease;
    box-shadow: none;
    white-space: nowrap;
    outline: none;
    box-sizing: border-box;
}

.vm-filter-btn:hover {
    filter: brightness(1.08);
    box-shadow: none;
    transform: none;
}

.vm-filter-btn:active {
    filter: brightness(0.95);
    transform: none;
    box-shadow: none;
}

.vm-filter-btn-icon {
    flex-shrink: 0;
    display: block;
}

/* Responsive filter bar */
@media (max-width: 900px) {
    .vm-filter-item {
        flex: 1 1 calc(50% - 6px);
    }
    .vm-filter-item.vm-filter-action {
        flex: 1 1 100%;
    }
    .vm-filter-btn {
        width: 100%;
    }
}

@media (max-width: 480px) {
    .vm-filter-item {
        flex: 1 1 100%;
    }
    .vm-post-filter-bar {
        margin-bottom: 20px;
    }
}

/* ═══════════════════════════════════════════════════════════════
   Content Wrapper & Loading Overlay
   ═══════════════════════════════════════════════════════════════ */
.vm-post-list-content-wrap {
    position: relative;
    width: 100%;
    min-height: 120px;
}

.vm-post-list-inner {
    width: 100%;
    transition: opacity 0.25s ease, filter 0.25s ease;
}

.vm-post-list-content-wrap.is-loading .vm-post-list-inner {
    opacity: 0.4;
    filter: blur(1px);
    pointer-events: none;
    user-select: none;
}

.vm-post-list-loading-overlay {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    min-height: 160px;
    display: none;
    align-items: center;
    justify-content: center;
    z-index: 30;
    pointer-events: none;
}

.vm-post-list-content-wrap.is-loading .vm-post-list-loading-overlay {
    display: flex;
}

/* Equalizer Soundwave Loader */
.loader {
    --color-1: #225074;
    --size: 1px;

    width: calc(8 * var(--size));
    height: calc(40 * var(--size));
    border-radius: calc(4 * var(--size));
    display: block;
    margin: calc(20 * var(--size)) auto;
    position: relative;
    background: currentColor;
    color: var(--color-1);
    box-sizing: border-box;
    animation: animloader 0.3s 0.3s linear infinite alternate;
}

.loader::after,
.loader::before {
    content: '';
    width: calc(8 * var(--size));
    height: calc(40 * var(--size));
    border-radius: calc(4 * var(--size));
    background: currentColor;
    position: absolute;
    top: 50%;
    transform: translateY(-50%);
    left: calc(20 * var(--size));
    box-sizing: border-box;
    animation: animloader 0.3s 0.45s linear infinite alternate;
}

.loader::before {
    left: calc(-20 * var(--size));
    animation-delay: 0s;
}

@keyframes animloader {
    0% {
        height: calc(48 * var(--size));
    }
    100% {
        height: calc(4 * var(--size));
    }
}

