/**
 * YF Boat Archive Unified Widget Styles
 *
 * Combines filters, drawer, results count bar, listing cards, loading spinner,
 * and paginated navigation styles. Supports side-by-side or top alignments.
 *
 * @package YachtFriends\Elementor
 */

/* ── Combined Wrapper Layouts ──────────────────────────────────────────────── */

.yf-archive-widget {
    width: 100%;
}

/* Side Layout (left or right positioning) */
.yf-archive-widget.layout-side {
    display: flex;
    gap: 30px;
    align-items: flex-start;
}

.yf-archive-widget.layout-side.filter-position-left {
    flex-direction: row;
}

.yf-archive-widget.layout-side.filter-position-right {
    flex-direction: row-reverse;
}

.yf-archive-widget.layout-side .yf-archive-sidebar-wrapper {
    flex: 0 0 280px;
    width: 280px;
    position: -webkit-sticky;
    position: sticky;
    top: 120px;
    align-self: flex-start;
}

.yf-archive-widget.layout-side .yf-archive-grid-wrapper {
    flex: 1;
    min-width: 0;
}

/* Top Layout (stacked positioning) */
.yf-archive-widget.layout-top {
    display: flex;
    flex-direction: column;
    gap: 30px;
}

.yf-archive-widget.layout-top .yf-archive-sidebar-wrapper {
    width: 100%;
}

.yf-archive-widget.layout-top .yf-archive-grid-wrapper {
    width: 100%;
}


/* ── Filters Sidebar Block ────────────────────────────────────────────────── */

.yf-archive-filter-box {
    position: relative;
    background-color: #ffffff;
    border: 1px solid #e2e8f0;
    border-radius: 16px;
    padding: 24px 20px;
    box-shadow: 0 4px 24px rgba(0, 0, 0, 0.05);
    box-sizing: border-box;
}

.yf-archive-filter-close-btn {
    position: absolute;
    top: 14px;
    right: 14px;
    background: none;
    border: none;
    color: #6b7280;
    font-size: 16px;
    cursor: pointer;
    line-height: 1;
    padding: 4px 6px;
    border-radius: 6px;
    transition: background-color 0.2s ease, color 0.2s ease;
    display: none; /* hidden on desktop */
}

.yf-archive-filter-close-btn:hover {
    background-color: #f3f4f6;
    color: #111827;
}

 body h3.yf-archive-filter-title {
    font-size: 1.25rem;
    font-weight: 700;
    color: #1a6985;
    margin: 0 0 20px;
    padding-bottom: 12px;
    border-bottom: 1px solid #e2e8f0;
    display: flex;
    align-items: center;
    gap: 10px;
    box-sizing: border-box;
}

.yf-archive-filter-title i,
.yf-archive-filter-title svg {
    font-size: 1.15rem;
    width: 1em;
    height: 1em;
    line-height: 1;
    display: inline-flex;
    align-items: center;
    justify-content: center;
}

.yf-archive-filter-form {
    display: flex;
    flex-direction: column;
    gap: 0;
}

.yf-archive-filter-groups {
    display: grid;
    gap: 18px;
}

.yf-archive-filter-groups.cols-1 { grid-template-columns: 1fr; }
.yf-archive-filter-groups.cols-2 { grid-template-columns: repeat(2, 1fr); }
.yf-archive-filter-groups.cols-3 { grid-template-columns: repeat(3, 1fr); }
.yf-archive-filter-groups.cols-4 { grid-template-columns: repeat(4, 1fr); }
.yf-archive-filter-groups.cols-6 { grid-template-columns: repeat(6, 1fr); }

.yf-archive-filter-group {
    display: flex;
    flex-direction: column;
}

.yf-archive-filter-group label {
    display: flex;
    align-items: center;
    gap: 7px;
    font-size: 0.82rem;
    font-weight: 600;
    color: #475569;
    margin-bottom: 8px;
}

.yf-archive-filter-group label i {
    color: #6c9e9e;
    font-size: 0.9em;
    width: 14px;
    text-align: center;
}

