/* ========================================
   DG Regalos Productos - Frontend Styles (Popup Modal)
   ======================================== */

/* Botón trigger para abrir popup */
.dg-gift-trigger-wrapper {
    margin-bottom: 20px;
    text-align: center;
}

.dg-open-gift-popup {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: #fff;
    border: none;
    padding: 15px 30px;
    font-size: 18px;
    font-weight: 600;
    border-radius: 8px;
    cursor: pointer;
    box-shadow: 0 4px 12px rgba(102, 126, 234, 0.3);
    transition: all 0.3s ease;
}

.dg-open-gift-popup:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 16px rgba(102, 126, 234, 0.4);
}

/* Overlay del popup */
.dg-gift-overlay {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.7);
    z-index: 9998;
    backdrop-filter: blur(4px);
    animation: fadeIn 0.3s ease;
}

.dg-gift-overlay.active {
    display: block;
}

/* Popup Modal */
.dg-gift-popup {
    display: none;
    position: fixed;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%) scale(0.9);
    width: 90%;
    max-width: 900px;
    max-height: 85vh;
    background: #fff;
    border-radius: 12px;
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.3);
    z-index: 9999;
    overflow: hidden;
    opacity: 0;
    transition: all 0.3s ease;
}

.dg-gift-popup.active {
    display: block;
    opacity: 1;
    transform: translate(-50%, -50%) scale(1);
    animation: popupSlideIn 0.3s ease;
}

/* Botón de cerrar */
.dg-close-popup {
    position: absolute;
    top: 15px;
    right: 15px;
    background: rgba(255, 255, 255, 0.9);
    border: none;
    width: 40px;
    height: 40px;
    border-radius: 50%;
    font-size: 28px;
    line-height: 1;
    cursor: pointer;
    color: #333;
    z-index: 10;
    transition: all 0.3s ease;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
}

.dg-close-popup:hover {
    background: #fff;
    transform: rotate(90deg);
    color: #667eea;
}

/* Contenido del popup */
.dg-gift-popup-content {
    max-height: 85vh;
    overflow-y: auto;
    padding: 0;
}

/* Scrollbar personalizado para el popup */
.dg-gift-popup-content::-webkit-scrollbar {
    width: 8px;
}

.dg-gift-popup-content::-webkit-scrollbar-track {
    background: #f1f1f1;
}

.dg-gift-popup-content::-webkit-scrollbar-thumb {
    background: #667eea;
    border-radius: 4px;
}

.dg-gift-popup-content::-webkit-scrollbar-thumb:hover {
    background: #5568d3;
}

.dg-gift-header {
    text-align: center;
    margin-bottom: 30px;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    padding: 30px;
    color: #fff;
    border-radius: 12px 12px 0 0;
    margin: 0;
}

.dg-gift-header h3 {
    margin: 0 0 10px 0;
    font-size: 28px;
    font-weight: 700;
    color: #fff;
}

.dg-gift-header p {
    margin: 0;
    font-size: 16px;
    opacity: 0.9;
}

.dg-gift-rule {
    background: #fff;
    border-radius: 0;
    padding: 25px;
    margin-bottom: 0;
    color: #333;
    border-bottom: 1px solid #e5e5e5;
}

.dg-gift-rule:last-child {
    margin-bottom: 0;
    border-bottom: none;
}

.dg-rule-info {
    margin-bottom: 20px;
    padding-bottom: 15px;
    border-bottom: 2px solid #e5e5e5;
}

.dg-rule-info h4 {
    margin: 0 0 10px 0;
    font-size: 20px;
    font-weight: 600;
    color: #667eea;
}

.dg-rule-description {
    margin: 5px 0;
    color: #666;
}

.dg-remaining-gifts {
    margin: 10px 0 0 0;
    padding: 10px 15px;
    background: #fff3cd;
    border-left: 4px solid #ffc107;
    border-radius: 4px;
    color: #856404;
    font-weight: 600;
}

.dg-completed-gifts {
    margin: 10px 0 0 0;
    padding: 10px 15px;
    background: #d4edda;
    border-left: 4px solid #28a745;
    border-radius: 4px;
    color: #155724;
    font-weight: 600;
}

.dg-gift-products {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(250px, 1fr));
    gap: 20px;
}

.dg-gift-product {
    background: #fff;
    border: 2px solid #e5e5e5;
    border-radius: 8px;
    padding: 15px;
    transition: all 0.3s ease;
    display: flex;
    flex-direction: column;
}

.dg-gift-product:hover {
    border-color: #667eea;
    box-shadow: 0 4px 12px rgba(102, 126, 234, 0.15);
    transform: translateY(-2px);
}

.dg-gift-product.dg-selected {
    border-color: #28a745;
    background: #f0f9f4;
}

.dg-gift-image {
    text-align: center;
    margin-bottom: 15px;
    position: relative;
}

