/* align-query-builder custom styles */
/* ==========================================================================
   1. GRID MODE
   ========================================================================== */
.align-qb-wrap--grid {
    display: grid;
    gap: 1.5rem;
    /* Default to 1 column */
    grid-template-columns: repeat(1, minmax(0, 1fr));
}
.align-qb-wrap--grid[data-qb-grid-cols="1"] { grid-template-columns: repeat(1, minmax(0, 1fr)); }
.align-qb-wrap--grid[data-qb-grid-cols="2"] { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.align-qb-wrap--grid[data-qb-grid-cols="3"] { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.align-qb-wrap--grid[data-qb-grid-cols="4"] { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.align-qb-wrap--grid[data-qb-grid-cols="5"] { grid-template-columns: repeat(5, minmax(0, 1fr)); }
.align-qb-wrap--grid[data-qb-grid-cols="6"] { grid-template-columns: repeat(6, minmax(0, 1fr)); }
/* Basic responsive rules for Grid */
@media (max-width: 1024px) {
    .align-qb-wrap--grid {
        grid-template-columns: repeat(2, minmax(0, 1fr)) !important;
    }
}
@media (max-width: 640px) {
    .align-qb-wrap--grid {
        grid-template-columns: 1fr !important;
    }
}
/* ==========================================================================
   2. SLIDER MODE (EDITOR PREVIEW FIX)
   ========================================================================== */
/* In the Editor screen, use Flexbox to simulate horizontal display for better preview */
.editor-styles-wrapper [data-type="align/query-builder"] .block-editor-block-list__layout.align_custom_block,
.editor-styles-wrapper [data-type="align/query-builder"] .block-editor-block-list__layout.swiper-wrapper,
.editor-styles-wrapper .align-qb-wrap--slider .swiper-wrapper {
    display: flex !important;
    flex-wrap: nowrap !important;
    flex-direction: row !important;
    overflow-x: auto !important;
    gap: 1rem;
    padding-bottom: 1rem;
}
.editor-styles-wrapper [data-type="align/swiper-slide"].swiper-slide,
.align-qb-wrap--slider .swiper-slide {
    flex-shrink: 0 !important;
}
/* ==========================================================================
   3. BASIC CARD STYLES (Prevent basic layout breakage)
   ========================================================================== */
.align-qb-card {
    display: flex;
    flex-direction: column;
    height: 100%;
    overflow: hidden;
    position: relative;
    font-family: inherit;
    text-decoration: none;
    background: #fff;
    border-radius: 8px;
    box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.1);
    transition: box-shadow 0.3s ease;
}
.align-qb-card:hover {
    box-shadow: 0 10px 15px -3px rgba(0, 0, 0, 0.1);
}
.align-qb-card--overlay .align-qb-image {
    position: absolute;
    inset: 0;
    z-index: 0;
}
.align-qb-card--overlay .align-qb-image img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}
.align-qb-card--overlay .align-qb-content {
    position: relative;
    z-index: 10;
    padding: 1.5rem;
    margin-top: auto;
    background: linear-gradient(to top, rgba(0,0,0,0.8), transparent);
    color: #fff;
}
.align-qb-card--stacked .align-qb-image-link {
    display: block;
    position: relative;
    aspect-ratio: 16/9;
    overflow: hidden;
}
.align-qb-card--stacked .align-qb-image img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}
.align-qb-card--stacked .align-qb-content {
    padding: 1.5rem;
    display: flex;
    flex-direction: column;
    flex-grow: 1;
}
.align-qb-title {
    font-size: 1.25rem;
    font-weight: bold;
    margin: 0.5rem 0;
    color: inherit;
    text-decoration: none;
}
.align-qb-excerpt {
    font-size: 0.875rem;
    color: #666;
    margin-bottom: 1rem;
}
.align-qb-card--overlay .align-qb-excerpt {
    color: #eee;
}
.align-qb-badge-wrap {
    position: absolute;
    top: 1rem;
    left: 1rem;
    z-index: 20;
}
.align-qb-badge {
    background: #2563eb;
    color: #fff;
    font-size: 0.75rem;
    font-weight: bold;
    padding: 0.25rem 0.75rem;
    border-radius: 9999px;
    text-transform: uppercase;
}
.align-qb-meta--date {
    font-size: 0.75rem;
    opacity: 0.8;
    text-transform: uppercase;
}
.align-qb-readmore-wrap {
    margin-top: auto;
}
.align-qb-readmore {
    color: #2563eb;
    font-size: 0.875rem;
    font-weight: bold;
    display: inline-flex;
    align-items: center;
    text-decoration: none;
}
.align-qb-icon {
    width: 1rem;
    height: 1rem;
    margin-left: 0.25rem;
}
/* Pagination */
.align-qb-pagination {
    margin-top: 2rem;
    text-align: center;
    width: 100%;
}
.qb-load-more-btn {
    padding: 0.5rem 1.5rem;
    background: #2563eb;
    color: #fff;
    border: none;
    border-radius: 6px;
    font-weight: bold;
    cursor: pointer;
}
.qb-infinite-trigger {
    padding: 2rem 0;
    display: flex;
    justify-content: center;
    align-items: center;
    width: 100%;
}
.align-spinner {
    animation: align-rotate 2s linear infinite;
    width: 32px;
    height: 32px;
}
.align-spinner .path {
    stroke: #2563eb;
    stroke-linecap: round;
    animation: align-dash 1.5s ease-in-out infinite;
}

