/* Give Form Grid Enhanced Styles */
.give-form-grid-enhanced-wrapper {
    width: 100%;
}

/* Filter Buttons */
.give-form-grid-filter {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    margin-bottom: 30px;
    justify-content: center;
}

.give-form-grid-filter .filter-btn {
    padding: 10px 20px;
    background-color: #f5f5f5;
    border: 1px solid #ddd;
    border-radius: 4px;
    cursor: pointer;
    transition: all 0.3s ease;
    font-size: 14px;
    font-weight: 500;
    color: #333;
}

.give-form-grid-filter .filter-btn:hover {
    background-color: #e9e9e9;
    border-color: #bbb;
}

.give-form-grid-filter .filter-btn.active {
    background-color: #69b86b;
    color: #fff;
    border-color: #69b86b;
}

/* Flexbox Grid */
.give-form-grid-enhanced {
    display: flex;
    flex-wrap: wrap;
    gap: 30px;
    width: 100%;
    --columns: 3;
    align-items: stretch;
    /* Ensure all cards have equal height */
    align-content: flex-start;
    /* Align rows to start */
}

/* Ensure each row has equal height items */
.give-form-grid-enhanced>.give-form-grid-item {
    display: flex;
    flex-direction: column;
}

.give-form-grid-enhanced.loading {
    min-height: 200px;
    position: relative;
}

.give-form-grid-enhanced .loading-spinner {
    text-align: center;
    padding: 50px;
    font-size: 16px;
    color: #666;
}

/* Grid Items - Using Campaign Widget Styles */
.give-form-grid-item {
    flex: 0 0 calc((100% - (30px * (var(--columns) - 1))) / var(--columns));
    min-width: 0;
    display: flex !important;
    /* Make grid items flex containers */
    flex-direction: column;
    /* Stack content vertically */
    align-items: stretch;
    /* Ensure items stretch to match tallest */
    align-self: stretch;
    /* Force item to stretch */
}