.dg-gift-image img {
    max-width: 100%;
    height: auto;
    border-radius: 4px;
}

/* Badge de cantidad */
.dg-quantity-badge {
    position: absolute;
    top: 10px;
    right: 10px;
    background: #667eea;
    color: #fff;
    width: 32px;
    height: 32px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 700;
    font-size: 14px;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.2);
}

.dg-gift-details {
    flex: 1;
    display: flex;
    flex-direction: column;
}

.dg-gift-details h5 {
    margin: 0 0 15px 0;
    font-size: 16px;
    font-weight: 600;
    color: #333;
    min-height: 40px;
}

.dg-variation-select {
    width: 100%;
    padding: 8px;
    margin-bottom: 15px;
    border: 1px solid #ddd;
    border-radius: 4px;
    font-size: 14px;
}

.dg-add-gift-btn {
    width: 100%;
    padding: 12px;
    background: #667eea;
    color: #fff;
    border: none;
    border-radius: 4px;
    font-size: 16px;
    font-weight: 600;
    cursor: pointer;
    transition: background 0.3s ease;
    margin-top: auto;
}

.dg-add-gift-btn:hover:not(:disabled) {
    background: #5568d3;
}

.dg-add-gift-btn:disabled {
    background: #ccc;
    cursor: not-allowed;
}

.dg-add-gift-btn.loading {
    position: relative;
    color: transparent;
}

.dg-add-gift-btn.loading::after {
    content: '';
    position: absolute;
    top: 50%;
    left: 50%;
    width: 16px;
    height: 16px;
    margin: -8px 0 0 -8px;
    border: 2px solid #fff;
    border-top-color: transparent;
    border-radius: 50%;
    animation: spin 0.6s linear infinite;
}

/* Contenedor de acciones de regalo */
.dg-gift-actions {
    margin-top: auto;
}

.dg-selected-info {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.dg-selected-label {
    display: block;
    padding: 10px;
    background: #28a745;
    color: #fff;
    text-align: center;
    border-radius: 4px;
    font-weight: 600;
    font-size: 14px;
}

/* Botón añadir más */
.dg-add-more-btn {
    background: #17a2b8 !important;
    border-color: #17a2b8 !important;
    font-size: 14px;
    padding: 8px 12px;
}

.dg-add-more-btn:hover:not(:disabled) {
    background: #138496 !important;
}

/* Botones de eliminar */
.dg-remove-buttons {
    display: flex;
    flex-direction: column;
    gap: 5px;
}

.dg-remove-gift-btn {
    background: #dc3545 !important;
    color: #fff !important;
    border: none;
    padding: 6px 12px;
    font-size: 13px;
    border-radius: 4px;
    cursor: pointer;
    transition: background 0.3s ease;
}

.dg-remove-gift-btn:hover:not(:disabled) {
    background: #c82333 !important;
}

.dg-remove-gift-btn.loading {
    opacity: 0.6;
    cursor: wait;
}

/* Cart item styles */
.woocommerce-cart-form__cart-item.dg-gift-item {
    background: #f0f9f4;
    border-left: 4px solid #28a745;
}

.woocommerce-cart-form__cart-item.dg-gift-item .product-name::after {
    content: '🎁';
    margin-left: 8px;
}

.woocommerce-cart-form__cart-item.dg-gift-item .product-price {
    color: #28a745;
    font-weight: 600;
}

/* Animations */
@keyframes spin {
    to {
        transform: rotate(360deg);
    }
}

/* Animaciones */
@keyframes fadeIn {
    from {
        opacity: 0;
    }

    to {
        opacity: 1;
    }
}

@keyframes popupSlideIn {
    from {
        opacity: 0;
        transform: translate(-50%, -50%) scale(0.9);
    }

    to {
        opacity: 1;
        transform: translate(-50%, -50%) scale(1);
    }
}

/* Responsive */
@media screen and (max-width: 768px) {
    .dg-gift-popup {
        width: 95%;
        max-height: 90vh;
    }

    .dg-gift-header {
        padding: 20px;
    }

    .dg-gift-header h3 {
        font-size: 22px;
    }

    .dg-gift-products {
        grid-template-columns: 1fr;
    }

    .dg-gift-rule {
        padding: 15px;
    }

    .dg-close-popup {
        width: 35px;
        height: 35px;
        font-size: 24px;
    }
}

@media screen and (max-width: 480px) {
    .dg-gift-popup {
        width: 98%;
        max-height: 95vh;
    }

    .dg-gift-header {
        padding: 15px;
    }

    .dg-gift-header h3 {
        font-size: 20px;
    }

    .dg-gift-header p {
        font-size: 14px;
    }

    .dg-open-gift-popup {
        padding: 12px 24px;
        font-size: 16px;
    }
}