@keyframes align-rotate {
    100% {
        transform: rotate(360deg);
    }
}
@keyframes align-dash {
    0% {
        stroke-dasharray: 1, 150;
        stroke-dashoffset: 0;
    }
    50% {
        stroke-dasharray: 90, 150;
        stroke-dashoffset: -35;
    }
    100% {
        stroke-dasharray: 90, 150;
        stroke-dashoffset: -124;
    }
}

/* ==========================================================================
   4. CUSTOM SELECT CONTROL STYLES (Extracted from editor.js)
   ========================================================================== */
.align-custom-select-wrapper label {
    display: block;
    margin-bottom: 8px;
    font-size: 13px;
    color: #1e1e1e;
}
.align-custom-select-wrapper .align-select-btn {
    width: 100%;
    text-align: left;
    padding: 6px 12px;
    font-size: 13px;
    line-height: normal;
    background: #fff;
    border: 1px solid #757575;
    border-radius: 2px;
    cursor: pointer;
    display: flex;
    justify-content: space-between;
    align-items: center;
    min-height: 30px;
    color: #1e1e1e;
}
.align-custom-select-wrapper .align-select-btn:focus,
.align-custom-select-wrapper .align-select-btn:active {
    outline: none !important;
    box-shadow: none !important;
    border-color: #757575 !important;
}
.align-custom-select-wrapper.is-open .align-select-btn {
    border-bottom-left-radius: 0;
    border-bottom-right-radius: 0;
}
.align-custom-select-wrapper .align-select-dropdown {
    position: absolute;
    top: 100%;
    left: 0;
    width: 100%;
    background: #fff;
    border: 1px solid #757575;
    border-top: none;
    border-radius: 0 0 2px 2px;
    box-shadow: 0 4px 8px rgba(0,0,0,0.1);
    z-index: 999999;
    max-height: 250px;
    overflow-y: auto;
}
.align-custom-select-wrapper .align-select-opt {
    padding: 8px 12px;
    cursor: pointer;
    font-size: 13px;
    color: #1e1e1e;
}
.align-custom-select-wrapper .align-select-opt:hover {
    background: #f0f0f0;
}
.align-custom-select-wrapper .align-select-opt.is-disabled {
    opacity: 0.5;
    cursor: not-allowed;
    background: #f8f8f8;
    font-weight: bold;
}
.align-custom-select-arrow {
    border-left: 4px solid transparent;
    border-right: 4px solid transparent;
    border-top: 4px solid #757575;
    margin-left: 8px;
}
.align-custom-select-wrapper.is-open .align-custom-select-arrow {
    border-top: none;
    border-bottom: 4px solid #757575;
}

/* Prevent text/block selection highlighting on all Swiper sliders (both FE and BE Editor) */
.swiper,
.swiper-slide,
.align-swiper-slider,
.editor-styles-wrapper .swiper,
.editor-styles-wrapper .swiper-slide,
.editor-styles-wrapper .align-swiper-slider {
    -webkit-user-select: none !important;
    -moz-user-select: none !important;
    -ms-user-select: none !important;
    user-select: none !important;
}

/* Ensure inputs, textareas and contenteditable fields remain selectable */
.swiper input,
.swiper textarea,
.swiper [contenteditable="true"],
.editor-styles-wrapper .swiper input,
.editor-styles-wrapper .swiper textarea,
.editor-styles-wrapper .swiper [contenteditable="true"] {
    -webkit-user-select: text !important;
    -moz-user-select: text !important;
    -ms-user-select: text !important;
    user-select: text !important;
}

/* ==========================================================================
   8. CUSTOM DOT TEXT LABELS
   ========================================================================== */
.align-qb-dot-text.swiper-pagination-bullet {
    width: auto;
    height: auto;
    border-radius: 0;
    background: transparent;
    opacity: 0.5;
    font-size: 14px;
    line-height: 1.4;
    padding: 4px 8px;
    transition: opacity 0.3s ease, color 0.3s ease;
}
.align-qb-dot-text.swiper-pagination-bullet-active {
    opacity: 1;
    background: transparent;
}
