/* Product Page Gift Checkbox Styles */

.wpgv-product-gift-checkbox-wrapper {
    margin: 15px 0;
    padding: 10px;
    border: 1px solid #e0e0e0;
    border-radius: 5px;
    background-color: #f9f9f9;
}


.wpgv-gift-checkbox-container label {
    display: flex;
    align-items: center;
    font-size: 16px;
    font-weight: 600;
    cursor: pointer;
}

.wpgv-gift-checkbox-container input[type="checkbox"] {
    width: 20px;
    height: 20px;
    margin-right: 10px;
    cursor: pointer;
}

#wpgv-gift-form-fields,
#wpgv_template_canvas_container,
#wpgv-templates-list,
#wpgv-template-tabs,
#wpgv-gift-form-container p{
    margin-top: 15px !important;
    margin-bottom: 0 !important ;
    gap: 15px;
}

.wpgv-gift-form-container h4 {
    margin-bottom: 15px;
    font-size: 18px;
    color: #333;
}

.wpgv-templates-list {
    display: grid;
    /* Show exactly 5 items per row */
    grid-template-columns: repeat(4, 1fr);
    gap: 10px;
}

/* Skeleton/loading effect for template items */
.wpgv-template-item.loading {
    position: relative;
    overflow: hidden;
}

.wpgv-template-item.loading img,
.wpgv-template-item.loading .template-title {
    visibility: hidden;
}

.wpgv-template-item.loading::after {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    /* Darker, higher-contrast skeleton overlay */
    background: linear-gradient(90deg, rgba(0, 0, 0, 0.20) 0%, rgba(255, 255, 255, 0.09) 45%, rgba(0, 0, 0, 0.20) 100%);
    mix-blend-mode: normal;
    animation: wpgv-skeleton-shimmer 0.9s infinite linear;
}

@keyframes wpgv-skeleton-shimmer {
    0% {
        transform: translateX(-120%);
    }

    100% {
        transform: translateX(120%);
    }
}

.wpgv-template-item.loading {
    box-shadow: 0 0 0 3px rgba(19, 113, 255, 0.08) inset, 0 6px 18px rgba(0, 0, 0, 0.08);
    background-color: rgba(0, 0, 0, 0.03);
}

/* Visible loading label + spinner inside template item */
.wpgv-template-item .wpgv-item-loading-label {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    z-index: 60;
    display: flex;
    align-items: center;
    gap: 8px;
    background: rgba(0, 0, 0, 0.72);
    color: #fff;
    padding: 6px 10px;
    border-radius: 4px;
    font-size: 13px;
    pointer-events: none;
}

.wpgv-template-item .wpgv-item-loading-label .wpgv-spinner {
    width: 14px;
    height: 14px;
    border: 2px solid rgba(255, 255, 255, 0.25);
    border-top-color: #ffffff;
    border-radius: 50%;
    animation: wpgv-spinner 0.8s linear infinite;
}

@keyframes wpgv-spinner {
    to {
        transform: rotate(360deg);
    }
}

/* Ensure the image area shows a subtle neutral background while loading */
.wpgv-template-item.loading {
    background: linear-gradient(180deg, #f6f7f9 0%, #eef0f3 100%);
}

/* Skeleton for canvas preview container */
#wpgv_template_canvas_container.loading {
    position: relative;
    min-height: 220px;
    /* reasonable preview height */
    background-color: #f3f4f6;
    overflow: hidden;
    border-radius: 4px;
}

#wpgv_template_canvas_container.loading::after {
    content: '';
    position: absolute;
    top: 0;
    left: -150%;
    width: 250%;
    height: 100%;
    background: linear-gradient(90deg, rgba(0, 0, 0, 0.1) 10%, rgba(255, 255, 255, 0.2) 50%, rgba(0, 0, 0, 0.3) 100%);
    animation: wpgv-canvas-shimmer 1.2s linear infinite;
}

@keyframes wpgv-canvas-shimmer {
    0% {
        transform: translateX(0);
    }

    100% {
        transform: translateX(-40%);
    }
}