.yf-archive-filter-input {
    width: 100%;
    height: 42px;
    padding: 8px 12px;
    font-size: 0.875rem;
    color: #374151;
    background-color: #f8fafc;
    border: 1.5px solid #e2e8f0;
    border-radius: 8px;
    outline: none;
    transition: border-color 0.2s ease, background-color 0.2s ease, box-shadow 0.2s ease;
    appearance: none;
    -webkit-appearance: none;
    box-sizing: border-box;
}

select.yf-archive-filter-input {
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 20 20' fill='%236b7280'%3E%3Cpath fill-rule='evenodd' d='M5.293 7.293a1 1 0 011.414 0L10 10.586l3.293-3.293a1 1 0 111.414 1.414l-4 4a1 1 0 01-1.414 0l-4-4a1 1 0 010-1.414z' clip-rule='evenodd'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 10px center;
    background-size: 18px;
    padding-right: 34px;
    cursor: pointer;
}

.yf-archive-filter-input:focus {
    border-color: #1a6985;
    background-color: #ffffff;
    box-shadow: 0 0 0 3px rgba(26, 105, 133, 0.12);
}

.yf-archive-filter-input::placeholder {
    color: #9ca3af;
}

/* Range Inputs */
.yf-archive-filter-range {
    display: flex;
    align-items: center;
    gap: 8px;
}

.yf-archive-filter-range-input {
    flex: 1;
    min-width: 0;
}

.yf-archive-filter-range-sep {
    color: #9ca3af;
    font-size: 0.85rem;
    flex-shrink: 0;
}

/* Actions */
.yf-archive-filter-actions {
    display: flex;
    flex-direction: column;
    gap: 10px;
    margin-top: 24px;
}

/* Apply button */
.yf-archive-filter-apply-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    width: 100%;
    padding: 11px 20px;
    font-size: 0.875rem;
    font-weight: 600;
    color: #ffffff;
    background-color: #1a6985;
    border: 2px solid #1a6985;
    border-radius: 8px;
    cursor: pointer;
    transition: background-color 0.2s ease, border-color 0.2s ease, transform 0.15s ease;
    letter-spacing: 0.02em;
}

.yf-archive-filter-apply-btn:hover {
    background-color: #15546b;
    border-color: #15546b;
    transform: translateY(-1px);
}

/* Reset button */
.yf-archive-filter-reset-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    width: 100%;
    padding: 10px 20px;
    font-size: 0.82rem;
    font-weight: 600;
    color: #636e72;
    background-color: transparent;
    border: 1.5px solid #dfe6e9;
    border-radius: 8px;
    cursor: pointer;
    transition: background-color 0.2s ease, color 0.2s ease, border-color 0.2s ease;
    letter-spacing: 0.02em;
}

.yf-archive-filter-reset-btn:hover {
    background-color: #f8fafc;
    color: #2d3436;
    border-color: #b2bec3;
}


/* ── Results count bar ─────────────────────────────────────────────────────── */

.yf-archive-results-bar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    background-color: #f0f4ff;
    border-radius: 8px;
    padding: 10px 16px;
    margin-bottom: 20px;
}

.yf-archive-results-count {
    font-size: 0.85rem;
    font-weight: 500;
    color: #374151;
}


/* ── Cards grid container ──────────────────────────────────────────────────── */

.yf-archive-grid-container {
    position: relative;
}

/* Loading overlay */
.yf-archive-loading-overlay {
    position: absolute;
    inset: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    background: rgba(255, 255, 255, 0.85);
    z-index: 10;
    border-radius: 12px;
    backdrop-filter: blur(2px);
}

.yf-archive-spinner {
    font-size: 2rem;
    color: #1a6985;
    animation: yf-pulse 1.2s ease-in-out infinite;
}

@keyframes yf-pulse {
    0%, 100% { transform: scale(0.6); opacity: 0.4; }
    50%      { transform: scale(1.2); opacity: 1; }
}

/* The Grid */
.yf-archive-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 24px;
}