/* Campaign Widget Styles - when combined with give-form-grid-item */
.give-form-grid-item.give-campaigns-component-campaign {
    background-color: #fff;
    border: 1px solid var(--neutral-100, #e5e7eb);
    border-radius: 8px;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
    padding: 0;
    transition: transform 0.3s ease, box-shadow 0.3s ease;
    flex-direction: column !important;
    /* Override any other flex-direction */
    width: 100%;
    /* Ensure full width */
    flex-grow: 1;
    flex-basis: 30%;
    height: 100%;
    min-height: 490px;
}

/* Campaign Widget Styles - standalone */
.give-campaigns-component-campaign {
    background-color: #fff;
    border: 1px solid var(--neutral-100, #e5e7eb);
    border-radius: 8px;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
    padding: 0;
    transition: transform 0.3s ease, box-shadow 0.3s ease;
    display: flex;
    flex-direction: column;
    height: 100%;
    width: 100%;
    /* Ensure full width */
    flex: 1 1 auto;
    /* Grow and shrink as needed */
}

.give-campaigns-component-campaign:hover,
.give-form-grid-item.give-campaigns-component-campaign:hover {
    transform: translateY(-5px);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
}

.give-campaigns-component-campaign-image {
    border-radius: 8px 8px 0 0;
    width: 100%;
    overflow: hidden;
    /* Prevent figure from overflowing */
    flex-shrink: 0;
    /* Don't shrink the image */
    position: relative;
}

.give-campaigns-component-campaign-image figure {
    background-size: cover;
    background-position: center;
    width: 100%;
    height: 100%;
    margin: 0;
    padding: 0;
    transition: transform 0.5s ease;
}

.give-campaigns-component-campaign:hover .give-campaigns-component-campaign-image figure {
    transform: scale(1.1);
}

/* Content wrapper - takes remaining space */
.give-campaigns-component-campaign-content {
    display: flex;
    flex-direction: column;
    flex: 1 1 auto;
    padding-bottom: 8px;
    min-height: 0;
    /* Allow flex shrinking */
}

.give-campaigns-component-campaign-title {
    color: #060c1a;
    font-size: 16px;
    font-weight: 700;
    line-height: 1.5;
    padding: 8px;

    .give-campaigns-component-campaign-title__link {
        text-decoration: none;
        color: inherit;
        display: inline-flex;
        align-items: center;
        gap: 6px;
    }

    .give-campaigns-component-campaign-title__link:hover {
        text-decoration: underline;
    }

    flex-shrink: 0;
    /* Don't shrink title */
}

.give-campaigns-component-campaign-description {
    color: #363636;
    font-size: 14px;
    font-weight: 400;
    line-height: 1.43;
    padding: 0 8px;
    flex-shrink: 0;
    /* Don't shrink description */
}

.give-campaigns-component-campaign__goal {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
    margin-top: auto;
    /* Push goal to bottom of content area */
    padding: 8px;
    flex-shrink: 0;
    /* Don't shrink goal */
}

/* Spacer for cards without goals - added via PHP to maintain equal height */
.give-campaigns-component-campaign-goal-spacer {
    margin-top: auto;
    flex: 0 0 auto;
    /* Don't grow or shrink */
    /* This spacer will push content up and maintain space at bottom */
    min-height: 1px;
    /* Minimum height to ensure it takes space */
}

.give-campaigns-component-campaign__goal-container {
    display: flex;
    flex-direction: row;
    justify-content: space-between;
}

.give-campaigns-component-campaign__goal-container-item {
    display: flex;
    flex-direction: column;
}

.give-campaigns-component-campaign__goal-container-item span {
    color: #4b5563;
    font-size: 12px;
    font-weight: 600;
    letter-spacing: 0.48px;
    line-height: 1.5;
    text-transform: uppercase;
}

.give-campaigns-component-campaign__goal-container-item strong {
    color: #060c1a;
    font-size: 16px;
    font-weight: 600;
    line-height: 1.5;
}

.give-campaigns-component-campaign__goal-container-item:first-child {
    margin-bottom: 8px;
}

.give-campaigns-component-campaign__goal-progress {
    display: flex;
}

.give-campaigns-component-campaign__goal-progress-container {
    background-color: #f2f2f2;
    border-radius: 14px;
    box-shadow: inset 0 1px 4px 0 rgba(0, 0, 0, 0.09);
    display: flex;
    flex-grow: 1;
    height: 8px;
    overflow: hidden;
}

.give-campaigns-component-campaign__goal-progress-bar {
    background: var(--givewp-secondary-color, #2d802f);
    border-radius: 14px;
    box-shadow: inset 0 1px 4px 0 rgba(0, 0, 0, 0.09);
    display: flex;
    height: 8px;
    transition: width 0.3s ease;
}

/* Button container - always at bottom */
.give-campaigns-component-campaign-button-wrapper {
    padding: 8px;
    margin-top: auto;
    flex-shrink: 0;
    display: flex;
    gap: 12px;
    flex-wrap: wrap;
}

/* When only one button, center it and make it 90% width */
.give-campaigns-component-campaign-button-wrapper .give-campaigns-component-campaign-button:only-child {
    flex: 0 0 100% !important;
    max-width: 100% !important;
    margin: 0 auto;
}

/* Center the wrapper when only one button */
.give-campaigns-component-campaign-button-wrapper:has(.give-campaigns-component-campaign-button:only-child) {
    justify-content: center;
}

.give-campaigns-component-campaign-button {
    flex: 1 1 calc(50% - 6px);
    display: flex;
}

.give-campaigns-component-campaign-button--donate,
.give-campaigns-component-campaign-button--view {
    width: 100%;
}

/* Button styles */
.give-donate-button,
.give-view-campaign-button {
    display: inline-block;
    text-decoration: none;
    font-weight: 600;
    text-align: center;
    width: 100%;
    box-sizing: border-box;
    color: #ffffff;
    background-color: var(--givewp-primary-color, #0b72d9);
    border-radius: 4px;
    padding: 10px 20px;
    transition: background-color 0.3s ease, color 0.3s ease;
}

.give-view-campaign-button {
    display: flex;
    align-items: center;
    text-align: center;
    justify-content: center;
    background-color: var(--givewp-secondary-color, #27ae60);
}

.give-campaigns-component-campaign-button-wrapper .givewp-donation-form-modal__open {
    display: inline-block;
    width: 100%;
    box-sizing: border-box;
    background-color: var(--givewp-primary-color, #0b72d9);
    border-radius: 4px;
    padding: 10px 20px;
    transition: background-color 0.3s ease, color 0.3s ease;
}

.givewp-donation-form-modal__open .give-donate-button {
    background: transparent !important;
    color: inherit !important;
    padding: 0;
    border: 0;
    width: 100%;
}

/* Ensure modal wrapper is transparent to match GiveWP modal styling */
.give-donation-grid-item-form {
    background: transparent !important;
    padding: 0;
    height: 100%;
}

/* Optimize iframe loading - start collapsed, expand on modal open */
.give-donation-grid-item-form.mfp-hide iframe {
    height: 0px !important;
    min-height: 0px !important;
    visibility: hidden;
    opacity: 0;
    transition: height 0.3s ease, visibility 0.3s ease, opacity 0.3s ease;
}

/* Expand iframe when modal is visible */
.give-donation-grid-item-form:not(.mfp-hide) iframe,
.mfp-ready .give-donation-grid-item-form iframe,
.mfp-container .give-donation-grid-item-form iframe {
    height: auto !important;
    min-height: 600px !important;
    max-height: 90vh !important;
    visibility: visible !important;
    opacity: 1 !important;
    width: 100% !important;
}

/* Ensure modal container is properly sized */
.mfp-container .give-donation-grid-item-form {
    max-width: 90vw !important;
    max-height: 90vh !important;
    width: 100% !important;
    margin: 0 auto !important;
    overflow: visible !important;
}

.mfp-container .give-donation-grid-item-form .modal-content {
    max-width: 100% !important;
    width: 100% !important;
    overflow: visible !important;
    padding: 20px !important;
}

/* Ensure iframe container is properly sized */
.mfp-container .root-data-givewp-embed {
    width: 100% !important;
    max-width: 100% !important;
    overflow: visible !important;
}

.givewp-donation-form-modal__open {
    position: relative;
}

.givewp-donation-form-modal__open__label {
    display: inline-block;
}

.givewp-donation-form-modal__open__spinner {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.2s ease;
}

.givewp-donation-form-modal__open__spinner-inner {
    width: 20px;
    height: 20px;
    border-radius: 50%;
    border: 2px solid rgba(255, 255, 255, 0.6);
    border-top-color: rgba(255, 255, 255, 1);
    animation: give-grid-spin 0.8s linear infinite;
    display: block;
}

.givewp-donation-form-modal__open[data-loading="true"] .givewp-donation-form-modal__open__spinner {
    opacity: 1;
}

.givewp-donation-form-modal__open[data-loading="true"] .givewp-donation-form-modal__open__label {
    visibility: hidden;
}

@keyframes give-grid-spin {
    0% {
        transform: rotate(0deg);
    }

    100% {
        transform: rotate(360deg);
    }
}

/* Override Magnific close button styles */
.give-donation-grid-item-form .close-btn.givewp-donation-form-modal__close {
    position: absolute;
    top: 12px;
    right: 12px;
    width: auto !important;
    height: auto !important;
    line-height: 1;
    text-align: center;
    border: none;
    background-color: #ffffff !important;
    color: #000000 !important;
    opacity: 1 !important;
    padding: 6px;
    border-radius: 999px;
    box-shadow: 0 4px 10px rgba(0, 0, 0, 0.15);
    cursor: pointer;
}

.give-donation-grid-item-form .close-btn.givewp-donation-form-modal__close:active,
.give-donation-grid-item-form .close-btn.givewp-donation-form-modal__close:focus {
    outline: none;
    box-shadow: none;
    background-color: #ffffff !important;
}

.give-donation-grid-item-form {
    background: transparent !important;
    padding: 0;
    position: relative;
    height: 100%;
}

.give-donation-grid-item-form .modal-content {
    background: transparent !important;
    padding: 0;
    box-shadow: none;
}

.give-donation-grid-item-form[data-loading="true"]::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    min-height: 600px;
    background: rgba(0, 0, 0, 0.45);
    z-index: 10;
    border-radius: inherit;
    display: block !important;
}

.give-donation-grid-item-form[data-loading="true"]::after {
    content: '';
    position: absolute;
    top: 50%;
    left: 50%;
    width: 40px;
    height: 40px;
    border-radius: 50%;
    border: 3px solid rgba(255, 255, 255, 0.6);
    border-top-color: rgba(255, 255, 255, 1);
    transform: translate(-50%, -50%);
    animation: give-grid-spin 0.8s linear infinite;
    z-index: 11;
    display: block !important;
}

/* Override Magnific close button styles */
.give-donation-grid-item-form .close-btn.givewp-donation-form-modal__close {
    position: fixed;
    top: 25px;
    right: 25px;
    height: auto !important;
    line-height: 1;
    text-align: center;
    border: none;
    background-color: #ffffff !important;
    color: #000000 !important;
    opacity: 1 !important;
    padding: 14px;
    border-radius: 999px;
    box-shadow: 0 4px 10px rgba(0, 0, 0, 0.15);
    cursor: pointer;
    width: fit-content;
    z-index: 999;
    display: flex;
}

.give-donation-grid-item-form .close-btn.givewp-donation-form-modal__close:focus,
.give-donation-grid-item-form .close-btn.givewp-donation-form-modal__close:active {
    outline: none;
    background-color: #ffffff !important;
    box-shadow: 0 0 0 2px rgba(0, 0, 0, 0.1);
}

.give-donation-grid-item-form {
    background: transparent !important;
    padding: 0;
    min-height: 400px;
    position: relative;
}

.give-donation-grid-item-form[data-loading="true"]::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    min-height: 600px;
    background: rgba(0, 0, 0, 0.45);
    z-index: 10;
    border-radius: inherit;
    display: block !important;
}

.give-donation-grid-item-form[data-loading="true"]::after {
    content: '';
    position: absolute;
    top: 50%;
    left: 50%;
    width: 40px;
    height: 40px;
    border-radius: 50%;
    border: 3px solid rgba(255, 255, 255, 0.6);
    border-top-color: rgba(255, 255, 255, 1);
    transform: translate(-50%, -50%);
    animation: give-grid-spin 0.8s linear infinite;
    z-index: 11;
    display: block !important;
}

/* Hide loading when iframe is loaded */
.give-donation-grid-item-form[data-opened="true"]:not([data-loading="true"])::before,
.give-donation-grid-item-form[data-opened="true"]:not([data-loading="true"])::after {
    display: none !important;
}

/* Specific column layouts for better browser support */
.give-form-grid-enhanced[data-columns="1"] {
    --columns: 1;
}

.give-form-grid-enhanced[data-columns="2"] {
    --columns: 2;
}

.give-form-grid-enhanced[data-columns="3"] {
    --columns: 3;
}

.give-form-grid-enhanced[data-columns="4"] {
    --columns: 4;
}

/* Responsive */
@media (max-width: 1024px) {

    .give-form-grid-enhanced[data-columns="4"],
    .give-form-grid-enhanced[data-columns="3"] {
        --columns: 2;
    }
}

@media (max-width: 768px) {
    .give-form-grid-enhanced {
        gap: 20px;
    }

    .give-form-grid-item {
        flex: 0 0 100% !important;
    }

    .give-form-grid-filter {
        justify-content: flex-start;
    }

    .give-form-grid-filter .filter-btn {
        padding: 8px 16px;
        font-size: 13px;
    }

    .give-campaigns-component-campaign-button {
        flex: 1 1 100%;
    }

}

/* Remove old styles - now using campaign widget classes */

/* Pagination */
.give-form-grid-pagination {
    margin-top: 40px;
    text-align: center;
}

.give-form-grid-pagination .page-numbers {
    display: inline-flex;
    gap: 5px;
    list-style: none;
    padding: 0;
    margin: 0;
}

.give-form-grid-pagination .page-numbers li {
    display: inline-block;
}

.give-form-grid-pagination .page-numbers a,
.give-form-grid-pagination .page-numbers span {
    display: block;
    padding: 8px 12px;
    border: 1px solid #ddd;
    border-radius: 4px;
    text-decoration: none;
    color: #333;
    transition: all 0.3s ease;
}

.give-form-grid-pagination .page-numbers a:hover {
    background-color: #69b86b;
    color: #fff;
    border-color: #69b86b;
}

.give-form-grid-pagination .page-numbers .current {
    background-color: #69b86b;
    color: #fff;
    border-color: #69b86b;
}

/* No Forms Found */
.no-forms-found,
.error-message {
    text-align: center;
    padding: 40px 20px;
    color: #666;
    font-size: 16px;
}

.error-message {
    color: #d32f2f;
}

/* Modal Styles */
.give-modal-form {
    background: #fff;
    padding: 30px;
    max-width: 600px;
    margin: 0 auto;
    border-radius: 8px;
}

/* Hide items when filtering */
.give-form-grid-item.hidden {
    display: none !important;
}

/* No forms found message for filtered results */
.no-forms-found-filter {
    text-align: center;
    padding: 40px 20px;
    color: #666;
    font-size: 16px;
    width: 100%;
    grid-column: 1 / -1;
}

/* Media Queries */

@media (max-width: 420px) {
    .give-campaigns-component-campaign-button--donate,
    .give-campaigns-component-campaign-button--view {
        flex: 0 0 100% !important;
        max-width: 100% !important;
        gap: 20px;
    }
}