#wpgv_template_canvas_container.loading .wpgv-canvas-loading-label {
    position: absolute;
    top: 8px;
    left: 12px;
    background: rgba(0, 0, 0, 0.6);
    color: #fff;
    padding: 5px 10px;
    border-radius: 4px;
    font-size: 12px;
    z-index: 20;
}

.wpgv-template-item.disabled {
    pointer-events: none;
    opacity: 0.6;
}

/* Template tabs */
#wpgv-template-tabs{
    display: flex;
}
#wpgv-template-tabs button {
    display: flex !important;
    justify-content: center !important;
    align-items: center !important;
    padding: 5px 10px !important;
    cursor: pointer;
}

#wpgv-template-preview-container {
    margin: 15px 0 !important;
}

#wpgv-template-tab.active,
#wpgv-template-tab:hover {
   /* background: transparent !important;
    color: #000 !important;
    border: none !important;
    padding: 0 !important;
    margin: 0 !important; */
}

.wpgv-template-item {
    position: relative;
    border: 1px solid #e0e0e0;
    border-radius: 3px;
    overflow: hidden;
    cursor: pointer;
    transition: all 0.3s ease;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 5px;
    background: #fff;
}

.wpgv-template-item:hover {
    border-color: #1371ff;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
}

.wpgv-template-item.selected {
    border-color: #1371ff;
    box-shadow: 0 0 0 2px #1371ff;
}

.wpgv-template-item img {
    width: 100% !important;
    height: 100% !important;
    object-fit: cover;
    object-position: center;
    display: block;
}

.wpgv-template-item .template-title {
    padding: 8px;
    text-align: center;
    font-size: 12px;
    background-color: #fff;
    border-top: 1px solid #e0e0e0;
}

.wpgv-template-item .selected-badge {
    position: absolute;
    top: 5px;
    right: 5px;
    background-color: #1371ff;
    color: #fff;
    padding: 3px 8px;
    border-radius: 4px;
    font-size: 11px;
    font-weight: bold;
    display: none;
}

.wpgv-template-item.selected .selected-badge {
    display: block;
}

.wpgv-template-item .template-price-badge {
    position: absolute;
    top: 5px;
    left: 5px;
    background-color: #28a745;
    color: #fff;
    padding: 3px 8px;
    border-radius: 4px;
    font-size: 11px;
    font-weight: bold;
    z-index: 1;
}

/* Preview container selected styling to match template items */
#wpgv_template_canvas_container.selected {
    border: 2px solid #1371ff;
    box-shadow: 0 0 0 2px #1371ff;
    border-radius: 8px;
    overflow: hidden;
}


.wpgv-form-field {
    margin-bottom: 15px;
}

.wpgv-form-field label {
    display: block;
    margin-bottom: 5px;
}

.wpgv-form-field .required {
    color: #ff0000;
}

.wpgv-form-field input.wpgv-input,
.wpgv-form-field textarea.wpgv-input {
    width: 100%;
    padding: 10px;
    border: 1px solid #ddd;
    border-radius: 4px;
    font-size: 14px;
    transition: border-color 0.3s ease;
}

.wpgv-form-field input.wpgv-input:focus,
.wpgv-form-field textarea.wpgv-input:focus {
    outline: none;
    border-color: #1371ff;
}

.wpgv-form-field textarea.wpgv-input {
    resize: vertical;
}

/* Loading state */
.wpgv-templates-list.loading {
    text-align: center;
    color: #999;
}

/* Error state */
.wpgv-templates-error {
    color: #ff0000;
    padding: 10px;
    background-color: #fff0f0;
    border: 1px solid #ffcccc;
    border-radius: 4px;
    margin-bottom: 15px;
}

.wpgv-gift-price .wpgv-same-as-product {
    font-size: 11px;
    color: #666;
    margin-left: 5px;
}

/* Responsive */
@media (max-width: 768px) {
    .wpgv-templates-list {
        /* On medium screens show 3 columns */
        grid-template-columns: repeat(3, 1fr);
        gap: 10px;
    }
}

@media (max-width: 480px) {
    .wpgv-templates-list {
        grid-template-columns: repeat(2, 1fr);
    }
}