/* ── Card ─────────────────────────────────────────────────────────────────── */

.yf-archive-card {
    display: flex;
    flex-direction: column;
    background-color: #ffffff;
    border-radius: 16px;
    overflow: hidden;
    box-shadow: 0 2px 16px rgba(0, 0, 0, 0.05);
    transition: transform 0.3s ease, box-shadow 0.3s ease;
    will-change: transform;
    border: 1px solid #f0f0f0;
}

.yf-archive-card:hover {
    transform: translateY(-6px);
    box-shadow: 0 12px 40px rgba(0, 0, 0, 0.1);
}

/* Card Image */
.yf-archive-card-image {
    position: relative;
    height: 220px;
    overflow: hidden;
    border-radius: 16px 16px 0 0;
    background-color: #e5e7eb;
}

.yf-archive-card-image img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
    transition: transform 0.5s ease;
}

.yf-archive-card:hover .yf-archive-card-image img {
    transform: scale(1.04);
}

.yf-archive-card-image::after {
    content: '';
    position: absolute;
    inset: 0;
    background-color: transparent;
    transition: background-color 0.3s ease;
    pointer-events: none;
}

.yf-archive-card:hover .yf-archive-card-image::after {
    background-color: rgba(0, 0, 0, 0.05);
}

/* Price Badge */
.yf-archive-card-price {
    position: absolute;
    bottom: 12px;
    left: 12px;
    background-color: #1a6985;
    color: #ffffff;
    font-size: 0.8rem;
    font-weight: 700;
    padding: 5px 10px;
    border-radius: 8px;
    z-index: 2;
    letter-spacing: 0.02em;
    white-space: nowrap;
    box-shadow: 0 4px 10px rgba(0, 0, 0, 0.15);
}

/* Card Content */
.yf-archive-card-content {
    display: flex;
    flex-direction: column;
    flex: 1;
    padding: 18px 18px 20px;
}

/* Title */
.yf-archive-card-title {
    font-size: 1.15rem;
    font-weight: 700;
    margin: 0 0 10px;
    line-height: 1.35;
}

.yf-archive-card-title a {
    color: #2d3436;
    text-decoration: none;
    transition: color 0.2s ease;
}

.yf-archive-card-title a:hover,
.yf-archive-card:hover .yf-archive-card-title a {
    color: #1a6985;
}

/* Meta */
.yf-archive-card-meta {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 12px;
    margin-bottom: 12px;
}

.yf-archive-card-meta-item {
    display: flex;
    align-items: center;
    gap: 5px;
    position: relative;
}

.yf-archive-card-meta-item + .yf-archive-card-meta-item::before {
    content: '';
    display: inline-block;
    width: 4px;
    height: 4px;
    border-radius: 50%;
    background-color: #d1d5db;
    position: absolute;
    left: -8px;
    top: 50%;
    transform: translateY(-50%);
}

.yf-archive-card-meta-item i {
    color: #6c9e9e;
    font-size: 13px;
    width: 16px;
    text-align: center;
}

.yf-archive-card-meta-item span {
    font-size: 0.8rem;
    color: #636e72;
    font-weight: 500;
    white-space: nowrap;
}

/* Excerpt */
.yf-archive-card-excerpt {
    font-size: 0.83rem;
    color: #636e72;
    line-height: 1.6;
    flex: 1;
    margin-bottom: 16px;
    display: -webkit-box;
    -webkit-line-clamp: 3;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

/* Footer & Button */
.yf-archive-card-footer {
    margin-top: auto;
}

.yf-archive-card-btn {
    display: block;
    text-align: center;
    width: 100%;
    padding: 10px 20px;
    background-color: #6c9e9e;
    color: #ffffff;
    font-size: 0.85rem;
    font-weight: 600;
    border-radius: 8px;
    text-decoration: none;
    border: 2px solid #6c9e9e;
    letter-spacing: 0.02em;
    box-sizing: border-box;
    transition: background-color 0.2s ease, color 0.2s ease, border-color 0.2s ease, transform 0.15s ease;
}

.yf-archive-card-btn:hover {
    background-color: #5a8a8a;
    border-color: #5a8a8a;
    color: #ffffff;
    transform: translateY(-1px);
}

.yf-archive-card-btn:active {
    transform: translateY(0);
}


/* ── No Results ───────────────────────────────────────────────────────────── */

.yf-archive-no-results {
    grid-column: 1 / -1;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 60px 20px;
    text-align: center;
    color: #6b7280;
}

.yf-archive-no-results-icon {
    font-size: 3rem;
    color: #d1d5db;
    margin-bottom: 16px;
}

.yf-archive-no-results p {
    font-size: 1rem;
    color: #9ca3af;
    margin: 0;
}


/* ── Pagination ───────────────────────────────────────────────────────────── */

.yf-archive-pagination {
    margin-top: 32px;
    display: flex;
    justify-content: center;
}

.yf-archive-pagination .nav-links {
    display: flex;
    align-items: center;
    gap: 6px;
    flex-wrap: wrap;
    justify-content: center;
}

.yf-archive-pagination .page-numbers {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 38px;
    height: 38px;
    padding: 0 8px;
    border-radius: 6px;
    font-size: 0.875rem;
    font-weight: 500;
    color: #2d3436;
    text-decoration: none;
    background-color: #ffffff;
    border: 1px solid #dfe6e9;
    transition: background-color 0.2s ease, color 0.2s ease, border-color 0.2s ease;
}

.yf-archive-pagination .page-numbers:hover {
    background-color: #6c9e9e;
    color: #ffffff;
    border-color: #6c9e9e;
}

.yf-archive-pagination .page-numbers.current {
    background-color: #6c9e9e;
    color: #ffffff;
    border-color: #6c9e9e;
    font-weight: 700;
}

.yf-archive-pagination .page-numbers.dots {
    border-color: transparent;
    background-color: transparent;
    pointer-events: none;
}


/* ── Mobile & Responsive Off-Canvas Toggle ──────────────────────────────── */

/* Hide mobile toggle by default on desktop */
.yf-mobile-filter-toggle {
    display: none;
}

/* Hide mobile backdrop by default */
.yf-sidebar-backdrop {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    background: rgba(15, 23, 42, 0.4);
    backdrop-filter: blur(4px);
    z-index: 99998;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

.yf-sidebar-backdrop.is-visible {
    opacity: 1;
    pointer-events: auto;
}

body.yf-sidebar-open {
    overflow: hidden;
}

@media (max-width: 991px) {
    .yf-archive-widget.layout-side {
        flex-direction: column !important;
    }

    .yf-mobile-filter-toggle {
        display: flex;
        align-items: center;
        justify-content: center;
        gap: 8px;
        width: 100%;
        padding: 12px 24px;
        background-color: #1a6985;
        color: #ffffff !important;
        border: none;
        border-radius: 8px;
        font-weight: 700;
        font-size: 1rem;
        cursor: pointer;
        margin-bottom: 20px;
        transition: all 0.3s ease;
        box-shadow: 0 4px 6px rgba(26, 105, 133, 0.15);
        box-sizing: border-box;
    }

    .yf-mobile-filter-toggle:hover {
        background-color: #15546b;
    }

    /* Force mobile Sidebar Off-Canvas behavior regardless of desktop layout settings */
    .yf-archive-sidebar-wrapper {
        position: fixed !important;
        top: 0 !important;
        left: 0 !important;
        width: 320px !important;
        max-width: 85% !important;
        height: 100vh !important;
        z-index: 99999 !important;
        background-color: #ffffff !important;
        box-shadow: 5px 0 25px rgba(0, 0, 0, 0.15) !important;
        transform: translateX(-100%) !important;
        transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1) !important;
        overflow-y: auto !important;
        margin-bottom: 0 !important;
        box-sizing: border-box !important;
        align-self: stretch !important;
    }

    .yf-archive-sidebar-wrapper.is-open {
        transform: translateX(0) !important;
    }

    .yf-archive-sidebar-wrapper .yf-archive-filter-close-btn {
        display: flex;
        position: absolute;
        top: 24px;
        right: 24px;
        background-color: #f1f5f9;
        color: #475569;
        border: none;
        border-radius: 50%;
        width: 36px;
        height: 36px;
        align-items: center;
        justify-content: center;
        font-size: 1.1rem;
        cursor: pointer;
        transition: all 0.2s ease;
        z-index: 10;
        box-sizing: border-box;
    }

    .yf-archive-sidebar-wrapper .yf-archive-filter-close-btn:hover {
        background-color: #e2e8f0;
        color: #1e293b;
    }

    .yf-archive-sidebar-wrapper .yf-archive-filter-box {
        border: none !important;
        border-radius: 0 !important;
        padding: 30px 24px !important;
        min-height: 100% !important;
        box-shadow: none !important;
        max-height: none !important;
        overflow-y: visible !important;
        box-sizing: border-box !important;
    }

    .yf-archive-sidebar-wrapper .yf-archive-filter-title {
        padding-right: 40px;
    }

    /* Force columns inside the mobile drawer to collapse to single stack */
    .yf-archive-filter-groups {
        grid-template-columns: 1fr !important;
    }
}

@media (max-width: 1024px) {
    .yf-archive-grid {
        grid-template-columns: repeat(2, 1fr) !important;
    }
}

@media (max-width: 640px) {
    .yf-archive-grid {
        grid-template-columns: 1fr !important;
        gap: 16px !important;
    }

    .yf-archive-card-image {
        height: 200px !important;
    }

    .yf-archive-results-bar {
        flex-direction: column !important;
        align-items: flex-start !important;
        gap: 8px !important;
    }
}

/* Mobile Toggle alignment classes */
@media (max-width: 991px) {
    .yf-mobile-toggle-align-left .yf-mobile-filter-toggle {
        display: inline-flex !important;
        width: auto !important;
        margin-left: 0 !important;
        margin-right: auto !important;
    }
    .yf-mobile-toggle-align-center .yf-mobile-filter-toggle {
        display: inline-flex !important;
        width: auto !important;
        margin-left: auto !important;
        margin-right: auto !important;
    }
    .yf-mobile-toggle-align-right .yf-mobile-filter-toggle {
        display: inline-flex !important;
        width: auto !important;
        margin-left: auto !important;
        margin-right: 0 !important;
    }
    .yf-mobile-toggle-align-justify .yf-mobile-filter-toggle {
        display: flex !important;
        width: 100% !important;
        margin-left: 0 !important;
        margin-right: 0 !important;
    }
}

/* Custom styled inputs for range selection (Min/Max fields) */
.yf-archive-filter-range-input,
.yf-range-input {
    height: 44px !important;
    padding: 8px 12px !important;
    font-size: 14px !important;
    color: #1e293b !important;
    background-color: #ffffff !important;
    background-image: none !important;
    border: 1px solid #e2e8f0 !important;
    border-radius: 8px !important;
    box-shadow: 0 1px 2px 0 rgba(0, 0, 0, 0.05) !important;
    box-sizing: border-box !important;
    text-align: left !important;
    outline: none !important;
    transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1) !important;
}

.yf-archive-filter-range-input:hover,
.yf-range-input:hover {
    border-color: #cbd5e1 !important;
    background-color: #f8fafc !important;
}

.yf-archive-filter-range-input:focus,
.yf-range-input:focus {
    border-color: #0284c7 !important;
    background-color: #ffffff !important;
    box-shadow: 0 0 0 3px rgba(2, 132, 199, 0.15) !important;
}

/* Stacked Date Availability Layout for Widget */
.yf-archive-filter-date-wrapper {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 8px;
    width: 100%;
}

.yf-archive-date-input {
    width: 100% !important;
    box-sizing: border-box;
}

.yf-archive-date-arrow {
    color: #6c9e9e;
    font-size: 1.1rem;
    margin: 2px 0;
    display: flex;
    align-items: center;
    justify-content: center;
}
